
function validate() {
    var is_valid = "";
    //var email = document.getElementById("email").value;
    var emailID = document.getElementById("email");
    var first_name = document.getElementById("first").value;
    var last_name = document.getElementById("last").value;
    var address = document.getElementById("add1").value;
    var city = document.getElementById("city").value;
    var state = document.getElementById("state").value;
    var zip = document.getElementById("zip").value;
    var country = document.getElementById("country").value;
    var home_phone = document.getElementById("home_phone").value;
    var num_people = document.getElementById("num_people").value;
    
    if ((emailID.value==null)||(emailID.value=="")){
	alert("Please Enter your Email ID");
	emailID.focus();
	return false;
    }
    else if (echeck(emailID.value)==false){
	emailID.value=""
	emailID.focus()
	return false
    }
    else if(isEmpty(first_name) == false || isEmpty(last_name) == false || isEmpty(address) == false || isEmpty(city) == false || isEmpty(state) == false || isEmpty(zip) == false || isEmpty(country) == false || isEmpty(home_phone) == false || isEmpty(num_people) == false) {
	return false;
    }
    else if(isNaN(num_people)) {
	alert("Number of People Travelling field must be a number");
	return false;
    }
    else if(num_people < 0 || num_people > 100) {
	alert("Number of People Travelling cannot be less than 0 or greater than 100");
	return false;
    }
    return true
}

function isEmpty(str) {
    if((str == null) || (str == "")) {
	alert("All fields with * must be entered");
	return false;
    }
}

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 ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

