var SW=screen.width;

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
var bg_img="WDCAHRS_bg.gif";
if (SW==800){
img="WDCAHRS_bg.gif";
}else if (SW==1024){
bg_img="WDCAHRS_bg_1024.gif";
}else if (SW==1152){
bg_img="WDCAHRS_bg_1152.gif";
}else if (SW==1280){
bg_img="WDCAHRS_bg_1280.gif";
}
loc=""+top.location+"";


if(loc.indexOf("hot-deals-")<0){
document.write("<style type=\"text/css\">");
document.write("body {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #000000; background-image: url("+bg_img+");}");
document.write("</style>");
}

year_diff=0;





function Val_date(Index,Name){
get_obj = new Array(3);
if (Name.indexOf("In")>-1){
get_obj = new Array("cmb","CheckIn","Month");
}else{
get_obj = new Array("cmb","CheckOut","Month");
}
sel_obj=get_obj[(get_obj.length-1)]

with(document.form1){
Mon	=Number(elements[""+get_obj[0]+""+get_obj[1]+"Month"].options[elements[""+get_obj[0]+""+get_obj[1]+"Month"].selectedIndex].value)+1;
Day	=Number(elements[""+get_obj[0]+""+get_obj[1]+"Date"].options[elements[""+get_obj[0]+""+get_obj[1]+"Date"].selectedIndex].value);
Yer	=Number(elements[""+get_obj[0]+""+get_obj[1]+"Year"].options[elements[""+get_obj[0]+""+get_obj[1]+"Year"].selectedIndex].value);
}
if (Name ==""+get_obj[0]+""+get_obj[1]+"Month" || Name==""+get_obj[0]+""+get_obj[1]+"Year"){
Curr_no_opts=document.form1.elements[""+get_obj[0]+""+get_obj[1]+"Date"].options;
Curr_index=document.form1.elements[""+get_obj[0]+""+get_obj[1]+"Date"].selectedIndex;
DD_max=DDM(Day,Mon,Yer);
	if (DD_max!=Curr_no_opts.length){
	Curr_no_opts.length=0;
		for(x=0; x<DD_max; x++){
			if ((x+1)<10){
			Curr_no_opts[x]=new Option("0"+(x+1),"0"+(x+1)+"");
			}else{
			Curr_no_opts[x]=new Option(""+(x+1),""+(x+1)+"");
			}
		}
	}
x=0;
Curr_no_opts=document.form1.elements[""+get_obj[0]+""+get_obj[1]+"Date"].options;
if (Curr_no_opts.length>Curr_index){
document.form1.elements[""+get_obj[0]+""+get_obj[1]+"Date"].selectedIndex=Curr_index;
}else{
document.form1.elements[""+get_obj[0]+""+get_obj[1]+"Date"].selectedIndex=(Curr_no_opts.length-1);
}
}
set_inout(get_obj[0]+""+get_obj[1],Name)
}

function DDM(D,M,Y){
if (M==1 || M==3 || M==5 || M==7 || M==8 || M==10 || M==12){
Ret_D = 31;
}else{
	if (M!=2){
	Ret_D =30;
	}else{
	Ret_D = (Y%4==0)? 29:28;
	}
}
return Ret_D;
}


function set_inout(objset,Name){

}

var DateIndexIn = 0;
var MonthIndexIn = 0;
var YearIndexIn = 0;
var DateIndexOut = 0;
var MonthIndexOut = 0;
var YearIndexOut = 0;
var def_in_date

var Mydate = new Date();
var MM_date = Mydate.getDate();
var MM_month = Mydate.getMonth();
var MM_year = Mydate.getYear();
if (navigator.appName=="Netscape"){
MM_year=MM_year+1900
}



function get_curnetdate(){
DateIndexIn =MM_date+3;
MonthIndexIn =MM_month;
YearIndexIn =MM_year;
DateIndexOut =MM_date+4;
MonthIndexOut =MM_month;
YearIndexOut =MM_year;
MaxDays = DDM(MM_date,MM_month+1,MM_year);
	if (DateIndexIn>MaxDays){
	DateIndexIn = DateIndexIn-MaxDays;
	MonthIndexIn= MM_month+1;
	if (MonthIndexIn>11){
	MonthIndexIn=0;
	YearIndexIn=YearIndexIn+1;
	}
	}

	if (DateIndexOut>MaxDays){
	DateIndexOut = DateIndexOut-MaxDays;
	MonthIndexOut= MM_month+1;
	if (MonthIndexOut>11){
	MonthIndexOut=0;
	YearIndexOut=YearIndexOut+1;
	}
	}	
	

document.form1.cmbCheckInDate.selectedIndex = DateIndexIn-1
document.form1.cmbCheckInMonth.selectedIndex = MonthIndexIn
document.form1.cmbCheckInYear.selectedIndex = YearIndexIn-2002
document.form1.cmbCheckOutDate.selectedIndex = DateIndexOut-1
document.form1.cmbCheckOutMonth.selectedIndex = MonthIndexOut
document.form1.cmbCheckOutYear.selectedIndex = YearIndexOut-2002
document.form1.cmbNoOfNights.selectedIndex=0;
def_in_date = new Date(document.form1.cmbCheckInYear.selectedIndex+2002,document.form1.cmbCheckInMonth.selectedIndex,document.form1.cmbCheckOutDate.selectedIndex)
if (navigator.appName=="Netscape"){
document.form1.browser.value="NS";
year_diff=1900;
}
Val_date(document.form1.cmbCheckInMonth.selectedIndex,"cmbCheckInMonth")
Val_date(document.form1.cmbCheckOutMonth.selectedIndex,"cmbCheckOutMonth")
}


