function queryStringRepair(QS){
  //alert(QS);
	if (QS == 'g=1' || QS == 'g=1&' || QS == '&'){
    //alert('returned empty string');
		return '';
	}else if( QS.length > 4){
		if (QS.slice(0,4) == 'g=1&'){
      //alert(QS.slice(4,QS.length));
			return QS.slice(4,QS.length);
		}else if (QS.slice(0,1) == '&'){
      //alert(QS.slice(1,QS.length));
			return QS.slice(1,QS.length);
		}else{
      //alert(QS);
			return QS;
		}
	}else{
    //alert(QS);
		return QS;
	}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

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) { //v3.0
  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); 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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function BuildURL(strAddParamName,strAddParamContents)	{
	if (strAddParamContents == "")	{
		alert("please make a selection before you continue.")
		return;
	}
	if (eval(document.getElementById("changelogo")))	{
		if (document.getElementById("changelogo").value == "true")	{
			opener.doChangeLogo(strAddParamContents)
			close()
			return
		}
	}
	if (eval(document.getElementById("changelogoFlex")))	{
		if (document.getElementById("changelogoFlex").value == "true")	{
			opener.addImage(strAddParamContents, 'stock')
			//close()
			return
		}
	}
	if (eval(document.getElementById("changeBackground")))	{
		if (document.getElementById("changeBackground").value == "true")	{
			opener.doChangeBackground(strAddParamContents)
			close()
			return
		}
	}
	//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&" + strAddParamName + "=" + strAddParamContents
  location.href = "predesign.asp?" + queryStringRepair(document.forms[1].strQueryString.value + "&") + strAddParamName + "=" + strAddParamContents
}
function BuildURL2(strAddParamName,strAddParamContents)	{
	if (strAddParamContents == "")	{
		alert("please make a selection before you continue.")
		return;
	}
	if (eval(document.getElementById("changelogo")))	{
		if (document.getElementById("changelogo").value == "true")	{
			opener.doChangeLogo(strAddParamContents)
			close()
			return
		}
	}
	if (eval(document.getElementById("changelogoFlex")))	{
		if (document.getElementById("changelogoFlex").value == "true")	{
			opener.addImage(strAddParamContents, 'stock')
			//close()
			return
		}
	}
	if (eval(document.getElementById("changeBackground")))	{
		if (document.getElementById("changeBackground").value == "true")	{
			opener.doChangeBackground(strAddParamContents)
			close()
			return
		}
	}
	//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&" + strAddParamName + "=" + strAddParamContents
  location.href = "predesign.asp?" + queryStringRepair(document.forms[1].strQueryString.value + "&") + strAddParamName + "=" + strAddParamContents
  
}
function SendValue(value){
	//alert(value)
	document.forms[1].queryvalue.value = value
}
function AppendValue(attr1,value1,attr2,value2){

	if (value1 == "" || value2 == "" )	{
		alert("Please make both selections before you continue.")
		return;
	}
	if (eval(document.getElementById("changeBackground")))	{
		if (document.getElementById("changeBackground").value == "true")	{
			opener.doChangeBackground(value2)
			close()
			return
		}
	}
	document.forms[1].queryvalue.value = attr1 + "=" + value1 + "&" + attr2 + "=" + value2
	//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&" + document.forms[1].queryvalue.value
  location.href = "predesign.asp?" + queryStringRepair(document.forms[1].strQueryString.value + "&") + document.forms[1].queryvalue.value
  
}
function AppendValue3(attr1,value1,attr2,value2,attr3,value3){
	if (value1 == "" || value2 == "" )	{
		alert("please make both selections before you continue.")
		return;
	}
	document.forms[1].queryvalue.value = attr1 + "=" + value1 + "&" + attr2 + "=" + value2 + "&" + attr3 + "=" + value3
	//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&" + document.forms[1].queryvalue.value
  location.href = "predesign.asp?" + queryStringRepair(document.forms[1].strQueryString.value + "&") + document.forms[1].queryvalue.value
  
}

