// JavaScript Document

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openNewWindow(theURL,windowName,height,width)
{
windowFeatures ="menubar=no,scrollbars=no,location=yes,favorites=no,resizable=no,status=no,toolbar=no,directories=no";
var test = "'";
winLeft = (screen.width-width)/2;
winTop = (screen.height-(height+110))/2;
window.open(theURL,windowName,"width=" + width +",height=" + height + ",left=" + winLeft + ",top=" + winTop + test + windowFeatures + test);
/*
myWin= open(theURL,windowName,"width=" + width +",height=" + height + ",left=" + winLeft + ",top=" + winTop + test + windowFeatures + test);
myWin.document.open();
myWin.document.close();
*/
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

ie5  = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);


function isIE()
{
	return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}


opac = 0;
var fadeOutTimer
var fadeInTimer

var helpTxtArray=new Array(9);
helpTxtArray[0]="Highlighting the newest works of art added to our collection.";
helpTxtArray[1]="Everything you want to know about the works of art in our collection.";
helpTxtArray[2]="Displaying great works of art for sale from our featured artists.";
helpTxtArray[3]="Short biography of the gallery's main artist, David Master.";
helpTxtArray[4]="Informative answers to frequently asked questions about the gallery.";
helpTxtArray[5]="An opportunity to share your thoughts and ideas.";
helpTxtArray[6]="Information on how to order bronze sculptures from our collection.";
//helpTxtArray[7]="Customized shelving for your sculptures, for the convenience to display them anywhere.";
//helpTxtArray[5]="Coming soon!";
helpTxtArray[7]="Coming soon!";

helpTxtArray[8]="Other websites you may find interesting.";
 
function fadeIn(txtID) {
//fades layer in

	//switch help content
	document.getElementById('HelpText').innerHTML = helpTxtArray[txtID];

    if(opac < 100){
        clearTimeout(fadeOutTimer)
		opac+=3;
        if(ie5) document.getElementById('helpBox').filters.alpha.opacity = opac;
        if(ns6) document.getElementById('helpBox').style.MozOpacity = opac/100;
        fadeInTimer = setTimeout("fadeIn(" + txtID + ")", 0);

		//document.getElementById('ShowTimer').innerHTML = opac;
		
    }
}

function fadeOut() {
//fades layer out
    
	if(opac > 0){
        clearTimeout(fadeInTimer)
		opac-=3;
        if(ie5) document.getElementById('helpBox').filters.alpha.opacity = opac;
        if(ns6) document.getElementById('helpBox').style.MozOpacity = opac/100;
        fadeOutTimer = setTimeout('fadeOut()', 0);
		
		//document.getElementById('ShowTimer').innerHTML = opac;
    }
}


	function showhide(id){
	if (document.getElementById){
	obj = document.getElementById(id);
	if (obj.style.display == "none"){
	obj.style.display = "";
	} else {
	obj.style.display = "none";
	}
	}
	}
	
// Scripts for Social Bookmarking

      function deliciousBookmark()
      {
         window.open("http://del.icio.us/post?v=4;url="+encodeURIComponent(window.location.href)+';title='+encodeURIComponent(document.title),'popup','width=450px,height=480px,status=0,location=0,resizable=1,scrollbars=1,left=100,top=50',0);
         //window.location = location;
      }
      
      function diggBookmark()
      {
         window.open("http://digg.com/submit?phase=2&url="+encodeURIComponent(window.location.href)+"&title="+encodeURIComponent(document.title),'popup','width=900px,height=600px,status=0,location=0,resizable=1,scrollbars=1,left=100,top=50',0);
         //window.location = location;
      }
      
      function googleBookmark()
      {
         var a=window,b=document,c=encodeURIComponent,d=a.open("http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk="+c(b.location)+"&title="+c(b.title),"bkmk_popup","left="+((a.screenX||a.screenLeft)+10)+",top="+((a.screenY||a.screenTop)+10)+",height=420px,width=550px,resizable=1,alwaysRaised=1");a.setTimeout(function(){d.focus()},300)
         //window.location = location;
      }
      
      function yahooBookmark() 
      {
         window.open('http://bookmarks.yahoo.com/toolbar/savebm?t='+encodeURIComponent(document.title)+'&u='+encodeURIComponent(window.location.href)+'&opener=bm&ei=UTF-8','popup','width=450px,height=480px,status=0,location=0,resizable=1,scrollbars=1,left=100,top=50',0);
         //window.location = location;
      }
      
      function technoratiBookmark()
      {
         window.open('http://technorati.com/faves?sub=favthis&add='+escape(document.location),'popup','width=450px,height=480px,status=0,location=0,resizable=1,scrollbars=1,left=100,top=50',0);
         //window.location = location;
      }
      
      function winLiveBookmark()
      {
         t=document.title;u=escape(location.href);
         window.open('http://favorites.live.com/quickadd.aspx?url='+u+'&title='+t,'popup','width=450px,height=480px,status=0,location=0,resizable=1,scrollbars=1,left=100,top=50',0);
         //window.location = loc;
      }

      function facebookBookmark()
      {
         window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(window.location.href),'popup','width=450px,height=480px,status=0,location=0,resizable=1,scrollbars=1,left=100,top=50',0);
         //window.location = loc;
      }

      function mySpaceBookmark()
      {
         window.open('http://www.myspace.com/Modules/PostTo/Pages/?u='+encodeURIComponent(window.location.href+'&t='+encodeURIComponent(document.title)),'popup','width=450px,height=480px,status=0,location=0,resizable=1,scrollbars=1,left=100,top=50',0);
         //window.location = loc;
      }

/* Preload Images */

<!--

    if (document.images)
    {
      preload_image_object = new Image();
      // set image url
      image_url = new Array();
      image_url[0] = "/images/contact_us_s.gif";
      image_url[1] = "/images/live.gif";
      image_url[2] = "/images/live_fade.gif";
      image_url[3] = "/images/yahoo.gif";
	  image_url[4] = "/images/yahoo_fade.gif";
	  image_url[5] = "/images/google.gif";
	  image_url[6] = "/images/google_fade.gif";
	  image_url[7] = "/images/digg.gif";
	  image_url[8] = "/images/digg_fade.gif";
	  image_url[9] = "/images/Del.gif";
	  image_url[10] = "/images/Del_fade.gif";
	  image_url[11] = "/images/facebook.gif";
	  image_url[12] = "/images/facebook_fade.gif";
	  image_url[13] = "/images/myspace.gif";
	  image_url[14] = "/images/myspace_fade.gif";

       var i = 0;
       for(i=0; i<=14; i++) 
         preload_image_object.src = image_url[i];
    }