var nav=navigator.appName;
var myindate = new Date();
var myoutdate = new Date();
myoutdate = new Date(myoutdate.setDate(myoutdate.getDate()+1));
var inmm 	= myindate.getMonth();
var indd 	= myindate.getDate();
var inyy 	= myindate.getFullYear();
var outmm = myoutdate.getMonth();
var outdd = myoutdate.getDate();
var outyy = myoutdate.getFullYear();
var dayimagepath="images";

function set_default_date(){
document.frm1.cmbCheckInYear.options.length=0;
for (a=0; a<5; a++){
with (document.frm1){
yr1=inyy+a;
yr2=yr1.toString();
cmbCheckInYear.options[a]= new Option(yr2.substring(yr2.length-2,yr2.length),inyy+a);
}
}
with (document.frm1){
cmbNoOfAdults.selectedIndex=1;
cmbCheckInMonth.selectedIndex		=	inmm;
cmbCheckInYear.selectedIndex			= inyy-inyy;
cmbCheckOutMonth.value	= outmm;
cmbCheckOutYear.value		= outyy;
cmbNoOfNights.selectedIndex				=	0;
}
setMonthDays("In");
document.frm1.cmbCheckInDate.selectedIndex			= indd-1;
document.frm1.cmbCheckOutDate.value		= outdd;
}

function setCheckOut(){
tmpInDate = new Date(document.frm1.cmbCheckInYear.options[document.frm1.cmbCheckInYear.selectedIndex].value,document.frm1.cmbCheckInMonth.options[document.frm1.cmbCheckInMonth.selectedIndex].value,document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value,0,0,0,0);
noDays = Number(document.frm1.cmbNoOfNights.options[document.frm1.cmbNoOfNights.selectedIndex].value);
tmpOutDate = new Date(tmpInDate.setDate(tmpInDate.getDate()+noDays));
document.frm1.cmbCheckOutMonth.value	= tmpOutDate.getMonth();
document.frm1.cmbCheckOutYear.value		= tmpOutDate.getFullYear();
document.frm1.cmbCheckOutDate.value		= tmpOutDate.getDate();
}

function setNights(){
tmpInDate = new Date(document.frm1.cmbCheckInYear.options[document.frm1.cmbCheckInYear.selectedIndex].value,document.frm1.cmbCheckInMonth.options[document.frm1.cmbCheckInMonth.selectedIndex].value,document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value,0,0,0,0);
tmpOutDate = new Date(document.frm1.cmbCheckOutYear.value,document.frm1.cmbCheckOutMonth.value,document.frm1.cmbCheckOutDate.value,0,0,0,0);
dateDifference = get_deference(tmpInDate,tmpOutDate);
if (dateDifference<1 || dateDifference>15){
return;
}
if (dateDifference>0){
document.frm1.cmbNoOfNights.selectedIndex = dateDifference-1;
}
}

function maxdate(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;
}
}

function setMonthDays(name){
tmpmm	= document.frm1.elements["cmbCheck"+name+"Month"].options[document.frm1.elements["cmbCheck"+name+"Month"].selectedIndex].value;
tmpyy	= document.frm1.elements["cmbCheck"+name+"Year"].options[document.frm1.elements["cmbCheck"+name+"Year"].selectedIndex].value;
maxdays = maxdate(tmpmm,tmpyy);
selectedInd=document.frm1.elements["cmbCheck"+name+"Date"].selectedIndex; 
document.frm1.elements["cmbCheck"+name+"Date"].options.length=28;
toAdd=maxdays-28;
for (a=0; a<toAdd; a++){
document.frm1.elements["cmbCheck"+name+"Date"].options[document.frm1.elements["cmbCheck"+name+"Date"].options.length] = new Option(29+a,29+a);
}
new_lnth=document.frm1.elements["cmbCheck"+name+"Date"].options.length;
if (new_lnth<selectedInd+1){
document.frm1.elements["cmbCheck"+name+"Date"].selectedIndex=document.frm1.elements["cmbCheck"+name+"Date"].options.length-1;
}else{
document.frm1.elements["cmbCheck"+name+"Date"].selectedIndex=selectedInd;
}
}