function AppendValueFlatWallSign(attr1,value1,attr2,value2,attr3,value3){
	if (!IsNumeric(value1)){
		alert("Please enter a number for sign WIDTH.")
		return;
	}
	if (!IsNumeric(value2)){
		alert("Please enter a number for sign HEIGHT.")
		return;
	}
	if (value1 == "" || value2 == "" )	{
		alert("Please enter sign WIDTH and HEIGHT before you continue.")
		return;
	}else{
    if (value1 > 24 || value2 > 24){
        alert("The maximum WIDTH/HEIGHT allowed is 24 inches.")
    		return;
    }
    if (value1 < 0.75 || value2 < 0.75){
        alert("The minimum WIDTH/HEIGHT allowed is 3/4 inches.")
    		return;
    }
  }
	document.forms[1].queryvalue.value = attr1 + "=" + value1 + "&" + attr2 + "=" + value2 + "&" + attr3 + "=" + value3
	//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&" + document.forms[1].queryvalue.value
  location.href = "predesign.asp?" + queryStringRepair(document.forms[1].strQueryString.value + "&") + document.forms[1].queryvalue.value
  
}
function isNumber(n) {
  return !isNaN(parseFloat(n)) && isFinite(n);
}

function IsNumeric(input)
{
   return (input - 0) == input && input.length > 0;
}

function AppendLongValue(attr1,value1,attr2,value2,attr3,value3,attr4,value4){

	document.forms[1].queryvalue.value = attr1 + "=" + value1 + "&" + attr2 + "=" + value2 + "&" + attr3 + "=" + value3 + "&" + attr4 + "=" + value4
	//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&" + document.forms[1].queryvalue.value
  location.href = "predesign.asp?" + queryStringRepair(document.forms[1].strQueryString.value + "&") + document.forms[1].queryvalue.value
  
}
function AppendValueFlatInk(attr1,value1,attr2,value2,attr3,value3,attr4,value4){
	 var form = document.forms[1]
	 
     if (value2 == null){
        alert("please make ink selection before you continue.")
        return;
	}
    if (value1 == "" || value2 == "")	{
		alert("please make both selections before you continue.")
		return;
	}
	for (var i = 0; i < form.length; i ++) {
		if (form.inktype[i].checked) {
			break
		}
	}
	if (form.inktype[i].value)	{
		value3 = form.inktype[i].value
	}
	else	{
		value3 = "raised"
	}

	if(attr4) {
		for (var x = 0; x < form.length; x ++) {
			if (form.rdoBlankSheet[x].checked) {
				break
			}
		}

		if(form.rdoBlankSheet[x].value == "true") {
			value4 = value1
		} else {
			value4 = "none"
		}

		document.forms[1].queryvalue.value = attr1 + "=" + value1 + "&" + attr2 + "=" + value2 + "&" + attr3 + "=" + value3 + "&" + attr4 + "=" + value4
		//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&" + attr1 + "=" + value1 + "&" + attr2 + "=" + value2 + "&" + attr3 + "=" + value3 + "&" + attr4 + "=" + value4
		location.href = "predesign.asp?" + queryStringRepair(document.forms[1].strQueryString.value + "&") + attr1 + "=" + value1 + "&" + attr2 + "=" + value2 + "&" + attr3 + "=" + value3 + "&" + attr4 + "=" + value4
    
    return;
	}


	document.forms[1].queryvalue.value = attr1 + "=" + value1 + "&" + attr2 + "=" + value2 + "&" + attr3 + "=" + value3
	//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&" + document.forms[1].queryvalue.value
	//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&" + attr1 + "=" + value1 + "&" + attr2 + "=" + value2 + "&" + attr3 + "=" + value3
  location.href = "predesign.asp?" + queryStringRepair(document.forms[1].strQueryString.value + "&") + attr1 + "=" + value1 + "&" + attr2 + "=" + value2 + "&" + attr3 + "=" + value3
  
}
function AppendValueFlatInkCat(attr2,value2,attr3,value3){
	var form = document.forms[1]
	if (value2 == "")	{
		alert("please make ink selection before you continue.")
		return;
	}
	for (var i = 0; i < form.length; i ++) {
		if (form.inktype[i].checked) {
			break
		}
	}
	if (form.inktype[i].value)	{
		value3 = form.inktype[i].value
	}
	else	{
		value3 = "raised"
	}

	document.forms[1].queryvalue.value = attr2 + "=" + value2 + "&" + attr3 + "=" + value3
	//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&" + attr2 + "=" + value2 + "&" + attr3 + "=" + value3
  location.href = "predesign.asp?" + queryStringRepair(document.forms[1].strQueryString.value + "&") + attr2 + "=" + value2 + "&" + attr3 + "=" + value3
  
}

