function sweepsForm() {
  subwin = window.open('/sweeps/sweepsentry.asp', 'sweeps', 'width=800,height=627,left=0,top=0,scrollbars=no,status=yes,toolbar=no,resizeable=no')
  subwin.focus();
}
function doReset()
{
    document.getElementById("workedWithDealerNameDISPLAY").innerHTML="";
    document.dataCapture.LocationID.value=""
}
function dealerLookup()
{	
  if(document.dataCapture.zip.value == "") {
  	alert("Please enter your zip code so we can locate your nearest KMBS representative");
  	document.dataCapture.currentCustomer[0].checked=false;
                     document.getElementById('workedWithDealerNameDISPLAY').innerHTML="";
  	return false;
  }
  else {	  
  	window.open("/content/rfq/dealer_lookup.html?zip=" + document.dataCapture.zip.value + "&subcat=" + document.dataCapture.productSubCategory.value,null,"top=300,height=150,width=450,status=no,toolbar=no,menubar=no,location=no");
  }	
}
function showRfqForm(cat,subcat,model)
{
	 document.getElementById("rfqTable").className="dataTableNoBorder";
	 document.getElementById("submitNoRfq").innerHTML="<h2 class=\"headingTypeB01\">Please enter the information below to complete your request for a quote.</h2>";
	 document.getElementById("submitWithRfq").style.visibility="visible";             
                       
                      if(cat != '' && subcat == '') {
                           PopulateSubCats(document.dataCapture.productCategory, document.dataCapture.productSubCategory,document.dataCapture.productModel,cat);
                      }

                      if(cat != '' && subcat != '') {
                           PopulateSubCats(document.dataCapture.productCategory, document.dataCapture.productSubCategory,document.dataCapture.productModel,subcat);
                           PopulateRfqModels(document.dataCapture.productCategory, document.dataCapture.productSubCategory,document.dataCapture.productModel, model);
                      }

                      nlCookie = getCookie("nlsource");

                      if(nlCookie == "dc" || nlCookie == "wbkmpf0percentdc" || nlCookie == "c200kmpfpromodc") {
                        document.dataCapture.currentCustomer[0].checked=true;
	   document.getElementById("existingCustomer").className="invisible";
                      }
                      
}
function hideRfqForm()
{
	 document.getElementById("rfqTable").className="dataTableInvisible";
	 document.getElementById("submitNoRfq").innerHTML="<div align=\"center\"><input TYPE=\"image\" src=\"/img/buttons/submit.gif\" ID=\"btnSubmit\" NAME=\"btnSubmit\"  alt=\"Submit Request\"></div>";
	 document.getElementById("submitWithRfq").style.visibility="hidden";
}

