var portalName="NRBHotels";
var servletUrl="http://nhrb-reservations.com/servlets/";
var logoUrl="http://www1.secure-reservation.com/" ;
var pageCentered="Y";
var progressBar="Y"
var progressLeft=242;
var progressTop=310;

var nav=navigator.appName;
var myindate = (new Date());
var myoutdate = new Date();
myindate = new Date(myindate.setDate(myindate.getDate()+1));
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 afflogoURL = logoUrl+portalName+"/AffiliateImages/en/";

function RG_set_default_date(){
document.RG_frm1.afftCode.value=RG_AFF_CODE;
document.RG_frm1.AffiliateMainPage.value=RG_AFF_MAIN_URL;
document.RG_frm1.linkFrm.value=RG_VEN_CODE;
if (document.RG_frm1.MultiCity.value=="N") {
document.RG_frm1.cmbCity.value=RG_CITY_CODE;
document.RG_frm1.hotelCode.value=RG_HOTEL_CODE;
} else {
RG_Cities();
}

//[ added by hisham(24-Feb-2004) to fix preselecting future year in the drop down issue ]
document.RG_frm1.elements["cmbCheckInYear"].options.length=0;
document.RG_frm1.elements["cmbCheckOutYear"].options.length=0;
for (var y=0; y< 5; y++){
 document.RG_frm1.elements["cmbCheckInYear"].options[document.RG_frm1.elements["cmbCheckInYear"].options.length] = new Option(inyy+y,inyy+y);
 document.RG_frm1.elements["cmbCheckOutYear"].options[document.RG_frm1.elements["cmbCheckOutYear"].options.length] = new Option(inyy+y,inyy+y);
}
//[ end of fixing preselecting future year issue ]

with (document.RG_frm1){
cmbCheckInMonth.selectedIndex		=	inmm;
cmbCheckInYear.selectedIndex			= inyy-inyy;
cmbCheckOutMonth.selectedIndex	= outmm;
cmbCheckOutYear.selectedIndex		= outyy-inyy;
cmbNoOfNights.selectedIndex				=	0;
}
document.images["inday"].src="RG_dd"+(myindate.getDay())+".gif";
document.images["outday"].src="RG_dd"+(myoutdate.getDay())+".gif";
setMonthDays("In");
setMonthDays("Out");
document.RG_frm1.cmbCheckInDate.selectedIndex			= indd-1;
document.RG_frm1.cmbCheckOutDate.selectedIndex		= outdd-1;
}

function setCheckOut(){
tmpInDate = new Date(document.RG_frm1.cmbCheckInYear.options[document.RG_frm1.cmbCheckInYear.selectedIndex].value,document.RG_frm1.cmbCheckInMonth.options[document.RG_frm1.cmbCheckInMonth.selectedIndex].value,document.RG_frm1.cmbCheckInDate.options[document.RG_frm1.cmbCheckInDate.selectedIndex].value,0,0,0,0);
document.images["inday"].src="RG_dd"+(tmpInDate.getDay())+".gif";
noDays = Number(document.RG_frm1.cmbNoOfNights.options[document.RG_frm1.cmbNoOfNights.selectedIndex].value);
tmpOutDate = new Date(tmpInDate.setDate(tmpInDate.getDate()+noDays));
document.RG_frm1.cmbCheckOutMonth.selectedIndex	= tmpOutDate.getMonth();
document.RG_frm1.cmbCheckOutYear.selectedIndex		= ((nav=="Netscape")? tmpOutDate.getYear()+1900:tmpOutDate.getYear())-inyy;
setMonthDays("Out");
document.RG_frm1.cmbCheckOutDate.selectedIndex		= tmpOutDate.getDate()-1;
document.images["outday"].src="RG_dd"+(tmpOutDate.getDay())+".gif";
}

