

bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
bVersion = parseFloat(navigator.appVersion);
Id = "undefined"

function Rates(ID){
  document.location = "http://www.ihsadvantage.com/h/hotelAvailAll.do?hotelID=" + ID + "&pfs=3355&spfs=0&city=" + document.hotelSearchCriteriaForm.city.value + "&state=" + document.hotelSearchCriteriaForm.state.value + "&country=US&arrivalMonth=" + document.hotelSearchCriteriaForm.arrivalMonth.value + "&arrivalDay=" + document.hotelSearchCriteriaForm.arrivalDay.value + "&departureMonth=" + document.hotelSearchCriteriaForm.departureMonth.value + "&departureDay=" + document.hotelSearchCriteriaForm.departureDay.value + "&adults=" + document.hotelSearchCriteriaForm.adults.value + "&children=" + document.hotelSearchCriteriaForm.children.value
}

function Photos(ID){
  document.location = "http://www.ihsadvantage.com/h/hotelinfo/" + document.hotelSearchCriteriaForm.city.value + "/" + document.hotelSearchCriteriaForm.state.value + "/us/" + ID + "/?showAvailWithList=false&pfs=3355&arrivalMonth=" + document.hotelSearchCriteriaForm.arrivalMonth.value + "&arrivalDay=" + document.hotelSearchCriteriaForm.arrivalDay.value + "&departureMonth=" + document.hotelSearchCriteriaForm.departureMonth.value + "&departureDay=" + document.hotelSearchCriteriaForm.departureDay.value + "&adults=" + document.hotelSearchCriteriaForm.adults.value + "&children=" + document.hotelSearchCriteriaForm.children.value + "#photos"
}

function AllRates(){
  document.location = "http://www.ihsadvantage.com/h/hotelAvail.do?showAvailWithList=true&chainCode=" + document.hotelSearchCriteriaForm.chainCode.value + "&pfs=3355&spfs=0&city=" + document.hotelSearchCriteriaForm.city.value + "&state=" + document.hotelSearchCriteriaForm.state.value + "&country=US&arrivalMonth=" + document.hotelSearchCriteriaForm.arrivalMonth.value + "&arrivalDay=" + document.hotelSearchCriteriaForm.arrivalDay.value + "&departureMonth=" + document.hotelSearchCriteriaForm.departureMonth.value + "&departureDay=" + document.hotelSearchCriteriaForm.departureDay.value + "&adults=" + document.hotelSearchCriteriaForm.adults.value + "&children=" + document.hotelSearchCriteriaForm.children.value 
}


function PopUpPt(Label, Lat, Lon) {

	FrameWidth = 380
	FrameHeight= 350
	
	if ( bVer < 4 ) {
	    alert("Sorry, you will need to update your browser to a newer version to view this technology");
	    newwin=window.open("http://www.I-Maps.com/UpdateBrowser.htm", "newwindow", "width=478,height=333,top=170,left=162,location=no,dependent=no,resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,status=yes,directories=no");
	    newwin.focus();
	}
	
	var SLabel = "", flag = 0;
		for (i = 0; i < Label.length; i++) {
			if (Label.charAt(i) != "&") {
				SLabel += Label.charAt(i);
				flag = 0;
			}
			else {
				if(flag == 0) {
					SLabel += "@";
					flag = 1;
				}
			}
	}  
	
	if ( bName == "Microsoft Internet Explorer" ) {
		MapImage = "png"
	 	newmap=window.open("http://www.i-maps.com/IHSAdvantage/PopUpMap_frames.asp?cmd=PopUpPt&W=360&H=300&MC=Tan&Color=ffffff&BC=Silver&Lat=" +Lat+ "&Lon=" +Lon+ "&Label=" +SLabel, "mapwindow", "width=" + FrameWidth + ",height=" + FrameHeight + ",top=120,left=200,location=no,dependent=no,resizable=no,scrollbars=no,toolbar=no,menubar=no,status=no,directories=no");
 		newmap.resizeTo(FrameWidth+10, FrameHeight+30)
 		newmap.focus();
  }
  
	else {
		if (bName == "Netscape" ) {
	  	MapImage = "png"
  	 	newmap=window.open("http://www.i-maps.com/IHSAdvantage/PopUpMap_frames.asp?cmd=PopUpPt&W=360&H=300&MC=Tan&Color=ffffff&BC=Silver&Lat=" +Lat+ "&Lon=" +Lon+ "&Label=" +SLabel, "mapwindow", "width=" + FrameWidth + ",height=" + FrameHeight + ",top=120,left=200,location=no,dependent=no,resizable=no,scrollbars=no,toolbar=no,menubar=no,status=no,directories=no");
			newmap.resizeTo(FrameWidth+6, FrameHeight+26),
 			newmap.focus();
		}
	}
}
  
