
today = new Date()
day = today.getDate();
var months=new Array("Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec");
today_month=today.getMonth();
year=today.getYear();

function checkform()
{		
	var formcheck=document.myform.name.value;
	var formcheck1=document.myform.email.value;
	var formcheck2=document.myform.address.value;

	var formcheck3=document.myform.pax.value;
	var formcheck4=document.myform.duration.value;


	
	var datecheck = document.myform.checkin_d.value
	var monthcheck=document.myform.checkin_m.value;
	var yearcheck = document.myform.checkin_y.value
	
	var message = "";
	var flag =0;
	
	if(formcheck=="" || formcheck1=="" || formcheck2=="" || formcheck3=="" || formcheck4=="" )
	{
			flag=1;
			if(formcheck4=="")
			 {
			 	if(message!="")message="," +message;
				message=" No. of Days"+ message;
				document.myform.duration.focus();
			 }
			
			
			if(formcheck3=="")
			 {
			 	if(message!="")message="," +message;
				message=" No of persons"+ message;
				document.myform.pax.focus();
			 }
			
			if(formcheck2=="")
			 {
			 	if(message!="")message="," +message;message=" Address"+ message;
				document.myform.address.focus();
			 }
				
			if(formcheck1=="")
			 {
			 	if(message!="")message="," +message;message=" Email"+ message;
			document.myform.email.focus();
			}
			
			if(formcheck=="")
			 {
			 	if(message!="")message="," +message;message=" Name"+ message;
				document.myform.name.focus();
			 }
			
	
			
			
		alert('Please fill up your ' +message + ".");
		return (false);
	}
	
if(flag==0)
{
	if(formcheck1.indexOf(" ") >= 0 )
		{
			alert("Please enter the E-Mail address without any white space character.");
			document.myform.email.focus();
			return (false);
		}

		
		AtRateCheckfrom = formcheck1.indexOf("@");
		AtDotCheckfrom  = formcheck1.indexOf(".");

		
		AtRateCheckLastfrom = formcheck1.lastIndexOf("@");
		AtDotCheckLastfrom = formcheck1.lastIndexOf(".");
 

		
		if ( (AtRateCheckfrom == -1) || (AtDotCheckfrom == -1) && flag==0)
		{
			alert("Please enter your valid email-id"); 
			document.myform.email.focus();
			
			
			return (false);
		}
		
			
		if( (AtRateCheckLastfrom != AtRateCheckfrom)  && flag==0)
		{
			alert("Please enter your valid email-id"); 
			document.myform.email.focus();
			return (false);
		}

		BeforeAtRatefrom = formcheck1.substring(0,formcheck1.indexOf("@"));
		AfterAtRatefrom = formcheck1.substring(formcheck1.indexOf("@")+1,formcheck1.length);

				
		if (AfterAtRatefrom.indexOf(".") == -1 && flag==0)
		{
			alert("Please enter your valid email-id"); 
			document.myform.email.focus();
			return (false);
		}

		
		middlefrom = AfterAtRatefrom.substring(0, AfterAtRatefrom.indexOf("."))
		lastfrom = AfterAtRatefrom.substring(AfterAtRatefrom.indexOf(".") + 1,AfterAtRatefrom.length)

		
		if (BeforeAtRatefrom.length == 0 || middlefrom.length == 0 || lastfrom.length == 0 && flag==0)
		{
			alert("Please enter your valid E-Mail"); 
			document.myform.email.focus();
			return (false);
		}

	else
		{
		if(yearcheck > year)
			{
				document.myform.submit();
				return (true);
			}
		else
		
		if(yearcheck == year && monthcheck > today_month+1)
		{
		 	document.myform.submit();
			return (true);
		}
		else
		
		if(yearcheck == year && monthcheck == today_month+1 && datecheck > day)
		{
		 	document.myform.submit();
			return (true);
			
		}
		else
		{
			alert("The Check-In date you have entered is not valid. Please enter a date in the near future!!");
			return (false);
			document.myform.checkin_m.value.focus();
		
		}
		
				}}	
	
		

}
