var chk = false;
function checkCheck() { 
	if (document.getElementById("brochureCheck").checked == true) {
		chk = true;
		//alert(chk);
	}
	else {
		chk = false;
		//alert(chk);
	}
}
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail address")
		    return false
		 }

 		 return true					
	}

function ValidateEmail(){
	var emailID=document.getElementById("email2")
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
function validate_required(){
	
	if (document.getElementById("fname").value=="")
	  {
	  alert("Please enter your first name");
	  document.getElementById("fname").focus();
	  return false;
	  }
	else if (document.getElementById("lname").value=="")
	  {
	  alert("Please enter your last name");
	  document.getElementById("lname").focus();
	  return false;
	  }
	else if (ValidateEmail()==false) {
		  return false;
	  }
	/*else if (document.getElementById("questions_comments").value=="")
	  {
	  alert("Please describe describe what information you would like");
	  document.getElementById("questions_comments").focus();
	  return false;
	  }	*/
	else if (chk == true) {
		//alert(chk);
			if (document.getElementById("address").value == "" || document.getElementById("city").value == "" || document.getElementById("zip").value == "" || document.getElementById("state").value == "")
			{
	  alert("Please enter your full address if you would like us to send you a brochure.");
	  document.getElementById("address").focus();
	  return false;
		}
	  }
	else
	 {
	 return true;
	 }
}