//show-hide ship-to
function ShowHideShipTo(Action){
 if(Action=="true"){
  document.getElementById("ShipToDisplayFlag").value = "0";
  document.getElementById("ShipToHeaderPadding").style.display='none';
  document.getElementById("ShipToHeaderLabel").style.display='none';
  document.getElementById("ShipToHeaderText").style.display='none';
  document.getElementById("ShipCopyBillTo").style.display='none';
  document.getElementById("FirstNameShip").style.display='none';
  document.getElementById("LastNameShip").style.display='none';
  document.getElementById("CompanyShip").style.display='none';
  document.getElementById("StreetShip").style.display='none';
  document.getElementById("Street2Ship").style.display='none';
  document.getElementById("Street3Ship").style.display='none';
  document.getElementById("CityShip").style.display='none';
  document.getElementById("CountryShip").style.display='none';
  document.getElementById("ShipState").style.display='none';
  document.getElementById("ZipShip").style.display='none';
  document.getElementById("PhoneShip").style.display='none';
  document.getElementById("EmailShip").style.display='none';
  document.getElementById("ShipToLocType").style.display='none';
  document.getElementById("AddressBook").style.display='none';
  }
  else{
  document.getElementById("ShipToDisplayFlag").value = "1";
  document.getElementById("ShipToHeaderPadding").style.display='block';
  document.getElementById("ShipToHeaderLabel").style.display='block';
  document.getElementById("ShipToHeaderText").style.display='block';
  document.getElementById("ShipCopyBillTo").style.display='block';
  document.getElementById("FirstNameShip").style.display='block';
  document.getElementById("LastNameShip").style.display='block';
  document.getElementById("CompanyShip").style.display='block';
  document.getElementById("StreetShip").style.display='block';
  document.getElementById("Street2Ship").style.display='block';
  document.getElementById("Street3Ship").style.display='block';
  document.getElementById("CityShip").style.display='block';
  document.getElementById("CountryShip").style.display='block';
  document.getElementById("ShipState").style.display='block';
  document.getElementById("ZipShip").style.display='block';
  document.getElementById("PhoneShip").style.display='block';
  document.getElementById("EmailShip").style.display='block';
  document.getElementById("ShipToLocType").style.display='block';
  document.getElementById("AddressBook").style.display='block';
  }
}

//clear cookies
function cookieClear(){
  var cookie = document.cookie.split(/;\s*/);
  for(var i=0;i<cookie.length;i++){
    var cName = cookie[i].split('=')[0];
    document.cookie=cName+"=; path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT;";
    document.cookie=cName+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT;";
  }
}

//validate session timeout
function SessionTimeout(TimeoutTime,Message,RedirectOkURL,RedirectCancelURL){
  setTimeout("ConfirmRedirect('"+Message+"','"+RedirectOkURL+"','"+RedirectCancelURL+"')",TimeoutTime) 
}

//confirm response and redirect
function ConfirmRedirect(Message,RedirectOkURL,RedirectCancelURL){
 var response = confirm(Message)

   if (response==true) {  //user pressed OK
   location.href=RedirectOkURL  
   } 
   else {  //user pressed Cancel
   location.href=RedirectCancelURL
   }
} 

//validate gift card email address
function ValidateGiftCardOrder(){

 //get the recipient id
  var RecipientToId = document.getElementById("RecipientTo").value
  var RecipientFromId = document.getElementById("RecipientFrom").value
  var RecipientEmailId = document.getElementById("RecipientEmail").value
  var RecipientEmailConfirmId = document.getElementById("RecipientEmailConfirm").value
  
 //validate the To field 
  var RecipientTo = document.getElementById(RecipientToId).value

  if (RecipientTo == ""){
     alert("The To field is required");
     document.getElementById(RecipientToId).focus()
     document.getElementById(RecipientToId).select()
     return false
   }

 //validate the From field 
  var RecipientFrom = document.getElementById(RecipientFromId).value
  
  if (RecipientFrom == ""){
     alert("The From field is required");
     document.getElementById(RecipientFromId).focus();
     document.getElementById(RecipientFromId).select();
     return false;
   }
  
 //validate the recipient email
 
  var RecipientEmail = document.getElementById(RecipientEmailId).value.toUpperCase()
  
  if (RecipientEmail == ""){
     alert("The Recipient Email field is required");
     document.getElementById(RecipientEmailId).focus();
     document.getElementById(RecipientEmailId).select();
     return false;
   }
   
 // Validate the recipient email address is formatted correctly
  
  if (reEmail.test(RecipientEmail)) { 
   } // The email is valid 
	 else { 
	 alert("The Recipient Email address isn't valid.  Please use the following format: john@company.com")
     document.getElementById(RecipientEmailId).focus();
     document.getElementById(RecipientEmailId).select();
	 return false; 
   }

 //validate the confirm email
 
  var RecipientEmailConfirm = document.getElementById(RecipientEmailConfirmId).value.toUpperCase()

  if (RecipientEmailConfirm == ""){
     alert("The Confirm Email field is required");
     document.getElementById(RecipientEmailConfirmId).focus();
     document.getElementById(RecipientEmailConfirmId).select();
     return false;
   }
   
 //validate the email addresses match 
 
  if (RecipientEmail != RecipientEmailConfirm){
     alert("The email addresses must match");
     document.getElementById(RecipientEmailConfirmId).focus();
     document.getElementById(RecipientEmailConfirmId).select();
     return false;
   }
   
}

