var title = [];
title[1] = "<span class='learnAboutHeader'>Type/Styles:</span><br><span class='learnAboutText'><br>Three card and card-keytag configurations for fast/rush printing are available. CR80 credit card size, card plus one key tag and card plus two key tags.";
title[2] = "<p><span class='learnAboutHeader'>Rush Printing:</span><br><span class='learnAboutText'><br>To get the best pricing on rush printing set the printing days to a high number and the shipping time to the fastest. Total days until delivery is notated in the Estimated Delivery in: box.</span>";
title[3] = "<p><span class='learnAboutHeader'>Barcodes and Numbering:</span><br><span class='learnAboutText'><br>Variable barcodes and/or numbers can be printed on the back of the cards and/or the Key Tags.</span>";
title[4] = "<p><span class='learnAboutHeader'>Color:</span><br><span class='learnAboutText'><br>Front of cards is always printed with four colors (CMYK) even if the artwork is one color. The back of the card can be blank, one color (Black) or full color (CMYK). The price is the same for any configuration. Pantone colors cannot be printed on rush jobs.</span>";
function learnText(selection){
	document.getElementById("learn").innerHTML= title[selection];
}
function days1(list) {
         list.length = 6;
         list.options[0].text = "1 Day";
         list.options[0].value = "1";
         list.options[1].text = "2 Days";
         list.options[1].value = "2";
         list.options[2].text = "3 Days";
         list.options[2].value = "3";
         list.options[3].text = "4 Days";
         list.options[3].value = "4";
         list.options[4].text = "5 Days";
         list.options[4].value = "5";
         list.options[5].text = "6 Days";
		 list.options[5].value = "6";
      }
function days2(list) {
		 list.length = 5;
         list.options[0].text = "2 Days";
         list.options[0].value = "2";
         list.options[1].text = "3 Days";
         list.options[1].value = "3";
         list.options[2].text = "4 Days";
         list.options[2].value = "4";
         list.options[3].text = "5 Days";
         list.options[3].value = "5";
         list.options[4].text = "6 Days";
		 list.options[4].value = "6";
      }
function updateDays(thisForm) {
	    if (thisForm.scratch.selectedIndex == 1){
			days2(thisForm.PrintSpeed);
			}else{
				  days1(thisForm.PrintSpeed);
				  }
}

var TAGcardtemplate = [];
TAGcardtemplate[1] = "Cr80_Template.pdf";
TAGcardtemplate[2] = "CreditCardSizeplusTag.pdf";
TAGcardtemplate[3] = "CR80plus2sideTags.pdf";
TAGcardtemplate[4] = "Tripletag.pdf";

function TAGtemplate(){
	if(document.form1.cardTypeNumber.selectedIndex == 0){
		window.alert("First Select the Key Tag Type");
		document.form1.cardTypeNumber.focus();
	}else{
		window.open("cardTemplates/" + TAGcardtemplate[document.form1.cardTypeNumber.selectedIndex], "blank","toolbar=yes, resizable=yes");
	}	
}

function checkForm(formObj) {
     var formOK = true;
      if (formObj.cardTypeNumber.value == "0") {
       window.alert("Please select a Card Type.");
       formObj.cardTypeNumber.focus();
       formOK = false;
	   return;
     }
      if (formObj.quant.value == "0") {
       window.alert("Please select a quantity.");
       formObj.quant.focus();
       formOK = false;
	   return;
     }
	 // Check for correct zip code
     reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
	 var thezip = formObj.zip.value;
     //if (!reZip.test(thezip)) {
     //    alert("Zip Code Is Not Valid");
     //     formOK = false;
	 //  	  return;
	 //}
	 if( formObj.Country.selectedIndex == 0){ // Check US Zip Code 
		 if (!reZip.test(formObj.zip.value)) {
				 alert("Zip Code Is Not Valid");
				 formObj.zip.focus();
				 formOK = false;
				 return;
		 }
	 }else{ //Check Canadian Postal Code
		 reg_exp_pcode = new RegExp(/(^s*([a-z](\s)?\d(\s)?){3}$)s*/i);
		 if(!reg_exp_pcode.test(formObj.zip.value)){
			 alert("Postal Code Is Not Valid");
			 formObj.zip.focus();
			 formOK = false;
			 return;
		 	 }
	  }
	 if (formObj.shipmethod.selectedIndex == 0) {
       window.alert("Please select a UPS Shipping method.");
       formObj.shipmethod.focus();
       formOK = false;
	   return;
     }
	  if (formOK){formObj.submit();}
}