function validateForm() {

    if(document.dataCapture.firstName.value == "") {
    document.dataCapture.firstName.focus();
    window.alert ("Please enter a First Name.");
    return false; } else {
    if (!isProper(document.dataCapture.firstName)) {
    	document.dataCapture.firstName.focus();
    	window.alert ("Please enter a proper value for First Name. No special characters allowed.");
    	return false;    	
    }  	
   }
    if(document.dataCapture.lastName.value == "" ) {
    document.dataCapture.lastName.focus();
     window.alert ("Please enter a Last Name.");
     return false; } else {
    if (!isProper(document.dataCapture.lastName)) {
    	document.dataCapture.lastName.focus();
    	window.alert ("Please enter a proper value for Last Name. No special characters allowed.");
    	return false;    	
    }
  }
    if(document.dataCapture.email.value == ""  ) {
    document.dataCapture.email.focus();
     window.alert ("Please enter an Email Address.");
     return false; }
    if((document.dataCapture.email.value.indexOf("@") < 0) || (document.dataCapture.email.value.indexOf(".") < 0) ) {
      document.dataCapture.email.focus();
      window.alert ("Please enter an valid Email Address.");
     return false; } 
         if(document.dataCapture.companyName.value == "" ) {
         document.dataCapture.companyName.focus();
          window.alert ("Please enter a Business Name.");
          return false; }
         if(document.dataCapture.address1.value == "" ) {
         document.dataCapture.address1.focus();
          window.alert ("Please enter a Business Address 1 value.");
          return false; } else {
    if (!isProper(document.dataCapture.address1)) {
    	document.dataCapture.firstName.focus();
    	window.alert ("Please enter a proper value for Business Address 1. No special characters allowed.");
    	return false;    	
    }
  }
  if(document.dataCapture.address2.value != "" ) {  	
    if (!isProper(document.dataCapture.address2)) {
    	document.dataCapture.firstName.focus();
    	window.alert ("Please enter a proper value for Business Address 2. No special characters allowed.");
    	return false;    	
    }
  }
         if(document.dataCapture.city.value == "" ) {
         document.dataCapture.city.focus();
          window.alert ("Please enter a City.");
          return false; } else {
    if (!isProper(document.dataCapture.city)) {
    	document.dataCapture.city.focus();
    	window.alert ("Please enter a proper value for City. No special characters allowed.");
    	return false;    	
    }
  }
         if(document.dataCapture.state.value == "" ) {
          document.dataCapture.state.focus();
          window.alert ("Please select a State.");
          return false; }
         if(document.dataCapture.zip.value == "" ) {
         document.dataCapture.zip.focus();
          window.alert ("Please enter a Zip Code.");
          return false; } else {
            if(!(/^\d{5}$/.test(document.dataCapture.zip.value))) {
               document.dataCapture.zip.focus();
              window.alert ("Please enter a valid 5-digit Zip Code.");
              return false;
           }
         }
         if(document.dataCapture.telephoneArea.value == "" ) {
         document.dataCapture.telephoneArea.focus();
          window.alert ("Please enter an Area Code.");
          return false; }
         if(!IsNumeric(document.dataCapture.telephoneArea.value)) {
         document.dataCapture.telephoneArea.focus();
          window.alert ("Please enter a valid Area Code.");
          return false; }     
         if(document.dataCapture.telephonePrefix.value == "" ) {
         document.dataCapture.telephonePrefix.focus();
          window.alert ("Please enter a Business Phone Number.");
          return false; }     
         if(!IsNumeric(document.dataCapture.telephonePrefix.value)) {
         document.dataCapture.telephonePrefix.focus();
          window.alert ("Please enter a valid Business Phone Number.");
          return false; }     
         if(document.dataCapture.telephoneNumber.value == "" ) {
         document.dataCapture.telephoneNumber.focus();
          window.alert ("Please enter a Business Phone Number.");
          return false; }
         if(!IsNumeric(document.dataCapture.telephoneNumber.value)) {
         document.dataCapture.telephoneNumber.focus();
          window.alert ("Please enter a valid Business Phone Number.");
          return false; }  
         if(document.dataCapture.industry.value == "" ) {
         document.dataCapture.industry.focus();
          window.alert ("Please select an Industry.");
          return false; }
    if(document.dataCapture.requestQuote[0].checked==false && document.dataCapture.requestQuote[1].checked==false) {    	
			document.dataCapture.requestQuote[0].focus();
      window.alert ("Please select if you would like to Request a Quote.");
      return false;     
    }      
    
    if(document.dataCapture.requestQuote[0].checked==true) {    

         nlCookie = getCookie("nlsource");        

         if(nlCookie != "dc" && nlCookie != "wbkmpf0percentdc" && nlCookie != "c200kmpfpromodc") {
                   
              if(document.dataCapture.currentCustomer[0].checked==false && document.dataCapture.currentCustomer[1].checked==false) {    	
                document.dataCapture.currentCustomer[0].focus();
                 window.alert ("Please select if you are a current customer.");
                 return false;     
              }              
              if(document.dataCapture.currentCustomer[0].checked==true && document.dataCapture.LocationID.value == "") {

                document.dataCapture.currentCustomer[0].focus();
                window.alert ("Please select your sales location.");
                dealerLookup();
                return false;     
              }

       }

       if(document.dataCapture.productSubCategory.value == "pagepro" || document.dataCapture.productSubCategory.value == "magicolor") {
 
             if(nlCookie != "dc") {

                 if(document.dataCapture.currentCustomer[0].checked==true && document.dataCapture.LocationID.value == "Other") {

                    if(document.dataCapture.wherePurchasedOther.value == "" ) {
                      document.dataCapture.wherePurchasedOther.focus();
                      window.alert ("Please enter where you purchased your equipment.");
                      return false; }
                 }

              }        
  
              if((document.dataCapture.printerPurchase[0].checked==false) && (document.dataCapture.printerPurchase[1].checked==false)) {

                 document.dataCapture.printerPurchase[0].focus();
                 window.alert ("Please select how many printers you are looking to purchase.");
                 return false; 
               }
        }
    
     } // END REQUEST A QUOTE SELECTED        
     
     return true;
   }

