var nav					= navigator.appName;
var indate 	= new Date();
var indd				= indate.getDate();
var inmm				= indate.getMonth();
var inyy				= (nav=="Netscape")? indate.getYear()+1900:indate.getYear();

var indd			=indd+3;
if (indd > maxdate1(inmm,inyy)){
indd=indd-maxdate1(inmm,inyy);
inmm = inmm+1;
if (inmm>11){
inyy=inyy+1;
inmm=0;
}
}

function maxdate1(mm,yy){
if (mm==1){
	if(yy%4==0){
	return 29;
	}else{
	return 28;
	}
}else if (mm==0 || mm==2 || mm==4 || mm==6 || mm==7 || mm==9 || mm==11){
return 31;
}else{
return 30;
}
}
var outdd			=indd+1;
var outmm			=inmm;			
var outyy			=inyy;
if (outdd > maxdate1(inmm,inyy)){
outdd=outdd-maxdate1(inmm,inyy);
outmm = inmm+1;
if (outmm>11){
outyy=outyy+1;
outmm=0;
}
}
function get_date(){
with(document.frm1){
cmbCheckInMonth.selectedIndex = inmm;
cmbCheckInDate.selectedIndex = indd-1;
cmbCheckInYear.selectedIndex = inyy-2003;
cmbCheckOutMonth.selectedIndex = outmm;
cmbCheckOutDate.selectedIndex = outdd-1;
cmbCheckOutYear.selectedIndex = outyy-2003;
}
setDay(document.frm1.cmbCheckOutDate,document.frm1.cmbCheckOutMonth,document.frm1.cmbCheckOutYear,document.frm1.cmbCheckInDate,document.frm1.cmbCheckInMonth,document.frm1.cmbCheckInYear);
}

function  setNights(){
tmpnights=0;
with(document.frm1){
date1 = new Date(cmbCheckInYear.options[cmbCheckInYear.selectedIndex].value,cmbCheckInMonth.options[cmbCheckInMonth.selectedIndex].value,cmbCheckInDate.options[cmbCheckInDate.selectedIndex].value,0,0,0);
date2 = new Date(cmbCheckInYear.options[cmbCheckOutYear.selectedIndex].value,cmbCheckOutMonth.options[cmbCheckOutMonth.selectedIndex].value,cmbCheckOutDate.options[cmbCheckOutDate.selectedIndex].value,0,0,0);
tmpnights=get_deference(date1,date2);
if (tmpnights>0 && tmpnights<=15){
document.frm1.cmbNoOfNights.selectedIndex=(tmpnights-1);
}
}
}

function get_deference(ind,oud){
ind_d = ind.getDate();
ind_m = ind.getMonth();
ind_y = ind.getYear();
oud_d = oud.getDate();
oud_m = oud.getMonth();
oud_y = oud.getYear();
ret_val=0;
		if (ind_y==oud_y){
				if (ind_m==oud_m){
				ret_val=oud_d-ind_d;
				}else{
				ret_val=(maxdate1(ind_m,ind_y)-ind_d)+oud_d
				}
		}else{
				if (ind_m==11 && oud_m==0){
				ret_val=(maxdate1(ind_m,ind_y)-ind_d)+oud_d
				}
		}
return ret_val;
}

var userName='yyy'
var passWord='jjj'
var closeWnd=false;
function setUserPass(){ 
document.frm1.userName.value=userName
document.frm1.passWord.value=passWord
} 

var chDate
var chMonth
var chYear
var calDate
var calMonth
var calYear
var calType
var maxAdultsPerRoom = 4
var curDate = new Date(2003,5,3);
var dayArr = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
function loadDate(){
if(calMonth==curDate.getMonth()){calMonth=calMonth+1}
if(calType==1){
document.frm1.cmbCheckInDate.value = Number(calDate);
document.frm1.cmbCheckInMonth.value = Number(calMonth-1);	
document.frm1.cmbCheckInYear.value=Number(calYear);	
setCheckOut(1);
}else{
document.frm1.cmbCheckOutDate.value = Number(calDate) 
document.frm1.cmbCheckOutMonth.value = Number(calMonth-1);
document.frm1.cmbCheckOutYear.value=Number(calYear);	
setCheckOut(2);
}	
}	

