<!-- Hide
// setTheColors function sets the color image value for each option during 
// the onload event
function setTheColors ()
{
	// set the ink color
	setColor();
	// set the napkin color
	setNapkinColor();
	// set the foil color
	setFoilColor();
	// set the lining color
	setLiningColor();
} // setTheColors function

// subForm function sets options based on form values before being submitted
// to the cart
function subForm ()
{
	// set the return address fields for the cart
	validateRA();
	// set the lining fields for the cart
	subLining();
	// change the discount field based on the ordered options
	chgDis();
	// check the quanity ordered and send an alert
	if ( document.product_form.Qty.value > 30 )
	{
		alert("When ordering more than 30 sets please\n   contact customer service for pricing!")
		return false;
	}
	else
	{
		return true;
	}
} // subForm function

// setColor will set the color image when the page is loaded to the
// selected color in the ink colors list.
function setColor ()
{
	if ( document.product_form.colorSelect )
	{
		document.product_form.inkColor.src = "images/colors/" + document.product_form.colorSelect.options[document.product_form.colorSelect.selectedIndex].value + ".jpg";
		document.product_form.inkColor.alt = document.product_form.colorSelect.options[document.product_form.colorSelect.selectedIndex].value;
	}
} // end setColor function

// colorSwap function changed the color displayed next to the
// ink color list when the user selects a ink color
function colorSwap (form)
{
	form.inkColor.src = "images/colors/" + form.colorSelect.options[form.colorSelect.selectedIndex].value + ".jpg";
	form.inkColor.alt = form.colorSelect.options[form.colorSelect.selectedIndex].value;
} // end colorSwap function

// setColor will set the color image when the page is loaded to the
// selected color in the ink colors list.
function setNapkinColor ()
{
	if ( document.product_form.napkinColorSelect )
	{
		document.product_form.napkinColor.src = "images/napkinColors/" + document.product_form.napkinColorSelect.options[document.product_form.napkinColorSelect.selectedIndex].value + ".jpg";
		document.product_form.napkinColor.alt = document.product_form.napkinColorSelect.options[document.product_form.napkinColorSelect.selectedIndex].value;
	}
} // end setNapkinColor function

// colorSwap function changed the color displayed next to the 
// napkikn color list when the user selects a napkin color
function napkinColorSwap (form)
{
	form.napkinColor.src = "images/napkinColors/" + form.napkinColorSelect.options[form.napkinColorSelect.selectedIndex].value + ".jpg";
	form.napkinColor.alt = form.napkinColorSelect.options[form.napkinColorSelect.selectedIndex].value;
} // end napkinColorSwap function

// setfoilColor will set the color image when the page is loaded to the
// selected color in the foil colors list.
function setFoilColor ()
{
	if ( document.product_form.foilColorSelect )
	{
		document.product_form.foilColor.src = "images/napkinFoilColors/" + document.product_form.foilColorSelect.options[document.product_form.foilColorSelect.selectedIndex].value + ".jpg";
		document.product_form.foilColor.alt = document.product_form.foilColorSelect.options[document.product_form.foilColorSelect.selectedIndex].value;
	}
} // end setFoilColor function

// foilColorSwap function changed the foil color displayed next to the
// color list when the user selects a foil color
function foilColorSwap (form)
{
	form.foilColor.src = "images/napkinFoilColors/" + form.foilColorSelect.options[form.foilColorSelect.selectedIndex].value + ".jpg";
	form.foilColor.alt = form.foilColorSelect.options[form.foilColorSelect.selectedIndex].value;
} // end foilColorSwap function

// The setLiningColor function is used to change the dropdown color list to the first color if 
// the linings check box is checked by the user
function setLiningColor ()
{
	if ( document.product_form.linings )
	{
		if ( document.product_form.linings.checked == true && document.product_form.linings.disabled == false && document.product_form.liningColor.selectedIndex == 0 )
		{
			document.product_form.liningColor.selectedIndex = 1;
		}
		else
		{
			document.product_form.liningColor.selectedIndex = 0;
		}
	}
} // end setLiningColor function

// The subLining function is used to hide the lining field from the cart if no lining color is selected
// otherwise it will populate the lining color.
function subLining ()
{
	if ( document.product_form.liningColor )
	{
		if ( document.product_form.liningColor.selectedIndex == 0 && document.product_form.liningColor[document.product_form.liningColor.selectedIndex].value == "" )
		{
			// This code will hide the lining color option when linings are not ordered
			document.product_form.liningColorVal.value = "h-Lining Color";
			// This message will appear on the invoice email to the client "Envelope not lined"
			document.product_form.liningColor[document.product_form.liningColor.selectedIndex].value = "Envelope not lined";
		}
	}
} // end subLining function

// The setLiningCheck function is used to update the linings check box based on the lining color drop down list
function setLiningCheck ()
{
	if ( document.product_form.liningColor.selectedIndex == 0  && document.product_form.linings.disabled == false )
	{
		document.product_form.linings.checked = false;
	}
	else
	{
		document.product_form.linings.checked = true;
	}
} // end setLiningCheck function