//validation function for iContact.com
  function verifyRequired(First_Name_Required,Last_Name_Required,Prefix_Required,Suffix_Required,Fax_Required,Phone_Required,Business_Required,Address_1_Required,City_Required,State_Required,Zip_Required) {
   if (document.icpsignup.fields_email.value == "" || document.icpsignup.fields_email.value == "Email") {
    alert("The Email field is required.");
    return false;
   }
    
   if (First_Name_Required == "Yes"){
    if (document.icpsignup.fields_fname.value == "" || document.icpsignup.fields_fname.value == "First Name") {
     alert("The First Name field is required.");
     return false;
    }
   }

   if (Last_Name_Required == "Yes"){
    if (document.icpsignup.fields_lname.value == "" || document.icpsignup.fields_lname.value == "Last Name") {
     alert("The Last Name field is required.");
     return false;
    }
   }
   
   if (Prefix_Required == "Yes"){
    if (document.icpsignup.fields_prefix.value == "" || document.icpsignup.fields_prefix.value == "Prefix") {
     alert("The Prefix field is required.");
     return false;
    }
   }
   
   if (Suffix_Required == "Yes"){
    if (document.icpsignup.fields_suffix.value == "" || document.icpsignup.fields_suffix.value == "Suffix") {
     alert("The Suffix field is required.");
     return false;
    }
   }

   if (Fax_Required == "Yes"){
    if (document.icpsignup.fields_fax.value == "" || document.icpsignup.fields_fax.value == "Fax Number") {
     alert("The Fax Number field is required.");
     return false;
    }
   }
   
   if (Phone_Required == "Yes"){
    if (document.icpsignup.fields_phone.value == "" || document.icpsignup.fields_phone.value == "Phone Number") {
     alert("The Phone Number field is required.");
     return false;
    }
   }
   
   if (Business_Required == "Yes"){
    if (document.icpsignup.fields_business.value == "" || document.icpsignup.fields_business.value == "Company") {
     alert("The Company field is required.");
     return false;
    }
   }
   
   if (Address_1_Required == "Yes"){
    if (document.icpsignup.fields_address1.value == "" || document.icpsignup.fields_address1.value == "Address 1") {
     alert("The Address 1 field is required.");
     return false;
    }
   }
   
   if (City_Required == "Yes"){
    if (document.icpsignup.fields_city.value == "" || document.icpsignup.fields_city.value == "City") {
     alert("The City field is required.");
     return false;
    }
   }
   
   if (State_Required == "Yes"){
    if (document.icpsignup.fields_state.value == "" || document.icpsignup.fields_state.value == "State/Province") {
     alert("The State/Province field is required.");
     return false;
    }
   }
   
   if (Zip_Required == "Yes"){
    if (document.icpsignup.fields_zip.value == "" || document.icpsignup.fields_zip.value == "Postal Code") {
     alert("The Postal Code field is required.");
     return false;
    }
   }
   
   return true;
}

//validate check for express ordering
var checkflag = "false";

function check(field) {
 if (checkflag == "false") {
   for (i = 0; i < field.length; i++) {
     field[i].checked = true;}
     checkflag = "true";
     return "Uncheck"; }
  else {
   for (i = 0; i < field.length; i++) {
     field[i].checked = false; }
     checkflag = "false";
     return "Check All"; }
}

//validate string is not empty by trimming left and right
		function trimAll(sString) 
         { 
           while (sString.substring(0,1) == ' ')
            {// trim the left side of string
              sString = sString.substring(1, sString.length);
            }
           while (sString.substring(sString.length-1, sString.length) == ' ')
            {// trim the right side of string
              sString = sString.substring(0,sString.length-1);
            }
          return sString;
        }

