var portalName="ACCentral";
var servletUrl="http://web1.secure-reservation.com/servlets/";
var logoUrl="http://web1.secure-reservation.com/html/" ;
var afflogoURL = logoUrl+portalName+"/AffiliateImages/en/";
var pageCentered="Y";
var progressBar="Y"
var progressLeft=280;
var progressTop=310;
var nav=navigator.appName;
var myindate = new Date();
var myoutdate = new Date();
myoutdate = new Date(myoutdate.setDate(myoutdate.getDate()+1));
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 dayimagepath="images";
var nav=navigator.appName;
var uag=navigator.userAgent;
var brow="";
if (uag.indexOf("Netscape/7")>-1){
brow="NS7";
}else if (uag.indexOf("Firefox")>-1){
brow="Firefox";
}else if (uag.indexOf("Opera")>-1){
brow="Opera";
}else{
brow="IE";
}

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]+"";
}



function set_default_date(){
 
 document.RG_frm1.afftCode.value=RG_AFF_CODE;
 
 if (document.RG_frm1.MultiCity.value=="N") {
   document.RG_frm1.cmbCity.value=RG_CITY_CODE;
  } else {
  RG_Cities();
}

 

 document.RG_frm1.cmbCheckInYear.options.length=0;
 for (a=0; a<5; a++){
	with (document.RG_frm1){
	yr1=inyy+a;
	yr2=yr1.toString();
	cmbCheckInYear.options[a]= new Option(inyy+a,inyy+a);
 }
}


with (document.RG_frm1){
	cmbNoOfAdults.selectedIndex=1;
	cmbCheckInMonth.selectedIndex		=	inmm;
	cmbCheckInYear.selectedIndex			= inyy-inyy;
	cmbCheckOutMonth.value	= outmm;
	cmbCheckOutYear.value		= outyy;
	cmbNoOfNights.selectedIndex				=	0;
}
document.images["inday"].src="RG_dd"+(myindate.getDay())+".gif";
setMonthDays("In");
document.RG_frm1.cmbCheckInDate.selectedIndex			= indd-1;
if (Number(outdd)<10){
 document.RG_frm1.cmbCheckOutDate.value		= "0"+outdd+"";
}else{
 document.RG_frm1.cmbCheckOutDate.value		= outdd;
}
}

function LoadCal(DateType,monthField,dayField,yearField,formName){
 dayval  = Number(document.forms[formName].elements[dayField].options[document.forms[formName].elements[dayField].selectedIndex].value);
 monthval= Number(document.forms[formName].elements[monthField].options[document.forms[formName].elements[monthField].selectedIndex].value);
 yearval = Number(document.forms[formName].elements[yearField].options[document.forms[formName].elements[yearField].selectedIndex].value);
 window.open("loadDatesIndex.asp?DateType="+DateType+"&formName="+formName+"&DayField="+dayField+"&day="+dayval+"&MonthField="+monthField+"&month="+(Number(monthval)+1)+"&YearField="+yearField+"&year="+yearval+"","calwin","width=235,height=190,top=280,left=100,location=0,status=0");
}

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.value	= tmpOutDate.getMonth();
 document.RG_frm1.cmbCheckOutYear.value		= tmpOutDate.getFullYear();
 if (Number(tmpOutDate.getDate())<10){
  document.RG_frm1.cmbCheckOutDate.value		= "0"+tmpOutDate.getDate()+"";
 }else{
  document.RG_frm1.cmbCheckOutDate.value		= tmpOutDate.getDate();
 }
}

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.value,document.RG_frm1.cmbCheckOutMonth.value,document.RG_frm1.cmbCheckOutDate.value,0,0,0,0);
 dateDifference = get_deference(tmpInDate,tmpOutDate);
 if (dateDifference<1 || dateDifference>15){
  return;
 }
 if (dateDifference>0){
 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); 
 }
 new_lnth=document.RG_frm1.elements["cmbCheck"+name+"Date"].options.length;
 if (new_lnth<selectedInd+1){
  document.RG_frm1.elements["cmbCheck"+name+"Date"].selectedIndex=document.RG_frm1.elements["cmbCheck"+name+"Date"].options.length-1;
 }else{
  document.RG_frm1.elements["cmbCheck"+name+"Date"].selectedIndex=selectedInd; 
 }
}


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.value,document.RG_frm1.cmbCheckOutMonth.value,document.RG_frm1.cmbCheckOutDate.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();
  if ((today-tmpInDate)>86400000){
   alert("Check in date can not be less than the system date");
   set_default_date();
  return;
 }

 if (dateDifference>15 || dateDifference<1){
  alert("Number of night(s) can not be grater than "+document.RG_frm1.cmbNoOfNights.options.length+" or less than 1.\r\nPlease select again ...");
  set_default_date();
  return;
 }else{
  document.RG_frm1.cmbNoOfNights.selectedIndex=dateDifference-1;
 }

 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;
}
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;
}

function showCal(img){
	
	document.getElementById("calWin").style.left=getPos("left",img)+30;
	document.getElementById("calWin").style.top=getPos("top",img);
	document.getElementById("calWin").style.width="190px";
	document.getElementById("calWin").style.height="230px";
	document.getElementById("calWin").style.visibility="visible";
	
}

function getPos(val,img){
posObj=document.images[img];
var temp_pos=0;
if (brow=="NS7"){
if (val=="top"){temp_pos=document.images[img].y;}else{
	temp_pos=document.images[img].x;}
}else{
	while(posObj.tagName!='BODY'){
		if (val=="top"){temp_pos+=posObj.offsetTop;}else{
		temp_pos+=posObj.offsetLeft;}
		posObj=posObj.offsetParent;
		}
	}
return temp_pos;
}