// JavaScript Document
// Fuck off jackers ¬¬


//Funciones para revisar email
//----------------------------
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
}



function ValidateForm()
{


	var emailID =document.forma.email;
	var fname =document.forma.name;
	var phone =document.forma.phone;
	var thehotel =document.forma.hotel;
	var address =document.forma.address;
	var state =document.forma.state;
	var city =document.forma.city;
	var creditcardholder =document.forma.creditcardholder;
	var creditcard =document.forma.creditcard;
	var securecode =document.forma.securecode;
	var zip =document.forma.zip;
	
	


	if (document.forma.adults.selectedIndex == 0 && document.forma.childs.selectedIndex == 0)
			{
				alert("Please enter a value for the Adults or childs.");
				document.forma.adults.focus();
				return (false);
			}

	if(fname.value=="")
	{
		alert("Please Enter your Name")
		fname.focus()
		return false
	}

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}

	if(phone.value=="")
	{
		alert("Please Enter your Phone contact")
		phone.focus()
		return false
	}

	if(thehotel.value=="")
	{
		alert("Please Enter your Hotel")
		thehotel.focus()
		return false
	}
		if(address.value=="")
	{
		alert("Please Enter your Address")
		address.focus()
		return false
	}
		if(state.value=="")
	{
		alert("Please Enter your State")
		state.focus()
		return false
	}
	
		if(city.value=="")
	{
		alert("Please Enter your City")
		city.focus()
		return false
	}


			if(creditcardholder.value=="")
	{
		alert("Please Enter your Creditcard holder ")
		creditcardholder.focus()
		return false
	}
			if(creditcard.value=="")
	{
		alert("Please Enter your Credit Card Number")
		creditcard.focus()
		return false
	}
			if(securecode.value=="")
	{
		alert("Please Enter your Secure Code")
		securecode.focus()
		return false
	}

			if(zip.value=="")
	{
		alert("Please Enter your Credit Card Zip..  This is the Zip Code from your credit card statement")
		zip.focus()
		return false
	}


			if (document.forma.CARDTYPE.selectedIndex == 0)
			{
				alert("Please enter a value for the \"Credit Card Type:\" field.");
				document.forma.CARDTYPE.focus();
				return (false);
			}
			


	
		if (document.forma.CARDMONTH.selectedIndex == 0)
			{
				alert("Please enter a value for the \"Expiration Date:\" field (Month).");
				document.forma.CARDMONTH.focus();
				return (false);
			}
	
		if (document.forma.CARDYEAR.selectedIndex == 0)
			{
				alert("Please enter a value for the \"Expiration Date:\" field (Year).");
				document.forma.CARDYEAR.focus();
				return (false);
			}
			
	

	if (document.forma.agree.checked == false)
	{
		alert ('You must agree with reservation and cancellation policies in order to reserve');
		document.forma.agree.focus();
		return false;
	}


	return true
}