function setNights(){
tmpInDate = new Date(document.RG_frm1.cmbCheckInYear.options[document.RG_frm1.cmbCheckInYear.selectedIndex].value,document.RG_frm1.cmbCheckInMonth.options[document.RG_frm1.cmbCheckInMonth.selectedIndex].value,document.RG_frm1.cmbCheckInDate.options[document.RG_frm1.cmbCheckInDate.selectedIndex].value,0,0,0,0);
tmpOutDate = new Date(document.RG_frm1.cmbCheckOutYear.options[document.RG_frm1.cmbCheckOutYear.selectedIndex].value,document.RG_frm1.cmbCheckOutMonth.options[document.RG_frm1.cmbCheckOutMonth.selectedIndex].value,document.RG_frm1.cmbCheckOutDate.options[document.RG_frm1.cmbCheckOutDate.selectedIndex].value,0,0,0,0);
dateDifference = get_deference(tmpInDate,tmpOutDate);
document.images["outday"].src="RG_dd"+(tmpOutDate.getDay())+".gif";
if (dateDifference<1 || dateDifference>15){
return;
}
document.RG_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.RG_frm1.elements["cmbCheck"+name+"Month"].options[document.RG_frm1.elements["cmbCheck"+name+"Month"].selectedIndex].value;
tmpyy	= document.RG_frm1.elements["cmbCheck"+name+"Year"].options[document.RG_frm1.elements["cmbCheck"+name+"Year"].selectedIndex].value;
maxdays = maxdate(tmpmm,tmpyy);
selectedInd=document.RG_frm1.elements["cmbCheck"+name+"Date"].selectedIndex; 
document.RG_frm1.elements["cmbCheck"+name+"Date"].options.length=28;
toAdd=maxdays-28;
for (a=0; a<toAdd; a++){
document.RG_frm1.elements["cmbCheck"+name+"Date"].options[document.RG_frm1.elements["cmbCheck"+name+"Date"].options.length] = new Option(29+a,29+a);
}
}

function RG_checkValues(){
tmpInDate = new Date(document.RG_frm1.cmbCheckInYear.options[document.RG_frm1.cmbCheckInYear.selectedIndex].value,document.RG_frm1.cmbCheckInMonth.options[document.RG_frm1.cmbCheckInMonth.selectedIndex].value,document.RG_frm1.cmbCheckInDate.options[document.RG_frm1.cmbCheckInDate.selectedIndex].value,0,0,0,0);
tmpOutDate = new Date(document.RG_frm1.cmbCheckOutYear.options[document.RG_frm1.cmbCheckOutYear.selectedIndex].value,document.RG_frm1.cmbCheckOutMonth.options[document.RG_frm1.cmbCheckOutMonth.selectedIndex].value,document.RG_frm1.cmbCheckOutDate.options[document.RG_frm1.cmbCheckOutDate.selectedIndex].value,0,0,0,0);
dateDifference = get_deference(tmpInDate,tmpOutDate);
noNights = document.RG_frm1.cmbNoOfNights.options[document.RG_frm1.cmbNoOfNights.selectedIndex].value;
today = new Date();

today2 = new Date(today.getFullYear(),today.getMonth(),today.getDate(),0,0,0,0);
if ((tmpInDate-today2)<(86400000)){
alert("Because your arrival date is within 24 hours, please call our reservation desk on 18002171503 and a sales agent will assist you");
RG_set_default_date();
return;
}

if ((today-tmpInDate)>86400000){
alert("Check in date can not be less than the system date");
RG_set_default_date();
return;
}
if (noNights!=dateDifference){
alert("Number of nights cannot be greater than "+document.RG_frm1.cmbNoOfNights.options.length+" days ");
RG_set_default_date();
return;
}
noOfRooms = document.RG_frm1.cmbNoOfRooms.selectedIndex+1;
noOfAdults = document.RG_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 (document.RG_frm1.MultiCity.value=="Y") {
if (document.RG_frm1.cmbCity.selectedIndex==0){
alert("Please Select a City");
return;
}else{
document.RG_frm1.selCity.value = document.RG_frm1.cmbCity.options[document.RG_frm1.cmbCity.selectedIndex].value;
}
}


if (progressBar=="Y"){
op_win();
}
document.RG_frm1.action = servletUrl+portalName+".ResevationSearch";
document.RG_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 && pageCentered=="Y"){
toadd = (sWith-800)/2;
}