function AppendAttributes() {
	var strURL = location.href

	if((arguments.length%2) > 0) {	// Ensure even number of arguments
		return;
	}

	for(var i=0; i < arguments.length; i++) {
		if((i%2) > 0) {	// If value, then...
//			if(arguments[i].length > 0) {
//				for (var x = 0; x < arguments[i].length; x ++) {
//					if (arguments[i][x].checked) {
//						strURL += arguments[i][x].value
//					}
//				}
//			} else {
				strURL += arguments[i]
//			}
		} else {	// If attribute, then...
			strURL += "&" + arguments[i] + "="
		}
	}

	location.href = strURL

//	if (value1 == "" || value2 == "")	{
//		alert("please make both selections before you continue.")
//		return;
//	}
//	for (var i = 0; i < form.length; i ++) {
//		if (form.inktype[i].checked) {
//			break
//		}
//	}
//	if (form.inktype[i].value)	{
//		value3 = form.inktype[i].value
//	}
//	else	{
//		value3 = "raised"
//	}
//	document.forms[1].queryvalue.value = attr1 + "=" + value1 + "&" + attr2 + "=" + value2 + "&" + attr3 + "=" + value3
//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&" + document.forms[1].queryvalue.value
//	location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&" + attr1 + "=" + value1 + "&" + attr2 + "=" + value2 + "&" + attr3 + "=" + value3

}

function swapAttributes(value1, value2){
	var PrevQueryString = document.editForm.strQueryString.value
	if (PrevQueryString.indexOf(value1,0)==-1){
		document.editForm.strQueryString.value = PrevQueryString + "&" + value1 + value2
	}
	else{
		var GraphicQueryString = PrevQueryString.substring(PrevQueryString.indexOf(value1,0), PrevQueryString.length)
    if (GraphicQueryString.indexOf("&") == -1){
			document.editForm.strQueryString.value = PrevQueryString.substring(0, PrevQueryString.indexOf(value1, 0)) + value1 + value2
		}
		else{
			var graphicString = GraphicQueryString.substring(GraphicQueryString.indexOf(value1,0), GraphicQueryString.indexOf("&",0))
      var arrGraphic = graphicString.split("=");
			var graphicName = arrGraphic[1];
			GraphicQueryString = GraphicQueryString.replace(graphicName, value2);
			document.editForm.strQueryString.value = PrevQueryString.substring(0, PrevQueryString.indexOf(value1, 0)) + GraphicQueryString
		}
	}
}

function MenuSelect(value)	{
if (eval(document.getElementById("changelogo")))	{
	if (document.getElementById("changelogo").value == "true")	{
		//alert("graphic_library.asp?" + document.getElementById("changelogoQueryString").value + "graphic_library=" + value)
		if (document.getElementById("changelogoQueryString").value.indexOf("graphic_library", 0) == -1){
			location.href = "graphic_library.asp?" + document.getElementById("changelogoQueryString").value + "&graphic_library=" + value
			return
		}
		else{
			var PrevQueryString = document.getElementById("changelogoQueryString").value
			PrevQueryString = PrevQueryString.substring(0,PrevQueryString.indexOf("graphic_library",0))
			location.href = "graphic_library.asp?" + PrevQueryString + "graphic_library=" + value
			return
		}
	}
}
if (document.predesign.strQueryString.value.indexOf("graphic_library",0) == -1){
//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&graphic_library=" + value
location.href = "predesign.asp?" + queryStringRepair(document.forms[1].strQueryString.value) + "&graphic_library=" + value

}
if (document.predesign.strQueryString.value.indexOf("graphic_library",0) != -1){
var PrevQueryString
PrevQueryString = queryStringRepair(document.forms[1].strQueryString.value) //document.forms[1].strQueryString.value
PrevQueryString = PrevQueryString.substring(0,document.predesign.strQueryString.value.indexOf("graphic_library",0))
location.href = "predesign.asp?" + PrevQueryString + "graphic_library=" + value
}
}
function MenuSelect2(value)	{
if (document.predesign.strQueryString.value.indexOf("templatechoice",0) == -1){
//location.href = "predesign.asp?" + document.forms[1].strQueryString.value + "&templatechoice=" + value
location.href = "predesign.asp?" + queryStringRepair(document.forms[1].strQueryString.value + "&") + "templatechoice=" + value

}
if (document.predesign.strQueryString.value.indexOf("templatechoice",0) != -1){
var PrevQueryString
PrevQueryString = queryStringRepair(document.forms[1].strQueryString.value) //document.forms[1].strQueryString.value
PrevQueryString = PrevQueryString.substring(0,document.predesign.strQueryString.value.indexOf("templatechoice",0))
location.href = "predesign.asp?" + PrevQueryString + "templatechoice=" + value
}
}
function ForwardHREF(URL){
	window.location.href = URL
}
function ReplaceHREF(URL){
	window.location.replace(URL)
}
function DoSubmit()	{
  var graphicFileName = document.predesign.graphicfile.value
	if ( graphicFileName!= "") {
	    var fileExtension = graphicFileName.substr(graphicFileName.length-3).toLowerCase()
     if (fileExtension!="gif"&&fileExtension!="jpg"&&fileExtension!="peg"&&fileExtension!="png"&&fileExtension!="bmp"&&fileExtension!="tif"
     &&fileExtension!="iff"&&fileExtension!="eps"&&fileExtension!="pdf"&&fileExtension!=".ps"&&fileExtension!="psd"&&fileExtension!="emf"&&fileExtension!="ico"){
          alert("We are Sorry. \nThe File Format you chose to upload- " + fileExtension.toUpperCase() + "- is not supported.\n\n We support the following formats: \n GIF, JPG, PNG, BMP, TIF, PDF, EPS, PS, PSD, EMF, ICO.")
          return
       }
       else{
           document.predesign.submit()
    	     return
      }
 	}
	alert("please choose a file to upload.")
}
function dologinsubmit() {
	//document.addtocart.submit()
	if (document.LoginForm.username.value == "" || document.LoginForm.password.value == "")	{
		alert("please enter your Login ID and Password before you continue.")
		return;
	}
	document.LoginForm.submit()
}
function UpdateApproveCart()	{
	if (document.cart.changed.value == "false") {
		document.cart.job.value = "approve"
		document.cart.submit()
	} else {
		alert("Items have changed. Please click Update.")
	}
}
function UpdateDeleteCart()	{
		document.cart.job.value = "delete"
		document.cart.submit()
}
function UpdateUpdateCart()	{
		document.cart.job.value = "update"
		document.cart.submit()
}
function UpdateCart()	{
		//for(var i=1; i < document.cart.quantity.length+1; i++)	{
		//	if (document.cart.quantity[i-1].value < 1)	{
		//		if (confirm("you have entered a zero quantity for a shopping cart item. would you like to delete this item from your cart?") == false)	{
		//			return
		//		}
		//	}
		//}
		document.cart.submit()
}

