// JavaScript Document

//Example: preloadImages('file.gif', 'http://www.x.com/y.gif');

function preloadImages() {
  if(document.images)  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    for(i=0; i<args.length; i++)    {
      if (args[i].indexOf("#")!=0)      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}


	
// Example:
// simplePreload( '01.gif', '02.gif' ); 
function simplePreload(){ 
  var args = simplePreload.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];
  }
}

function switchImage(imgName, imgSrc) {
  if (document.images)  {
    if (imgSrc != "none")    {
      document.images[imgName].src = imgSrc;
    }
  }
}


/********************* Macromedia Functions *********************
*
*
*/

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_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_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_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
  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_findObj(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 == '');
}

/********************* END Macromedia Functions *********************
*
*
*/

/*<option value="single">Single/Individual 
                        <option value="couple">Husband/Wife 
                        <option value="parentchild">Parent/Child 
                        <option value="family">Family 
                        <option value="group">Group */
						

function chooseColor ( ) {
	// always takes at least two arguments. first is sku, second is color.
	// third optional argument is the form we want to submit.
	//function chooseColor( sku, color, theForm="a2c1" )
	
	//alert("starting");
	sku = "";
	color = "";
	theForm = "a2c1";
	//theForm = "document.a2c1";
	sku = arguments[0]; // the first arg is the sku
	color = arguments[1]; // second arg is the color
	if ( arguments[2] ) {
			theForm = arguments[2]; // third arg is the form
	}

/*	alert("done");
	alert("theForm: " + theForm);
	//document.theForm.hidSKU.value = sku;
	alert("hmm");
	theForm.hidSKU.value = sku;
	alert("hmm2");
	alert("SKU: " + (theForm).hidSKU.value);
	alert("hmm3");
	//document.theForm.hidBoxCt.value = color;
	(theForm).hidBoxCt.value = color;
	alert("COLOR: " + (theForm).hidBoxCT.value);
	//changes = (document.theForm.hidSKU.value) + " - " + color;
	
	changes = ((theForm).hidSKU.value) + " - " + color;
	//document.theForm.submit();
	alert("about to submit");
	(theForm).submit();*/
	//alert("done");
	//alert("theForm: " + theForm);
	document.forms[theForm].hidSKU.value = sku;
	document.forms[theForm].hidBoxCt.value = color;
	changes = (document.forms[theForm].hidSKU.value) + " - " + color;
	if(document.getElementById("txtQty2"))
		{
		secondtxtqty = document.getElementById("txtQty2");
		if(eval(secondtxtqty.value) > eval(document.forms[theForm].txtQty.value))
			{document.forms[theForm].txtQty.value = secondtxtqty.value;}
		}
	document.forms[theForm].submit();

	//document.theForm.hidBoxCt.value = color;
	//changes = (document.theForm.hidSKU.value) + " - " + color;
	
/*	changes = ((theForm).hidSKU.value) + " - " + color;
	//document.theForm.submit();
	alert("about to submit");
	(theForm).submit();*/
	
	
/*	document.a2c1.hidSKU.value = sku;
	document.a2c1.hidBoxCt.value = color;
	changes = (document.a2c1.hidSKU.value) + " - " + color;
	document.a2c1.submit();*/
}
	
		
/************* ORIGINAL CHOOSECOLOR FUNCTION *****************
* NO LONGER IN USE 
*/
//function chooseColor( sku, color, theForm="a2c1" ) {
//	/* original condensed */
//	document.a2c1.hidSKU.value = sku;
//	document.a2c1.hidBoxCt.value = color;
//	changes = (document.a2c1.hidSKU.value) + " - " + color;
//	document.a2c1.submit();
//	
//	/* using theForm */
//	document.theForm.hidSKU.value = sku;
//	document.theForm.hidBoxCt.value = color;
//	changes = (document.theForm.hidSKU.value) + " - " + color;
//	document.theForm.submit();	
	
	
	/* original 
	document.a2c1.hidSKU.value = sku;
	document.a2c1.hidBoxCt.value = color;
	//document.a2c1.hidName.value += color;
	//alert(object);
	//alert(theform);
	//document.this.hidSKU.value = sku;
	//document.this.hidName.value += color;
	changes = (document.a2c1.hidSKU.value) + " - " + color;
	//alert( changes );
	document.a2c1.submit();
	//alert("hi");
	//alert(document.a2c1.hidSKU.value);
	//alert(document.a2c1.hidName.value);
	//document.a2c1.submit();
	*/
//}

function selectchooseColor ( sku, color ) {
	
}

/*****New12-08-06*****/

function SymError()
{
  return true;
}
 
window.onerror = SymError;
//**************** Javascript countdown **********************

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}

function DaysLeft()
{
	var Today = new Date();
	var x = 0;
	
	if (Today.getMonth() == 6)
	{
		x = 34 - Today.getDate();
	
	}
	else if (Today.getMonth() == 7)
		{
		x = 3 - Today.getDate() ;
}
	if (x > 0 && x < 12)
		document.getElementById("topspecial").src = "images/banner/summer/summersmall/"+x+"special.gif";
}

function ovr(theImg) {
	theImg.src = theImg.src.replace('.jpg','-b.jpg');
}

// image rollout
function out(theImg) {
	theImg.src = theImg.src.replace('-b.jpg','.jpg');
}