var now = new Date();
		var today = new Date();
		now = new Date (now.getFullYear(),now.getMonth(),now.getDate()+1,0,0,0);
		var now_year = now.getFullYear();
		var now_month = now.getMonth();
		var now_date = now.getDate();
		var tommorrow = new Date (now_year,now_month,now_date+1,0,0,0);
		var tommorrow_year = tommorrow.getFullYear();
		var tommorrow_month = tommorrow.getMonth();
		var tommorrow_date = tommorrow.getDate();
		
			tommorrow_month += 1;
			now_month +=1;
			 
		var next_year=now_year+1;
		
	
	function checkform()
	{
		var theform=document.selform;
		var inputday;
		var inputday2;
		
		inputday= new Date(theform.year.value,theform.mon.value - 1,theform.day.value);
		inputday2= new Date(theform.year2.value,theform.mon2.value - 1,theform.day2.value);
		
		
		if(inputday.getTime() >= inputday2.getTime()) 
		{
			alert("退房日期 <= 入住日期");
			return false;
		}
		if(inputday.getTime() < now.getTime()) 
		{
			alert("入住日期 <= 今天");
			return false;
		}
		if((theform.hotel_id.value=="")|| (theform.hotel_id.value==0))
		{
			alert("请选择饭店");
			return false;
		}
		
		theform.inputday.value=theform.year.value+"/"+theform.mon.value+"/"+theform.day.value;
		theform.inputday2.value=theform.year2.value+"/"+theform.mon2.value+"/"+theform.day2.value;
		return true;
	}
		function SetToday()
	{
		 	var theform=document.selform;
		 	
			theform.year.length=2;
			theform.year2.length=2;
			theform.year.options[0].text = now_year;
			theform.year.options[0].value = now_year;
			theform.year.options[1].text = next_year;
			theform.year.options[1].value = next_year;
			theform.year2.options[0].text = now_year;
			theform.year2.options[0].value = now_year;
			theform.year2.options[1].text = next_year;
			theform.year2.options[1].value = next_year;
			
			theform.mon.length=12;
			theform.mon2.length=12;
			
			for(i=0;i<12;i++)
			{
				theform.mon.options[i].text = i+1;
				theform.mon.options[i].value = i+1;
				theform.mon2.options[i].text = i+1;
				theform.mon2.options[i].value = i+1;
			}
			
			theform.day.length=31;
			theform.day2.length=31;
			
			for(i=0;i<31;i++)
			{
				theform.day.options[i].text = i+1;
				theform.day.options[i].value = i+1;
				theform.day2.options[i].text = i+1;
				theform.day2.options[i].value = i+1;
			}
			
			theform.roomcount.length=10;
			
			for(i=0;i<theform.roomcount.length;i++)
			{
				theform.roomcount.options[i].text = i+1;
				theform.roomcount.options[i].value = i+1;
			}
			
			theform.year.value=now_year;
			theform.mon.value=now_month;
			theform.day.value=now_date;
			theform.year2.value=tommorrow_year;
			theform.mon2.value=tommorrow_month;
			theform.day2.value=tommorrow_date;
	}
			function showcalendar(type,year,month)
	{
		if(year==0)
		{ 
			year=now_year;
			month=now_month;
		}	
		var monstartday = new Date(year,month-1,1);
		var monendday = new Date(year,month,0);
		var thisid,monthstr,datetypestr,startday;
		
		if(type==1) 
		{
			thisid="c1";
			datetypestr="入住日期";
		}	
		else 
		{
			thisid="c2";
			datetypestr="退房日期";
		}
		year=monstartday.getFullYear();
		month=monstartday.getMonth()+1;
		startday=monstartday.getDay();
		monthstr="<table class=table1 width=212 bgcolor=ffffff border=1 style='border-collapse:collapse'  bordercolor='#7599D0' cellspacing=0 cellpadding=0 style='font-size:9pt;font-family:'arial'>";
		monthstr+="<tr><td align=center  valign=middle width=196 colspan=2 style='padding-left:16px'>";
		monthstr+= ""+datetypestr+"</td>";
		monthstr+="<td width =16 ><div class=calendarspan3><img src='http://www.ezhotel.com.tw/images/month_close.gif' style='cursor:hand' width=16 height=16 align=absmiddle onclick='closcalendar("+type+")' alt=' 关 闭 '></div></td></tr>";
		monthstr+="<tr><td align=center valign=middle  width =16><div class=calendarspan3><img src='http://www.ezhotel.com.tw/images/month_back.gif'  align=absmiddle style='cursor:hand' onclick='javascript:showcalendar("+type+","+year+","+(month-1)+");' alt='上个月'></div></td>";
		monthstr+="<td width =170 align=center>"+year+" / "+(month)+"</td>";
		monthstr+="<td align=center valign=middle  width =16 ><div class=calendarspan3><img src='http://www.ezhotel.com.tw/images/month_to.gif' style='cursor:hand'  align=absmiddle onclick='javascript:showcalendar("+type+","+year+","+(month+1)+");' alt='下个月'></div></td></tr>";
		monthstr+="<tr><td width=100% align=left colspan=3>";
					monthstr+="<div class=calendarspan2><font color=#777777>日</font></div>";
						monthstr+="<div class=calendarspan1><font color=#777777>一</font></div>";
						monthstr+="<div class=calendarspan1><font color=#777777>二</font></div>";
						monthstr+="<div class=calendarspan1><font color=#777777>三</font></div>";
						monthstr+="<div class=calendarspan1><font color=#777777>四</font></div>";
						monthstr+="<div class=calendarspan1><font color=#777777>五</font></div>";
						monthstr+="<div class=calendarspan2><font color=#777777>六</font></div>";
					for(i=0;i<monstartday.getDay();i++)
		{
			monthstr+="<div class=calendarspan1> </div>";
		}
		for(i=0;i<monendday.getDate();i++)
		{
			if((year==today.getFullYear())&&(month==today.getMonth()+1)&&((i+1)==today.getDate())) monthstr+="<div class=calendarspan4 ><b>"+(i+1)+"</b></div>";
			else if((year>today.getFullYear())||(year==today.getFullYear() && month>today.getMonth()+1)||(year==today.getFullYear() && month==today.getMonth()+1 && (i+1) > today.getDate()))
			{
				monthstr+="<div class=calendarspan1><a href='javascript:setorderdate("+type+","+year+","+month+","+(i+1)+");' class='datemenu'>"+(i+1)+"</a></div>";	
			}
			else
			{
				monthstr+="<div class=calendarspan1><font color=bbbbbb>"+(i+1)+"</font></div>";
			}
			if((startday+1)%7==0) monthstr+="<br>";
			startday++;
		}
		monthstr+="</td></tr></table>";
		
		c1.style.display='none';
		c2.style.display='none';
		document.getElementById("d1").style.display='none';
		document.getElementById("d2").style.display='none';
		eval("document.getElementById('d"+type+"').style.display=''");
		eval(thisid+".style.display=''");
		eval(thisid+".innerHTML=''");
		eval(thisid+".innerHTML=\""+monthstr+"\"");
	}
	function setorderdate(type,year,month,date)
	{
		var theform=document.selform;
		if(type==1)
		{
			theform.year.value=year;
			theform.mon.value=month;
			theform.day.value=date;
			showcalendar(2,year,month);
		}
		else
		{
			theform.year2.value=year;
			theform.mon2.value=month;
			theform.day2.value=date;
			c2.style.display='none';
			document.getElementById("d2").style.display='none';
		}
	}
	function closcalendar(type)
	{
		if(type==1) thisid="c1";
		else  thisid="c2";
		eval(thisid+".style.display='none'");
		eval("document.getElementById('d"+type+"').style.display='none'");
	}