// If a return address was entered or evelope lining use the correct discount field and set the correct price.
function chgDis ()
{
	if ( document.product_form.rae ) // return address defined on the product form
	{
		if ( !( document.product_form.liningColorVal ) ) // no lined envelopes option defined on the product form
		{
			// return address no lined envelopes option
			if ( document.product_form.rae.checked == true )
			{
				document.product_form.discount.value = document.product_form.retDis.value;
				document.product_form.Price.value = parseFloat(document.product_form.Price.value) + parseFloat(document.product_form.retPrice.value);
			}
		}
		else // else envelope lining defined on the product form
		{
			// Return address and lined envelopes and return address is not free
			if ( document.product_form.rae.checked == true && document.product_form.linings.checked == true && document.product_form.liningPrice.value > 0 && document.product_form.retPrice.value > 0 )
			{
				document.product_form.discount.value = document.product_form.retLiningDis.value;
				document.product_form.Price.value = parseFloat(document.product_form.Price.value) + parseFloat(document.product_form.retPrice.value) + parseFloat(document.product_form.liningPrice.value);
			}
			else // no Return address lined envelopes and are not included in the price or return address is FREE
			{
				if ( document.product_form.linings.checked == true && document.product_form.liningPrice.value > 0 )
				{
					document.product_form.discount.value = document.product_form.liningDis.value;
					document.product_form.Price.value = parseFloat(document.product_form.Price.value) + parseFloat(document.product_form.liningPrice.value);
				}
				else
				{
					if ( document.product_form.rae.checked == true )
					{
						document.product_form.discount.value = document.product_form.retDis.value;
						document.product_form.Price.value = parseFloat(document.product_form.Price.value) + parseFloat(document.product_form.retPrice.value);
					}
				}
			}
		} //  end else envelope lining defined on the product form
	} // return address defined on the product form
	return true;
} // end chgDis function

// When the return address box is checked and the return address fields are all 
// empty reset the return address check box.
function validateRA ()
{
	if ( document.product_form.rae )
	{
		// The return address box is checked
		if ( document.product_form.rae.checked == true )
		{
			if ( document.product_form.raeLine[0].value.length == 0 && document.product_form.raeLine[1].value.length == 0 && document.product_form.raeLine[2].value.length == 0 )
			{
				document.product_form.rae.checked = false;
				// check the return address line check boxes
				document.product_form.raeChk[0].checked = true;
				document.product_form.raeChk[1].checked = true;
				document.product_form.raeChk[2].checked = true;
				// null the cart fields
				document.product_form.cartRaeLine[0].value = "";
				document.product_form.cartRaeLine[1].value = "";
				document.product_form.cartRaeLine[2].value = "";
			}
		}
		else // No return address ordered
		{
			// null the cart fields
			document.product_form.cartRaeLine[0].value = "";
			document.product_form.cartRaeLine[1].value = "";
			document.product_form.cartRaeLine[2].value = "";
		}
	}
} // end validateRA function

// The removeRA function removes the return address lines when the return address
// check box is unchecked.
function removeRA (form)
{
	// The return address box has been unchecked
	if ( form.rae.checked == false )
	{
		form.raeChk[0].checked = true;
		form.raeLine[0].value = "";
		form.raeChk[1].checked = true;
		form.raeLine[1].value = "";
		form.raeChk[2].checked = true;
		form.raeLine[2].value = "";
	}
} // end removeRA function

// The raeCheck function is used to change the return address check box 
// when the user checks the return address line box.
function raeCheck (form, idx)
{
	// checked the line check box to blank out the text line
	if ( form.raeChk[idx].checked == true )
	{
		// clear the text box
		form.raeLine[idx].value = "";
		
		// if all the return address text boxes are null uncheck the return address check box
		if ( form.raeLine[0].value.length == 0 && form.raeLine[1].value.length == 0 && form.raeLine[2].value.length == 0 )
		{
			form.rae.checked = false;
		}
	}
} // end raeCheck function

// The returnAddr function is used to check the return address check box and uncheck the leave blank
// check box when the user adds text to the address text box.
function returnAddr (form,idx)
{
	// text has been added to the text box
	if ( form.raeLine[idx].value.length > 0 )
	{
		form.raeChk[idx].checked = false;
		form.rae.checked = true;
	}
	else // text has been removed from the text box
	{
		form.raeChk[idx].checked = true;
		
		// if all the return address lines are null uncheck the return address check box
		if ( form.raeLine[0].value.length == 0 && form.raeLine[1].value.length == 0 && form.raeLine[2].value.length == 0 )
		{
			form.rae.checked == false;
		}
	}
} // end returnAddr function

// The CheckForm funtion is used to force the user to use a string in the search 
// text box.
function checkForm (form)
{
	if ( form.SRCHSTRNG.value.length <= 2 )
	{
		alert("Please enter a value of at least 3 characters in the search box!")
		return false;
	}
	else
	{
		return true;
	}
} // end checkForm function

// nav bar macros

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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}
// end navbar macro

// Unhide --> 
