var roomobj=[];
function starBg(str,class1,class2) {
	var obj=document.getElementById(str).getElementsByTagName("tr");
    for (i=0;i<obj.length;i++) { 
    obj[i].className = (i%2>0)?class1:class2; 
    }
}


function check_date(checkin, checkout, roomtype,period,ForeCastCount){
var i, err_msg, date_checkout,date_checkout,start, date_start, end, date_end, inner_str, year_start, year_end, alert_str,netdays
var month = new Array(12)
month[0] = "Jan"
month[1] = "Feb"
month[2] = "Mar"
month[3] = "Apr"
month[4] = "May"
month[5] = "Jun"
month[6] = "Jul"
month[7] = "Aug"
month[8] = "Sep"
month[9] = "Oct"
month[10] = "Nov"
month[11] = "Dec"
if(checkin==""||checkout=="")
{
inner_str = "Sorry, your Check-in Date or Check-out Date is invalid.";
document.getElementById("error").className = "errorcss";
document.getElementById("error").innerHTML = inner_str;
return false;
}
checkin = checkin.split("-");
date_checkin = new Date(checkin[0],parseInt(checkin[1])-1,checkin[2]);
checkout = checkout.split("-");
date_checkout = new Date(checkout[0],parseInt(checkout[1])-1,checkout[2])
netdays=parseInt(Math.abs(date_checkout - date_checkin) / 1000 / 60 / 60 /24)
for(var n=0;n<roomobj.length;n++)
{
	if(roomtype==roomobj[n].roomtype)
	{
		inner_str = "<input type='hidden' name='postto' value='package'><input type='hidden' name='netdays' value='"+netdays+"'><input type='hidden' name='requestdays' value='"+roomobj[n].roomnum+"'>";
			document.getElementById("error").className = "";
			document.getElementById("error").innerHTML = inner_str;
		if(netdays<parseInt(roomobj[n].roomnum))
		{
			inner_str = "Sorry, the package is applied for the booking no less than "+roomobj[n].roomnum+" nights.  ";
			document.getElementById("error").className = "errorcss";
			document.getElementById("error").innerHTML = inner_str;
			return false;
		}
		break;
	}
}

var nowdate=new Date();
nowdate=new Date(nowdate.getYear(),nowdate.getMonth(),nowdate.getDate());
if(date_checkout<=nowdate||date_checkin<nowdate)
{
inner_str = "Sorry, your Check-in Date or Check-out Date can not be earlier than today.";
document.getElementById("error").className = "errorcss";
document.getElementById("error").innerHTML = inner_str;
return false;
}
if(date_checkout<=date_checkin)
{
inner_str = "Sorry, your Check-out Date should be later than Check-in Date.";
document.getElementById("error").className = "errorcss";
document.getElementById("error").innerHTML = inner_str;
return false;
}
for(i=0;i<ForeCastCount;i++){
	start = period[i][0].split("-");
	date_start = new Date(start[0],start[1]-1,start[2]);
	end = period[i][1].split("-");
	date_end = new Date(end[0],end[1]-1,end[2]);	
	if(roomtype==period[i][2]&&((date_start<=date_checkin&&date_checkin<=date_end)||(date_checkin<=date_start&&date_checkout>date_start)) ){
		alert_str = month[parseInt(date_start.getMonth())]+" "+date_start.getDate() +", " + date_start.getFullYear()+ " to " + month[parseInt(date_end.getMonth())]+" "+date_end.getDate() +", " + date_end.getFullYear();
		switch(period[i][3]){
			case "Fully booked":
				inner_str = "Sorry, this hotel's "+roomtype.toLowerCase()+"s are unavailable from " + alert_str;
				break;
			case "Under decoration":
				inner_str = "Sorry, this hotel's "+roomtype.toLowerCase()+"s are under decoration from "+ alert_str;
				break;
			case "Price unknow":
				inner_str = "The hotel has not published "+roomtype.toLowerCase()+" rate yet since "+ alert_str;
				break;
			default:
				inner_str = "";
				break;
		}
		document.getElementById("error").className = "errorcss";
		document.getElementById("error").innerHTML = inner_str;
		return false;
	}
}
return true;
}


 function Eb(f){
   rVN = f.value;
  document.getElementById("select19").innerHTML = "";
  if (rVN>0){
  for (var i =0;i<=rVN;i++){
    option = document.createElement("option");
	option.value = i;
	option.innerHTML = i;
	document.getElementById("select19").appendChild(option);
  }
  }else{
      option = document.createElement("option");
		option.value = 0;
		option.innerHTML = 0;
	document.getElementById("select19").appendChild(option);
  }
 }