function searchHotel(){
if(!setCheckOut(2)){return;}
setUserPass();
var inMonth = document.frm1.cmbCheckInMonth.options[document.frm1.cmbCheckInMonth.selectedIndex].value;
var inDate  = Number(document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value);
var inYear  = document.frm1.cmbCheckInYear.options[document.frm1.cmbCheckInYear.selectedIndex].value;
var chDate  = new Date(inYear,inMonth,inDate); 
var today   = new Date(inyy,inmm,indd); 
if(chDate<curDate){      alertMsg('tittle','Check in Date cannot be less then the System date !');
return;
}
noOfRooms = document.frm1.cmbNoOfRooms.selectedIndex+1;
noOfAdults = document.frm1.cmbNoOfAdults.selectedIndex+1;
if(noOfRooms>noOfAdults){
alertMsg('tittle','No. of adults is greater then the maximum no of adults for the rooms selected!');
return;
}

if (document.frm1.cmbCity.length==2){
document.frm1.cmbCity[0].value=document.frm1.cmbCity[1].options[document.frm1.cmbCity[1].selectedIndex].value;
}


document.frm1.action = 'http://web1.secure-reservation.com/servlets/WDCAHotels.ResevationSearch'
op_win();
document.frm1.submit();
}

function alertMsg(tittle,msg){ 
alert(msg);
}

function setCheckOut(type){
chkInDate  = document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value;
chkInMonth = document.frm1.cmbCheckInMonth.options[document.frm1.cmbCheckInMonth.selectedIndex].value;
chkInYear  = document.frm1.cmbCheckInYear.options[document.frm1.cmbCheckInYear.selectedIndex].value;
chkOutDate  = document.frm1.cmbCheckOutDate.options[document.frm1.cmbCheckOutDate.selectedIndex].value;
chkOutMonth = document.frm1.cmbCheckOutMonth.options[document.frm1.cmbCheckOutMonth.selectedIndex].value;
chkOutYear  = document.frm1.cmbCheckOutYear.options[document.frm1.cmbCheckOutYear.selectedIndex].value;
noOfNights  = document.frm1.cmbNoOfNights.options[document.frm1.cmbNoOfNights.selectedIndex].value;
if(type==1){
_date = new Date(chkInYear,chkInMonth,chkInDate,0,0,0);
var date;
if(_date.getMonth()!=chkInMonth){
_maxDate=maxDate(Number(chkInMonth));
document.frm1.cmbCheckInDate.selectedIndex=_maxDate-1;
date = new Date(chkInYear,chkInMonth,_maxDate,0,0,0);
}else{
date = _date;
}
_timeMills     = date.valueOf();
_timeMills1    = noOfNights*24*60*60*1000;
_timeAcctMills = Number(_timeMills)+Number(_timeMills1);
_tDate      =  new Date(_timeAcctMills)
document.frm1.cmbCheckOutDate.selectedIndex=_tDate.getDate()-1;
document.frm1.cmbCheckOutMonth.selectedIndex=_tDate.getMonth();
document.frm1.cmbCheckOutYear.value=_tDate.getYear();
setDay(document.frm1.cmbCheckOutDate,document.frm1.cmbCheckOutMonth,document.frm1.cmbCheckOutYear,document.frm1.cmbCheckInDate,document.frm1.cmbCheckInMonth,document.frm1.cmbCheckInYear);
}else if(type==2){
date1 = new Date(chkInYear,chkInMonth,chkInDate,0,0,0);
date2 = new Date(chkOutYear,chkOutMonth,chkOutDate,0,0,0);
noOfNights  = get_deference(date1,date2);
if((noOfNights <= document.frm1.cmbNoOfNights.length)&&(noOfNights>=1)){ 
if(document.frm1.cmbCheckOutDate.selectedIndex+1> maxDate(Number(chkInMonth))){  
date1.setDate(date1.getDate()+1)
document.frm1.cmbCheckOutDate.selectedIndex=date1.getDate()-1;
document.frm1.cmbCheckOutMonth.selectedIndex=date1.getMonth();
document.frm1.cmbCheckOutYear.value=date1.getYear();
document.frm1.cmbNoOfNights.selectedIndex=0;
}else {
document.frm1.cmbNoOfNights.selectedIndex=noOfNights-1;
}
}else {
alert('Number of Nights can not be greater then  '+document.frm1.cmbNoOfNights.length+' and less than 0')
document.frm1.cmbNoOfNights.selectedIndex=0
date1.setDate(date1.getDate()+1)
document.frm1.cmbCheckOutDate.selectedIndex=date1.getDate()-1;
document.frm1.cmbCheckOutMonth.selectedIndex=date1.getMonth();
document.frm1.cmbCheckOutYear.selectedIndex=date1.getYear()-2003;
return false;
}
setDay(document.frm1.cmbCheckOutDate,document.frm1.cmbCheckOutMonth,document.frm1.cmbCheckOutYear,document.frm1.cmbCheckInDate,document.frm1.cmbCheckInMonth,document.frm1.cmbCheckInYear);
}
return true;
}

