//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;
}
setMonthDays("In");
document.frm1.cmbCheckInDate.selectedIndex= indd-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);
noDays = Number(document.frm1.cmbNoOfNights.value);
tmpOutDate = new Date(tmpInDate.setDate(tmpInDate.getDate()+noDays));
}

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="http://server2.secure-reservation.com/html/LeisureTime/Images/en/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.cmbPrCat.selectedIndex==0){
alert("Please Select a Program Category");
return;
}

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 1.702.247.1306. our friendly travel experts will help process your reservation.  If you are flexible with your arrival date, please choose an arrival date at least 24 hours from now, and continue to book online.');
return;
}else if (today>chDate){
alert("Check in Date cannot be earlier then the current 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.txtcity.value=document.frm1.cmbCity.options[document.frm1.cmbCity.selectedIndex].text;
document.frm1.action = ""+servletURL+"LeisureTime.ResevationSearch";
document.frm1.submit();
}

function op_hotels(){
window.open(""+servletURL+"/LeisureTime.HotelPartnerMain","","");
}

function loadCalender(type){
calType=type;
iwindow=window.open(""+servletURL+"/LeisureTime.RezGatewaycalendar?language=en&country=US&browser=IE","iop","width=250,height=250,top=200,left=500");
}

function loadDate(){

}
/////////////////////////////////////////
var chDate
var chMonth
var chYear
var calDate
var calMonth
var calYear
var calType
var curDate = new Date();
var dayArr = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
function loadCalender(type){
calType=type;iwindow=window.open('/servlets/LeisureTime.RezGatewaycalendar?language=en&country=US&browser=IE','iop','width=250,height=250,top=200,left=500,status=1');	
}
function loadDate(){
		document.frm1.cmbCheckInDate.selectedIndex = Number(calDate)-1;
		document.frm1.cmbCheckInMonth.selectedIndex = Number(calMonth)-1;
		document.frm1.cmbCheckInYear.selectedIndex=Number(calYear)-2004+1;
		loadDay();
}
function loadDay()
{
   chkInDate  = document.frm1.cmbCheckInDate.options[document.frm1.cmbCheckInDate.selectedIndex].value;
   chkInMonth = document.frm1.cmbCheckInMonth.options[document.frm1.cmbCheckInMonth.selectedIndex].value;
   chkInYear  = document.frm1.cmbCheckInYear.options[document.frm1.cmbCheckInYear.selectedIndex].value;
   	

   		_date = new Date(chkInYear,chkInMonth,chkInDate,0,0,0);
   		var date;
   		if(_date.getMonth()!=chkInMonth){
   			_maxDate=maxDate(Number(chkInMonth),Number(chkInYear));
   			date = new Date(chkInYear,chkInMonth,_maxDate,0,0,0);
   		}
   		else{
   		date = _date;
   		}
   	
   	setDay(document.frm1.cmbCheckInDate,document.frm1.cmbCheckInMonth,document.frm1.cmbCheckInYear);
}

function setDay(obj4,obj5,obj6){
   	idate=new Date((obj6.options[obj6.selectedIndex].value),Number(obj5.options[obj5.selectedIndex].value),obj4.options[obj4.selectedIndex].value);
   	
   	iday=idate.getDay();
   	document.frm1.iday.src='http://server2.secure-reservation.com/html/LeisureTime/Images/en/'+dayArr[iday]+'.gif';	
   	
function maxDate(month,year){
  			month=month+=1;
  			maxD=0;
   			if((month==1)||(month==3)||(month==5)||(month==7)||(month==8)||(month==10)||(month==12)){ 
      			maxD=31;
   			}
   			else if((month==4)||(month==6)||(month==9)||(month==11)){ 
     			maxD=30;
   			}else{   
   				if (year % 4 == 0){
     			maxD=29;
   				}else{   
     			maxD=28;
  				} 
  			}
   			return maxD;
}

}