var imageList = new Array;
imageList[0] = new Image;
imageList[0].src = "images/Rush-Jobs-All-L.jpg";
imageList[1] = new Image;
imageList[1].src = "images/Rush-Jobs-CR80-L.jpg";
imageList[2] = new Image;
imageList[2].src = "images/key-cardtag.jpg";
imageList[3] = new Image;
imageList[3].src = "images/key-1plus2sided.jpg";
imageList[4] = new Image;
imageList[4].src = "images/key-3up.jpg";
imageList[5] = new Image;
imageList[5].src = "images/key-taginCr80.jpg";
imageList[6] = new Image;
imageList[6].src = "images/key-singleshop.jpg";
imageList[7] = new Image;
imageList[7].src = "images/key-multi.jpg";
imageList[8] = new Image;
imageList[8].src = "images/key-triple.jpg";
imageList[9] = new Image;
imageList[9].src = "images/key-1plus2sided.jpg";
imageList[10] = new Image;
imageList[10].src = "images/key-1plus3sided.jpg";

function changeImage(imageSelected){
	if(imageSelected != 999){
    	document.form1.cardTypeNumber.selectedIndex = imageSelected;
		}
	document.keytagimage.src = imageList[document.form1.cardTypeNumber.selectedIndex].src;		
}
function isZip(s) 
{

     // Check for correct zip code
     reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);

     if (!reZip.test(s)) {
          alert("Zip Code Is Not Valid");
          return false;
     }

return true;
}
function doNothing(){
 return false;
 }	
 
 function UPS_US(list) { // UPS options for USA
         list.length = 5;
		 list.options[0].text = "--- SELECT USA ---";
		 list.options[0].value = "NULL";
         list.options[1].text = "UPS - Next Day Air";
		 list.options[1].value = "01";
         list.options[2].text = "UPS - Second Day Air";
		 list.options[2].value = "02";
		 list.options[3].text = "UPS - 3 Day Select";
		 list.options[3].value = "12";
		 list.options[4].text = "UPS - Ground (4-5 Days) ";
		 list.options[4].value = "3";
}
function UPS_CA(list) { // UPS options for Canada
         list.length = 4;
		 list.options[0].text = "--- SELECT CANADA ---";
		 list.options[0].value = "NULL";
		 list.options[1].text = "Worldwide Express (Next Day 12:00 pm)";
		 list.options[1].value = "07";
		 list.options[2].text = "Worldwide Expedited (2 Days)";
		 list.options[2].value = "08";
		 list.options[3].text = "Standard (6 Days Max)";
		 list.options[3].value = "11";
}
function setfields(thisForm){
	if (thisForm.Country.selectedIndex == 0){ // USA
		UPS_US(thisForm.shipmethod);
		document.getElementById("deliveryEstimate").innerHTML = "";
	}else{
		UPS_CA(thisForm.shipmethod);
		document.getElementById("deliveryEstimate").innerHTML = "";
	}
}
function estimatedDelivery(){
	var days;
	document.getElementById("deliveryEstimate").innerHTML = "";
	if (document.form1.Country.selectedIndex == 0){ // USA
		if(document.form1.shipmethod.selectedIndex != 0){
			days = document.form1.shipmethod.selectedIndex + document.form1.PrintSpeed.selectedIndex + 1;
			if(document.form1.shipmethod.selectedIndex == 4){
				days = days + 1;
			}
		document.getElementById("deliveryEstimate").innerHTML= days + " Days";
		}
	}else if (document.form1.Country.selectedIndex == 1){ // Canada
		if(document.form1.shipmethod.selectedIndex != 0){
				days = document.form1.shipmethod.selectedIndex + document.form1.PrintSpeed.selectedIndex + 1;
				if(document.form1.shipmethod.selectedIndex == 3){ // Canadian adjustments
					days = days + 3;
				}
			document.getElementById("deliveryEstimate").innerHTML= days + " Days";
			}
	}
	
}