function Validator(lang)
{
f= document.all;
fa = document.form;
if(!check_email(f.Email.value))
{
if (lang=='EN')
{alert("Please Check Email again !!!");}
else
{alert("กรุณาตรวจสอบ อีเมล อีกครั้ง !!!");}
f.Email.focus();
}
else if (Trim(f.Guestname.value))
{
if (lang=='EN')
{alert("Please input Guestname.");}
else
{alert("กรุณากรอก ชื่อ ");}
f.Guestname.focus();
}

		else if(Trim(f.BirthDay.value))
					{
						if (lang=='EN')
									{alert("Please Select Date Birth !!!");}
						else
									{alert("กรุณาเลือก วันที่เกิด  !!!");}
						f.BirthDay.focus();
					}
					
		else if(Trim(f.BirthMonth.value))
					{
						if (lang=='EN')
									{alert("Please Select Month Birth !!!");}
						else
									{alert("กรุณาเลือก เดือนที่เกิด  !!!");}
						f.BirthMonth.focus();
					}
					
			else if(Trim(f.BirthYear.value))
					{
						if (lang=='EN')
									{alert("Please Select Year Birth !!!");}
						else
									{alert("กรุณาเลือก ปีที่เกิด  !!!");}
						f.BirthYear.focus();
					}
/*else if(Trim(f.Surname.value))
{
if (lang=='EN')
{alert("Please input Surname.");}
else
{alert("กรุณากรอก นามสกุล ");}
f.Surname.focus();
}
else if(Trim(f.Age.value))
{
if (lang=='EN')
{alert("Please select Age.");}
else
{alert("กรุณาเลือก อายุ ");}
f.Age.focus();
}*/
else if(Trim(f.Tel.value))
{
if (lang=='EN')
{alert("Please Insert Tel again !!!");}
else
{alert("กรุณากรอก เบอร์โทรศัพท์ ");}
f.Tel.focus();
}
/*	else if(Trim(f.fax.value))
{
if (lang=='EN')
{alert("Please Insert fax  !!!");}
else
{alert("กรุณากรอก เบอร์โทรสาร");}
f.fax.focus();
}*/
else if(Trim(f.Address.value))
{
if (lang=='EN')
{alert("Please Insert  address  !!!");}
else
{alert("กรุณากรอก  ที่อยู่");}
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))
{
if (lang=='EN')
{alert("Please Select Start Date !!!");}
else
{alert("กรุณาเลือก วันที่เริ่ม");}
f.Checkin_Date.focus();
}
else if(Trim(f.Checkin_Month.value))
{
if (lang=='EN')
{alert("Please Select Start Month !!!");}
else
{alert("กรุณาเลือก เดือนที่เริ่ม");}
f.Checkin_Month.focus();
}
else if(Trim(f.Checkin_Year.value))
{
if (lang=='EN')
{alert("Please Select Start Year !!!");}
else
{alert("กรุณาเลือก ปีที่เริ่ม");}
f.Checkin_Year.focus();
}
else if(Trim(f.Checkout_Date.value))
{
	if (lang=='EN')
	{alert("Please Select Finish Date !!!");}
	else
	{alert("กรุณาเลือก วันที่สิ้นสุด");}
	f.Checkout_Date.focus();
}
else if(Trim(f.Checkout_Month.value))
{
if (lang=='EN')
{alert("Please Select Finish Month !!!");}
else
{alert("กรุณาเลือก เดือนที่สิ้นสุด");}
f.Checkout_Month.focus();
}
else if(Trim(f.Checkout_Year.value))
{
if (lang=='EN')
{alert("Please Select Finish Year !!!");}
else
{alert("กรุณาเลือก ปีที่สิ้นสุด");}
f.Checkout_Year.focus();
}
else if(f.numberseat.value == 0)
{
			if (lang=='EN')
			{alert("Please Select Pax Quantity  !!!");}
			else
			{alert("กรุณาเลือก จำนวนที่นั่ง");}
f.Adult.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") == "")
																																										{
																																														if (lang=='EN')
																																														{alert("Please Insert Name  No. "+k+"")}
																																														else
																																														{alert("กรุณากรอก ชื่อที่ "+k+"");}
																																										eval("f.res_name"+k+".focus()")
																																										submit = true
																																										}
																																				}
																																				else
																																				{
																																				submit=false
																																				}
																																				if (submit == false)
																																				{
																																				count = (eval(count)+1)
																																								if (eval(count) == eval(numtotal))
																																								{
																																												if (!Trim(f.Checkin_Date.value))
																																												{
																																																				if (lang=="EN")
																																																				{con = confirm(" Thank you Very much for your Reservation  We will contact you shortly.")}
																																																				else
																																																				{con = confirm(" ขอบคุณสำหรับการจอง เราจะติดต่อไปอีกครั้ง.")}
																																												

																																													if(con)
																																													{
																																													document.form.submit()
																																													}
																																												}
																																								} 
																																				}
																													}
																		}
										}

}
}