function Adjust_date(){
in_M=document.form1.cmbCheckInMonth.selectedIndex;
in_D=document.form1.cmbCheckInDate.selectedIndex;
in_Y=document.form1.cmbCheckInYear.selectedIndex;

out_M=document.form1.cmbCheckOutMonth.selectedIndex;
out_D=document.form1.cmbCheckOutDate.selectedIndex;
out_Y=document.form1.cmbCheckOutYear.selectedIndex;

today = new Date(MM_year,MM_month,MM_date)
ind = new Date(in_Y+2002,in_M,in_D+1)
utd = new Date(out_Y+2002,out_M,out_D+1)

new_out = new Date(Number(ind)+60*60*24*1000*(document.form1.cmbNoOfNights.selectedIndex+1));
document.form1.cmbCheckOutMonth.selectedIndex=new_out.getMonth();
document.form1.cmbCheckOutDate.selectedIndex=new_out.getDate()-1;
document.form1.cmbCheckOutYear.selectedIndex=(new_out.getYear()+year_diff)-2002;

Val_date(document.form1.cmbCheckOutMonth.selectedIndex,"cmbCheckOutMonth")
}

var curDate = new Date(MM_year,MM_month,MM_date);
function searchHotel(){
var inMonth = document.form1.cmbCheckInMonth.options[document.form1.cmbCheckInMonth.selectedIndex].value
var inDate  = Number(document.form1.cmbCheckInDate.options[document.form1.cmbCheckInDate.selectedIndex].value)
var inYear  = document.form1.cmbCheckInYear.options[document.form1.cmbCheckInYear.selectedIndex].value

var outMonth = document.form1.cmbCheckOutMonth.options[document.form1.cmbCheckOutMonth.selectedIndex].value
var outDate  = Number(document.form1.cmbCheckOutDate.options[document.form1.cmbCheckOutDate.selectedIndex].value)
var outYear  = document.form1.cmbCheckOutYear.options[document.form1.cmbCheckOutYear.selectedIndex].value

var chIDate  = new Date(inYear,inMonth,inDate); 
var chODate  = new Date(outYear,outMonth,outDate); 
var today   = new Date(MM_year,MM_month,MM_date); 

if((chIDate>today) && (chIDate<def_in_date)){ 
window.open( "date_range_alert.html", "ID", "left="+(screen.width-450)/2+",top="+(screen.height-115)/2+",width=450,height=115,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0") ; 
return;
}
if(chIDate<curDate){
alert('Note ...\nCheck in Date cannot be less then the System date');
get_curnetdate();
return;
}

in_M=document.form1.cmbCheckInMonth.selectedIndex;
in_D=document.form1.cmbCheckInDate.selectedIndex;
in_Y=document.form1.cmbCheckInYear.selectedIndex;

out_M=document.form1.cmbCheckOutMonth.selectedIndex;
out_D=document.form1.cmbCheckOutDate.selectedIndex;
out_Y=document.form1.cmbCheckOutYear.selectedIndex;

today = new Date(MM_year,MM_month,MM_date)
ind = new Date(in_Y+2002,in_M,in_D+1)
utd = new Date(out_Y+2002,out_M,out_D+1)

if (utd<=ind){
alert("Note ...\nCheck out date can not be less than or equal to Check in date  ");
get_curnetdate();
return;
}

if ((utd-ind)/(60*60*24*1000)>15){
alert("Note ...\nNumber of night(s) can not be greater than 15  ");
get_curnetdate();
return;
}

noOfRooms = document.form1.cmbNoOfRooms.selectedIndex+1;
noOfAdults = document.form1.cmbNoOfAdults.selectedIndex+1;
if(noOfRooms>noOfAdults){
alert('No. of adults is less then the minumum no of adults for the room(s) selected!')
return;
}
document.form1.submit()
}



function pop_info(id,URL){
window.open( ""+URL+"", ""+id+"", "left=0,top=0,width="+(screen.width-200)+",height="+(screen.height-80)+",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=0") ; 
}

var scr_width=screen.width;
if (navigator.appName=="Netscape"){
setInterval("checkres()",2000);
}

function checkres(){
if (scr_width!=screen.width){
location.reload();
}
}

function setformat(val){
document.form1.Hformat.value=val;
}

function check(){
with(document.form1){
if (name.value=="" || name.value==" "){alert("Please enter Name");return;}
if (mail.value=="" || mail.value==" "){alert("Please enter e mail address");return;}
if (mail.value.indexOf("@")<0){alert("Please enter a valid e mail address");return;}
if (mail.value.indexOf(".")<0){alert("Please enter a valid e mail address");return;}
}
document.form1.submit();
}