function setDay(obj1,obj2,obj3,obj4,obj5,obj6){
odate=new Date(obj3.options[obj3.selectedIndex].value,obj2.options[obj2.selectedIndex].value,obj1.options[obj1.selectedIndex].value);
idate=new Date(obj6.options[obj6.selectedIndex].value,obj5.options[obj5.selectedIndex].value,obj4.options[obj4.selectedIndex].value);
iday=idate.getDay();
oday=odate.getDay();
}

function maxDate(month){
month=month+=1;
maxD=0;
if((month==1)||(month==3)||(month==5)||(month==7)||(month==8)||(month==10)||(month==12)) 
maxD=31;
else if((month==4)||(month==6)||(month==9)||(month==11)) 
maxD=30;
else   
maxD=28;
return maxD;
}

function op_win(){
if (nav=="Netscape"){
return;
if (navigator.userAgent.indexOf("Netscape/7")>-1){
document.getElementById("progress").style.visibility="show";
}else{
document.layers("progress").visibility="show";
}
}else{
document.all("progress").style.visibility="visible";
}
}

function progress(){
if (nav=="Netscape"){
if (navigator.userAgent.indexOf("Netscape/7")>-1){
document.getElementById("progress").style.visibility="hide";
}else{
document.layers("progress").visibility="hide";
}
}else{
document.all("progress").style.visibility="hidden";
}
}


tmpstr="<div id=\"progress\" style=\"position:absolute; left:18px; top:457px; width:220px; height:92px; z-index:1; visibility: hidden;\">\r\n";
tmpstr=tmpstr+"<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"#FF0000\">\r\n";
tmpstr=tmpstr+"<tr>\r\n";
tmpstr=tmpstr+"<td><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">\r\n";
tmpstr=tmpstr+"<tr>\r\n";
tmpstr=tmpstr+"<td>\r\n<table width=\"200\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">\r\n";
tmpstr=tmpstr+"<tr>\r\n";
tmpstr=tmpstr+"<td><img src=\"images/spacer.gif\" width=\"1\" height=\"1\"></td>\r\n";
tmpstr=tmpstr+"</tr>\r\n";
tmpstr=tmpstr+"<tr>\r\n";
tmpstr=tmpstr+"<td class=\"txt4\">\r\n";

if (navigator.appName=="Netscape" && navigator.userAgent.indexOf("Netscape/7")==-1){
tmpstr=tmpstr+"Please wait one moment ...";
}else if (navigator.appName=="Netscape" && navigator.userAgent.indexOf("Netscape/7")>-1){
tmpstr=tmpstr=+"<blink><span class=\"divtxt\">Please wait one moment ...&nbsp;&nbsp;&nbsp;</span></blink>\r\n";
}else{
tmpstr=tmpstr+"<blink><div id=\"progress1\" class=\"divstyle\"><marquee align=\"middle\" behavior=\"alternate\" scrollamount=\"400\" scrolldelay=\"180\" width=\"400\"><span class=\"divtxt\">Please wait one moment ...&nbsp;&nbsp;&nbsp;</span></marquee></div></blink>";
}

tmpstr=tmpstr+"</td>\r\n";
tmpstr=tmpstr+"</tr>\r\n";
tmpstr=tmpstr+"<tr>\r\n";
tmpstr=tmpstr+"<td class=\"txt3\">We are checking and retrieving hotel rates and availability</td>\r\n";
tmpstr=tmpstr+"</tr>\r\n";
tmpstr=tmpstr+"<tr>\r\n";
tmpstr=tmpstr+"<td><img src=\"images/spacer.gif\" width=\"1\" height=\"1\"></td>\r\n";
tmpstr=tmpstr+"</tr>\r\n";
tmpstr=tmpstr+"</table></td>\r\n";
tmpstr=tmpstr+"</tr>\r\n";
tmpstr=tmpstr+"</table></td>";
tmpstr=tmpstr+"</tr>";
tmpstr=tmpstr+"</table>";
tmpstr=tmpstr+"</div>\r\n";
if (nav!="Netscape"){
document.write(tmpstr);
}