function setdate(){
	thisForm = document.hotelSearchCriteriaForm;
	if ( thisForm != null ) {
		var now = new Date();
		var checkinDate = new Date(now.getTime() + (14 * 24*60*60*1000));
		var checkoutDate = new Date(now.getTime() + (16 * 24*60*60*1000));
		thisForm.arrivalMonth.options[checkinDate.getMonth()].selected = true;
		thisForm.departureMonth.options[checkoutDate.getMonth()].selected = true;
		thisForm.arrivalDay.options[checkinDate.getDate()-1].selected = true;
		thisForm.departureDay.options[checkoutDate.getDate()-1].selected = true;
	}
}


function isBrowserSupp() {
    version =  parseFloat( navigator.appVersion );
	if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {
        return false;
    }
    else {
    	return true;
    }
	return true;
}

function isLeapYear(yrStr) {
	var leapYear=false;
	var year = parseInt(yrStr, 10);
	if (year%4 == 0) {
	    leapYear=true;
    	if (year%100 == 0) {
	        leapYear=false;
        	if (year%400 == 0) {
	            leapYear=true;
            }
        }
    }
	return leapYear;

}






function getDaysInMonth(mthIdx, YrStr) {
	var maxDays=31
	if (mthIdx==1) {
	    if (isLeapYear(YrStr)) {
	        maxDays=29;
        }
    	else {
	        maxDays=28;
        }
    }
	if (mthIdx==3 || mthIdx==5 || mthIdx==8 || mthIdx==10) {
	    maxDays=30;
    }
	return maxDays;
}

function adjustDate(mthIdx, Dt) {
	var value=0;
	var today = new Date()
	var theYear = parseInt(today.getYear(),10)
	if (mthIdx < today.getMonth()) {
    	theYear = (parseInt(today.getYear(), 10) + 1)
	}
	if(theYear<100){
    	theYear = "19" + theYear
	}
	else {
    	if((theYear-100) < 10) {
        	theYear = "0" + (theYear-100)
    	}
    	else{
        	theYear = (theYear-100)+""
    	}
    	theYear = "20" + theYear
	}
	var numDays=getDaysInMonth(mthIdx, theYear);
	if (mthIdx==1) {
	    if (Dt.options.selectedIndex + 1 < numDays) {
	        return 0;
        }
    	else {
        	Dt.options.selectedIndex=numDays - 1;
        	if (numDays==29) {
	            return 99;
            }
        	else {
            	return 1;
            }
        }
    }
	if (Dt.options.selectedIndex + 1 < numDays) {
    	value=0;
    }
	else {
    	if (Dt.options.selectedIndex + 1 > numDays) {
	        Dt.options.selectedIndex ;
       	 	value=3;
        }
    	else {
        	value=2;
        }
    }
	return value;
}

function dateChange(inM,inD,outM,outD) {
    if (!isBrowserSupp()) {
    	return;
    }
	var res = adjustDate(inM.options.selectedIndex, inD);
	if (res != 0) {
		outD.options.selectedIndex=0;
        if (outM.options.selectedIndex==11){
        	outM.options.selectedIndex=0
		}
        else {
			outM.options.selectedIndex=inM.options.selectedIndex + 1;
        }
    } 
    else {
    	outM.options.selectedIndex = inM.options.selectedIndex;
    	outD.options.selectedIndex = inD.options.selectedIndex+2;
    }
	return ;
}

function dmddChange(outM,outD) {
    if (!isBrowserSupp()) {
	    return;
    }
	adjustDate(outM.options.selectedIndex,outD);
	return;
}
