// JavaScript Document
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("txtEmail")
	
	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("txtName").value=="")
	  {
	  alert("Please enter your name");
	  document.getElementById("txtName").focus();
	  return false;
	  }
	else if (document.getElementById("txtTourDate").value=="")
	  {
	  alert("Please enter the tour date");
	  document.getElementById("txtTourDate").focus();
	  return false;
	  }
	  
	else if (document.getElementById("tourTime1").value== "" && document.getElementById("tourTime2").value=="")
	  {
	  alert("Please select the time of the tour");
	  return false;
	  }
	
	else if (document.getElementById("txtNumPeople").value=="")
	  {
	  alert("Please enter the number of people in your group");
	  document.getElementById("txtNumPeople").focus();
	  return false;
	  }
	else if (document.getElementById("txtPhone").value=="")
	  {
	  alert("Please enter a contact phone number");
	  document.getElementById("txtPhone").focus();
	  return false;
	  }
	else if (ValidateEmail()==false) {
		  return false;
	  }
	else
	 {
	 return true;
	 }
}
