// JScript source code
  function ValidateForm()
  {
     if (document.contactform.companyname.value=="")
     {
        alert("Please enter company name")
        document.contactform.companyname.focus();
        return false;
     }
	 else if (document.contactform.companyname.value.indexOf("@") >= 0 || document.contactform.companyname.value.indexOf(".") >= 0)
	 {
	    alert("Please enter valid user name");
	    document.contactform.companyname.focus();
        return false;
	 }
	 else if (document.contactform.contact.value=="")
     {
        alert("Please enter your contact name")
        document.contactform.contact.focus();
        return false ;
     }
    
     else if (document.contactform.shippingaddress.value=="")
     {
        alert("Please enter your shipping address")
        document.contactform.shippingaddress.focus();
        return false;
     }
     else if (document.contactform.city.value=="")
     {
        alert("Please enter your city")
        document.contactform.city.focus();
        return false;
     }
	 else if (document.contactform.selCountry.selectedIndex ==0)
     {
        alert("Please select a country")
        document.contactform.selCountry.focus();
        return false;
     }
     else if (document.contactform.state.value=="")
     {
        alert("Please enter your state")
        document.contactform.state.focus();
        return false;
     }
	 else if (document.contactform.ziporpostalcode.value=="")
     {
        alert("Please enter your zip or postalcode")
        document.contactform.ziporpostalcode.focus();
        return false;
     }
	  else if (isNaN(document.contactform.ziporpostalcode.value) ) 
      {
      alert("Please enter numeric value!");
	  document.contactform.ziporpostalcode.focus();
      return false;
      }
	  else if (document.contactform.phone.value=="")
     {
        alert("Please enter your phone")
        document.contactform.phone.focus();
        return false;
     }
	    else if (document.contactform.fax.value=="")
     {
        alert("Please enter your fax")
        document.contactform.fax.focus();
        return false;
     }
	     else if (document.contactform.email.value=="")
     {
        alert("Please enter your email")
        document.contactform.email.focus();
        return false;
     }

	  else if (document.contactform.email.value.indexOf("@") == -1 || document.contactform.email.value.indexOf(".") == -1 || ! isEmail(document.contactform.email.value))
	{
		alert("Invalid email address, Please check the email address you have entered.");
		document.contactform.email.focus();
		return false;
	}
	 else if (isNaN(document.contactform.ziporpostalcode1.value) ) 
      {
      alert("Please enter numeric value!");
	  document.contactform.ziporpostalcode1.focus();
        return false;
      }
	if ( ( document.contactform.RBRCind[0].checked == false ) && ( document.contactform.RBRCind[1].checked == false ) && ( document.contactform.RBRCind[2].checked == false ) )
        {
                alert ( "Please select RBRC Boxes for collecting individual battery types." );
				document.contactform.RBRCind.focus();
                valid = false;
        }
	if ( ( document.contactform.RRBRC2[0].checked == false ) && ( document.contactform.RRBRC2[1].checked == false ) && ( document.contactform.RRBRC2[2].checked == false ) )
        {
                alert ( "Please select RRBRC Boxes for collecting all battery types and cell phones." );
                valid = false;
        }

	else
	  {
			document.contactform.method="post";
			document.contactform.action = "http://www.wizartsolutions.com/honeywell/AddDataRecycling.asp";
			document.contactform.submit(); 
			return true;
	  }
  }	 

	function validateForNumbers(fieldName)
	{
		var obj = eval("document.all."+fieldName)
		val = obj.value;
		var IsNumber=true;
		for (i=0; i< val.length && IsNumber==true; i++) 
		{
			character = val.charAt(i);
			if (isNaN(character))
			{
				IsNumber = false;
				alert("Please enter numbers only")
				obj.value="";
				obj.focus();
			}
		}
		return IsNumber;
	}
    
    function validateMonthAndYear(month, yr)
    {
        var today = new Date()
        thisMonth = today.getMonth()+1
        thisYear = today.getFullYear()

        if ((yr< thisYear)  || ((month < thisMonth) && (yr<= thisYear)))
        {
            alert ("Invalid Expiry Date");
            return false;
         }
         else
         {
            return true;
         }
    }
    
