function validateCustom1Form(){
	if(document.custom1.DepartureCity.value==""){
		alert("Please select the City you would like to fly from!");
		return false;
	}

	if(document.custom1.HotelType.value==""){
		alert("Please select a type of Hotel Accommodation!");
		return false;
	}
	
	if(checkdate_script(document.custom1.DepartureMonth.value+document.custom1.DepartureDay.value+document.custom1.DepartureYear.value)==false){
		return false;
	}
}

function validateCustom2Form(num){
	
	for(i=1; i<num+1;i++){
		
		if(document.custom2['DestinationNo'+i].value==""){
			alert("Please select a Destination #"+i+"!");
			return false;
		}
	}
}

function validateCustom3Form(){
	if(document.custom3.FlyInCity.value==""){
		alert("Please select where you want to Fly Into!");
		return false;
	}

	if(document.custom3.FlyOutCity.value==""){
		alert("Please select where you want to Fly Out Of!");
		return false;
	}

}

function validateCustom4Form(){
	if(document.custom4.FirstName.value==""){
		alert("Please enter your First Name!");
		return false;
	}

	if(document.custom4.LastName.value==""){
		alert("Please enter your Last Name!");
		return false;
	}

	if(document.custom4.Email.value==""){
		alert("Please enter your Email!");
		return false;
	}
	
	if(echeck(document.custom4.Email.value)==false){
		alert("Please enter a valid Email!");
		return false;
	}
		
	if(document.custom4.ReferredBy.value==""){
		alert("Please select a Reference!");
		return false;
	}
	if(document.custom4.txtSecurityCode.value==""){
		alert("Please enter Verification Code!");
		document.custom4.txtSecurityCode.focus();
		return false;
	}	
}

function echeck(str, owner) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
}



function checkdate_script(date) {

  			var myDayStr = date.substr(2,2);
			var myMonthStr = date.substr(0,2);
			var myYearStr = date.substr(4,4);

			var myDate = new Date();

			if(myDayStr.charAt(0)=="0")
				myDayStr = myDayStr.substr(1,1);

			if(myMonthStr.charAt(0)=="0")
				myMonthStr = myMonthStr.substr(1,1);

			myMonthStr = myMonthStr-1;

			myDate.setFullYear( myYearStr, myMonthStr, myDayStr );

			var todaydate = new Date();

			if(todaydate<=myDate){

				if ( myDate.getMonth() != myMonthStr ) {
  					alert("Please select a Valid Date!");
  					return false;
				} else {
  					return true;
				}
			}
			else {
				alert("Departure date must be later than Today!");
  				return false;
			}
}