function UpdateCartCheckout()	{
		document.cart.action = document.cart.action + "&checkout=true"
		document.cart.submit()
}
function UpdateArchive()	{
		document.archive.submit()
}
function DoOrderFormSubmit()	{
	document.OrderForm.submit()
}
function DoExecutiveGiftsOrderFormSubmit(item)	{
 var frm = document.forms["OrderForm"];
 if(item==""){
     if(frm.SIGNTEXT1.value==""){
        var fRet;
        fRet = confirm('You entered no text to be engraved. Proceed to the shopping cart?');
        if(fRet==false){
        } else{
          document.OrderForm.submit()
        }
     }else{
          if(frm.SIGNTEXT1.value!="" && frm.FONT.value == ""){
            alert('Please select a font.');
          }
          else{
            document.OrderForm.submit()
          }
       }
  }else{
     if(frm.SIGNTEXT1.value=="" && frm.SIGNTEXT2.value=="" && frm.SIGNTEXT3.value==""){
          var fRet;
          fRet = confirm("You entered no text to be engraved. Proceed to the shopping cart?\n\nClick 'OK' to proceed to the Shopping Card, or click 'Cancel' to modify engraving text information.");
          if(fRet==false){
          }else{
            document.OrderForm.submit()
          }
       }else{
          if(frm.SIGNTEXT1.value!="" && frm.FONT[0].value ==""){
            alert('Please select a font for pen text.')
          }
          else if(frm.SIGNTEXT2.value!="" && frm.FONT[1].value ==""){
            alert('Please select a font for pencil text.')
          }
          else if(frm.SIGNTEXT3.value!="" && frm.FONT[2].value ==""){
            alert('Please select a font for box text.')
          }
         else{
            var rVal
            var tMessage = "You've entered the following text to be engraved:"
            tMessage = tMessage + "\n  Text on the Pen: "
            if(frm.SIGNTEXT1.value==""){
                tMessage = tMessage + " no engraving"
            }else{
                tMessage = tMessage + "'" + frm.SIGNTEXT1.value + "' ---- Font: " + frm.FONT[0].value
            }
            tMessage = tMessage + "\n  Text on the Pencil: "
            if(frm.SIGNTEXT2.value==""){
                tMessage = tMessage + " no engraving"
            }else{
                tMessage = tMessage + "'" + frm.SIGNTEXT2.value + "'----Font: " + frm.FONT[1].value
            }
            tMessage = tMessage + "\n  Text on the Box: "
            if(frm.SIGNTEXT3.value==""){
                tMessage = tMessage + " no engraving"
            }else{
                tMessage = tMessage + "'" + frm.SIGNTEXT3.value + "'----Font: " + frm.FONT[2].value
            }
            tMessage = tMessage + "\n\nClick 'OK' to proceed to the Shopping Card, or click 'Cancel' to modify engraving text information."
            rVal = confirm(tMessage)
            if(rVal==false){
            }else{
                document.OrderForm.submit()
            }
          }
       }

   }
}
function SubmitAccount()	{
	document.account.submit()
}

