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="http://www4.secure-reservation.com/HTML/ACCentral/HotelTemplate/Affiliates/partyshuttle/HOTimages";

function set_default_date(){
document.frm1.cmbCheckInYear.options.length=0;
document.frm1.cmbCheckOutYear.options.length=0;
for (a=0; a<5; a++){
with (document.frm1){
if (a!=4){
cmbCheckInYear.options[a]= new Option(inyy+a,inyy+a);
}
cmbCheckOutYear.options[a]= new Option(inyy+a,inyy+a);
}
}
if (inyy<2004){
return;
}
with (document.frm1){
cmbNoOfAdults.selectedIndex=1;
cmbCheckInMonth.selectedIndex		=	inmm;
cmbCheckInYear.selectedIndex			= inyy-inyy;
cmbCheckOutMonth.selectedIndex	= outmm;
cmbCheckOutYear.selectedIndex		= outyy-inyy;
cmbNoOfNights.selectedIndex				=	0;
}
document.images["inday"].src=""+dayimagepath+"/dd"+(myindate.getDay())+".gif";
document.images["outday"].src=""+dayimagepath+"/dd"+(myoutdate.getDay())+".gif";
setMonthDays("In");
setMonthDays("Out");
document.frm1.cmbCheckInDate.selectedIndex			= indd-1;
document.frm1.cmbCheckOutDate.selectedIndex		= outdd-1;
}

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);
document.images["inday"].src=""+dayimagepath+"/dd"+(tmpInDate.getDay())+".gif";
noDays = Number(document.frm1.cmbNoOfNights.options[document.frm1.cmbNoOfNights.selectedIndex].value);
tmpOutDate = new Date(tmpInDate.setDate(tmpInDate.getDate()+noDays));
document.frm1.cmbCheckOutMonth.selectedIndex	= tmpOutDate.getMonth();
document.frm1.cmbCheckOutYear.selectedIndex		= tmpOutDate.getFullYear()-inyy;
setMonthDays("Out");
document.frm1.cmbCheckOutDate.selectedIndex		= tmpOutDate.getDate()-1;
document.images["outday"].src=""+dayimagepath+"/dd"+(tmpOutDate.getDay())+".gif";
}

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.options[document.frm1.cmbCheckOutYear.selectedIndex].value,document.frm1.cmbCheckOutMonth.options[document.frm1.cmbCheckOutMonth.selectedIndex].value,document.frm1.cmbCheckOutDate.options[document.frm1.cmbCheckOutDate.selectedIndex].value,0,0,0,0);
dateDifference = get_deference(tmpInDate,tmpOutDate);
document.images["outday"].src=""+dayimagepath+"/dd"+(tmpOutDate.getDay())+".gif";
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.options[document.frm1.cmbCheckOutYear.selectedIndex].value,document.frm1.cmbCheckOutMonth.options[document.frm1.cmbCheckOutMonth.selectedIndex].value,document.frm1.cmbCheckOutDate.options[document.frm1.cmbCheckOutDate.selectedIndex].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 grater 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 no 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.AffiliateMainPage.value=""+document.location+"";
document.frm1.action = "http://web1.secure-reservation.com/servlets/ACCentral.ResevationSearch";
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)-15;
document.getElementById("progress").style.top=parseInt(document.images["searachIMG"].y)+35;
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-15;
document.all["progress"].style.top=tpos+35;
document.all["progress"].style.visibility="visible";
}
}

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_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_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 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));