function op_win(){
if (nav=="Netscape"){
if (navigator.userAgent.indexOf("Netscape/7")>-1){
document.getElementById("progress").style.left=progressLeft+toadd;
document.getElementById("progress").style.top=progressTop;
document.getElementById("progress").style.visibility="visible";
}else{
document.layers["progress"].left=progressLeft+toadd;
document.layers["progress"].top=progressTop+toadd;
document.layers["progress"].visibility="show";
}
}else{
document.all["progress"].style.left=progressLeft+toadd;
document.all["progress"].style.top=progressTop;
document.all["progress"].style.visibility="visible";
}
}

function hide_progress(){
if (progressBar!="Y"){
return;
}
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";
}
}

var top_loc=""+document.location+"";
var top_str=top_loc.substring(top_loc.indexOf(".html?")+6,top_loc.length);
var value_arr = top_str.split("&");

function get_logo(){
		if (top_loc.indexOf(".html?")==-1){
		return;
		}else{
		document.images["RG_afflogo"].src=""+afflogoURL+""+value_arr[0]+"";
		document.bgColor="#"+value_arr[1]+"";
		}
}

function goHome(){
top.location=""+value_arr[4]+"";
}

if (navigator.appName=="Netscape" && navigator.userAgent.indexOf("Netscape/7")==-1){
tmpstr="<layer name=\"progress\" visibility=\"hide\" top=\""+progressTop+"\" left=\""+progressLeft+"\">";
}else{
tmpstr="<div id=\"progress\" style=\"position:absolute; left:"+progressLeft+"px; top:"+progressTop+"px; width:220px; height:92px; z-index:1; visibility: hidden;\">";
}
tmpstr=tmpstr+"<table width=\"220\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"#19417B\">"+
"<tr>"+
"<td><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">"+
"<tr>"+
"<td><table width=\"200\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">"+
"<tr>"+
"<td><img src=\"RG_space.gif\" width=\"1\" height=\"1\"></td>"+
"</tr>"+
"<tr>"+
"<td class=\"RG_divtxt\">";
if (navigator.appName=="Netscape" && navigator.userAgent.indexOf("Netscape/7")==-1){
tmpstr=tmpstr+"Please wait one moment ...";
}else if (navigator.appName=="Netscape" && navigator.userAgent.indexOf("Netscape/7")>-1){
tmpstr=tmpstr+"<blink><span class=\"RG_divtxt\">Please wait one moment ...&nbsp;&nbsp;&nbsp;</span></blink>";
}else{
tmpstr=tmpstr+"<blink><div id=\"progress1\" class=\"RG_divstyle\"><marquee align=\"middle\" behavior=\"alternate\" scrollamount=\"400\" scrolldelay=\"180\" width=\"400\"><span class=\"RG_divtxt\">Please wait one moment ...&nbsp;&nbsp;&nbsp;</span></marquee></div></blink>";
}


tmpstr=tmpstr+"</td>"+
"</tr>"+
"<tr>"+
"<td class=\"RG_engtext1\">We are checking and retrieving hotel rates and availability</td>"+
"</tr>"+
"<tr>"+
"<td><img src=\"RG_space.gif\" width=\"1\" height=\"1\"></td>"+
"</tr>"+
"</table></td>"+
"</tr>"+
"</table></td>"+
"</tr>"+
"</table>";


if (navigator.appName=="Netscape" && navigator.userAgent.indexOf("Netscape/7")==-1){
tmpstr=tmpstr+"</layer>";
}else{
tmpstr=tmpstr+"</div>";
}
if (progressBar=="Y"){
document.write(tmpstr);
}