function validateFormByModel() {

    if(document.dataCapture.firstName.value == "") {
    document.dataCapture.firstName.focus();
    window.alert ("Please enter a First Name.");
    return false; } else {
    if (!isProper(document.dataCapture.firstName)) {
    	document.dataCapture.firstName.focus();
    	window.alert ("Please enter a proper value for First Name. No special characters allowed.");
    	return false;    	
    }  	
  }
    if(document.dataCapture.lastName.value == "" ) {
    document.dataCapture.lastName.focus();
     window.alert ("Please enter a Last Name.");
     return false; } else {
    if (!isProper(document.dataCapture.lastName)) {
    	document.dataCapture.lastName.focus();
    	window.alert ("Please enter a proper value for Last Name. No special characters allowed.");
    	return false;    	
    }
  }
    if(document.dataCapture.email.value == ""  ) {
    document.dataCapture.email.focus();
     window.alert ("Please enter an Email Address.");
     return false; }
    if((document.dataCapture.email.value.indexOf("@") < 0) || (document.dataCapture.email.value.indexOf(".") < 0) ) {
      document.dataCapture.email.focus();
      window.alert ("Please enter an valid Email Address.");
     return false; } 
         if(document.dataCapture.zip.value == "" ) {
         document.dataCapture.zip.focus();
          window.alert ("Please enter a Zip Code.");
          return false; }
    
        
         if(document.dataCapture.companyName.value == "" ) {
         document.dataCapture.companyName.focus();
          window.alert ("Please enter a Company value.");
          return false; }
         if(document.dataCapture.address1.value == "" ) {
         document.dataCapture.address1.focus();
          window.alert ("Please enter an Address 1 value.");
          return false; } else {
    if (!isProper(document.dataCapture.address1)) {
    	document.dataCapture.firstName.focus();
    	window.alert ("Please enter a proper value for Business Address 1. No special characters allowed.");
    	return false;    	
    }
  }
  if(document.dataCapture.address2.value != "" ) {  	
    if (!isProper(document.dataCapture.address2)) {
    	document.dataCapture.firstName.focus();
    	window.alert ("Please enter a proper value for Business Address 2. No special characters allowed.");
    	return false;    	
    }
  }
         if(document.dataCapture.city.value == "" ) {
         document.dataCapture.city.focus();
          window.alert ("Please enter a City.");
          return false; } else {
    if (!isProper(document.dataCapture.city)) {
    	document.dataCapture.city.focus();
    	window.alert ("Please enter a proper value for City. No special characters allowed.");
    	return false;    	
    }
  }
         if(document.dataCapture.state.value == "" ) {
          document.dataCapture.state.focus();
          window.alert ("Please select a State.");
          return false; }
         if(document.dataCapture.telephoneArea.value == "" ) {
         document.dataCapture.telephoneArea.focus();
          window.alert ("Please enter an Area Code.");
          return false; }
         if(!IsNumeric(document.dataCapture.telephoneArea.value)) {
         document.dataCapture.telephoneArea.focus();
          window.alert ("Please enter a valid Area Code.");
          return false; }     
         if(document.dataCapture.telephonePrefix.value == "" ) {
         document.dataCapture.telephonePrefix.focus();
          window.alert ("Please enter a Phone Number.");
          return false; }     
         if(!IsNumeric(document.dataCapture.telephonePrefix.value)) {
         document.dataCapture.telephonePrefix.focus();
          window.alert ("Please enter a valid Phone Number.");
          return false; }     
         if(document.dataCapture.telephoneNumber.value == "" ) {
         document.dataCapture.telephoneNumber.focus();
          window.alert ("Please enter a Phone Number.");
          return false; }
         if(!IsNumeric(document.dataCapture.telephoneNumber.value)) {
         document.dataCapture.telephoneNumber.focus();
          window.alert ("Please enter a valid Phone Number.");
          return false; }  
         if(document.dataCapture.industry.value == "" ) {
         document.dataCapture.industry.focus();
          window.alert ("Please select an Industry.");
          return false; }          
         if(document.dataCapture.currentCustomer[0].checked==false && document.dataCapture.currentCustomer[1].checked==false) {    	
           document.dataCapture.currentCustomer[0].focus();
            window.alert ("Please select if you are a current customer.");
            return false;     
         }              
         if(document.dataCapture.currentCustomer[0].checked==true && document.dataCapture.LocationID.value == "") {

           document.dataCapture.currentCustomer[0].focus();
           window.alert ("Please select your current company.");
           dealerLookup();
           return false;     
         }
    
     
     return true;
   }
   
var phone_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		phone_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != phone_field_length) {
			phone_field_length=obj.value.length;
			if (phone_field_length == len) {
				next_field.focus();
				}
			}
		}
	}
	
	function IsNumeric(sText)
{
   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) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


function setFocus() {
  document.dataCapture.firstName.focus();
}

function getCookie(NameOfCookie)
{

     if (document.cookie.length > 0) 
     { 

          begin = document.cookie.indexOf(NameOfCookie+"="); 
          if (begin != -1) // Note: != means "is not equal to"
          { 

                begin += NameOfCookie.length+1; 
                end = document.cookie.indexOf(";", begin);
                if (end == -1) end = document.cookie.length;
                return unescape(document.cookie.substring(begin, end)); } 
          }
          return null; 

}

function dealerLookupWTB()
{	
  if(document.dataCapture.zip.value == "") {
  	alert("Please enter your zip code so we can locate your nearest KMBS representative");
  	document.dataCapture.currentCustomer[0].checked=false;
                     document.getElementById('workedWithDealerNameDISPLAY').innerHTML="";
  	return false;
  }
  else {	  
  	window.open("/content/rfq/dealer_lookup_wtb.html?zip=" + document.dataCapture.zip.value + "&cat=" + document.dataCapture.productCategory.value,null,"top=300,height=150,width=450,status=no,toolbar=no,menubar=no,location=no");
  }	
}

function isProper(formField) {
	var string = formField.value.length;
	var iChars = "~^+=!*|,\":<>[]{}`\;()@&$#%";
	for (var i = 0; i < string; i++) {
		if (iChars.indexOf(formField.value.charAt(i)) != -1)
		return false;
	}
	return true;
}