
function convertno(cmonth)
	{
	switch(cmonth)
	{
	case "Jan" : return(1); break;
	case "Feb" : return(2); break;
	case "Mar" : return(3); break;
	case "Apr" : return(4); break;
	case "May" : return(5); break;
	case "Jun" : return(6); break;
	case "Jul" : return(7); break;
	case "Aug" : return(8); break;
	case "Sep" : return(9); break;
	case "Oct" : return(10); break;
	case "Nov" : return(11); break;
	case "Dec" : return(12); break;
	}
  }

function validate()
{
		if(document.frm.customer_no.value=="")
		{
			alert("Please Enter customer number");
			document.frm.customer_no.focus();
			return false;
		}
		
		if(document.frm.customer_name.value=="")
		{
			alert("Please Enter customer name");
			document.frm.customer_name.focus();
			return false;
		}
		
		if(document.frm.email.value=="")
		{
			alert("Please enter your eMail");
			document.frm.email.focus();
			return false;
			
		}

			val_flag="no";
			if(document.frm.email.value!="")
			{
				valu="no";
				val=document.frm.email.value;
				for(s=0;s<val.length;s++)
				{
					if(val.charAt(s)=='@')
					{
						valu="yes";
					}
				}
				if(valu=="yes")
				{
					valu="no";
					for(s=0;s<val.length;s++)			
					{
						if(val.charAt(s)=='.')
						{
							valu="yes";
						}
						if(valu=="yes")
						{
							valu="no";
							if(val.charAt(s+4)=='')
							{
								if(val.charAt(s+2)!='')
								{
									val_flag="yes";
								}
							}
						}
					} 
				}
				if(val_flag=="no")
				{
					alert("Please enter a valid eMail");
					document.frm.email.select();
					return false;
				}
			}
			
			
		
		
		if(document.frm.product.selectedIndex==0)
		{
			alert("Please select any Product");
			document.frm.product.focus();
			return false;
		}
		
		if(document.frm.resort.selectedIndex==0)
		{
			alert("Please select any Resort");
			document.frm.resort.focus();
			return false;			
		}
		
		var time=new Date();
		var cur_date=time.getDate();
		var cur_month=time.getMonth() + 1;
		var cur_year=time.getYear();
		//alert(cur_date+"/"+cur_month+"/"+cur_year);
		var arr_date = parseInt(document.frm.arr_date.value);
		var arr_month = convertno(document.frm.arr_month.value);
		var arr_year = parseInt(document.frm.arr_year.value);
		//alert(arr_date+"/"+arr_month+"/"+arr_year);

		var dep_date = parseInt(document.frm.dep_date.value);
		var dep_month = convertno(document.frm.dep_month.value);
		var dep_year = parseInt(document.frm.dep_year.value);


		var c11_date = parseInt(document.frm.c11_date.value);
		var c11_month = convertno(document.frm.c11_month.value);
		var c11_year = parseInt(document.frm.c11_year.value);
		var c12_date = parseInt(document.frm.c12_date.value);
		var c12_month = convertno(document.frm.c12_month.value);
		var c12_year = parseInt(document.frm.c12_year.value);
		
		var c21_date = parseInt(document.frm.c21_date.value);
		var c21_month = convertno(document.frm.c21_month.value);
		var c21_year = parseInt(document.frm.c21_year.value);
		var c22_date = parseInt(document.frm.c22_date.value);
		var c22_month = convertno(document.frm.c22_month.value);
		var c22_year = parseInt(document.frm.c22_year.value);
		
		var c31_date = parseInt(document.frm.c31_date.value);
		var c31_month = convertno(document.frm.c31_month.value);
		var c31_year = parseInt(document.frm.c31_year.value);
		var c32_date = parseInt(document.frm.c32_date.value);
		var c32_month = convertno(document.frm.c32_month.value);
		var c32_year = parseInt(document.frm.c32_year.value);


	//if (dep_year >= arr_year)
		if (arr_year >= cur_year)
		{
			if(arr_year == cur_year){
				if(arr_month >=cur_month){
					if(arr_month == cur_month){
						if(arr_date < cur_date){
							//alert(arr_date + "--" + cur_date);
							alert("From Date should be equal or greater than the current date");
							document.frm.arr_date.focus();
							return false;
						}
					}
				}else{
					alert("From Month should be equal or greater than the current month");
					document.frm.arr_month.focus();
					return false;
				}
			}
			
			
			
		}
		else
		{ 
			alert("Year should be equal or greater than the current Year");
			document.frm.arr_year.focus();
			return false;
		}
		
		if (dep_year >= arr_year)
		{
			if(dep_date >= arr_date && dep_month>=arr_month){ }
			else if(dep_month>arr_month || dep_year > arr_year){ }
			else
			{ 
				alert("To Date should be equal or greater than the From Date");
				document.frm.dep_date.focus();
				return false;
			}
		}
		else
		{
			alert("Year should be equal or greater than the current Year");
			document.frm.dep_year.focus();
			return false;
		}


		if(document.frm.resort1.selectedIndex==0)
		{
			alert("Please select any Choice of Resort");
			document.frm.resort1.focus();
			return false;
			
		}
		
		/*if ((c11_date >= cur_date && c11_month >= cur_month)  || c11_month > cur_month)
		{
			if(c12_date >= c11_date && c12_month>=c11_month){ }
			else if(c12_month>c11_month){ }
			else { 
			alert("To Date should be equal or greater than the From Date");
			document.frm.c12_month.focus();
			return false;
			}
		}
			else { 
			alert("From Date should be equal or greater than the current date");
			document.frm.c11_month.focus();
			return false;
		}
				
		if ((c21_date >= cur_date && c21_month >= cur_month)  || c21_month > cur_month)
		{
			if(c22_date >= c21_date && c22_month>=c21_month){ }
			else if(c22_month>c21_month){ }
			else { 
			alert("To Date should be equal or greater than the From Date");
			document.frm.c22_month.focus();
			return false;
			}
		}
			else { 
			alert("From Date should be equal or greater than the current date");
			document.frm.c21_month.focus();
			return false;
		}
		
		if ((c31_date >= cur_date && c31_month >= cur_month)  || c31_month > cur_month)
		{
			if(c32_date >= c31_date && c32_month>=c31_month){ }
			else if(c32_month>c31_month){ }
			else { 
			alert("To Date should be equal or greater than the From Date");
			document.frm.c32_month.focus();
			return false;
			}
		}
			else { 
			alert("From Date should be equal or greater than the current date");
			document.frm.c31_month.focus();
			return false;
		}*/
		
		if (c11_year >= cur_year)
		{
			if(c11_year == cur_year){
				if(c11_month >=cur_month){
					if(c11_month == cur_month){
						if(c11_date < cur_date){
							//alert(c11_date + "--" + cur_date);
							alert("From Date should be equal or greater than the current date");
							document.frm.c11_date.focus();
							return false;
						}
					}
				}else{
					alert("From Month should be equal or greater than the current month");
					document.frm.c11_month.focus();
					return false;
				}
			}
			
		}
		else
		{ 
			alert("Year should be equal or greater than the current Year");
			document.frm.c11_year.focus();
			return false;
		}
		
		if (c12_year >= c11_year)
		{
			if(c12_date >= c11_date && c12_month>=c11_month){ }
			else if(c12_month>c11_month || c12_year > c11_year){ }
			else
			{ 
				alert("To Date should be equal or greater than the From Date");
				document.frm.c12_date.focus();
				return false;
			}
		}
		else
		{
			alert("Year should be equal or greater than the current Year");
			document.frm.c12_year.focus();
			return false;
		}
		
		
		if (c21_year >= cur_year)
		{
			if(c21_year == cur_year){
				if(c21_month >=cur_month){
					if(c21_month == cur_month){
						if(c21_date < cur_date){
							//alert(c21_date + "--" + cur_date);
							alert("From Date should be equal or greater than the current date");
							document.frm.c21_date.focus();
							return false;
						}
					}
				}else{
					alert("From Month should be equal or greater than the current month");
					document.frm.c21_month.focus();
					return false;
				}
			}
			
		}
		else
		{ 
			alert("Year should be equal or greater than the current Year");
			document.frm.c21_year.focus();
			return false;
		}
		
		if (c22_year >= c21_year)
		{
			if(c22_date >= c21_date && c22_month>=c21_month){ }
			else if(c22_month>c21_month || c22_year > c21_year){ }
			else
			{ 
				alert("To Date should be equal or greater than the From Date");
				document.frm.c22_date.focus();
				return false;
			}
		}
		else
		{
			alert("Year should be equal or greater than the current Year");
			document.frm.c22_year.focus();
			return false;
		}
		
		
		if (c31_year >= cur_year)
		{
			if(c31_year == cur_year){
				if(c31_month >=cur_month){
					if(c31_month == cur_month){
						if(c31_date < cur_date){
							//alert(c31_date + "--" + cur_date);
							alert("From Date should be equal or greater than the current date");
							document.frm.c31_date.focus();
							return false;
						}
					}
				}else{
					alert("From Month should be equal or greater than the current month");
					document.frm.c31_month.focus();
					return false;
				}
			}
			
		}
		else
		{ 
			alert("Year should be equal or greater than the current Year");
			document.frm.c31_year.focus();
			return false;
		}
		
		if (c32_year >= c31_year)
		{
			if(c32_date >= c31_date && c32_month>=c31_month){ }
			else if(c32_month>c31_month || c32_year > c31_year){ }
			else
			{ 
				alert("To Date should be equal or greater than the From Date");
				document.frm.c32_date.focus();
				return false;
			}
		}
		else
		{
			alert("Year should be equal or greater than the current Year");
			document.frm.c32_year.focus();
			return false;
		}

		if(document.frm.no_apart.value=="")
		{
			alert("Please enter number of Apartments");
			document.frm.no_apart.focus();
			return false;
			
		}
		
		if(document.frm.adults.value=="")
		{
			alert("Please enter number of Adults");
			document.frm.adults.focus();
			return false;
			
		}


		if(document.frm.children.value=="")
		{
			alert("Please enter number of Children");
			document.frm.children.focus();
			return false;
	
		}

		
		if(document.frm.address.value=="")
		{
			alert("Please enter your address");
			document.frm.address.focus();
			return false;
	
		}

		if(document.frm.phone.value=="")
		{
			alert("Please enter your phone number");
			document.frm.phone.focus();
			return false;
	
		}
		
		
		if(document.getElementById("cvno").style.display=="inline" && document.frm.cv_no.value=="")
		{
			alert("Please enter confirmation number");
			document.frm.cv_no.focus();
			return false;
		}

}


function checkCancel(val)
{
	//alert (val);
	if(val=="Cancellation")
	{
		document.getElementById("cvno").style.display="inline";
		document.frm.cr_no.value="";
	}
	else
	{
		document.getElementById("cvno").style.display="none";
	}
}