function checkValues(affcode){
tmpInDate = new Date(document.frm1.cmbCheckInYear.options[document.frm1.cmbCheckInYear.selectedIndex].value,document.frm1.cmbCheckInMonth.options[document.frm1.cmbCheckInMonth.selectedIndex].value,document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value,0,0,0,0);
tmpOutDate = new Date(document.frm1.cmbCheckOutYear.value,document.frm1.cmbCheckOutMonth.value,document.frm1.cmbCheckOutDate.value,0,0,0,0);
dateDifference = get_deference(tmpInDate,tmpOutDate);
noNights = document.frm1.cmbNoOfNights.options[document.frm1.cmbNoOfNights.selectedIndex].value;
today = new Date();
if ((today-tmpInDate)>86400000){
alert("Check in date can not be less than the system date");
set_default_date();
return;
}

if (dateDifference>15 || dateDifference<1){
alert("Number of night(s) can not be greater than "+document.frm1.cmbNoOfNights.options.length+" or less than 1.\r\nPlease select again ...");
set_default_date();
return;
}else{
document.frm1.cmbNoOfNights.selectedIndex=dateDifference-1;
}

noOfRooms = document.frm1.cmbNoOfRooms.selectedIndex+1;
noOfAdults = document.frm1.cmbNoOfAdults.selectedIndex+1;

if(noOfRooms>noOfAdults){
alert("Number of adults is greater then the maximum number of adults for the rooms selected!");
return;
}

if (affcode!=''){
document.frm1.afftCode.value=""+affcode+"";
}

document.frm1.selCity.value="%";
op_win();
docdom=""+document.domain+"";
document.frm1.action = "http://web1.secure-reservation.com/servlets/ACCentral.ResevationSearch";
document.frm1.AffiliateMainPage.value=""+document.location+"";
document.frm1.submit();
}

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=(maxdate(ind_m,ind_y)-ind_d)+oud_d
				}
		}else{
				if (ind_m==11 && oud_m==0){
				ret_val=(maxdate(ind_m,ind_y)-ind_d)+oud_d
				}
		}
return ret_val;
}

var sWith=screen.width;
var toadd= 0;
if (sWith>800){
toadd = (sWith-800)/2;
}

function op_win(){
if (navigator.userAgent.indexOf("Netscape/7")>-1){
document.getElementById("progress").style.left=parseInt(document.images["searachIMG"].x)-150;
document.getElementById("progress").style.top=parseInt(document.images["searachIMG"].y)+45;
document.getElementById("progress").style.visibility="visible";
}else if(navigator.userAgent.indexOf("MSIE")>-1){
posObj=document.images["searachIMG"];
lpos=0;
tpos=0;
while(posObj.tagName!='BODY'){
lpos+=posObj.offsetLeft;
tpos+=posObj.offsetTop;
posObj=posObj.offsetParent;
}
document.all["progress"].style.left=lpos-150;
document.all["progress"].style.top=tpos+45;
document.all["progress"].style.visibility="visible";
}
}

var brwag=navigator.userAgent;
function getTag(val,name,l,t,w,h){if (brwag.indexOf("/4.7")>-1){
tag1="<layer name=\""+name+"\" left=\""+l+"\" top=\""+t+"\" width=\""+w+"\" height=\""+h+"\" visibility=\"hide\">";
tag2="</layer>";}else{
tag1="<div id=\""+name+"\" style=\"position:absolute; width:"+w+"px; height:"+h+"px; z-index:1; left: "+l+"px; top: "+t+"px; visibility: hidden;\">";
tag2="</div>";}return eval("tag"+val+"");}
prloadtxt="<table width='190' height='75' border='0' cellpadding='0' cellspacing='0' class='msgborder'>"+
"<tr><td><table width='186' height='71' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='#FFFFCC'>"+
"<tr><td><table width='170' border='0' align='center' cellpadding='2' cellspacing='0'><tr>";
if (brwag.indexOf("/4.7")>-1){prloadtxt=prloadtxt+"<td align='center'><span  class='blinkmsg'>Please Wait One Moment ...</span></td>";
}else if (brwag.indexOf("Netscape/7")>-1){prloadtxt=prloadtxt+"<td align='center'><blink><span  class='blinkmsg'>Please Wait One Moment ...</span></blink></td>";
}else{prloadtxt=prloadtxt+"<td align='center'><span style='width:155px;overflow:hidden;'><marquee align='middle' behavior='alternate' scrollamount='340' scrolldelay='240' width='340'><span class='blinkmsg'>Please Wait One Moment ...</span></marquee></span></td>";}
prloadtxt=prloadtxt+"</tr><tr>"+
"<td class='msgttxt'>We are checking and retrieving the rates and availability of our hotels</td>"+
"</tr></table></td></tr></table></td></tr></table>";
document.write(getTag(1,'progress',50,50,190,67)+prloadtxt+getTag(2));