var portalName="ACEGroup";
var servletUrl="http://www2.secure-reservation.com/servlet/";
var logoUrl="http://www2.secure-reservation.com/html/" ;
var pageCentered="Y";
var progressBar="Y"
var progressLeft=280;
var progressTop=310;

var nav=navigator.appName;
var uag=navigator.userAgent;
var myindate = new Date();
var myoutdate = new Date();

var MySetInDate = new Date();
var MySetOutDate = 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(){

//alert('comes to Func R_s_d_date()');

document.RGfrm1.cmbCheckInYear.options.length=0;
document.RGfrm1.cmbCheckOutYear.options.length=0;

for (a=0; a<5; a++){
		with (document.RGfrm1){
		if (a!=4){
		cmbCheckInYear.options[a]= new Option(inyy+a,inyy+a);
		}
		cmbCheckOutYear.options[a]= new Option(inyy+a,inyy+a);
	}
}

//alert('after loop');

document.RGfrm1.afftCode.value=RG_AFF_CODE;
document.RGfrm1.eventId.value=RG_EVENT_ID;
document.RGfrm1.AffiliateMainPage.value=RG_AFF_MAIN_URL;

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){

inmm =Number(RG_INMM)-1; 
indd =Number(RG_INDD);
outmm=Number(RG_OUTMM)-1;
outdd=Number(RG_INDD)+1;

outyy=Number(RG_OUTYY);
//inyy =Number(RG_INYY);

//alert('inmm >'+inmm);
//alert('indd >'+indd);
//alert('inyy >'+inyy);
//alert('outyy >'+outyy);
//alert('outdd>'+outdd);
//alert('outmm>'+outmm);

cmbCheckInMonth.selectedIndex		= inmm;
cmbCheckInYear.selectedIndex        = outyy-inyy;
//alert('inyy set >'+inyy);
//alert('cmbCheckInYear>'+cmbCheckInYear.selectedIndex);

cmbCheckOutMonth.selectedIndex	    = outmm;
cmbCheckOutYear.selectedIndex       = outyy-inyy;
//alert('outyy set >'+outyy);
//alert('cmbCheckOutYear>'+cmbCheckOutYear.selectedIndex);
cmbNoOfNights.selectedIndex			=0;

}


//document.images["inday"].src ="RG_dd"+(myindate.getDay())+".gif";
//document.images["outday"].src="RG_dd"+(myoutdate.getDay())+".gif";


//------------------------------------

MySetInDate = new Date(inyy,inmm,indd,0,0,0,0)
MySetOutDate= new Date(outyy,outmm,outdd,0,0,0,0)

//------------------------------------

document.images["inday"].src ="RG_dd"+(MySetInDate.getDay())+".gif";
document.images["outday"].src="RG_dd"+(MySetOutDate.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()-inyy;
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);

//alert('tempIn>'+tmpInDate.getDay());
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 1-888-609-347-9000 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"){
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(){
	document.getElementById("progress").style.left=progressLeft+toadd;
	document.getElementById("progress").style.top=progressTop;
	document.getElementById("progress").style.visibility="visible";
}


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.bgColor="#"+value_arr[1]+"";
		}
}
function goHome(){
top.location=""+value_arr[4]+"";
}

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 (uag.indexOf("Firefox")>-1){
tmpstr=tmpstr+"<blink><span class=\"RG_divtxt\">Please wait one moment ...&nbsp;&nbsp;&nbsp;</span></blink>";
}else if (uag.indexOf("Safari")>-1){
tmpstr=tmpstr+"<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>";
}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>";
tmpstr=tmpstr+"</div>";

if (progressBar=="Y"){
document.write(tmpstr);
}