function Validator(f)
{
		f= document.all;
		fa = document.form;
		if (Trim(f.Guestname.value))
		{
    		alert("Please input Guestname.");
			f.Guestname.focus();
		}
		else if(Trim(f.Surname.value))
		{
			alert("Please input Surname.");
			f.Surname.focus();
		}
		else if(Trim(f.Age.value))
		{
			alert("Please select Age.");
			f.Age.focus();
		}
		else if(!check_email(f.Email.value))
		{
    		alert("Please Check Email again !!!");
			f.Email.focus();
		}
		else if(Trim(f.Tel.value))
		{
    		alert("Please Insert Tel again !!!");
			f.Tel.focus();
		}
		else if(Trim(f.fax.value))
		{
    		alert("Please Insert fax  !!!");
			f.fax.focus();
		}
		else if(Trim(f.Address.value))
		{
    		alert("Please Insert address  !!!");
			f.Address.focus();
		}
		//else if(Trim(f.hotel.value))
	//	{
    //		alert("Please Insert hotel  !!!");
	//		f.hotel.focus();
	//	}
	//	else if(Trim(f.city.value))
	//	{
   // 		alert("Please Insert city  !!!");
	//		f.city.focus();
	//	}
		else if(Trim(f.Checkin_Date.value))
		{
    		alert("Please Select Start Date !!!");
			f.Checkin_Date.focus();
		}
		else if(Trim(f.Checkin_Month.value))
		{
    		alert("Please Select Start Month !!!");
			f.Checkin_Month.focus();
		}
		else if(Trim(f.Checkin_Year.value))
		{
    		alert("Please Select Start Year !!!");
			f.Checkin_Year.focus();
		}
		else if(Trim(f.Checkout_Date.value))
		{
    		alert("Please Select Finish Date !!!");
			f.Checkout_Date.focus();
		}
		else if(Trim(f.Checkout_Month.value))
		{
    		alert("Please Select Finish Month !!!");
			f.Checkout_Month.focus();
		}
		else if(Trim(f.Checkout_Year.value))
		{
    		alert("Please Select Finish Year !!!");
			f.Checkout_Year.focus();
		}
		else if(f.numberseat.value == 0)
		{
    		alert("Please Select num of attendance !!!");
			f.numberseat.focus();
		}
		else
		{
					if(chk_date("Checkin_Date","Day CheckIn","Checkin_Month","Month CheckIn","Checkin_Year","Year CheckIn") &&chk_date("Checkout_Date","Day Checkout","Checkout_Month","Month Checkout","Checkout_Year","Year Checkout") && chk_during("Checkin_Date","Checkin_Month","Checkin_Year","Checkout_Date","Checkout_Month","Checkout_Year"))
					{
					 if(f.numberseat.value != "")
		{
			var submit=false;
			count = 0
			var numtotal = eval(document.all.numberseat.value)
			for(k=1;k<=eval(document.all.numberseat.value);k++)
				{
					if  (eval("f.res_name"+k+".value")  ==  "")
					{
						if  (eval("f.res_name"+k+".value") == "")
						{
						alert("Please Insert Name  "+k+"")
						eval("f.res_name"+k+".focus()")
						submit = true
						return 0
						}
					}
					else
					{
					submit=false
					}
					if (submit == false)
					{
					count = (eval(count)+1)
						if (eval(count) == eval(numtotal))
						{
						if(Trim(f.flight_information.value))
						{
							alert("Please Insert Incoming & Outgoing Flight Information !!!");
							f.flight_information.focus();
						}
						else if (!Trim(f.Checkin_Date.value))
						{
								//con = confirm(" Confirm Reserving")
								//if(con)
								//{
								fa.submit()
								//}
						}

						} 
					}
				}
			}
			}

		}

	function chk_during(dbegin,mbegin,ybegin,dlast,mlast,ylast)
	{
			var f  = document.all;
			str_dbegin 	= eval("f."+dbegin+".value");
			str_mbegin	= eval("f."+mbegin+".value");
			str_ybegin	= eval("f."+ybegin+".value");
			str_dlast		= eval("f."+dlast+".value");
			str_mlast		= eval("f."+mlast+".value");
			str_ylast		= eval("f."+ylast+".value");
			if (str_ylast < str_ybegin)
			{
				alert(" Please Check During Time check- In and check -out again ")
				eval("f."+ylast+".focus()");
				return false;
			}
			else if(str_ylast <= str_ybegin && str_mlast < str_mbegin)
			{
				alert(" Please Check During Time check- In and check -out again ")
				eval("f."+mlast+".focus()");
				return false;
			}
			else if(str_ylast <= str_ybegin && str_mlast <= str_mbegin &&  str_dlast < str_dbegin )
			{
				alert(" Please Check During Time check- In and check -out again ")
				eval("f."+dlast+".focus()");
				return false;
			}
			else
			{
				return true;
			}
	}


	function chk_date(d,named,m,namem,y,namey)
	{
			var f  = document.all;
			var str_day		=	eval("f."+d+".value");
			var str_month	=	eval("f."+m+".value");
			var str_year		=	eval("f."+y+".value");
			if((str_month == '04')||(str_month == '06')||(str_month == '09')||(str_month == '11'))
			{
				if(str_day > 30)
				{
				alert ('Please Check Date again Because In  the Month have 30 days');
				eval("f."+d+".focus()");
				return false;
				}
				else
				{
				return true;
				}
			}
	else if(str_month =='02')
		{
		var nyear = eval((str_year - 543)%4);
		if( nyear > 0 && str_day > 28)
			{
				alert ('Please Check Date again Because In  the Month have 28 days');
				eval("f."+d+".focus()");
								return false;

			}
		else if( nyear == 0 && str_day > 29)
			{
				alert ('Please Check Date again Because In  the Month have 29 days');
				eval("f."+d+".focus()");
								return false;
			}
			else
			{
				return true;
			}
		}
		else
		{
			return true;
		}	
	}


function Tele(e) 
	{
			ok = "1234567890-,";
			found = 0;
			for(i=0; i < e.length ;i++){
					if(ok.indexOf(e.charAt(i)) > 0){ 
					found = eval("found") + 1;
					}	
			} 
			if (found == e.length){
					return true;
					}
			else{return false;}
	}
	
	function check_email(e) {
			ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
			for(i=0; i < e.length ;i++){
						if(ok.indexOf(e.charAt(i))<0){ 
						return (false);}	
			} 
			if (document.images) {
			re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
			re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
			if (!e.match(re) && e.match(re_two)) {
			return (-1);		} 
					}
			}

		function Trim(key)
		{
			sp =key.split(" ");
				ch = 0
			 	for (st = 0;st<sp.length;st++){
					if (sp[st] == ""){
						ch++;
					}
				}
				if (eval(sp.length) ==eval(ch)){
							return true;}
				else{
							return false;}
		}
  }
  
  function ShwRow()
  {
  		var f = document.forms(0);
		var numtotal = f.numtotal.value;
		var numroom = f.Room.value;
				for ( j=1;j<=eval(numtotal);j++)
					{
					eval("document.all.Row"+j+".style.display ='none' ") 
					 }
					for ( i=1;i<=eval(numroom);i++)
					{
					eval("document.all.Row"+i+".style.display ='' ") 
					 }
	}
