var sNow = new Date();				//get now date
var syear = sNow.getYear();			//get now year
var snyear = syear+1;				//get next year
var smonth = sNow.getMonth()+1;		//get now month

var sday = sNow.getDate();			//get now day
function ShowYear()
{
if(smonth<=8)
	{document.write("<option selected value="+syear+">"+syear+"</option>");}
else
	{
	document.write("<option selected value="+syear+">"+syear+"</option>");
	document.write("<option value="+snyear+">"+snyear+"</option>");
	}
}
function ShowMonth()
{
pomonth = new Array(13);
pomonth[1]="Jan.";
pomonth[2]="Feb.";
pomonth[3]="Mar.";
pomonth[4]="Apr.";
pomonth[5]="May.";
pomonth[6]="Jun.";
pomonth[7]="Jul.";
pomonth[8]="Aug.";
pomonth[9]="Sep.";
pomonth[10]="Oct.";
pomonth[11]="Nov.";
pomonth[12]="Dec.";

for(i=1;i<=12;i++)
{
	if(i<10)
	{document.write("<option value=0"+i+">"+pomonth[i]+"</option>");}
	else
	{
	
	document.write("<option value="+i+">"+pomonth[i]+"</option>");
	}
	}
}


function ShowDate()
{
	for(j=1;j<=31;j++)
	{
		if(j<10)
		{document.write("<option value=0"+j+">0"+j+"</option>");}
		else 
		{
			document.write("<option value="+j+">"+j+"</option>");
		}
			
	}

}

function Check()
{	
//+----------------------Begin read personal information----------------------+
	fname = document.res.fname.value;
	lname = document.res.lname.value;
	nation = document.res.nation.value;
	sex = document.res.sex.value;
	birthyear = document.res.birthyear.value;
	birthmonth = document.res.birthmonth.value;
	birthday = document.res.birthday.value;
	passport = document.res.passport.value;
	tel = document.res.tel.value;
	fax= document.res.fax.value;
	email= document.res.email.value;
	addr= document.res.addr.value;
	zcode= document.res.zcode.value;
	arrmonth= document.res.arrmonth.value;
	arrday=document.res.arrday.value;
//+----------------------End read personal information----------------------+
//+----------------------Check the personal information----------------------+
if (fname==""||lname=="")
{
	alert ("Check your name,please!");
	document.res.fname.focus();
	return false;
}
if (nation=="")
{
	alert ("Check your Nationality, please!");
	document.res.nation.focus();
	return false;
}
if (sex=="")
{
	alert ("Check your Sex,please!");
	document.res.sex.focus();
	return false;
}
if (birthyear==""||birthmonth==""||birthday=="")
{
	alert ("Check your Birthday,please!");
	document.res.birthyear.focus();
	return false;
}
if (passport=="")
{
	alert ("Check your Passport number,please!");
	document.res.passport.focus();
	return false;
}
if (tel=="")
{
	alert ("Check your Telephone Number, please!");
	document.res.tel.focus();
	return false;
}
if (fax=="")
{
	alert ("Check your fax, please!");
	document.res.fax.focus();
	return false;
}
if (email == "" || email.indexOf('@', 0) == -1)
{
	alert ("Check your E-mail,please!");
	document.res.email.focus();
	return false;
}
if (arrmonth=="none")
{
	alert ("Please input Date of tour starts!");
	document.res.arrmonth.focus();
}
if(arrmonth<smonth)
{
	alert ("Please input Date of tour starts!");
	document.res.arrmonth.focus();
	return false;
}
if (arrday=="none")
{
	alert ("Please input Date of tour starts!");
	document.res.arrday.focus();
	return false;
}
//+----------------------Check the personal information----------------------+
//----------------------Begin read reservation information----------------------
		ayear = document.res.arryear.value;
		amonth = document.res.arrmonth.value;
		aday = document.res.arrday.value;
		dyear = document.res.depyear.value;
		dmonth = document.res.depmonth.value;
		dday = document.res.depday.value;

//----------------------End read reservation information----------------------
/*		var adate = new Date(amonth+"/"+aday+"/"+ayear);
		var a = adate.getTime();
		var ddate = new Date(dmonth+"/"+dday+"/"+dyear);
		var b = ddate.getTime();

		
		if(chkValid(amonth,aday,ayear,dmonth,dday,dyear)) return true;

		else return false;

		document.res.submit();
		
}
*/
function chkValid(mm,dd,yy,mmm,ddd,yyy)
{
	var date2 = new Date(mm+'/'+dd+'/'+yy);
	var dd2 = date2.getDate();
	var mm2 = date2.getMonth()+1;
	var yy2 = date2.getFullYear();

	if(dd==dd2 && mm==mm2 && yy==yy2)
	{
		var date3 = new Date(mmm+'/'+ddd+'/'+yyy);
		var dd3 = date3.getDate();
		var mm3 = date3.getMonth()+1;
		var yy3 = date3.getFullYear();	
		if(ddd==dd3 && mmm==mm3 && yyy==yy3)
			return true;	
		else
		{
		alert("Invalid Date !");
		document.res.depday.focus();
		return false;
		}		
	}	
	else
	{
		alert("Invalid Date !!");
		document.res.arrday.focus();
		return false;
	}			
}

