var servletURL="http://www.secure-etspl.com/servlets/";
//var servletURL="http://server2.secure-reservation.com/servlets/";
var resAgentName="LeisureTime";

var nav=navigator.appName;

var myindate = new Date();
var myoutdate = new Date();
myindate = new Date(myindate.setDate(myindate.getDate()));
myoutdate = new Date(myoutdate.setDate(myoutdate.getDate()+2));
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();


function set_default_date(){
if (inyy<2003){
return;
}
with (document.frm1){
cmbCheckInMonth.selectedIndex	=	inmm;
cmbCheckInYear.selectedIndex	= inyy-2003;
//cmbCheckOutMonth.value	        = outmm;
//cmbCheckOutYear.value		    = outyy-2003;
//cmbNoOfNights.value				=	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.value		= outdd-1;
 
//alert('document.frm1.cmbCheckOutMonth.value '+document.frm1.cmbCheckOutMonth.value);
//alert('document.frm1.cmbCheckOutYear.value '+document.frm1.cmbCheckOutYear.value);
//alert('document.frm1.cmbCheckOutDate.value '+document.frm1.cmbCheckOutDate.value);
//alert('document.frm1.cmbNoOfNights.value '+document.frm1.cmbNoOfNights.value);
}

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.value);
tmpOutDate = new Date(tmpInDate.setDate(tmpInDate.getDate()+noDays));
//document.frm1.cmbCheckOutMonth.value	= tmpOutDate.getMonth();
//document.frm1.cmbCheckOutYear.value		= ((nav=="Netscape")? tmpOutDate.getYear()+1900:tmpOutDate.getYear())-2003;
//setMonthDays("Out");
//document.frm1.cmbCheckOutDate.value		= tmpOutDate.getDate()-1;

//alert('document.frm1.cmbCheckOutMonth.value '+document.frm1.cmbCheckOutMonth.value);
//alert('document.frm1.cmbCheckOutYear.value '+document.frm1.cmbCheckOutYear.value);
//alert('document.frm1.cmbCheckOutDate.value '+document.frm1.cmbCheckOutDate.value);
//alert('document.frm1.cmbNoOfNights.value '+document.frm1.cmbNoOfNights.value);
}

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 = Number(tmpOutDate-tmpInDate)/86400000;
document.images["outday"].src="images/dd"+(tmpOutDate.getDay())+".gif";
if (dateDifference<1 || dateDifference>15){
return;
}
document.frm1.cmbNoOfNights.selectedIndex = dateDifference-1;
}

function checkValues(){
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 = Number(tmpOutDate-tmpInDate)/86400000;
noNights = document.frm1.cmbNoOfNights.options[document.frm1.cmbNoOfNights.selectedIndex].value;
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;
}
}

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;
	}
}

var userName="-";
var passWord="-";
var userType="RA";
var closeWnd=false;

function setUserPass(){ 
document.frm1.userName.value=userName;
document.frm1.passWord.value=passWord;
document.frm1.userType.value=userType;
} 

function memberLogin(){
     window.open(""+servletURL+""+resAgentName+".RezgatewayLoginScreen?init=1&language=en&country=US&afftCode=RA&browserType=IE","iWindow","width=300,height=180,top=200,left=300,statusbar=0,menubar=0,toolbar=0");
}

function searchHotel(){
/*
if (document.frm1.cmbCity.selectedIndex==0){
alert("Please Select a City");
return;
}
*/
setUserPass();
setCheckOut();

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,0,0,0,0); 
var tmptoday   = new Date(); 
mm1 	= tmptoday.getMonth();
dd1 	= tmptoday.getDate();
yy1 	= (nav=="Netscape")? tmptoday.getYear()+1900:tmptoday.getYear();
var today   = new Date(yy1,mm1,dd1,0,0,0,0); 


if (((chDate-today)/86400000)<1 &&((chDate-today)/86400000)>=0){
alert('Because your chosen arrival date is within the next 24 hours,please call us Toll-Free 1.800.449.1876, or Local (702) 247-1306.  Our friendly hotel experts will help pocess your reservation.  If you are flexible with your arrival date,please choose an arrival date 24 hours from now,and continue to book online.');
return;
}else if (today>chDate){
alert("Check in Date cannot be less then the System date");
return;
}

noOfRooms = document.frm1.cmbNoOfRooms.selectedIndex+1;
noOfAdults = document.frm1.cmbNoOfAdults.selectedIndex;
if(noOfRooms>noOfAdults){
alert("No. of adults is greater then the maximum no of adults for the rooms selected!");
return;
}
document.frm1.selCity.value='%'
document.frm1.action = "http://www2.secure-reservation.com/servlets/LeisureTime.ResevationSearch";
op_win();
document.frm1.submit();
}

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){
document.getElementById("progress").style.left=parseInt(document.getElementById("progress").style.left)+toadd;
document.getElementById("progress").style.visibility="visible";
}else{
document.layers["progress"].left=parseInt(document.layers["progress"].left)+toadd;
document.layers["progress"].visibility="show";
}
}else{
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 op_hotels(){
window.open("http://"+document.domain+"/servlets/LeisureTime.HotelPartnerMain","","");
}

function loadCalender(type){
calType=type;
iwindow=window.open("http://"+document.domain+"/servlets/LeisureTime.RezGatewaycalendar?language=en&country=US&browser=IE","iop","width=250,height=250,top=200,left=500");
}

function loadDate(){

}
