var servletURL="http://www2.secure-reservation.com/servlet/";


var resAgentName="HDMC";
var top_loc=""+window.location+"";
var StrDom=""+document.domain+"";
var tmpPortal=top_loc.substring(top_loc.indexOf(".com")+5,top_loc.length);
var StrPortal=tmpPortal.substring(0,tmpPortal.indexOf("/"));


var nav=navigator.appName;
var myindate = new Date();
var myoutdate = new Date();
myindate = new Date(myindate.setDate(myindate.getDate()));//+3
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();
var dayimagepath="";

var userName="-";
var passWord="****";
var userType="RA";

//added 1/9/2006
var baseyear = 2005;

function setNextYear(){
  var curDate  = new Date();
  var curMonth = curDate.getMonth();
  var curYear  = curDate.getYear();
  
  chkInMonth     = document.frm1.cmbCheckInMonth.options[document.frm1.cmbCheckInMonth.selectedIndex].value*1;
  chkOutMonth    = document.frm1.cmbCheckOutMonth.options[document.frm1.cmbCheckOutMonth.selectedIndex].value*1;
  
  CurrMonth      = curMonth*1;
  CurrYear       = curYear*1;
  chkInYearInd   = document.frm1.cmbCheckInYear.selectedIndex*1;
  chkOutYearInd  = document.frm1.cmbCheckOutYear.selectedIndex*1;
  tempChkInYear  = document.frm1.cmbCheckInYear.options[chkInYearInd].value*1;
  
  if(((chkOutMonth<CurrMonth) || (chkInMonth<CurrMonth)) && (CurrYear==tempChkInYear)){
      document.frm1.cmbCheckInYear.selectedIndex = chkInYearInd+1;
      document.frm1.cmbCheckOutYear.selectedIndex = chkOutYearInd+1;
  }
}

function setUserPass(){ 
document.frm1.userName.value=userName;
//document.frm1.passWord.value=passWord;
document.frm1.userType.value=userType;
alert('document.frm1.userName.value '+document.frm1.userName.value);
alert('document.frm1.passWord.value '+document.frm1.passWord.value);

alert('document.frm1.userType.value '+document.frm1.userType.value);
} 

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 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(Number(inyy)+a,Number(inyy)+a);
}
cmbCheckOutYear.options[a]= new Option(Number(inyy)+a,Number(inyy)+a);
}
}

with (document.frm1){
cmbNoOfAdults.selectedIndex=1;
cmbCheckInMonth.selectedIndex		=	Number(inmm);
cmbCheckInYear.selectedIndex			= Number(inyy)-Number(inyy);
cmbCheckOutMonth.selectedIndex	= Number(outmm);
cmbCheckOutYear.selectedIndex		= Number(outyy)-Number(inyy);
cmbNoOfNights.selectedIndex				=	1;
}
setMonthDays("In");
setMonthDays("Out");
document.frm1.cmbCheckInDate.selectedIndex			= Number(indd)-1;
document.frm1.cmbCheckOutDate.selectedIndex		= Number(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);
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())-inyy;
document.frm1.cmbCheckOutYear.selectedIndex = ((nav=="Netscape")? tmpOutDate.getYear()+1900:tmpOutDate.getYear())-baseyear;
setMonthDays("Out");
document.frm1.cmbCheckOutDate.selectedIndex		= tmpOutDate.getDate()-1;
}


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;
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);
}
newlnth= document.frm1.elements["cmbCheck"+name+"Date"].options.length;
if (newlnth<selectedInd+1){
newlnth= document.frm1.elements["cmbCheck"+name+"Date"].selectedIndex=newlnth-1;
}else{
document.frm1.elements["cmbCheck"+name+"Date"].selectedIndex=selectedInd;
}
}

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 = 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;
}

document.frm1.selCity.value="%";
document.frm1.action = ""+servletURL+""+resAgentName+".ResevationSearch_tmp";
document.frm1.txtcity.value=document.frm1.cmbCity.options[document.frm1.cmbCity.selectedIndex].text;
op_win();
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 nav=navigator.appName;
var uag=navigator.userAgent;
var Br="IE";
if (nav=="Netscape"){
Br="NS";
}

function getreferrer(){
	if(document.referrer){
	return ""+escape(document.referrer)+"";
	}else{
	return "";
	}
}
var mUrl ="http://"+StrDom+":7001/servlet/HDMC.ReservationLookUp?menu=top&language=en&country=US&browser="+Br+"&afftCode=RA&referer=";

function loadEngine(id){
if (id==""){
tmp_url=mUrl+getreferrer();
}else{
tmp_url=mUrlH+getreferrer()+"&hotelCode="+id
}

if (nav.indexOf("Microsoft")!=-1){
lyrObj = document.getElementById("ExchangeFrame")
document.frames[0].location.replace(tmp_url);
}else if (nav.indexOf("Netscape")!=-1){ 
if(uag.indexOf("Netscape/7")!=-1){
lyrObj = document.getElementById("ExchangeFrame")
lyrObj.style.height=parseInt(lyrObj.style.height)+25;
lyrObj.src=tmp_url;
}else{
document.layers['ExchangeFrame'].src=tmp_url;
position();
}	   
}else{
lyrObj = document.getElementById("ExchangeFrame")
lyrObj.src=tmp_url;
} 
}
function position(){
document.layers["ExchangeFrame"].left=document.images["bookeng"].x+5
document.layers["ExchangeFrame"].top=document.images["bookeng"].y+5;
document.layers["ExchangeFrame"].visibility="show";
}
//--------------------------
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.getElementById("progress").style.left=parseInt(document.getElementById("progress").style.left)+toadd;
		document.getElementById("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_login(){

}


