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 	= (nav=="Netscape")? myindate.getYear()+1900:myindate.getYear();
var outmm = myoutdate.getMonth();
var outdd = myoutdate.getDate();
var outyy = (nav=="Netscape")? myoutdate.getYear()+1900:myoutdate.getYear();
var dayimagepath="";


function set_default_date(){
if (inyy<2003){
return;
}
with (document.frm1){
cmbCheckInMonth.selectedIndex		=	inmm;
cmbCheckInYear.selectedIndex			= inyy-2003;
cmbCheckOutMonth.selectedIndex	= outmm;
cmbCheckOutYear.selectedIndex		= outyy-2003;
cmbNoOfNights.selectedIndex				=	0;
}
document.images["inday"].src=""+dayimagepath+"images/dd"+(myindate.getDay())+".gif";
document.images["outday"].src=""+dayimagepath+"images/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+"images/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		= ((nav=="Netscape")? tmpOutDate.getYear()+1900:tmpOutDate.getYear())-2003;
setMonthDays("Out");
document.frm1.cmbCheckOutDate.selectedIndex		= tmpOutDate.getDate()-1;
document.images["outday"].src=""+dayimagepath+"images/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+"images/dd"+(tmpOutDate.getDay())+".gif";
if (dateDifference<1 || dateDifference>15){
return;
}
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 (noNights!=dateDifference){
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;
}

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();
document.frm1.action = "http://www.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 (nav=="Netscape"){
if (navigator.userAgent.indexOf("Netscape/7")>-1){
if (document.getElementById("progress").style.visibility=="visible"){
return;
}
document.getElementById("progress").style.left=parseInt(document.getElementById("progress").style.left)+toadd;
document.getElementById("progress").style.visibility="visible";
}else{
if (document.layers["progress"].visibility=="show"){
return;
}
document.layers["progress"].left=parseInt(document.layers["progress"].left)+toadd;
document.layers["progress"].visibility="show";
}
}else{
if (document.all["progress"].style.visibility=="visible"){
return;
}
document.all["progress"].style.left=parseInt(document.all["progress"].style.left)+toadd;
document.all["progress"].style.visibility="visible";
}
}

function progress(){
if (nav=="Netscape"){
if (navigator.userAgent.indexOf("Netscape/7")>-1){
document.getElementById("progress").style.visibility="hidden";
}else{
document.layers["progress"].visibility="hide";
}
}else{
document.all["progress"].style.visibility="hidden";
}
}


function info(id,url){
if (id=="mod"){
newWin1 = window.open(""+dayimagepath+"modify-cancel-reservation.html", ""+id+"","top=200,left="+((screen.width)/2)-120+",width=350,height=220,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0");
}else if (id=="cus"){
newWin2 = window.open(""+dayimagepath+"customer-service.html", ""+id+"","top=200,left="+((screen.width)/2)-120+",width=530,height=240,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0");
}else if(id=="pol"){
newWin3 = window.open(""+dayimagepath+"res-policy.html", ""+id+"","top=200,left="+((screen.width)/2)-120+",width=530,height=320,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0");
}else if(id=="reg"){
newWin4 = window.open(""+url+"", ""+id+"","top=300,left="+((screen.width)/2)-120+",width=300,height=120,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=0");
}
}


var err=false;
var msg="";
function chkForm(){
return;
err=false;
if (document.form1.name.value=="" || document.form1.name.value==" "){
err=true;
msg="Please enter Name";
}
if (form1.mail.value=="" || (form1.mail.value.indexOf(".")==-1) || (form1.mail.value.indexOf("@")==-1) || (form1.mail.value.indexOf(" ")>-1) || (form1.mail.value.indexOf("@")==form1.mail.value.length)|| (form1.mail.value.indexOf(".")==form1.mail.value.length-1) || (form1.mail.value.indexOf(".@")>-1) || (form1.mail.value.indexOf("@.")>-1) || (form1.mail.value.length<6)){
if (msg==""){
	msg="Please enter a valid e-mail address";
}
err=true;
}

	if (err){
	alert(msg);
	err=false;
	msg="";
	return;
	}
	form1.submit();
}

function sendmail(){
tmpadd=document.forms["sendmail"].mailadd.value;
if (tmpadd=="" || (tmpadd.indexOf(".")==-1) || (tmpadd.indexOf("@")==-1) || (tmpadd.indexOf(" ")>-1) || (tmpadd.indexOf("@")==tmpadd.length)|| (tmpadd.indexOf(".")==tmpadd.length-1) || (tmpadd.indexOf(".@")>-1) || (tmpadd.indexOf("@.")>-1) || (tmpadd.length<6)){
alert("Please enter a valid e mail address");
document.forms["sendmail"].mailadd.value="";
return;
}
document.forms["sendmail"].mailadd.value="";
info("reg",""+dayimagepath+"register.html?mail="+tmpadd+"");
}

function showProgressBar(){
dayimagepath="";
	if (navigator.appName=="Netscape" && navigator.userAgent.indexOf("Netscape/7")==-1){
	document.write("&nbsp;&nbsp;&nbsp;Please wait one moment ...");
	}else if (navigator.appName=="Netscape" && navigator.userAgent.indexOf("Netscape/7")>-1){
	document.write("<blink><span class=\"divtxt\">&nbsp;&nbsp;&nbsp;Please wait one moment ...&nbsp;&nbsp;&nbsp;</span></blink>");
	}else{
	document.write("<blink><div id=\"progress1\" class=\"divstyle\"><marquee align=\"middle\" behavior=\"alternate\" scrollamount=\"400\" scrolldelay=\"180\" width=\"400\"><span class=\"divtxt\">&nbsp;&nbsp;&nbsp;Please wait one moment ...&nbsp;&nbsp;&nbsp;</span></marquee></div></blink>");
	}
}