//validate login page
    function PaymentMethodValidation(PaymentGateway,OrderAmount) {

	// set the action for the form
	
	  //handle No Charge    
	   if(OrderAmount == "0"){
          form1.action = "Checkout3a.asp";
          form1.submit()
           }
          
     //handle credit cards 
       if(OrderAmount > "0"){  
       if(document.getElementById("payMethod0DisplayFlag").value == "1"){
	    if(document.getElementById("payMethod0").checked){
         
			// Validate credit card name
				if (document.form1.ccname.value == "")
					{ alert("The cardholder name isn't valid");
						document.form1.ccname.focus();
						document.form1.ccname.select(); 
						return false }
						
			// Validate credit card number
				if (document.form1.ccnumber.value == "")
					{ alert("The credit card number isn't valid");
						document.form1.ccnumber.focus();
						document.form1.ccnumber.select(); 
						return false }
						
			// Validate credit card expiration month
				  if (document.form1.expMonth.value == "")
					{ alert("The credit card expiration month isn't valid");
						document.form1.expMonth.focus(); 
						return false }
						
			// Validate credit card expiration year
				  if (document.form1.expYear.value == "")
					{ alert("The credit card expiration year isn't valid");
						document.form1.expYear.focus();
						return false }
					
			// Set action
 				  if(PaymentGateway == "NONE"){
                    form1.action = "Checkout3a.asp";
                   }
                   
	              if(PaymentGateway == "AUTHORIZE.NET"){
                    form1.action = "Checkout3a.asp";
                   }
                   
	              if(PaymentGateway == "IGS"){
                    form1.action = "Checkout3a.asp";
                   }
                   
	              if(PaymentGateway == "Moneris"){
                    form1.action = "Checkout3a.asp";
                   }
           
	              if(PaymentGateway == "iTransact"){
                    form1.action = "Checkout3a.asp";
                   }
                   
	              if(PaymentGateway == "SecurePay"){
                    form1.action = "Checkout3a.asp";
                   }
           
	              if(PaymentGateway == "VeriSign_PL"){
                    form1.action = "https://payments.verisign.com/payflowlink";
                  }
              }
         }
      
       //handle business Account  
       if(document.getElementById("payMethod1DisplayFlag").value == "1"){  
	    if(document.getElementById("payMethod1").checked){
            form1.action = "Checkout3a.asp";
           }
          }

       //handle PayPal    
       if(document.getElementById("payMethod2DisplayFlag").value == "1"){
	    if(document.getElementById("payMethod2").checked){
            form1.action = "https://www.paypal.com/cgi-bin/webscr";
           }
          }
           
       //handle internal account 
       if(document.getElementById("CreditCardFlag")=="0"){  
	    if(document.getElementById("payMethod3").checked){
            form1.action = "Checkout3a.asp";
           }
          }

       //handle In-Store/Will Call    
       if(document.getElementById("payMethod4DisplayFlag").value == "1"){
	    if(document.getElementById("payMethod4").checked){
            form1.action = "Checkout3a.asp";
           }
          }
          
       //handle Check/Money Order   
       if(document.getElementById("payMethod5DisplayFlag").value == "1"){
	    if(document.getElementById("payMethod5").checked){
            form1.action = "Checkout3a.asp";
           }
          }
        
       //handle C.O.D.   
       if(document.getElementById("payMethod6DisplayFlag").value == "1"){
	    if(document.getElementById("payMethod6").checked){
            form1.action = "Checkout3a.asp";
           }
          }

       //handle Phone/Fax  
       if(document.getElementById("payMethod7DisplayFlag").value == "1"){
	    if(document.getElementById("payMethod7").checked){
            form1.action = "Checkout3a.asp";
           }
          }

       //handle E-check
       if(document.getElementById("payMethod8DisplayFlag").value == "1"){
        if(document.getElementById("payMethod8").checked){

			// Validate Tax ID / SSN Number 
				if (document.form1.x_customer_tax_id.value == "")
					{ alert("The Tax ID or SSN isn't valid");
						document.form1.x_customer_tax_id.focus();
						document.form1.x_customer_tax_id.select(); 
						return false }

			// Validate Bank Acct Name 
				if (document.form1.x_bank_acct_name.value == "")
					{ alert("The Name on Bank Account isn't valid");
						document.form1.x_bank_acct_name.focus();
						document.form1.x_bank_acct_name.select(); 
						return false }
						
			// Validate Bank Name 
				if (document.form1.x_bank_name.value == "")
					{ alert("The Bank Name isn't valid");
						document.form1.x_bank_name.focus();
						document.form1.x_bank_name.select(); 
						return false }
						
			    
			// Validate Bank Acct Number 
				if (document.form1.x_bank_acct_num.value == "")
					{ alert("The Bank Account Number isn't valid");
						document.form1.x_bank_acct_num.focus();
						document.form1.x_bank_acct_num.select(); 
						return false }
						
			    
			// Validate Bank Aba Code 
				if (document.form1.x_bank_aba_code.value == "")
					{ alert("The Bank ABA/Routing Number isn't valid");
						document.form1.x_bank_aba_code.focus();
						document.form1.x_bank_aba_code.select(); 
						return false }
						
			// Set action
           
	              if(PaymentGateway == "AUTHORIZE.NET"){
                    form1.action = "Checkout3a.asp";
                   }
                }
		      }
		      
			// Set submit
	          form1.submit()
	      }
  		
	}  // End function

//validate login page
    function FormValidationChk() {
    
	 // Validate first name has been entered	 	
         if (document.Form3.ufirstname.value == ""){
             alert("The first name isn't valid");
			    document.Form3.ufirstname.focus();
				return false }
				
	 // Validate last name has been entered	 	
         if (document.Form3.ulastname.value == ""){
             alert("The last name isn't valid");
			    document.Form3.ulastname.focus();
				return false }
				
	 // Validate user name has been entered	 	
         if (document.Form3.newusername.value == ""){
             alert("The username isn't valid");
			    document.Form3.newusername.focus();
				return false }
    
	 // Validate password has been entered	 	
         if (document.Form3.newpassword.value == ""){
             alert("The password isn't valid");
			    document.Form3.newpassword.focus();
				return false }
    
    // Validate password and confirm password match				
	     if (document.Form3.newpassword.value == document.Form3.confirmPassword.value)
              {} // value are the same
             else
              { alert("The Password and Confirm Password fields must match");
			    document.Form3.newpassword.focus();
				return false }
				
	 // Validate email has been entered	 	
         if (document.Form3.email.value == ""){
             alert("The email isn't valid");
			    document.Form3.email.focus();
				return false }			
	   
	}  // End function