function isEmail(strEMail) //validations for email
{
	var strInvalidChars,blnTemp,i,strTemp,intdot,IsMail,strEMailRev,intAtTheRate;
    intdot = strEMail.lastIndexOf(".");
	if (intdot == -1 )
		return false;
    
	intdot=strEMail.length-intdot-1;
	if (intdot < 2 )
		return false;

    // Disallowed characters
    strInvalidChars = "!#$%^&*()=+{}[]|\;:'/?>,< ";

	intAtTheRate = strEMail.indexOf("@") ;

    // Check that there is at least one '@' and a character before @
    if (intAtTheRate < 1)
		blnTemp=true;
	else
		blnTemp=false;

    if (blnTemp)
		return !blnTemp;

	// Check that there is at least one '.' in the form a@a.com
    blnTemp = (strEMail.indexOf(".") < 3);
   if (blnTemp)
		return !blnTemp;

	//   Check that there is at least one char between '.' and @ after @
	intdot= strEMail.indexOf(intAtTheRate+1,".");
	blnTemp = (intdot==2);
     if (blnTemp)
		return !blnTemp;

	//   Check that there is at least one char between '.' and @ before @
    blnTemp = (strEMail.substring(intAtTheRate - 1, intAtTheRate) == ".");
    if (blnTemp)
		return !blnTemp;

	//  and that the length is at least six (a@a.co)
    blnTemp = (strEMail.length < 6);
   if (blnTemp) 
		return !blnTemp;
	//  Check that there is only one '@'
    blnTemp = (intAtTheRate != strEMail.lastIndexOf("@"));
    
   if (blnTemp)
	return !blnTemp;
   //    extra checks
  //     AFTER '@' space is not allowed
	strTemp=strEMail.substring(intAtTheRate+1);
	blnTemp = (strTemp.indexOf(" ") > 0);
   if (blnTemp) 
		return !blnTemp;

  //   Check that there is one dot AFTER '@'
    blnTemp = (strTemp.indexOf(".") == 0);
   if (blnTemp)
		return !blnTemp;
    
	//    Check if there's a quote (")
    blnTemp = strEMail.indexOf("\"") > 0;
     if (blnTemp )
		return !blnTemp;
    
	//     Check if there's any other disallowed chars
	//     optimize a little if strEMail longer than strInvalidChars
	//     check the other way around
    if (strEMail.length > strInvalidChars.length)
	{
        for(var i = 0; i< strInvalidChars.length;i++)
		{
            if (strEMail.indexOf(strInvalidChars.substring(i,i+1)) > 0 )
                  blnTemp = true;
            if (blnTemp )
				break;
        } //end for
    } //end if
	else
	{
        for(var i = 0 ;i< strEMail.length;i++)
		{
            if (strInvalidChars.indexOf(strEMail.substring(i,i+1)) > 0) 
                  blnTemp = true;
            if (blnTemp )
				break;
        } //end for
    } //end else
    if (blnTemp)
		return !blnTemp;

	//     extra check
	 //    no two consecutive dots
    blnTemp = strEMail.indexOf("..") > 0;
    if (blnTemp)
		return !blnTemp;

	//    if any of the above are true, invalid e-mail
    return !blnTemp;
}