//Check Education-----------Start---------------
function CheckEducation1(lang)
	{
						f= document.form;
						fa = document.all;

		if(Trim(f.NameP.value))
				{
						if (lang=='EN')
									{alert("Please Insert Name !!!");}
						else
									{alert("กรุณากรอกชื่อ !!!");}
						f.NameP.focus();
				}
				/*
				else if(Trim(f.SurNameP.value))
					{
						if (lang=='EN')
									{alert("Please Insert  SurName !!!");}
						else
									{alert("กรุณากรอกนามสกุล !!!");}
						f.SurNameP.focus();
					}
					*/
			else if(Trim(f.NickName.value))
					{
						if (lang=='EN')
									{alert("Please Insert  NickName !!!");}
						else
									{alert("กรุณากรอก ชื่อเล่น !!!");}
						f.NickName.focus();
					}
					
		else if(Trim(f.DateBirth.value))
					{
						if (lang=='EN')
									{alert("Please Select Date Birth !!!");}
						else
									{alert("กรุณาเลือก วันที่เกิด  !!!");}
						f.DateBirth.focus();
					}
					
		else if(Trim(f.MonthBirth.value))
					{
						if (lang=='EN')
									{alert("Please Select Month Birth !!!");}
						else
									{alert("กรุณาเลือก เดือนที่เกิด  !!!");}
						f.MonthBirth.focus();
					}
					
			else if(Trim(f.YearBirth.value))
					{
						if (lang=='EN')
									{alert("Please Select Year Birth !!!");}
						else
									{alert("กรุณาเลือก ปีที่เกิด  !!!");}
						f.YearBirth.focus();
					}


			else if(Trim(f.NumberBook.value))
					{
						if (lang=='EN')
									{alert("Please Insert  Passport No !!!");}
						else
									{alert("กรุณากรอก เลขที่หนังสือเดินทาง !!!");}
						f.NumberBook.focus();
					}
					
					else if(Trim(f.Check_Date1.value))
					{
						if (lang=='EN')
									{alert("Please Select Date End !!!");}
						else
									{alert("กรุณาเลือก  วันที่หมดอายุ !!!");}
						f.Check_Date1.focus();
					}
					
					else if(Trim(f.Check_Month1.value))
					{
						if (lang=='EN')
									{alert("Please Select Month End !!!");}
						else
									{alert("กรุณาเลือก  เดือนที่หมดอายุ !!!");}
						f.Check_Month1.focus();
					}
					
					else if(Trim(f.Check_Year1.value))
					{
						if (lang=='EN')
									{alert("Please Select Year End !!!");}
						else
									{alert("กรุณาเลือก  ปีที่หมดอายุ !!!");}
						f.Check_Year1.focus();
					}
					else if(Trim(f.SchoolP.value))
					{
						if (lang=='EN')
									{alert("Please Input  Student's Contact Address !!!");}
						else
									{alert("กรุณากรอกข้อมูล ที่อยู่ !!!");}
						f.SchoolP.focus();
					}
					
					else if(Trim(f.ClassP1.value))
					{
						if (lang=='EN')
									{alert("Please Input  Tel No.. !!!");}
						else
									{alert("กรุณากรอกข้อมูล เบอร์โทร!!!");}
						f.ClassP1.focus();
					}
					/*
					else if(Trim(f.SchoolP.value))
					{
						if (lang=='EN')
									{alert("Please Insert  !!!");}
						else
									{alert("กรุณาเลือก  ปีที่หมดอายุ !!!");}
						f.SchoolP.focus();
					}
					
					else if(Trim(f.ClassP.value))
					{
						if (lang=='EN')
									{alert("Please Insert Class  !!!");}
						else
									{alert("กรุณากรอก  ชั้น !!!");}
						f.ClassP.focus();
					}
					*/
					else if(Trim(f.HomeP.value))
					{
						if (lang=='EN')
									{alert("Please Select  Do You like pets?  !!!");}
						else
									{alert("กรุณาเลือก  ใช่หรือไม่ใช่ !!!");}
						f.HomeP.focus();
					}
					
					else if(Trim(f.CigarP.value))
					{
						if (lang=='EN')
									{alert("Please Select  Any food you cannot eat ? !!!");}
						else
									{alert("กรุณาเลือก  ใช่หรือไม่ใช่ !!!");}
						f.CigarP.focus();
					}
					
					else if(Trim(f.Home_SunP.value))
						{
							if (lang=='EN')
										{alert("Please Select Any Personal illness ? !!!");}
							else
										{alert("กรุณาเลือก  ใช่หรือไม่ใช่ !!!");}
							f.Home_SunP.focus();
						}
						
							else if(Trim(f.AnimalP.value))
						{
							if (lang=='EN')
										{alert("Please Select  Any allergy? !!!");}
							else
											{alert("กรุณาเลือก  ใช่หรือไม่ใช่ !!!");}
							f.AnimalP.focus();
						}
						/*
						else if(Trim(f.FoodP.value))
						{
							if (lang=='EN')
										{alert("Please Select  Food  !!!");}
							else
										{alert("กรุณาเลือก อาหาร !!!");}
							f.FoodP.focus();
						}
						
							else if(Trim(f.Personal_sickness.value))
						{
							if (lang=='EN')
										{alert("Please Select  Personal sickness  !!!");}
							else
										{alert("กรุณาเลือก โรคประจำตัว !!!");}
							f.Personal_sickness.focus();
						}
						
						else if(Trim(f.Allergic_medicine.value))
							{
						if (lang=='EN')
										{alert("Please Select  Allergic medicine !!!");}
						else
										{alert("กรุณาเลือก ยาที่แพ้ !!!");}
							f.Allergic_medicine.focus();
							}
							*/
							else if(Trim(f.Name_Father.value))
							{
									if (lang=='EN')
										{alert("Please Insert  Father Name !!!");}
									else
										{alert("กรุณากรอก  ชื่อบิดา!!!");}
									f.Name_Father.focus();
							}
							//-----
								else if(Trim(f.TelFather.value))
							{
										if (lang=='EN')
										{alert("Please Insert  Contact  Member !!!");}
										else
										{alert("กรุณากรอก  ชื่อบิดา!!!");}
										f.TelFather.focus();
							}
							
						//	---
							else if(Trim(f.Name_Mother.value))
										{
										if (lang=='EN')
												{alert("Please Insert Mother Name !!!");}
										else
												{alert("กรุณากรอกชื่อมารดา !!!");}
												f.Name_Mother.focus();
										}
								//-----
								else if(Trim(f.TelMother.value))
							{
										if (lang=='EN')
										{alert("Please Insert  Contact  Member !!!");}
										else
										{alert("กรุณากรอก  ชื่อบิดา!!!");}
										f.TelMother.focus();
							}
							
						//	---
							/*
							else if(Trim(f.Name_Controller.value))
							{
							if (lang=='EN')
										{alert("Please Insert  Controller  Name  !!!");}
							else
										{alert("กรุณากรอก  ชื่อผู้ปกครอง!!!");}
							f.Name_Controller.focus();
							}
							
							else if(Trim(f.Add_Controller.value))
							{
							if (lang=='EN')
										{alert("Please Insert  Controller  Address  !!!");}
							else
										{alert("กรุณากรอก  ที่อยู่ปกครอง   !!!");}
							f.Add_Controller.focus();
							}
							
							else if(Trim(f.Collage_P.value))
							{
							if (lang=='EN')
										{alert("Please Insert   institute  !!!");}
							else
										{alert("กรุณากรอก  สถาบันที่ลงทะเบียน   !!!");}
							f.Collage_P.focus();
							}
							
								else if(Trim(f.StageP.value))
							{
							if (lang=='EN')
										{alert("Please Insert   Stage !!!");}
							else
										{alert("กรุณากรอก  ประเทศ   !!!");}
							f.StageP.focus();
							}
							
							else if(Trim(f.CityP.value))
							{
							if (lang=='EN')
										{alert("Please Insert   City !!!");}
							else
										{alert("กรุณากรอก  เมือง/อำเภอ   !!!");}
							f.CityP.focus();
							}
							*/
				//------------------------
		/*		
		else if(Trim(f.Checkin_Date.value)){
			if (lang=='EN'){
			alert("Please Select Start Date !!!");}
			else{
			alert("กรุณาเลือก วันที่เริ่ม");}
			f.Checkin_Date.focus();
		}else if(Trim(f.Checkin_Month.value)){
			if (lang=='EN'){
			alert("Please Select Start Month !!!");}
			else{
			alert("กรุณาเลือก เดือนที่เริ่ม");}
			f.Checkin_Month.focus();
		}else if(Trim(f.Checkin_Year.value)){
			if (lang=='EN')
			{alert("Please Select Start Year !!!");}
			else
			{alert("กรุณาเลือก ปีที่เริ่ม");}
			f.Checkin_Year.focus();
		}
		else if(Trim(f.Checkout_Date.value))
		{
			if (lang=='EN')
			{alert("Please Select Finish Date !!!");}
			else
			{alert("กรุณาเลือก วันที่สิ้นสุด");}
			f.Checkout_Date.focus();
		}
		else if(Trim(f.Checkout_Month.value))
		{
			if (lang=='EN')
			{alert("Please Select Finish Month !!!");}
			else
			{alert("กรุณาเลือก เดือนที่สิ้นสุด");}
			f.Checkout_Month.focus();
		}
		else if(Trim(f.Checkout_Year.value))
		{
			if (lang=='EN')
			{alert("Please Select Finish Year !!!");}
			else
			{alert("กรุณาเลือก ปีที่สิ้นสุด");}
			f.Checkout_Year.focus();
		}
		else if(f.numberseat.value == 0)
{
			if (lang=='EN')
					{alert("Please Select Pax Quantity  !!!");}
			else
					{alert("กรุณาเลือก จำนวนที่นั่ง");}
			f.Adult.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") == "")
																																										{
																																														if (lang=='EN')
																																														{alert("Please Insert Name  No. "+k+"")}
																																														else
																																														{alert("กรุณากรอก ชื่อที่  "+k+"");}
																																										eval("f.res_name"+k+".focus()")
																																										submit = true
																																										}
																																				}
																																				else
																																				{
																																				submit=false
																																				}
																																				if (submit == false)
																																				{
																																				count = (eval(count)+1)
																																								if (eval(count) == eval(numtotal))
																																								{
																																												if (!Trim(f.Checkin_Date.value))
																																												{
																																																				if (lang=="EN")
																																																				{con = confirm(" Confirm Booking")}
																																																				else
																																																				{con = confirm(" ยืนยันการจอง ")}
																																												
																																													if(con)
																																													{
																																												document.form.submit()
																																											
																																													}
																																												}
																																								} 
																																				}
																													}
																													
																		}
										}
										*/
					else
						{
								if (lang=="EN")
										{con = confirm(" Confirm Booking")}
									else
									{con = confirm(" ยืนยันการจอง ")}
									
									if(con){								
									document.form.submit()}											
									
						}
}



//EndEducation-------------------End----------

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 &&  parseInt(str_dlast) < parseInt(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 == '4') || (str_month == '04')|| (str_month == '6')||(str_month == '06')||(str_month == '9')||(str_month == '09')||(str_month == '11'))
			{
				if(str_day > 30)
				{
				alert ('กรุณาตรวจสอบวันอีกครั้ง เพราะเดือนนี้มี 30 วัน');
				eval("f."+d+".focus()");
				return false;
				}
				else
				{
				return true;
				}
			}
	else if((str_month =='2') || (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 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 ='' ") 
					 }
	}