//Personalization Answer Length
  function CheckAnswerLength(MaxLength,FormElement){
   var FormElementLength = document.getElementById(FormElement).value.length
   
    if(MaxLength==FormElementLength)
    {
     alert("The maximum number of characters is "+MaxLength);
    }
  }

//Payment Method Ajax handler
function AjaxHandlerPaymentMethod(FormElementId,PaymentMethod)
  {  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari    
         xmlHttp=new XMLHttpRequest();    
         }
  catch (e)
    {    // Internet Explorer    
    try
      {      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      }
    catch (e)
      {      try
        {        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        }
      catch (e)
        {        
        alert("Your browser does not support AJAX!");        
        return false;        
        }      
       }    
      }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        var response = xmlHttp.responseText;
        document.getElementById(FormElementId).innerHTML = response;
        }
      }
      
    //var PM = document.getElementById("payMethod").value  

    xmlHttp.open("GET","AjaxHandler.asp?Handler=WritePaymentMethod&PaymentMethod="+PaymentMethod,true);
    xmlHttp.send(null);}
  

//General Ajax handler
function AjaxHandler(FormElementId,CountryId,HtmlTagName,SelectedState)
  {  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari    
         xmlHttp=new XMLHttpRequest();    
         }
  catch (e)
    {    // Internet Explorer    
    try
      {      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      }
    catch (e)
      {      try
        {        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        }
      catch (e)
        {        
        alert("Your browser does not support AJAX!");        
        return false;        
        }      
       }    
      }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
        var response = xmlHttp.responseText;
        document.getElementById(FormElementId).innerHTML = response;
        }
      }
    
    
    if(CountryId!=1 && CountryId!=40)
     {
      CountryId = 0  
     }

    xmlHttp.open("GET","AjaxHandler.asp?Handler=WriteStateList&CountryId="+CountryId+"&HtmlTagName="+HtmlTagName+"&SelectedState="+SelectedState,true);
    xmlHttp.send(null);}

//Set text box to empty
  function SetTextBoxNull(FocusObject){
   document.getElementById(FocusObject).value = "";
  }
  
//Set text box to default value
  function SetTextBoxDefault(FocusObject, DefaultValue){
  
   var str = document.getElementById(FocusObject).value
  
    if(str.length == "0"){
     document.getElementById(FocusObject).value = DefaultValue
    }

  }

//Handle wish list
  function SetWishListTypeFocus(SetObject,FocusObject){
	document.getElementById(SetObject).checked = true;
		 if (FocusObject!=""){
		     document.getElementById(FocusObject).select()
		     }
		     else {
		     document.getElementById("FavoritesGroupName").value = "- Enter New List Name Here -"
    }
  }
		
//validate custom form
  function ValidateCustomForm() {
   // Validate fields
   
   for(i=1; i<31; i++){
    if (document.getElementById("Field"+i+"_Display").value == "Yes") {
      if (document.getElementById("Field"+i+"Required").value == "Yes") {
        if (document.getElementById("Field"+i+"").value == "") { 
          alert("The " + document.getElementById("Field"+i+"_Label").value + " field is required.");
           document.getElementById("Field"+i+"").focus();
            return false 
        } 
      }
     }
    }
   }
   
//submit form
 function SubmitForm(FormName){
   eval(FormName+'.submit()')
  }

//adv search set objects
  function setFields(){
  
    document.formAdvSearch.SearchFor.value = ""
    document.formAdvSearch.bid.value = 0
    
    if(document.formAdvSearch.cid.value > 0){
        window.location = "search.asp"
    }    
  }

//adv search reload page
  function reloadSearch(){
   formAdvSearch.action = "search.asp"
   formAdvSearch.submit()
  }
 
//search submit form validation
  function valSearch(){

    if (document.formSearch.SearchFor.value == ""){
     alert("You must enter a search keyword or phrase");
     return false }
     
    // formSearch.action = "SearchResults.asp"
    //formSearch.submit()      
  }

//adv search submit form validation
  function valAdvSearch(){

    if (document.formAdvSearch.SearchFor.value == ""){
     alert("You must enter a search keyword or phrase");
     return false }
     
    // formAdvSearch.action = "SearchResults.asp"
   //  formAdvSearch.submit()      
  }

