
function show_popup(str,x)
{
  var arg = 'resizable=no, toolbar=no,location=no,directories=no,addressbar=no,scrollbars=no,status=no,menubar=no,width=400,height=400,top=20,left=250';
  var newWindow  =  window.open(str, "_blank", arg);
  var ExpireDate = new Date ();
  ExpireDate.setTime(ExpireDate.getTime() + (1 * 24 * 3600 * 1000));
  document.cookie = "IsImg=" + x + ((1 == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function ch_img(){ 
	if (document.cookie.length > 0)	{
			begin = document.cookie.indexOf("IsImg=");
			if (begin != -1) {
				begin += "IsImg=".length;
				end = document.cookie.indexOf(";", begin);
				if (end == -1) end = document.cookie.length;
				y = unescape(document.cookie.substring(begin, end)); 
			}
	}
    document.getElementById('xx').src = y;  
}

function send(){
	window.close('send_message.html');
	
}

function ChangeAnnualSalesTextIfNonProfit(e)
{
	if (e == "Non Profit")
	{
		document.getElementById("spnAnnualSales").textContent = "Annual Budget ";
	}
	else
	{
		document.getElementById("spnAnnualSales").textContent = "Net Annual Sales ";
	}
}

function validation()
{
	if(document.form1.FullCompanyLegalName.value=="")
	{
		alert("Company Name Field Required!");
		document.form1.FullCompanyLegalName.focus();
		return false;
	}
	
	if(document.form1.AuthorizedOfficerTitle.value=="")
	{
	 alert("Title field Required!");
	 document.form1.AuthorizedOfficerTitle.focus();
	 return false;
    }
	
	if(document.form1.AuthorizedOfficer.value=="")
	{
	 alert("Full Name Required!");
	 document.form1.AuthorizedOfficer.focus();
	 return false;
    }

	if(document.form1.PhysicalAddress.value=="")
	{
	 alert("Address field Required!");
	 document.form1.PhysicalAddress.focus();
	 return false;
    }
	
	if(document.form1.City.value=="")
	{
	alert("City field Required!");
	document.form1.City.focus();
	return false;
	}
	
	if(document.form1.State.value=="")
	{
	alert("State field Required!");
	document.form1.State.focus();
	return false;
	}
	
	if(document.form1.Zip.value=="")
	{
	alert("Zip field  Required!");
	document.form1.Zip.focus();
	return false;
	}
	else
	{
	    var valid = "0123456789-.";
	     if (document.form1.Zip.value.length!=5 && document.form1.Zip.value.length!=10) 
	     {
            alert("Please enter your 5 digit or 5 digit+4 zip code.");
			document.form1.Zip.focus();
            return false;
         }
        var hyphencount = 0;
        for (var i=0; i < document.form1.Zip.value.length; i++) 
       {
            temp = "" + document.form1.Zip.value.substring(i, i+1);
            if (temp == "-") hyphencount++;
            if (valid.indexOf(temp) == "-1") 
            {
                alert("Invalid characters in your zip code.  Please try again.");
				document.form1.Zip.focus();
                return false;
            }
            if ((hyphencount > 1) || ((document.form1.Zip.value.length==10) && ""+document.form1.Zip.value.charAt(5)!="-")) 
            {
                alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
				document.form1.Zip.focus();
                return false;
            }  
	    }
	} 
				
	if(document.form1.Phone.value=="")
	{
	alert("Phone field Required!");
	document.form1.Phone.focus();
	return false;
	}
	else
	{
        var strValidChars = "0123456789- ()";
        var strChar;
        var blnResult = true;
	    strString = document.form1.Phone.value;
	
        if (strString.length == 0) return false;
		
		if (strString.length < 10)
		{
			alert("Phone field requires 10 digits 0-9 !");
			document.form1.Phone.focus();
			return false;
		}
		
        //  test strString consists of valid characters listed above
        for (i = 0; i < strString.length && blnResult == true; i++)
        {
            strChar = strString.charAt(i);
            if (strValidChars.indexOf(strChar) == -1)
            {
                blnResult = false;
            }
        }
        if(blnResult==false)
	    {
	        alert("You can input only 0-9 in the Phone field!");
	        document.form1.Phone.focus();
	        return false;
	    }
   }
	
	if(document.form1.Fax.value=="")
	{
	alert("Fax field Required!  If no fax, enter 2 zero's.");
	document.form1.Fax.focus();
	return false;
	}
	else
	
	{
   var strValidChars = "0123456789- ()";
   var strChar;
   var blnResult = true;
	strString = document.form1.Fax.value;
	
   //if (strString.length == 1) return true;
   
   if (strString.length < 2 && (strString.length < 10 ))
		{
			alert("Fax field requires 10 digits!  If no fax, enter 2 zero's.");
			document.form1.Fax.focus();
			return false;
		}
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   if(blnResult==false)
	{
	alert("You can input only 0-9 in the Fax field!");
	document.form1.Fax.focus();
	return false;
	}
   }
   
   /*if(document.form1.Cell.value=="")
	{
	alert("Cell field Required!");
	document.form1.Cell.focus();
	return false;
	}
	else
	
	{
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;
	strString = document.form1.Cell.value;
	
   //if (strString.length == 1) return true;
   
   if (strString.length > 1 && (strString.length < 10 || strString.length > 10))
	{
		alert("Cell field requires 10 digits!");
		document.form1.Cell.focus();
		return false;
	}
   
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   if(blnResult==false)
	{
	alert("You can input only 0-9 in the Cell field!");
	document.form1.Cell.focus();
	return false;
	}
   }*/
	
	
	if(document.form1.FleetSize.value=="")
	{
	alert("Fleet Size Required!");
	document.form1.FleetSize.focus();
	return false;
	}
	
				    
    if(document.form1.MonthlyFuelExpenses.value=="")
	{
	    alert("Monthly Fuel Expenses field Required!");
	    document.form1.MonthlyFuelExpenses.focus();
	    return false;
	}
	else
	{
        var strValidChars = "0123456789";
        var strChar;
        var blnResult = true;
	    strString = document.form1.MonthlyFuelExpenses.value;
	
        if (strString.length == 0) return false;
        //  test strString consists of valid characters listed above
        for (i = 0; i < strString.length && blnResult == true; i++)
        {
               strChar = strString.charAt(i);
               if (strValidChars.indexOf(strChar) == -1)
               {
                    blnResult = false;
               }
        }
        if(blnResult==false)
	    {
	        alert("You Can Input only 0-9 in the Monthly Fuel Expenses field!");
	        document.form1.MonthlyFuelExpenses.focus();
	        return false;
	    }
    }
	
	// if(document.form1.MonthlyFuelExpenses.value < 2500)
	// {
	    // alert("Monthly Fuel Expenses requires minimum of 2500");
	    // document.form1.MonthlyFuelExpenses.focus();
	    // return false;
	// }
   
    if(document.form1.FleetContactEmail.value=="")
	{
	alert("Contact Email field Required! ");
	document.form1.FleetContactEmail.focus();
	return false;
	}
	else
	{
	if((document.form1.FleetContactEmail.value.indexOf("@")==-1)||(document.form1.FleetContactEmail.value.indexOf(".")==-1))
		{
			alert("Enter a valid email address");
			document.form1.FleetContactEmail.focus();
			return false;
		}
	}
	
	if(document.form1.FleetSize.value=="")
	{
		alert("FleetSize field Required!");
		document.form1.FleetSize.focus();
		return false;
	}
	
	if(document.form1.YrsInBus.value=="")
	{
		alert("Years in Business field Required!");
		document.form1.YrsInBus.focus();
		return false;
	}
	else
	{   
	    var strValidChars = "0123456789,$.";
        var strChar;
        var blnResult = true;
	    strString = document.form1.YrsInBus.value;
	
        if (strString.length == 0) return false;
        //  test strString consists of valid characters listed above
        for (i = 0; i < strString.length && blnResult == true; i++)
        {
            strChar = strString.charAt(i);
            if (strValidChars.indexOf(strChar) == -1)
            {
                blnResult = false;
            }
        }
        if(blnResult==false)
	    {
	        alert("You Can Input only 0-9,$,. and , for Years In Business field!");
	        document.form1.YrsInBus.focus();
	        return false;
	    }
	}
	
	 document.form1.MM_insert.value = "form1";   
	 return true;
}

function validateContactForm()
{
    
   if(document.contactform.FirstName.value=="")
   {
        alert("First Name field Required!");
	    document.contactform.FirstName.focus();
	    return false;
   } 
   if(document.contactform.LastName.value=="")
   {
        alert("LastName field Required!");
	    document.contactform.LastName.focus();
	    return false;
   } 
    if(document.contactform.Phone.value=="")
	{
	    alert("phone field Required!");
	    document.contactform.Phone.focus();
	    return false;
	}
	else
	{
        var strValidChars = "0123456789-()";
        var strChar;
        var blnResult = true;
	    strString = document.contactform.Phone.value;
	
        if (strString.length == 0) return false;
        //  test strString consists of valid characters listed above
        for (i = 0; i < strString.length && blnResult == true; i++)
        {
            strChar = strString.charAt(i);
            if (strValidChars.indexOf(strChar) == -1)
            {
                blnResult = false;
            }
        }
        if(blnResult==false)
	    {
	        alert("You Can Input only 0-9 and - In the Phone field Required!");
	        document.contactform.Phone.focus();
	        return false;
	    }
   }
	
	if(document.contactform.Fax.value=="")
	{
	    alert("Fax field Required!");
	    document.contactform.Fax.focus();
	    return false;
	}
	else
	{
        var strValidChars = "0123456789-()";
        var strChar;
        var blnResult = true;
	    strString = document.contactform.Fax.value;
	
        if (strString.length == 0) return false;
        //  test strString consists of valid characters listed above
        for (i = 0; i < strString.length && blnResult == true; i++)
        {
            strChar = strString.charAt(i);
            if (strValidChars.indexOf(strChar) == -1)
            {
                blnResult = false;
            }
        }
        if(blnResult==false)
	    {
	        alert("You Can Input only 0-9 and - In the Fax field Required!");
	        document.contactform.Fax.focus();
	        return false;
	    }
   }
   
   if(document.contactform.Email.value=="")
	{
	    alert("Email field Required!");
	    document.contactform.Email.focus();
	    return false;
	}
	else
	{
	if((document.contactform.Email.value.indexOf("@")==-1)||(document.contactform.Email.value.indexOf(".")==-1))
		{
			alert("Enter the valid email address");
			document.contactform.Email.focus();
			return false;
		}
	}
	
	if(document.contactform.Comments.value=="")
   {
        alert("Comments field Required!");
	    document.contactform.Comments.focus();
	    return false;
   } 
   
	var vstr=document.contactform.eValidate.value;
	if(vstr.toUpperCase()!="A6"+"CF")
   {
        alert("Invalid Security Code!");
	    document.contactform.eValidate.focus();
	    return false;
   } 
   
   var width  = 250;
   var height = 150;
   var left   = (screen.width  - width)/2;
   var top    = (screen.height - height)/2;
   window.open("thankyou_contact.html","","left=" + left + ",top=" + top + ",width=300, height=200, status=no");
   return true; 
   
   
}

function validateQuickCallForm()
{
    if(document.quickcall.FirstName.value == "")
    {
        alert("First Name field Required!");
	    document.quickcall.FirstName.focus();
	    return false; 
    }
   
    if(document.quickcall.LastName.value == "")
    {
        alert("Last Name field Required!");
	    document.quickcall.LastName.focus();
	    return false; 
    }
	if(document.quickcall.BusinessName.value == "")
    {
        alert("Business Name field Required!");
	    document.quickcall.BusinessName.focus();
	    return false; 
    }
	if(document.quickcall.eValidate.value.toUpperCase() != "A6CF")
    {
        alert("Security Code Invalid!");
	    document.quickcall.eValidate.focus();
	    return false; 
    }
   
   if(document.quickcall.Phone.value=="")
	{
	    alert("phone number field Required!");
	    document.quickcall.Phone.focus();
	    return false;
	}
	else
	{
        var strValidChars = "0123456789-()";
        var strChar;
        var blnResult = true;
	    strString = document.quickcall.Phone.value;
	
        if (strString.length == 0) return false;
        //  test strString consists of valid characters listed above
        for (i = 0; i < strString.length && blnResult == true; i++)
        {
            strChar = strString.charAt(i);
            if (strValidChars.indexOf(strChar) == -1)
            {
                blnResult = false;
            }
        }
        if(blnResult==false)
	    {
	        alert("You Can Input only 0-9 and - In the Phone field Required!");
	        document.quickcall.Phone.focus();
	        return false;
	    }
   } 
    return true;
    
}

function validateRequestADemoForm()
{
    if(document.quickcall.FirstName.value == "")
    {
        alert("First Name field Required!");
	    document.quickcall.FirstName.focus();
	    return false; 
    }
   
    if(document.quickcall.LastName.value == "")
    {
        alert("Last Name field Required!");
	    document.quickcall.LastName.focus();
	    return false; 
    }
	if(document.quickcall.BusinessName.value == "")
    {
        alert("Business Name field Required!");
	    document.quickcall.BusinessName.focus();
	    return false; 
    }
	
	if(document.quickcall.Email.value=="")
	{
	alert("Email field Required! ");
	document.quickcall.Email.focus();
	return false;
	}
	else
	{
	if((document.quickcall.Email.value.indexOf("@")==-1)||(document.quickcall.Email.value.indexOf(".")==-1))
		{
			alert("Enter a valid email address");
			document.quickcall.Email.focus();
			return false;
		}
	}
	if(document.quickcall.Fleet.value=="")
	{
	    alert("Fleet Size field Required!");
	    document.quickcall.Fleet.focus();
	    return false;
	}
   
   if(document.quickcall.Phone.value=="")
	{
	    alert("phone number field Required!");
	    document.quickcall.Phone.focus();
	    return false;
	}
	else
	{
        var strValidChars = "0123456789-()";
        var strChar;
        var blnResult = true;
	    strString = document.quickcall.Phone.value;
	
        if (strString.length == 0) return false;
        //  test strString consists of valid characters listed above
        for (i = 0; i < strString.length && blnResult == true; i++)
        {
            strChar = strString.charAt(i);
            if (strValidChars.indexOf(strChar) == -1)
            {
                blnResult = false;
            }
        }
        if(blnResult==false)
	    {
	        alert("You Can Input only 0-9 and - In the Phone field Required!");
	        document.quickcall.Phone.focus();
	        return false;
	    }
   }

   if(document.quickcall.eValidate.value.toUpperCase() != "A6CF")
    {
        alert("Security Code Invalid!");
	    document.quickcall.eValidate.focus();
	    return false; 
    }
   
    return true;
    
}

function IsNumeric(fleet_val)
{  
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < fleet_val.length && IsNumber == true; i++) 
   { 
      Char = fleet_val.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
   }
   return IsNumber;
   
}

function validateApplicationForm()
{
    var checkEmail=document.application.Email.value;
	if (document.application.FirstName.value =="") 
	{
	alert("Please fill the First Name");
	document.application.FirstName.focus();
	return false;
	}	
	if (document.application.LastName.value =="") 
	{
	alert("Please fill the Last Name");
	document.application.LastName.focus();
	return false;
	}
	if(document.application.WorkPhone.value=="")
	{
	    alert("phone number field Required!");
	    document.application.WorkPhone.focus();
	    return false;
	}
	else
	{
        var strValidChars = "0123456789-()";
        var strChar;
        var blnResult = true;
	    strString = document.application.WorkPhone.value;
	
        if (strString.length == 0) return false;
        //  test strString consists of valid characters listed above
        for (i = 0; i < strString.length && blnResult == true; i++)
        {
            strChar = strString.charAt(i);
            if (strValidChars.indexOf(strChar) == -1)
            {
                blnResult = false;
            }
        }
        if(blnResult==false)
	    {
	        alert("You Can Input only 0-9 and - In the Phone field Required!");
	        document.application.WorkPhone.focus();
	        return false;
	    }
   }

if(document.application.CellPhone.value!="")
	//{
	    //alert("cellphone number field Required!");
	    //document.application.CellPhone.focus();
	    //return false;
	//}
	//else
	{
        var strValidChars = "0123456789-()";
        var strChar;
        var blnResult = true;
	    strString = document.application.CellPhone.value;
	
        if (strString.length == 0) return false;
        //  test strString consists of valid characters listed above
        for (i = 0; i < strString.length && blnResult == true; i++)
        {
            strChar = strString.charAt(i);
            if (strValidChars.indexOf(strChar) == -1)
            {
                blnResult = false;
            }
        }
        if(blnResult==false)
	    {
	        alert("You Can Input only 0-9 and - In the Cell Phone field!");
	        document.application.CellPhone.focus();
	        return false;
	    }
   }   
	
	if (document.application.Organization.value =="")
	{
	alert("Please fill the Company Name");
	document.application.Organization.focus();
	return false;
	}
	
	if (document.application.State.value =="")
	{
	alert("Please fill the State");
	document.application.State.focus();
	return false;
	}
	
	
	if (checkEmail=="")
	{
	alert("Please fill the Email Address.");
	document.application.Email.focus();
	return false;
	} 
	if ((checkEmail!="")&& ((checkEmail.indexOf("@")==-1) || (checkEmail.indexOf(".")==-1)))
	{
	alert("You have entered an invalid Email Address. Please try again.");
	document.application.Email.focus();
	return false;
	}
	
	if (document.application.City.value =="") 
	{
	alert("Please fill the City");
	document.application.City.focus();
	return false;
	}	
	 
	// if (!IsNumeric(document.application.years.value))
   // { 
   	  // alert('Please enter only numbers in years in business');
	  // document.application.years.focus();
	  // return false;
      
      // } 
	  
	if (document.application.Fleet_Size.value =="") 
	{
	alert("Please fill the Fleet size");
	document.application.Fleet_Size.focus();
	return false;
	}	
	if (!IsNumeric(document.application.Fleet_Size.value))
   { 
   	  alert('Please enter only numbers in the Fleet size');
	  document.application.Fleet_Size.focus();
	  return false;
      
      } 
	 if (document.application.Fuel_Costs.value =="") 
	 {
	 alert("Please fill the Total Fleet Monthly Fuel Spend");
	 document.application.Fuel_Costs.focus();
	 return false;
	 }	
	 if (!IsNumeric(document.application.Fuel_Costs.value))
    { 
   	   alert('Please enter only numbers in the Total Fleet Monthly Fuel Spend');
	   document.application.Fuel_Costs.focus();
	   return false;
      
       }
    return true;
}


function checkYears(e)
{
	var flagged = false;
	var dateNow = new Date();
	
    var amt;
	amt = dateNow.getFullYear() - e;
    amt = amt + "";
	
	//document.form1.FederalTaxID.value = e;
	
	if (amt >= 3)
	{
		AuthorizedInfoNotRequired();
		document.getElementById('trWillSupplyFinancials').style.display="none";
	} 
	else
	{
		AuthorizedInfoRequired();
		document.getElementById('trWillSupplyFinancials').style.display="none";
		//document.getElementById('trWillSupplyFinancials').style.display="inline";
		//document.getElementById('trWillSupplyFinancials').colspan = "2";
	}
}

function checkYears(e)
{
	var flagged = false;
	var dateNow = new Date();
	
    var amt;
	amt = dateNow.getFullYear() - e;
    amt = amt + "";
	
	//document.form1.FederalTaxID.value = e;
	
	if (amt > 3)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function ShowHideSubmitFinancialDocs(e)
{
	var flagged = false;
	var dateNow = new Date();
	
    var amt;
	amt = dateNow.getFullYear() - e;
    amt = amt + "";
	
	//document.form1.FederalTaxID.value = e;
	
	if (amt > 3)
	{
		//AuthorizedInfoRequired();
		document.getElementById('trWillSupplyFinancials').style.display="inline";
		document.getElementById('trWillSupplyFinancials').colspan = "2";
		return false;
	}
	else
	{
		document.getElementById('trWillSupplyFinancials').style.display="none";
		document.getElementById('trWillSupplyFinancials').colspan = "2";
		document.form1.WillSupplyFinancials.checked = false;
		return false;
	}
}

function AuthorizedInfoRequired()
{
		document.form1.DateofBirth.disabled=false;
        document.form1.DateofBirth.style.backgroundColor = "#F4F4F4";        
         
        document.form1.SocialSecurityNumber.disabled=false;
        document.form1.SocialSecurityNumber.style.backgroundColor = "#F4F4F4";
        
        document.form1.HomeAddress.disabled=false;
        document.form1.HomeAddress.style.backgroundColor = "#F4F4F4";
        
        document.form1.HomeCity.disabled=false;
        document.form1.HomeCity.style.backgroundColor = "#F4F4F4";
        
        document.form1.HomeState.disabled=false;
        
        document.form1.HomeZip.disabled=false;
        document.form1.HomeZip.style.backgroundColor = "#F4F4F4";
}

function AuthorizedInfoNotRequired()
{
	//alert("The following is not required below: Authorized Officer’s Date of Birth, SS# and Home Address if Years In Business is at least 3 years or submitting 2 years financial documents.");
        
        document.form1.DateofBirth.disabled=true;
        document.form1.DateofBirth.style.backgroundColor = "gray"; 
                       
        document.form1.SocialSecurityNumber.disabled=true;
        document.form1.SocialSecurityNumber.style.backgroundColor = "gray";   
        
        document.form1.HomeAddress.disabled=true;
        document.form1.HomeAddress.style.backgroundColor = "gray";
        
        document.form1.HomeCity.disabled=true;
        document.form1.HomeCity.style.backgroundColor = "gray";
        
        document.form1.HomeState.disabled=true;
        
        document.form1.HomeZip.disabled=true;
        document.form1.HomeZip.style.backgroundColor = "gray";
}

function CheckIfSubmitFinancials()
{
	if (document.form1.WillSupplyFinancials.checked)
	{
		AuthorizedInfoNotRequired();
	}
	else
	{
		AuthorizedInfoRequired();
	}
}

  function showCustomerServicePhoneNumber()
   {
        var acctCode;
        acctCode = document.form1.accountCode.value;
        var width  = 200;
        var height = 90;
        var left   = (screen.width  - width)/2;
        var top    = (screen.height - height)/2;
 
        if (document.form1.accountCode.value != "") 
        {
            if (isNaN(acctCode.substring(0,2)))
            {
                //alert("customer service number is 800-552-6529");
              
                  
               window.open("csNumber1.html","","left=" + left + ",top=" + top + ",width=230, height=120, status=no");
                return false;
            }
            else
            {
                window.open("csNumber2.html","","left=" + left + " ,top=" + top + " ,width=230, height=120, status=no");
                return false; 
            }
                 
       }
         
       else
       {
             alert("your account code");
             document.form1.accountCode.focus();   
             return false;
       } 
       
    return true;      
   }