var portalName="IVac";
var servletUrl="http://www4.secure-reservation.com/servlet/";
var logoUrl="http://www4.secure-reservation.com/html/" ;
var pageCentered="Y";
var progressBar="Y"
var progressLeft=280;
var progressTop=310;
var myToday=new Date();
var currentYY=myToday.getFullYear();

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 	= myindate.getFullYear();
var outmm = myoutdate.getMonth();
var outdd = myoutdate.getDate();
var outyy = myoutdate.getFullYear();
var afflogoURL = logoUrl+portalName+"/AffiliateImages/en/";

function RG_set_default_date(){
document.RGfrm1.afftCode.value=RG_AFF_CODE;
document.RGfrm1.AffiliateMainPage.value=RG_AFF_MAIN_URL;
assignHotelFilterBy();
if (document.RGfrm1.MultiCity.value=="N") {
document.RGfrm1.cmbCity.value=RG_CITY_CODE;
document.RGfrm1.hotelCode.value=RG_HOTEL_CODE;
} else {
RG_Cities();
}

with (document.RGfrm1){


cmbCheckInYear.options.length=0;
cmbCheckOutYear.options.length=0;
for (var rt=0; rt<5; rt++){
//if (rt!=4){//commented bandu 10_april
cmbCheckInYear.options[rt]=new Option(myToday.getFullYear()+rt,myToday.getFullYear()+rt);
//}
cmbCheckOutYear.options[rt]=new Option(myToday.getFullYear()+rt,myToday.getFullYear()+rt);
}



cmbCheckInMonth.selectedIndex		=	inmm;
cmbCheckInYear.selectedIndex			= inyy-currentYY;
cmbCheckOutMonth.selectedIndex	= outmm;
cmbCheckOutYear.selectedIndex		= outyy-currentYY;
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.RGfrm1.cmbCheckInDate.selectedIndex			= indd-1;
document.RGfrm1.cmbCheckOutDate.selectedIndex		= outdd-1;
}

function setCheckOut(){
tmpInDate = new Date(document.RGfrm1.cmbCheckInYear.options[document.RGfrm1.cmbCheckInYear.selectedIndex].value,document.RGfrm1.cmbCheckInMonth.options[document.RGfrm1.cmbCheckInMonth.selectedIndex].value,document.RGfrm1.cmbCheckInDate.options[document.RGfrm1.cmbCheckInDate.selectedIndex].value,0,0,0,0);
document.images["inday"].src="RG_dd"+(tmpInDate.getDay())+".gif";
noDays = Number(document.RGfrm1.cmbNoOfNights.options[document.RGfrm1.cmbNoOfNights.selectedIndex].value);
tmpOutDate = new Date(tmpInDate.setDate(tmpInDate.getDate()+noDays));
document.RGfrm1.cmbCheckOutMonth.selectedIndex	= tmpOutDate.getMonth();
document.RGfrm1.cmbCheckOutYear.selectedIndex		= tmpOutDate.getFullYear()-currentYY;
setMonthDays("Out");
document.RGfrm1.cmbCheckOutDate.selectedIndex		= tmpOutDate.getDate()-1;
document.images["outday"].src="RG_dd"+(tmpOutDate.getDay())+".gif";
}

function setNights(){
tmpInDate = new Date(document.RGfrm1.cmbCheckInYear.options[document.RGfrm1.cmbCheckInYear.selectedIndex].value,document.RGfrm1.cmbCheckInMonth.options[document.RGfrm1.cmbCheckInMonth.selectedIndex].value,document.RGfrm1.cmbCheckInDate.options[document.RGfrm1.cmbCheckInDate.selectedIndex].value,0,0,0,0);
tmpOutDate = new Date(document.RGfrm1.cmbCheckOutYear.options[document.RGfrm1.cmbCheckOutYear.selectedIndex].value,document.RGfrm1.cmbCheckOutMonth.options[document.RGfrm1.cmbCheckOutMonth.selectedIndex].value,document.RGfrm1.cmbCheckOutDate.options[document.RGfrm1.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.RGfrm1.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.RGfrm1.elements["cmbCheck"+name+"Month"].options[document.RGfrm1.elements["cmbCheck"+name+"Month"].selectedIndex].value;
tmpyy	= document.RGfrm1.elements["cmbCheck"+name+"Year"].options[document.RGfrm1.elements["cmbCheck"+name+"Year"].selectedIndex].value;
maxdays = maxdate(tmpmm,tmpyy);
selectedInd=document.RGfrm1.elements["cmbCheck"+name+"Date"].selectedIndex; 
document.RGfrm1.elements["cmbCheck"+name+"Date"].options.length=28;
toAdd=maxdays-28;
for (a=0; a<toAdd; a++){
document.RGfrm1.elements["cmbCheck"+name+"Date"].options[document.RGfrm1.elements["cmbCheck"+name+"Date"].options.length] = new Option(29+a,29+a);
}
new_lnth=document.RGfrm1.elements["cmbCheck"+name+"Date"].options.length;
if (new_lnth<selectedInd+1){
document.RGfrm1.elements["cmbCheck"+name+"Date"].selectedIndex=document.RGfrm1.elements["cmbCheck"+name+"Date"].options.length-1;
}else{
document.RGfrm1.elements["cmbCheck"+name+"Date"].selectedIndex=selectedInd;
}
}

function RG_checkValues(){
tmpInDate = new Date(document.RGfrm1.cmbCheckInYear.options[document.RGfrm1.cmbCheckInYear.selectedIndex].value,document.RGfrm1.cmbCheckInMonth.options[document.RGfrm1.cmbCheckInMonth.selectedIndex].value,document.RGfrm1.cmbCheckInDate.options[document.RGfrm1.cmbCheckInDate.selectedIndex].value,0,0,0,0);
tmpOutDate = new Date(document.RGfrm1.cmbCheckOutYear.options[document.RGfrm1.cmbCheckOutYear.selectedIndex].value,document.RGfrm1.cmbCheckOutMonth.options[document.RGfrm1.cmbCheckOutMonth.selectedIndex].value,document.RGfrm1.cmbCheckOutDate.options[document.RGfrm1.cmbCheckOutDate.selectedIndex].value,0,0,0,0);
dateDifference = get_deference(tmpInDate,tmpOutDate);
noNights = document.RGfrm1.cmbNoOfNights.options[document.RGfrm1.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.RGfrm1.cmbNoOfNights.options.length+" days ");
RG_set_default_date();
return;
}
noOfRooms = document.RGfrm1.cmbNoOfRooms.selectedIndex+1;
noOfAdults = document.RGfrm1.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.RGfrm1.MultiCity.value=="Y") {
if (document.RGfrm1.cmbCity.selectedIndex==0){
alert("Please Select a City");
return;
}else{
document.RGfrm1.selCity.value = document.RGfrm1.cmbCity.options[document.RGfrm1.cmbCity.selectedIndex].value;
}
}


if (progressBar=="Y" && navigator.userAgent.indexOf("Firefox")==-1){
op_win();
}
document.RGfrm1.action = servletUrl+portalName+".ResevationSearch";
document.RGfrm1.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 assignHotelFilterBy(){
 var v='ALL',v2='-';
 document.RGfrm1.hotelFilterBy.value=RG_HOTEL_FILTER_BY;
 document.RGfrm1.hotelRoomTypeCode.value=RG_HOTEL_ROOM_CODE;
 document.RGfrm1.hotelBedTypeCode.value=RG_HOTEL_BED_CODE;
 document.RGfrm1.hotelRateplanCode.value=RG_HOTEL_RPLAN_CODE;
 document.RGfrm1.RG_package.value=RG_PACKAGE;
 
 for (var i=0;i< value_arr.length;i++){
  v=value_arr[i];
  if(v=='ROOM' || v=='BED' || v=='RPLAN' || v=='PKG' ){
   v2=value_arr[i+1];   
   if(v!='PKG') document.RGfrm1.hotelFilterBy.value=v ;
   if(v=='ROOM'){ document.RGfrm1.hotelRoomTypeCode.value=v2;
   }else if(v=='BED'){ document.RGfrm1.hotelBedTypeCode.value=v2;
   }else if(v=='RPLAN'){ document.RGfrm1.hotelRateplanCode.value=v2;   
   }else if(v=='PKG'){ document.RGfrm1.RG_package.value=v2;   
   }
  }
   // alert(value_arr[i]);
 }
}

function getPackage(){
 var v='',v2=RG_PACKAGE; 
 for (var i=0;i<value_arr.length;i++){
  v=value_arr[i];
  if(v=='PKG'){   
   v2=value_arr[i+1];         
  }    
 }
 return v2;
}


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=\"#FF0000\">"+
"<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 program 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" && navigator.userAgent.indexOf("Firefox")==-1){
document.write(tmpstr);
}