function ShipSame(isOn)	{
	/*if (isOn == 1)	{
		document.account.Ship_Addr1.value = document.account.Bill_Addr1.value
		document.account.Ship_Addr2.value = document.account.Bill_Addr2.value
		document.account.Ship_City.value = document.account.Bill_City.value
		document.account.Ship_State.value = document.account.Bill_State.value
		document.account.Ship_ZipCode.value = document.account.Bill_ZipCode.value
	}*/
	if (isOn == "False")	{
		document.account.Ship_Addr1.value = document.account.Bill_Addr1.value
		document.account.Ship_Addr2.value = document.account.Bill_Addr2.value
		document.account.Ship_City.value = document.account.Bill_City.value
		document.account.Ship_State.value = document.account.Bill_State.value
		document.account.Ship_ZipCode.value = document.account.Bill_ZipCode.value
		document.account.ShipSameAsBill.value="True"
	}
	if (isOn == "True")	{
		document.account.Ship_Addr1.value = ""
		document.account.Ship_Addr2.value = ""
		document.account.Ship_City.value = ""
		document.account.Ship_State.value = ""
		document.account.Ship_ZipCode.value = ""
		document.account.ShipSameAsBill.value="False"
	}
}
function BillSame(isOn)	{
	/*if (isOn == 1)	{
		document.account.Bill_Addr1.value =  document.account.Ship_Addr1.value
		document.account.Bill_Addr2.value = document.account.Ship_Addr2.value
		document.account.Bill_City.value = document.account.Ship_City.value
		document.account.Bill_State.value = document.account.Ship_State.value
		document.account.Bill_ZipCode.value = document.account.Ship_ZipCode.value
	}*/
		if (isOn == "False")	{
		if (eval(document.account.Ship_Addr1)){
			document.account.Bill_Addr1.value =  document.account.Ship_Addr1.value
			document.account.Bill_Addr2.value = document.account.Ship_Addr2.value
			document.account.Bill_City.value = document.account.Ship_City.value
			document.account.Bill_State.value = document.account.Ship_State.value
			document.account.Bill_ZipCode.value = document.account.Ship_ZipCode.value
			document.account.BillSameAsShip.value="True"
		}else{
			document.account.Bill_Addr1.value =  document.currShippingAddr.currShipAddr1.value
			document.account.Bill_Addr2.value = document.currShippingAddr.currShipAddr2.value
			document.account.Bill_City.value = document.currShippingAddr.currShipCity.value
			document.account.Bill_State.value = document.currShippingAddr.currShipState.value
			document.account.Bill_ZipCode.value = document.currShippingAddr.currShipZipCode.value
			document.account.BillSameAsShip.value="True"
		}
	}
	if (isOn == "True")	{
		document.account.Bill_Addr1.value =  ""
		document.account.Bill_Addr2.value = ""
		document.account.Bill_City.value = ""
		document.account.Bill_State.value = ""
		document.account.Bill_ZipCode.value = ""
		document.account.BillSameAsShip.value="False"
	}
}
function MailSame(isOn)	{
	if (isOn == 1)	{
		document.account.Mail_Addr1.value = document.account.Bill_Addr1.value
		document.account.Mail_Addr2.value = document.account.Bill_Addr2.value
		document.account.Mail_City.value = document.account.Bill_City.value
		document.account.Mail_State.value = document.account.Bill_State.value
		document.account.Mail_ZipCode.value = document.account.Bill_ZipCode.value
	}
}
function checkBrowserDesigner() {
		//set this to test netscape
		//var isIE = true
		var isIE = false
		var agent	= navigator.userAgent.toLowerCase();
		if (agent.indexOf("msie") != -1)	{
			//indicates an ie browser
			if (parseInt(navigator.appVersion) >= 4)	{
				//indicates ie 4.x or higher
				isIE = true
			}
		}

		if (isIE == false)	{
			//Redirect non IE users
			window.location.replace("http://<%=ServerName%>/browsercheck.asp");
		}
	}
		
