function loadImages()
{ 
  var args = loadImages.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

showRow = (navigator.appName.indexOf("Internet Explorer") != -1) ? "block" : "table-row";

function hideCaption(){
	//hide captions
	for(i=1;i<=intLoop;i++){
		document.getElementById("txtCaption"+i).style.display='none'; 
	}
		document.getElementById("txtCaption1").style.display=showRow;
}

function imgLoadImage(imgName,intText, hasHidden){

	var enl1 = document.getElementById("enlLink");
	var enl2 = document.getElementById("enlLink2");
	if (enl1 != null && enl2 != null) {
		enl1.style.display = hasHidden ? 'none' : 'inline';
		enl2.style.display = enl1.style.display;
	}
	
    document.getElementById("imgShowImage").setAttribute("imgName", imgName);
    document.getElementById("imgShowImage").setAttribute("intText", intText);
    attrIsBig = document.getElementById("imgShowImage").getAttribute("isBig");

	if (attrIsBig != "1"){
        //change image
	    document.getElementById("imgShowImage").src="images/gallery/"+imgName;

		//change caption
		for(i=1;i<=intLoop;i++){
		  document.getElementById("txtCaption"+i).style.display='none'; 
		}
		  document.getElementById("txtCaption"+intText).style.display=showRow; 
    }else{
        //change image
	    document.getElementById("imgShowBigImage").src="images/gallery/"+imgName.replace(/.jpg/ig, "_big.jpg");
    }
	
}

function imgEnlargeImage(){
   document.getElementById("imgShowImage").setAttribute("isBig", "1");
  
   imgName = document.getElementById("imgShowImage").getAttribute("imgName");
   intText = document.getElementById("imgShowImage").getAttribute("intText");
   imgLoadImage(imgName, intText);

   document.getElementById("tblImage").style.display='none';
   document.getElementById("tblBigImage").style.display='';
   document.getElementById("tdBigImageNav").style.display='';
}

function imgBackToPageImage(){
   document.getElementById("imgShowImage").setAttribute("isBig", "0");
  
   imgName = document.getElementById("imgShowImage").getAttribute("imgName");
   intText = document.getElementById("imgShowImage").getAttribute("intText");
   imgLoadImage(imgName, intText);

   document.getElementById("tblImage").style.display='';
   document.getElementById("tblBigImage").style.display='none';
   document.getElementById("tdBigImageNav").style.display='none';
}

function getNextIdx(curIdx)
{
   intText = parseInt (curIdx) + 1;
   if (intText > intLoop)
   {
     intText = 1;
   }

   if (typeof(skippedIdx) != 'undefined' && skippedIdx.indexOf(intText) > -1)
   {
	  intText = getNextIdx(intText)     
   }

   return intText;
}

function getPrevIdx(curIdx)
{
   intText = parseInt (curIdx) - 1;

   if (intText == 0)
   {
     intText = intLoop;
   }

   if (typeof(skippedIdx) != 'undefined' && skippedIdx.indexOf(intText) > -1)
   {
	  intText = getPrevIdx(intText)     
   }

   return intText;
}

function imgLoadNextImage(){
   intText = document.getElementById("imgShowImage").getAttribute("intText");
   intText = getNextIdx(intText);
   imgName = imgs[intText];
   imgLoadImage(imgName, intText);
}

function imgLoadPrevImage(){
   intText = document.getElementById("imgShowImage").getAttribute("intText");
   intText = getPrevIdx(intText);
   imgName = imgs[intText];
   imgLoadImage(imgName, intText);
}


function OpenBuilttoship(){
	window.open('http://www.builttoship.com','builttoship','top=210,left=150,width=800,height=300,scrollbars=yes,location=yes,status=1,toolbar=1,resizable=1,menubar=1');
}

//frm validation
function MM_findObjValidate(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_findObjValidate(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//frm color 
function MM_validateForm() { //v4.0
  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=MM_findObjValidate(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+='- '+args[i+1]+' field must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+args[i+1]+' 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+='- '+args[i+1]+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+args[i+1]+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}