
//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 
        } 
      }
     }
    }
   }

//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 AddToCartValidation(SelectedItem,SelectedQty,SelectedOptionGroup,SelectedOption){
         if (document.cookie == "")
         {alert("Our Web site requires that cookies be enabled in your Web browser.  We uses 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 > Cookies tab and set to Allow");
           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}
           }		
		
		
		function jumpPage(newLoc) {
		  newPage = newLoc.options[newLoc.selectedIndex].value
	
			if (newPage != "") {
				window.location = newPage
			}
		}

		
		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){
		
		  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.stateShip.value = stateShip
		  opener.document.checkout.zipShip.value = zipShip
		  opener.document.checkout.phoneShip.value = phoneShip
		  opener.document.checkout.emailShip.value = emailShip
		  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(name1, name2, street1, street2, city1, state1, zip1, phone1, email1, state2, country1, company1){
         var firstNameShipTo = name1; lastNameShipTo = name2; streetShipTo = street1; street2ShipTo = street2; cityShipTo = city1; stateShipTo = state1; zipShipTo = zip1; phoneShipTo = phone1; emailShipTo = email1; stateShipToInt = state2; countryShipTo = country1; companyShipTo = company1
  
         window.document.checkout.firstName.value = firstNameShipTo;
         window.document.checkout.lastName.value = lastNameShipTo;
         window.document.checkout.company.value = companyShipTo;
         window.document.checkout.street.value = streetShipTo;
         window.document.checkout.street2.value = street2ShipTo;
         window.document.checkout.city.value = cityShipTo;  
         window.document.checkout.zip.value = zipShipTo;
         window.document.checkout.phone.value = phoneShipTo;
         window.document.checkout.email.value = emailShipTo;
         window.document.checkout.country.value = countryShipTo;
  
         if(document.checkout.countryship.value == 1){
           window.document.checkout.state.value = stateShipTo}
          else {
           window.document.checkout.state.value = stateShipToInt
          }
        }

       // 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 ship-to fields 
			
				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 }
						
				if (document.checkout.cityShip.value == "")
					{ alert("The ship-to city name isn't valid");
						document.checkout.cityShip.focus();
						document.checkout.cityShip.select(); 
						return false }
				
				if (document.checkout.stateShip.value == "" && document.checkout.countryship.value == 1)
					{ alert("The ship-to state name isn't valid");
						document.checkout.stateShip.focus(); 
						return false }
						
				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 }}
						
			// Validate the ship-to zip code
			   if(window.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 }
					
			// 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 zip code
			   if(window.document.checkout.countryship.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
                       if(window.document.checkout.countryship.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(window.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 }
					
			// Validate credit card name
				if (document.checkout.ccname.value == "" || document.checkout.ccname.value == "Business Account")
					{ alert("The cardholder name isn't valid");
						document.checkout.ccname.focus();
						document.checkout.ccname.select(); 
						return false }
						
			// Validate credit card number
				if (document.checkout.ccnumber.value == "")
					{ alert("The credit card number isn't valid");
						document.checkout.ccnumber.focus();
						document.checkout.ccnumber.select(); 
						return false }
						
			// Validate credit card expiration month
				if (document.checkout.payMethod.value == "0") {
				  if (document.checkout.expMonth.value == "")
					{ alert("The credit card expiration month isn't valid");
						document.checkout.expMonth.focus(); 
						return false }
				}
						
			// Validate credit card expiration year
				if (document.checkout.payMethod.value == "0") {
				  if (document.checkout.expYear.value == "")
					{ alert("The credit card expiration year isn't valid");
						document.checkout.expYear.focus();
						return false }
				}
				
			// Validate E-Check field	
				if (document.checkout.eCheckFlag.value == "true"){
				
			// Validate Bank Acct Name 
				if (document.checkout.x_bank_acct_name.value == "")
					{ alert("The Name on Bank Account isn't valid");
						document.checkout.x_bank_acct_name.focus();
						document.checkout.x_bank_acct_name.select(); 
						return false }
						
			// Validate Bank Name 
				if (document.checkout.x_bank_name.value == "")
					{ alert("The Bank Name isn't valid");
						document.checkout.x_bank_name.focus();
						document.checkout.x_bank_name.select(); 
						return false }
						
			    
			// Validate Bank Acct Number 
				if (document.checkout.x_bank_acct_num.value == "")
					{ alert("The Bank Account Number isn't valid");
						document.checkout.x_bank_acct_num.focus();
						document.checkout.x_bank_acct_num.select(); 
						return false }
						
			    
			// Validate Bank Aba Code 
				if (document.checkout.x_bank_aba_code.value == "")
					{ alert("The Bank ABA/Routing Number isn't valid");
						document.checkout.x_bank_aba_code.focus();
						document.checkout.x_bank_aba_code.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 }
						}

		}  // End function

		