function checkBrowser() {
		//set this to test netscape
		//var isIE = true
		var isIE = false
		var agent	= navigator.userAgent.toLowerCase();
		if (agent.indexOf("msie") != -1)	{
			//indicates an ie browser
			if (parseInt(navigator.appVersion) >= 4)	{
				//indicates ie 4.x or higher
				isIE = true
			}
		}

		if (isIE == false)	{
			//Redirect non IE users
			//window.location.replace("browsercheck.asp" + window.location.search);
			}
		}

function checkBrowserHomepage() {
		//set this to test netscape
		//var isIE = true
		var isIE = false
		var agent	= navigator.userAgent.toLowerCase();
		if (agent.indexOf("msie") != -1)	{
			//indicates an ie browser
			if (parseInt(navigator.appVersion) >= 4)	{
				//indicates ie 4.x or higher
				isIE = true
				//openPromoWin()
			}
		}

		if (isIE == false)	{
			//Redirect non IE users
			//window.location.replace("browsercheck.asp");
			}
		}

function openPriceWin(prodsubcat)	{
	window.open('pop_up_price_chart.asp?prodsubcat=' + prodsubcat,'newwin','height=400,width=550,scrollbars=yes, resizable')
	}

function openPriceWin2(prodsubcat)	{
	window.open('pop_up_price_chart_postit.asp?' + prodsubcat,'newwin','height=400,width=550,scrollbars=yes, resizable')
	}
function openPriceWin3(prodsubcat)	{
	window.open('pop_up_price_chart_shipping.asp?prodsubcat=' + prodsubcat,'newwin','height=400,width=550,scrollbars=yes, resizable')
	}
function openPriceWin4(prodsubcat)	{
	window.open('pop_up_price_chart_env.asp?prodsubcat=' + prodsubcat,'newwin','height=410,width=570,scrollbars=yes, resizable')
	}
function openPriceWin5(prodsubcat)	{
	window.open('pop_up_price_chart_label.asp?prodsubcat=' + prodsubcat,'newwin','height=400,width=550,scrollbars=yes, resizable')
	}
function openPriceWin6(prodsubcat, template)	{
	window.open('pop_up_price_chart_form.asp?prodsubcat=' + prodsubcat + '&template=' + template,'newwin','height=400,width=550,scrollbars=yes, resizable')
	}
function openPriceWin7(prodsubcat)	{
	window.open('pop_up_price_chart_blank.asp?prodsubcat=' + prodsubcat,'newwin','height=400,width=550,scrollbars=yes, resizable')
	}
function openPriceWin8(prodsubcat)	{
	window.open('pop_up_price_chart_businesscards.asp?prodsubcat=' + prodsubcat,'newwin','height=400,width=550,scrollbars=yes, resizable')
	}
function openInfo() {
	OpenWindow = window.open('morepaperinfo.html','Info',config='height=240,width=275,toolbar=no,menubar=no,scrollbars=no,resizable=no')
}



function doToolbarLoad()	{
MM_preloadImages('images/staplestoolbar/stamps2.gif','images/staplestoolbar/signs2.gif','images/staplestoolbar/promo2.gif','images/staplestoolbar/home2.gif','images/staplestoolbar/viewcart2.gif','images/staplestoolbar/customerservice2.gif','images/staplestoolbar/archives2.gif','images/staplestoolbar/checkout2.gif','images/staplestoolbar/help2.gif')
}
function doDelete(graphic)	{
	document.frmDelete.deletegraphics.value = graphic
	document.frmDelete.submit()
}

function openGraphicRulesWin()	{
window.open('graphic_upload_rules.asp','newwin','height=300,width=420,scrollbars=yes, resizable')
}

function showPopUp() {
var newWindow = window.open('','newwin', 'height=150,width=300,scrollbars=no, resizable')

newWindow.document.write('<html>')
newWindow.document.write('<head><title>Thermography Printing</title></head><body>')
newWindow.document.write('<font size="2" face="Arial, Helvetica, sans-serif"><b>Thermography</b> is a  raised printing process that involves dusting powder on ink and heating to make the lettering rise.  If you would rather not use this technique, please choose the <i>flat ink</i> option when you select your ink color(s).')
newWindow.document.write('<br><br><a href="javascript: self.close()">Close Window</a></font>')
newWindow.document.write('</body></html>')

}

function getInkType() {
	var form = document.forms[1]
	for (var i = 0; i < form.length; i ++) {
		if (form.inktype[i].checked) {
			break
		}
	}
}

function getPaperColor(paper, index) {
	document.getElementById.paper[index].setAttribute("checked", true)
	SendValue(paper)
}