function ValidateBuy()
  {
     if (document.frmhowtobuy.agency.value=="")
     {
        alert("Please enter agency name")
        document.frmhowtobuy.agency.focus();
        return false;
     }
	 else if (document.frmhowtobuy.contact.value.indexOf("@") >= 0 || document.frmhowtobuy.contact.value.indexOf(".") >= 0)
	 {
	    alert("Please enter valid contact name");
	    document.frmhowtobuy.contact.focus();
        return false;
	 }
	 else if (document.frmhowtobuy.contact.value=="")
     {
        alert("Please enter your contact name")
        document.frmhowtobuy.contact.focus();
        return false ;
     }
    else if (document.frmhowtobuy.phone.value=="")
     {
        alert("Please enter your phone")
        document.frmhowtobuy.phone.focus();
        return false;
     }
	    else if (document.frmhowtobuy.fax.value=="")
     {
        alert("Please enter your fax")
        document.frmhowtobuy.fax.focus();
        return false;
     }
     else if (document.frmhowtobuy.streetaddress.value=="")
     {
        alert("Please enter your street address")
        document.frmhowtobuy.streetaddress.focus();
        return false;
     }
	else if (document.frmhowtobuy.address2.value=="")
     {
        alert("Please enter your address")
        document.frmhowtobuy.address2.focus();
        return false;
     }
     else if (document.frmhowtobuy.city.value=="")
     {
        alert("Please enter your city")
        document.frmhowtobuy.city.focus();
        return false;
     }
	    else if (document.frmhowtobuy.state.value=="")
     {
        alert("Please enter your state")
        document.frmhowtobuy.state.focus();
        return false;
     }
	  else if (document.frmhowtobuy.zip.value=="")
     {
        alert("Please enter zip code")
        document.frmhowtobuy.zip.focus();
        return false;
     }
	 else if (IsNumeric(document.frmhowtobuy.zip.value) == false) 
      {
      alert("Please enter numeric value for zipcode!");
	  document.frmhowtobuy.zip.focus();
        return false;
      }
	 	
	  else if (document.frmhowtobuy.email.value=="")
     {
        alert("Please enter your email")
        document.frmhowtobuy.email.focus();
        return false;
     }
	  else if (document.frmhowtobuy.email.value.indexOf("@") == -1 || document.frmhowtobuy.email.value.indexOf(".") == -1 || ! isEmail(document.frmhowtobuy.email.value))
	{
		alert("Invalid email address, Please check the email address you have entered.");
		document.frmhowtobuy.email.focus();
		return false;
	}
	
	else
	  {
			document.frmhowtobuy.method="post";
			document.frmhowtobuy.action = "http://www.wizartsolutions.com/honeywell/Addhowtobuy.asp";
			document.frmhowtobuy.submit(); 
			return true;
	  }
  }	
  function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   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;
         }
      }
   return blnResult;
   }
   function ValidatePower()
  {
     if (document.frmpowerbythehour.name.value=="")
     {
        alert("Please enter name")
        document.frmpowerbythehour.name.focus();
        return false;
     }
	 else if (document.frmpowerbythehour.name.value.indexOf("@") >= 0 || document.frmpowerbythehour.name.value.indexOf(".") >= 0)
	 {
	    alert("Please enter valid name");
	    document.frmpowerbythehour.name.focus();
        return false;
	 }
	 else if (document.frmpowerbythehour.company.value=="")
     {
        alert("Please enter your company name")
        document.frmpowerbythehour.company.focus();
        return false ;
     }
    else if (document.frmpowerbythehour.title.value=="")
     {
        alert("Please enter title")
        document.frmpowerbythehour.title.focus();
        return false;
     }
	    else if (document.frmpowerbythehour.phone.value=="")
     {
        alert("Please enter your phone")
        document.frmpowerbythehour.phone.focus();
        return false;
     }
	else if (document.frmpowerbythehour.email.value=="")
     {
        alert("Please enter your email")
        document.frmpowerbythehour.email.focus();
        return false;
     }
	  else if (document.frmpowerbythehour.email.value.indexOf("@") == -1 || document.frmpowerbythehour.email.value.indexOf(".") == -1 || ! isEmail(document.frmpowerbythehour.email.value))
	{
		alert("Invalid email address, Please check the email address you have entered.");
		document.frmpowerbythehour.email.focus();
		return false;
	}
	else if (document.frmpowerbythehour.loc.value=="")
     {
        alert("Please enter number of locations.")
        document.frmpowerbythehour.loc.focus();
        return false;
     }
	 else if (isNaN(document.frmpowerbythehour.loc.value)) 
	 {
		alert("Please enter numeric value!");
		document.frmpowerbythehour.loc.focus();
        return false;
      }
	else if (document.frmpowerbythehour.est.value=="")
     {
        alert("Please enter Estimated number of wireless devices.")
        document.frmpowerbythehour.est.focus();
        return false;
     }
	 else if (isNaN(document.frmpowerbythehour.est.value)) 
	 {
		alert("Please enter numeric value!");
	    document.frmpowerbythehour.est.focus();
        return false;
      }
	else if (document.frmpowerbythehour.devices.value=="")
     {
        alert("Please enter Devices in operation.")
        document.frmpowerbythehour.devices.focus();
        return false;
     }
	 else if (isNaN(document.frmpowerbythehour.devices.value)) 
		 {
			alert("Please enter numeric value only for devices!");
		    document.frmpowerbythehour.devices.focus();
	        return false;
	      }
	else if (document.frmpowerbythehour.current.value=="")
	     {
        alert("Please enter where you are currently getting your batteries from.")
        document.frmpowerbythehour.current.focus();
        return false;
		}	 	
	 	
	else
	  {
			document.frmpowerbythehour.method="post";
			document.frmpowerbythehour.action = "http://www.wizartsolutions.com/honeywell/powerbythehour.asp";
			document.frmpowerbythehour.submit(); 
			return true;
	  }
  }
  
  
  
  function ValidateFormContact()
  {
     if (document.contactform.companyname.value=="")
     {
        alert("Please enter company name")
        document.contactform.companyname.focus();
        return false;
     }
	 else if (document.contactform.companyname.value.indexOf("@") >= 0 || document.contactform.companyname.value.indexOf(".") >= 0)
	 {
	    alert("Please enter valid user name");
	    document.contactform.companyname.focus();
        return false;
	 }
	 else if (document.contactform.contact.value=="")
     {
        alert("Please enter your contact name")
        document.contactform.contact.focus();
        return false ;
     }
    
     else if (document.contactform.SAddress.value=="")
     {
        alert("Please enter your street address")
        document.contactform.SAddress.focus();
        return false;
     }
     else if (document.contactform.City.value=="")
     {
        alert("Please enter your city")
        document.contactform.city.focus();
        return false;
     }
	 
     else if (document.contactform.State.value=="")
     {
        alert("Please enter your state")
        document.contactform.State.focus();
        return false;
     }
	 else if (document.contactform.ziporpostalcode.value=="")
     {
        alert("Please enter your zip or postalcode")
        document.contactform.ziporpostalcode.focus();
        return false;
     }
	  else if (isNaN(document.contactform.ziporpostalcode.value) ) 
      {
      alert("Please enter numeric value!");
	  document.contactform.ziporpostalcode.focus();
      return false;
      }
	  else if (document.contactform.Phone.value=="")
     {
        alert("Please enter your phone")
        document.contactform.Phone.focus();
        return false;
     }
	    else if (document.contactform.Fax.value=="")
     {
        alert("Please enter your fax")
        document.contactform.Fax.focus();
        return false;
     }
	     else if (document.contactform.email.value=="")
     {
        alert("Please enter your email")
        document.contactform.email.focus();
        return false;
     }
          else if (document.contactform.Address2.value=="")
     {
        alert("Please enter your Address2")
        document.contactform.Address2.focus();
        return false;
     }
           else if (document.contactform.Message.value=="")
     {
        alert("Please enter your Message")
        document.contactform.Message.focus();
        return false;
     }

	  else if (document.contactform.email.value.indexOf("@") == -1 || document.contactform.email.value.indexOf(".") == -1 || ! isEmail(document.contactform.email.value))
	{
		alert("Invalid email address, Please check the email address you have entered.");
		document.contactform.email.focus();
		return false;
	}
//	 else if (isNaN(document.contactform.ziporpostalcode1.value) ) 
//      {
//      alert("Please enter numeric value!");
//	  document.contactform.ziporpostalcode1.focus();
//        return false;
//      }
//	if ( ( document.contactform.RBRCind[0].checked == false ) && ( document.contactform.RBRCind[1].checked == false ) && ( document.contactform.RBRCind[2].checked == false ) )
//        {
//                alert ( "Please select RBRC Boxes for collecting individual battery types." );
//				document.contactform.RBRCind.focus();
//                valid = false;
//        }
//	if ( ( document.contactform.RRBRC2[0].checked == false ) && ( document.contactform.RRBRC2[1].checked == false ) && ( document.contactform.RRBRC2[2].checked == false ) )
//        {
//                alert ( "Please select RRBRC Boxes for collecting all battery types and cell phones." );
//                valid = false;
//        }

	else
	  {
			document.contactform.method="post";
			document.contactform.action = "http://www.wizartsolutions.com/honeywell/AddDataContact.asp";
			document.contactform.submit(); 
			return true;
	  }
  }	