function disable(){
 if (event.button == 2 || event.button == 3)
  {alert("Right click not available.")}
 }

        function CompareCounter(){
         var Records = document.getElementsByName("compareBox")
          if (Records.length > 0) {
           var NewCount = 0
            for (i=0; i<Records.length; i++) {
             thisRecord = Records[i]
              if(thisRecord.checked == true){
               var Count = 1 }
                else { 
                 var Count = 0 }
                  var NewCount = (NewCount + Count)     
                   }
                    if(NewCount > 3){
                     alert("Please limit your selection to three products"); return false}
                      }
                     }

         function ValidateCount(){
          var Records = document.getElementsByName("compareBox")
           if (Records.length > 0) {
            var NewCount = 0
             for (i=0; i<Records.length; i++) {
              thisRecord = Records[i]
               if(thisRecord.checked == true){
                var Count = 1 }
                 else { 
                  var Count = 0 }
                   var NewCount = (NewCount + Count)     
                    }
                    if(NewCount < 2){
                     alert("Please select a minimum of two products"); return false}
                      if(NewCount > 3){
                       alert("Please limit your selection to three products"); return false}
                        }
                       }
        
        function FormValidation() {
         // Check for blank fields
	     if (document.form1.eName.value == "")
		  { alert("Please provide your name"); return false } 
	     if (document.form1.eAddress.value == "")
		  { alert("Please provide your email address"); return false }
	     if (document.form1.rAddress.value == "")
		  { alert("Please provide an email address for your friend"); return false }		
          }
          
		function IsNumeric(sText){
         // Validate value is numeric
          var ValidChars = "0123456789.";
          var IsNumber=true;
          var Char;

 
          for (i = 0; i < sText.length && IsNumber == true; i++) 
           { 
            Char = sText.charAt(i); 
             if (ValidChars.indexOf(Char) == -1) 
           {
            alert("Please enter a numeric value.");
            IsNumber = false;
            }
           }
          return IsNumber;
        }
        
        function ValidateMinOrderQty(SelectedItem,SelectedQty,GoToItem){
         // Validate order qty is not less than minimum order qty

         var strIndex1
         var strIndex2
         var strItem
         var strMinQty
         
         strIndex1 = SelectedItem.indexOf("-Item=");
         strIndex2 = SelectedItem.indexOf("-ItemMinQty="); 
               
         strItem = SelectedItem.substring(strIndex1+6,strIndex2);
         strMinQty = SelectedItem.substring(strIndex2+12);

         if (parseFloat(SelectedQty) < parseFloat(strMinQty)){
          alert("The minimum order quantity for item " + strItem + " is " + strMinQty + ". Please enter a minimum of " + strMinQty + " and try again.");
          if (GoToItem == "TRUE"){
           document.getElementById(SelectedItem).focus();
           document.getElementById(SelectedItem).select();
          }
          return false} 
        }
        
        function ValidateOrderQty(ItemIdList){
      
        var x
        var SelectedQty
        var SelectedItem
        var ItemList = ItemIdList
        var ItemArrayList = new Array()
        
        ItemArrayList = ItemList.split(",")
        
        for (x in ItemArrayList)
        {
         // Get the item and min order quantity
         SelectedItem = ItemArrayList[x]

         // Get the order quantity
         SelectedQty = document.getElementById(ItemArrayList[x]).value

         // Validate qty entered
         if (SelectedQty == "0")
          {alert("Please enter a quantity greater than zero");
           return false}
         if (SelectedQty == "")
          {alert("Please enter a quantity");
           return false}
           
         // Validate order qty is numeric
         if (IsNumeric(SelectedQty) == false){
           return false}
         
         // Validate order qty is not less than minimum order qty
         if (ValidateMinOrderQty(SelectedItem,SelectedQty,"TRUE") == false){
           return false} 

        }

        } // End function	
        
        function ValidateRequiredPersonalization(){
        
        var ItemIdList
        
        ItemIdList = document.getElementById("PersonalizationIdListRequired").value
        
        if (ItemIdList == ""){
           return true }
        
        else {

          var x
          var SelectedId
          var SelectedIdResult
          var ItemList = ItemIdList
          var ItemArrayList = new Array()
        
          ItemArrayList = ItemList.split(",")
        
          for (x in ItemArrayList){
           // Get the id
           SelectedId = "PersonalizationAnswer"+ItemArrayList[x]

           // Get the result
           SelectedIdResult = document.getElementById(SelectedId).value

          // Validate field is populated
           if (SelectedIdResult == "")
            {alert("Please complete all required fields.");
            return false }
           }
          }
        }
		

        function AddToCartValidation(SelectedItem,SelectedQty,SelectedOptionGroup,SelectedOption){
         if (document.cookie == "")
          {alert("Our Web site requires that cookies be enabled in your Web browser.  We use cookies strictly for the purpose of managing your shopping cart.  To enable cookies please do the following: (1) Internet Explorer Users: Click Tools > Internet Options > Privacy tab and set to Medium (2) FireFox Users:  Click Tools > Options > Privacy tab and set to Accept Cookies from Sites.");
           return false}
         if (SelectedItem == "0")
          {alert("Please select an item from the selection box");
           return false}
         if (SelectedOptionGroup == "1"){ 
           if (SelectedOption == "0")
          {alert("Please select an option from the selection box");
           return false}}
         if (SelectedQty == "0")
          {alert("Please enter a quantity greater than zero");
           return false}
         if (SelectedQty == "")
          {alert("Please enter a quantity");
           return false}
 
          // Validate required fields for personalization
         if (ValidateRequiredPersonalization() == false){
           return false;}

         // Validate order qty is not less than minimum order qty
         if (ValidateMinOrderQty("-Item="+SelectedItem,SelectedQty,"FALSE") == false){
           return false;}
           
         // Validate order qty is numeric
         if (IsNumeric(SelectedQty) == false){
           return false;}
           
        } // End function		
		
		
		function jumpPage(newLoc) {
		  newPage = newLoc.options[newLoc.selectedIndex].value
	
			if (newPage != "") {
				window.location = newPage
			}
		}
		
		function GiftCardCurrentValue(PageURl){
		
		 var eGiftCardNumber = document.getElementById("eGiftCardNumber").value
		 var eGiftCardPin = document.getElementById("eGiftCardPin").value
		 var eGiftCardError = false
		
		  if (eGiftCardNumber == ""){
		   eGiftCardError = true;
		   alert("Please enter your e-gift card number.");
		  }

		  if (eGiftCardPin == ""){
		   eGiftCardError = true;
		   alert("Please enter your e-gift card pin.");
		  }
		  
		  
		  if (eGiftCardError == false){
		   var page = PageURl+"/GiftCardValue.aspx?GCN="+eGiftCardNumber+"&GCP="+eGiftCardPin
		   //var page = "http://localhost:3227/GiftCardValue.aspx?GCN="+eGiftCardNumber+"&GCP="+eGiftCardPin
		   var PxWidth = "580"
		   var PxHeight = "485"

		   PageWindow(page,PxWidth,PxHeight)
		  }
		  
		}
		
		function PageWindow(page,PxWidth,PxHeight) {
		  var leftPos = 0
		  var topPos = 0
			if (screen) {
			  leftPos = (screen.width-PxWidth)/2
			  topPos = (screen.height-PxHeight)/2
			  }

		    var newPage = page
	
			if (newPage != "") {
				invWindow = window.open(newPage,"PageWindow","width="+PxWidth+",height="+PxHeight+",left="+leftPos+",top="+topPos+",scrollbars=yes")
				invWindow.focus()
			}
		}

		function PriceListWindow(page,PxWidth,PxHeight) {
		  var leftPos = 0
		  var topPos = 0
			if (screen) {
			  leftPos = (screen.width-PxWidth)/2
			  topPos = (screen.height-PxHeight)/2
			  }

		    var newPage = page
	
			if (newPage != "") {
				invWindow = window.open(newPage,"PriceListWindow","width="+PxWidth+",height="+PxHeight+",left="+leftPos+",top="+topPos+",scrollbars=yes")
				invWindow.focus()
			}
		}

		function inventoryWindow(page) {
		  var leftPos = 0
		  var topPos = 0
			if (screen) {
			  leftPos = (screen.width-580)/2
			  topPos = (screen.height-485)/2
			  }
		  
		  var newPage = page.options[page.selectedIndex].value
	
			if (newPage != "") {
				invWindow = window.open(newPage,"inventoryWin","width=580,height=485,left="+leftPos+",top="+topPos+",scrollbars=yes")
				invWindow.focus()
			}
		}
		
		function questionWindow (question) {
		leftPos = 0
		topPos = 0
		if (screen) {
			leftPos = (screen.width-580)/2
			topPos = (screen.height-485)/2
			}
		queWindow = window.open(question,"questionWin","width=580,height=485,left="+leftPos+",top="+topPos+",scrollbars=yes")
		queWindow.focus()
		}
		
		function addressWindow (address) {
		
		var strAddress = address;
		var RegExp = /#|'/g;
		
		strAddress = String(address).replace(RegExp, "")
		
		leftPos = 0
		topPos = 0
		if (screen) {
			leftPos = (screen.width-580)/2
			topPos = (screen.height-485)/2
			}
		addrWindow = window.open(strAddress,"addressWin","width=580,height=485,left="+leftPos+",top="+topPos+",scrollbars=yes")
		addrWindow.focus()
		
		}
		
		function updateAddress(firstNameShip,lastNameShip,companyShip,streetShip,street2Ship,cityShip,stateShip,zipShip,phoneShip,emailShip,ShipToLocType,countryShip){
		
		  opener.document.checkout.firstNameShip.value = firstNameShip
		  opener.document.checkout.lastNameShip.value = lastNameShip
		  opener.document.checkout.companyShip.value = companyShip
		  opener.document.checkout.streetShip.value = streetShip
		  opener.document.checkout.street2Ship.value = street2Ship
		  opener.document.checkout.cityShip.value = cityShip
		  opener.document.checkout.zipShip.value = zipShip
		  opener.document.checkout.phoneShip.value = phoneShip
		  opener.document.checkout.emailShip.value = emailShip
		  opener.document.checkout.countryShip.value = countryShip 
		  
		  if(countryShip!=1 && countryShip!=40){
		   opener.document.getElementById('ShipToState').innerHTML = '<input type=text id=stateShip name=stateShip value='+stateShip+' />';
           }
           else {
           opener.document.getElementById('ShipToState').innerHTML = '<select id=stateShip name=stateShip><option value='+stateShip+'>'+stateShip+'</option></select>';
          }
          
		  if(ShipToLocType==0){
		    opener.document.checkout.radioA.checked = true
		    }
		    else {
		    opener.document.checkout.radioB.checked = true
		    }
		     
		  window.close()
		 
		}
		
		function statPending(newStat) {
				Load = "account.asp?orderstatus=Pending"
				window.location = Load	
			}
			
		
		function statClosed(newStat) {
				Load = "account.asp?orderstatus=Closed"
				window.location = Load	
			}
			
		
		function statCancelled(newStat) {
				Load = "account.asp?orderstatus=Cancelled"
				window.location = Load	
			}
			
		
		function statPendClosed(newStat) {
				Load = "account.asp"
				window.location = Load	
			}
		
		
		function newWindow(iLocation,iName){
			prdWindow = window.open("","newWin","width=680,height=485")
				prdWindow.document.write("<html>")
				prdWindow.document.write("<head><title> " + iName)
				prdWindow.document.write("</title></head>")
				prdWindow.document.write("<body><table align=center valign=bottom>")
				prdWindow.document.write("<tr><td align=center><a href='' onClick='window.close()'>Close Window</a></td></tr>")
				prdWindow.document.write("<tr><td>")
				prdWindow.document.write(iLocation)
				prdWindow.document.write("</td></tr></table>")
				prdWindow.document.write("</body></html>")
				prdWindow.document.close()	
		}	
		
		
		function cmpListWindow (cList) {
		leftPos = 0
		topPos = 0
		if (screen) {
			leftPos = (screen.width-560)/2
			topPos = (screen.height-500)/2
			}
		cmpWindow = window.open(cList,"cmpList","width=560,height=500,left="+leftPos+",top="+topPos+",scrollbars=yes,resizable=no")
		cmpWindow.focus()
		}
		
		
		function imageWindow (image) {
		leftPos = 0
		topPos = 0
		if (screen) {
			leftPos = (screen.width-680)/2
			topPos = (screen.height-485)/2
			}
		imgWindow = window.open(image,"imageWin","width=680,height=485,left="+leftPos+",top="+topPos+",scrollbars=yes,resizable=yes")
		imgWindow.focus()
		}
		
	    function CloseAndGoTo(newLocation){
		  opener.location = newLocation;
		  window.close()
		}
		
		function GoToProdInfo(newLocation){
		  opener.location = newLocation;
		}
		
		
		function GoToCart(newCart){
		  opener.location = newCart;
		}
		
        function setShipToLoc(shipVal){
         window.document.checkout.ShipToLocType.value = shipVal
        }
  
        function copyInfo(){

         document.checkout.firstNameShip.value = document.checkout.firstName.value;
         document.checkout.lastNameShip.value = document.checkout.lastName.value;
         document.checkout.companyShip.value = document.checkout.company.value;
         document.checkout.streetShip.value = document.checkout.street.value;
         document.checkout.street2Ship.value = document.checkout.street2.value;
         document.checkout.cityShip.value = document.checkout.city.value;  
         document.checkout.zipShip.value = document.checkout.zip.value;
         document.checkout.phoneShip.value = document.checkout.phone.value;
         document.checkout.emailShip.value = document.checkout.email.value;
         document.checkout.countryShip.value = document.checkout.country.value;
         AjaxHandler('ShipToState',checkout.country.value,'stateShip',document.getElementById("state").value);

        }

       // Regular Expression for zip code validation		
	    reZipCode = /^(\d{5})[\.\-\/ ]?(\d{4})?$/
       // Regular Expression for phone validation		
	    rePhone = /^(\d{3})[\.\-\/ ]?(\d{3})[\.\-\/ ]?(\d{4})$/
       // Regular Expression for email validation
	    reEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
       // Regular Expression for credit card validation
	    reCCExpiration = /^(\d{2})[\/](\d{4})$/

		function FormValidationChk0() {
		
			// Check for blank bill-to fields 
			
				if (document.checkout.firstName.value == "")
					{ alert("The bill-to first name isn't valid");
						document.checkout.firstName.focus();
						document.checkout.firstName.select(); 
						return false }
						
				if (document.checkout.lastName.value == "")
					{ alert("The bill-to last name isn't valid");
						document.checkout.lastName.focus();
						document.checkout.lastName.select(); 
						return false }
						
				if (document.checkout.street.value == "")
					{ alert("The bill-to street name isn't valid");
						document.checkout.street.focus();
						document.checkout.street.select(); 
						return false }
						
				if (document.checkout.city.value == "")
					{ alert("The bill-to city name isn't valid");
						document.checkout.city.focus();
						document.checkout.city.select(); 
						return false }
	
			// Validate the bill-to state code
			   if(document.checkout.country.value == 1 || document.checkout.country.value == 40){
				 if (document.getElementById("state").value == "")
					{ alert("The bill-to state / province name isn't valid");
						document.getElementById("state").focus();
						return false }
					}
						
			// Validate the bill-to zip code for usa
			   if(document.checkout.country.value == 1){
				if (reZipCode.test(window.document.checkout.zip.value))
					{}
				else
					{ alert("The bill-to zip code isn't valid");
						document.checkout.zip.focus();
						document.checkout.zip.select(); 
						return false }
				}
			
			// Validate the bill-to phone number for usa
                if(document.checkout.country.value == 1){		
			      validPhoneBill = rePhone.exec(window.document.checkout.phone.value)
				if (validPhoneBill) 
					{ window.document.checkout.phone.value = + validPhoneBill[1] + "-" + validPhoneBill[2] + "-" + validPhoneBill[3]}	
				else 
					{ alert("The bill-to phone number isn't valid.  Please use the following format: 555-555-5555.")
						window.document.checkout.phone.focus()
						window.document.checkout.phone.select();
						return false }
                        }	
					
			// Validate the bill-to email address	
				if (reEmail.test(document.checkout.email.value)) 
					{ } // The email is valid 
				else
					{ alert("The bill-to email address isn't valid.  Please use the following format: john@company.com")
						window.document.checkout.email.focus()
						window.document.checkout.email.select();
					return false }
		
		
			// Check for blank ship-to fields 
			  if(document.getElementById("ShipToDisplayFlag").value == "1"){
			  
				if (document.checkout.firstNameShip.value == "")
					{ alert("The ship-to first name isn't valid");
						document.checkout.firstNameShip.focus();
						document.checkout.firstNameShip.select(); 
						return false }
						
				if (document.checkout.lastNameShip.value == "")
					{ alert("The ship-to last name isn't valid");
						document.checkout.lastNameShip.focus();
						document.checkout.lastNameShip.select(); 
						return false }
						
				if (document.checkout.streetShip.value == "")
					{ alert("The ship-to street name isn't valid");
						document.checkout.streetShip.focus();
						document.checkout.streetShip.select(); 
						return false }
						
		       // check for po box	
			    var sStreetShip = document.checkout.streetShip.value;
			     sStreetShip = sStreetShip.toUpperCase();
			    var sPOBoxCheck1 = sStreetShip.indexOf("P.O. BOX");
			    var sPOBoxCheck2 = sStreetShip.indexOf("PO BOX");
			    var sPOBoxCheck3 = sStreetShip.indexOf("P O BOX");
			    var sPOBoxCheck4 = sStreetShip.indexOf("PO. BOX");
			    var sPOBoxCheck5 = sStreetShip.indexOf("P.O BOX");
			   
			   if (document.getElementById("AllowPOBox").value == "False"){
				if (sPOBoxCheck1 == "0" || sPOBoxCheck2 == "0" || sPOBoxCheck3 == "0" || sPOBoxCheck4 == "0" || sPOBoxCheck5 == "0")
					{ alert("The ship-to street address can not be a P.O. Box");
						document.checkout.streetShip.focus();
						document.checkout.streetShip.select(); 
						return false }
				   }
						
				if (document.checkout.cityShip.value == "")
					{ alert("The ship-to city name isn't valid");
						document.checkout.cityShip.focus();
						document.checkout.cityShip.select(); 
						return false }

			// Validate the ship-to state code
			    if(document.checkout.countryShip.value == 1 || document.checkout.countryShip.value == 40){
				 if (document.getElementById("stateShip").value == "")
					{ alert("The ship-to state / province name isn't valid");
						document.getElementById("stateShip").focus();
						return false }
				}
				
			// Validate the ship-to zip code
			    if(document.checkout.countryShip.value == 1){
				 if (reZipCode.test(window.document.checkout.zipShip.value))
					{}
				else
					{ alert("The ship-to zip code isn't valid");
						document.checkout.zipShip.focus();
						document.checkout.zipShip.select(); 
						return false }
				}
				
			// Validate the ship-to phone number
                      if(window.document.checkout.countryShip.value == 1){	
			     validPhoneShip = rePhone.exec(window.document.checkout.phoneShip.value)
				if (validPhoneShip) 
					{ window.document.checkout.phoneShip.value = + validPhoneShip[1] + "-" + validPhoneShip[2] + "-" + validPhoneShip[3]}	
				else 
					{ alert("The ship-to phone number isn't valid.  Please use the following format: 555-555-5555.")
						window.document.checkout.phoneShip.focus()
						window.document.checkout.phoneShip.select();
						return false }
                        }
						
			// Validate the ship-to email address	
				if (reEmail.test(window.document.checkout.emailShip.value)) 
					{ } // The email is valid 
				else
					{ alert("The ship-to email address isn't valid.  Please use the following format: john@company.com")
						window.document.checkout.emailShip.focus()
						window.document.checkout.emailShip.select();
					return false }				
               }
						
			// Validate User Defined 6 
				if (document.checkout.reg_user_defined6_required_flag.value == "REQUIRED"){
				 if (document.getElementById("ud1").value == "")
					{ alert("The following information is required: " + document.checkout.user_defined6_label.value);
						document.checkout.user_defined6.focus();
						document.checkout.user_defined6.select(); 
						return false }
						}

			// Validate User Defined 7
				if (document.checkout.reg_user_defined7_required_flag.value == "REQUIRED"){
				 if (document.getElementById("ud2").value == "")
					{ alert("The following information is required: " + document.checkout.user_defined7_label.value);
						document.checkout.user_defined7.focus();
						document.checkout.user_defined7.select(); 
						return false }
						}		

			// Validate User Defined 8
				if (document.checkout.reg_user_defined8_required_flag.value == "REQUIRED"){
				 if (document.getElementById("ud3").value == "")
					{ alert("The following information is required: " + document.checkout.user_defined8_label.value);
						document.checkout.user_defined8.focus();
						document.checkout.user_defined8.select(); 
						return false }
						}
						
			// Validate terms and conditions		
				if (document.checkout.vTermsConditions.value == 1){ 
				    if(document.checkout.terms.checked == false){
				      alert("You must check the Terms & Conditions box before moving forward");
						document.checkout.terms.focus(); 
						return false }}	

		}  // End function

		