function checkForEnter(evt)	{
	evt = (evt) ? evt : event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if (charCode == 13)	{
		document.sidebarlogin.submit()
		return false
	}
	return true
}

//function checkForEnter2(evt)	{
//	evt = (evt) ? evt : event
//	var charCode = (evt.which) ? evt.which : evt.keyCode
//	if (charCode == 13)	{
//		checkCUID()
//		return false
//	}
//	return true
//}

function checkForEnter3(evt)	{
	evt = (evt) ? evt : event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if (charCode == 13)	{
		ProofItem()
		return false
	}
	return true
}

function checkForSize() {
	var form = document.OrderForm
	if (form.HEIGHT.value == '' || form.WIDTH.value == '') {
		alert('Please enter a Height and Width for your product.')
	} else {
		DoOrderFormSubmit()
	}
}
function getColorSelection(formID,radioName){
    var color = null;
    for(var i=0;i<document.forms[1].colors.length;i++){
	    if(document.forms[1].colors[i].checked){
		    color = document.forms[1].colors[i].value;
		}

    }
	if (color == null){
	  alert("please make ink selection before you continue.")
	  return;     
    }
    return color;
}

function checkSignSize(){		
	if (document.forms[1].WIDTH.value == "" || document.forms[1].HEIGHT.value == "" )	{
		alert("Please enter sign WIDTH and HEIGHT before you continue.")
		return;
	}else{
	    if (document.forms[1].WIDTH.value > 20){
	        alert("The maximum WIDTH allowed is 20 inches.")
	    		return;
	    }
	    if (document.forms[1].HEIGHT.value > 12){
	        alert("The maximum HEIGHT allowed is 12 inches.")
	    		return;
	    }
	    if (document.forms[1].WIDTH.value  < 0.75 || document.forms[1].HEIGHT.value < 0.75){
	        alert("The minimum WIDTH/HEIGHT allowed is 3/4 inches.")
	    		return;
	    }
	}
	DoOrderFormSubmit();
}

  //Drop Down/ Overlapping Content: http://www.dynamicdrive.com
  //**Updated: Dec 19th, 07': Added ability to dynamically populate a Drop Down content using an external file (Ajax feature)
  //**Updated: Feb 29th, 08':
  //1) Added ability to reveal drop down content via "click" of anchor link (instead of default "mouseover")
  //2) Added ability to disable drop down content from auto hiding when mouse rolls out of it
  //3) Added hidediv(id) public function to directly hide drop down div dynamically

  //**Updated: Sept 11th, 08': Fixed bug whereby drop down content isn't revealed onClick of anchor in Safari/ Google Chrome
  //
  
  var dropdowncontent = {
  disableanchorlink: true, //when user clicks on anchor link, should link itself be disabled (always true if "revealbehavior" above set to "click")
  hidedivmouseout: [true, 200], //Set hiding behavior within Drop Down DIV itself: [hide_div_onmouseover?, miliseconds_before_hiding]
  ajaxloadingmsg: "Loading content. Please wait...", //HTML to show while ajax page is being feched, if applicable
  ajaxbustcache: true, //Bust cache when fetching Ajax pages?

  getposOffset: function(what, offsettype) {
  return (what.offsetParent) ? what[offsettype] + this.getposOffset(what.offsetParent, offsettype) : what[offsettype]
  },

  isContained: function(m, e) {
  var e = window.event || e
  var c = e.relatedTarget || ((e.type == "mouseover") ? e.fromElement : e.toElement)
  while (c && c != m) try { c = c.parentNode } catch (e) { c = m }
  if (c == m)
  return true
  else
  return false
  },

  show: function(anchorobj, subobj, e) {
  if (!this.isContained(anchorobj, e) || (e && e.type == "click")) {
  var e = window.event || e
  if (e.type == "click" && subobj.style.visibility == "visible") {
  subobj.style.visibility = "hidden"
  return
  }
  var horizontaloffset = (subobj.dropposition[0] == "left") ? -(subobj.offsetWidth - anchorobj.offsetWidth) : 0 //calculate user added horizontal offset
  var verticaloffset = (subobj.dropposition[1] == "top") ? -subobj.offsetHeight : anchorobj.offsetHeight //calculate user added vertical offset
  subobj.style.left = this.getposOffset(anchorobj, "offsetLeft") + horizontaloffset + "px"
  subobj.style.top = this.getposOffset(anchorobj, "offsetTop") + verticaloffset - 20 + "px"
  subobj.style.clip = (subobj.dropposition[1] == "top") ? "rect(auto auto auto 0)" : "rect(0 auto 0 0)" //hide drop down box initially via clipping
  subobj.style.visibility = "visible"
  subobj.startTime = new Date().getTime()
  subobj.contentheight = parseInt(subobj.offsetHeight)
  if (typeof window["hidetimer_" + subobj.id] != "undefined") //clear timer that hides drop down box?
  clearTimeout(window["hidetimer_" + subobj.id])
  this.slideengine(subobj, (subobj.dropposition[1] == "top") ? "up" : "down")
  }
  },

  curveincrement: function(percent) {
  return (1 - Math.cos(percent * Math.PI)) / 2 //return cos curve based value from a percentage input
  },

  slideengine: function(obj, direction) {
  var elapsed = new Date().getTime() - obj.startTime //get time animation has run
  if (elapsed < obj.glidetime) { //if time run is less than specified length
            var distancepercent = (direction == "down") ? this.curveincrement(elapsed / obj.glidetime) : 1 - this.curveincrement(elapsed / obj.glidetime)
            var currentclip = (distancepercent * obj.contentheight) + "px"
            obj.style.clip = (direction == "down") ? "rect(0 auto " + currentclip + " 0)" : "rect(" + currentclip + " auto auto 0)"
            window["glidetimer_" + obj.id] = setTimeout(function() { dropdowncontent.slideengine(obj, direction) }, 10)
        }
        else { //if animation finished
            obj.style.clip = "rect(0 auto auto 0)"
        }
    },

    hide: function(activeobj, subobj, e) {
        if (!dropdowncontent.isContained(activeobj, e)) {
            window["hidetimer_" + subobj.id] = setTimeout(function() {
                subobj.style.visibility = "hidden"
                subobj.style.left = subobj.style.top = 0
                clearTimeout(window["glidetimer_" + subobj.id])
            }, dropdowncontent.hidedivmouseout[1])
        }
    },

    hidediv: function(subobjid) {
        document.getElementById(subobjid).style.visibility = "hidden"
    },

    ajaxconnect: function(pageurl, divId) {
        var page_request = false
        var bustcacheparameter = ""
        if (window.XMLHttpRequest) // if Mozilla, IE7, Safari etc
            page_request = new XMLHttpRequest()
        else if (window.ActiveXObject) { // if IE6 or below
            try {
                page_request = new ActiveXObject("Msxml2.XMLHTTP")
            }
            catch (e) {
                try {
                    page_request = new ActiveXObject("Microsoft.XMLHTTP")
                }
                catch (e) { }
            }
        }
        else
            return false
        document.getElementById(divId).innerHTML = this.ajaxloadingmsg //Display "fetching page message"
        page_request.onreadystatechange = function() { dropdowncontent.loadpage(page_request, divId) }
        if (this.ajaxbustcache) //if bust caching of external page
            bustcacheparameter = (pageurl.indexOf("?") != -1) ? "&" + new Date().getTime() : "?" + new Date().getTime()
  page_request.open('GET', pageurl + bustcacheparameter, true)
  page_request.send(null)
  },

  loadpage: function(page_request, divId) {
  if (page_request.readyState == 4 && (page_request.status == 200 || window.location.href.indexOf("http") == -1)) {
  document.getElementById(divId).innerHTML = page_request.responseText
  }
  },

  init: function(anchorid, pos, glidetime, revealbehavior) {
  var anchorobj = document.getElementById(anchorid)
  var subobj = document.getElementById(anchorobj.getAttribute("rel"))
  var subobjsource = anchorobj.getAttribute("rev")
  if (subobjsource != null && subobjsource != "")
  this.ajaxconnect(subobjsource, anchorobj.getAttribute("rel"))
  subobj.dropposition = pos.split("-")
  subobj.glidetime = glidetime || 1000
  subobj.style.left = subobj.style.top = 0
  if (typeof revealbehavior == "undefined" || revealbehavior == "mouseover") {
  anchorobj.onmouseover = function(e) { dropdowncontent.show(this, subobj, e) }
  anchorobj.onmouseout = function(e) { dropdowncontent.hide(subobj, subobj, e) }
  if (this.disableanchorlink) anchorobj.onclick = function() { return false }
  }
  else
  anchorobj.onclick = function(e) { dropdowncontent.show(this, subobj, e); return false }
  if (this.hidedivmouseout[0] == true) //hide drop down DIV when mouse rolls out of it?
  subobj.onmouseout = function(e) { dropdowncontent.hide(this, subobj, e) }
  }
  }
  
