var MapScriptManager={isScriptLoaded:false,scriptUrl:"http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2",callback:null,tryCount:0,infoBoxWidth:320,getScript:function(callback,mapObj){$.getScript(MapScriptManager.scriptUrl,function(){MapScriptManager.isScriptLoaded=true;if(callback&&mapObj){MapScriptManager.callback=callback.bind(mapObj);window.setTimeout("MapScriptManager.invokeCallBack()",500)}$(document.body).append("<style type='text/css'>.ero .ero-body { width:"+MapScriptManager.infoBoxWidth+"px; }</style>")})},invokeCallBack:function(){if(MapScriptManager.tryCount>5||MapScriptManager.callback==null){alert("Virtual Earth Map is temporarily unavailable.");return }MapScriptManager.tryCount++;if(L_invaliddirections_text){MapScriptManager.callback()}else{window.setTimeout("MapScriptManager.invokeCallBack()",500)}}};var MapResizer={resize:function(mapObj,divId){var mapW=0,mapH=0;var mapDiv=document.getElementById(divId);var mapDivOffset=document.cumulativeOffset(mapDiv);var dimensions=document.viewport.getDimensions();mapW=dimensions.width;if(mapW<500){mapW=500}mapH=dimensions.height-mapDivOffset.top;if(mapH<400){mapH=400}mapDiv.style.width=mapW+"px";mapDiv.style.height=mapH+"px";mapObj.map.Resize(mapW,mapH);return }};function NycVEMap(mc,lat,lon,zm,ppt,ppd,rhId,dbSize){this.map=null;this.mapContainer=mc;this.pinID=1;this.latitude=lat;this.longitude=lon;this.zoom=zm;this.pPTitle=ppt;this.pPDesc=ppd;this.routeHolderId=rhId;this.locsInMap=new Array();this.hasMapInit=false;this.shapesInMap=new Array();this.dashboardSize=dbSize;this.setMapContainer=function(mapContainer){this.mapContainer=mapContainer};this.setLatitude=function(latitude){this.latitude=latitude};this.setLongitude=function(longitude){this.longitude=longitude};this.setZoom=function(zoom){this.zoom=zoom};this.setPPTitle=function(pPTitle){this.pPTitle=pPTitle};this.setPPDesc=function(pPDesc){this.pPDesc=pPDesc};this.setRouteHolderId=function(rHId){this.routeHolderId=rHId};this.setDashboardSize=function(dbSize){this.dashboardSize=dbSize};this.getBrowserScrollBottom=function(){var scrollTop=document.body.scrollTop;if(scrollTop==0){if(window.pageYOffset){scrollTop=window.pageYOffset}else{scrollTop=(document.body.parentElement)?document.body.parentElement.scrollTop:0}}var winH=window.innerHeight;if(winH==null||winH=="undefined"){winH=document.body.clientHeight}var scrollBottom=winH+scrollTop;return scrollBottom};this.getMapScrollTop=function(){var me=this;return document.getElementById(me.mapContainer).offsetTop};this.onscrollGetMap=function(callback){var me=this;if(me.hasMapInit){return }var scrollBottom=me.getBrowserScrollBottom();var mapScrollTop=me.getMapScrollTop();if(mapScrollTop<=scrollBottom){me.getMap(callback)}};this.getMap=function(callback){var me=this;if(MapScriptManager.isScriptLoaded){me._getMap(callback)}else{MapScriptManager.getScript(function(){me._getMap(callback)},me)}};this._getMap=function(callback){var me=this;document.getElementById(me.mapContainer).style.textAlign="left";me.map=new VEMap(me.mapContainer);if(me.dashboardSize==null){me.dashboardSize=VEDashboardSize.Normal}me.map.SetDashboardSize(me.dashboardSize);if(me.latitude==null||me.longitude==null||me.zoom==null){me.map.LoadMap(null,null,VEMapStyle.Road,false,VEMapMode.Mode2D,true);if(me.zoom!=null){me.map.SetZoomLevel(me.zoom)}}else{me.map.LoadMap(new VELatLong(me.latitude,me.longitude),me.zoom,VEMapStyle.Road,false,VEMapMode.Mode2D,true);if(me.pPTitle!=null&&me.pPDesc!=null){me.addPin(me.latitude,me.longitude,me.pPTitle,me.pPDesc,"","","","",me.getCustomIcon("veIconStar"))}}window.onunload=function(){me.map.Dispose()};me.hasMapInit=true;if(callback){callback()}};this.setShowDetail=function(isShown){VEPushpin.ShowDetailOnMouseOver=isShown};this.showControl=function(){this.map.ShowDashboard()};this.hideControl=function(){this.map.HideDashboard()};this.getNextPinID=function(){return this.pinID};this.addPin=function(lat,lng,title,desc,iconPath,iconStyle,titleStyle,detailStyle,customIcon){var latlong=new VELatLong(lat,lng);var shape=new VEShape(VEShapeType.Pushpin,latlong);shape.SetTitle(title);shape.SetDescription(desc+"<!--[if lte IE 6.5]><iframe class='cal-select-free'></iframe><![endif]-->");if(iconPath){var icon="";iconStyle+="";if(iconStyle.match(/pushpin/i)){var iconText=iconStyle.toLowerCase().replace(/pushpin/g,"");if(iconText.match(/solo/i)){icon=this.getCustomIcon("veIconStar")}else{icon=this.getCustomIcon("veIconHotel",iconText,"vepp_"+this.pinID)}shape.SetCustomIcon(icon)}else{var img='<img id="vepp_'+this.pinID+'" src="'+iconPath+'"'+(iconStyle!=null?' class="'+iconStyle+'"':"")+" />";shape.SetCustomIcon(img)}}else{if(customIcon){shape.SetCustomIcon(customIcon)}}this.map.AddShape(shape);this.shapesInMap[this.pinID-1]=shape;this.pinID++;var loc=new VELatLong(lat,lng);this.locsInMap.push(loc)};this.getCustomIcon=function(className,text,iconId){var customIcon="<div "+(iconId?"id='"+iconId+"'":"")+" class='"+className+"' onmouseover='mapIconRollover(this)' onmouseout='mapIconRollover(this)'>"+(text?"<span>"+text+"</span>":"")+"</div>";return customIcon};this.deletePin=function(pId){var shape=this.shapesInMap[pId-1];if(shape!=null){this.map.DeleteShape(shape);this.shapesInMap[pId-1]=null}};this.deleteAllPins=function(){this.map.DeleteAllShapes();this.locsInMap=new Array();this.shapesInMap=new Array();this.pinID=1};this.getRoute=function(start,end,isInMiles,isQuickest,isDriving){var me=this;var routeOptions=new VERouteOptions();routeOptions.DistanceUnit=isInMiles?VERouteDistanceUnit.Mile:VERouteDistanceUnit.Mile.Kilometer;routeOptions.RouteOptimize=isQuickest?VERouteOptimize.MinimizeTime:VERouteOptimize.MinimizeDistance;routeOptions.RouteCallback=function(route){me.printRoute(start,end,routeOptions.DistanceUnit,route)};routeOptions.RouteMode=isDriving?VERouteMode.Driving:VERouteMode.Walking;this.deleteAllPins();me.map.GetDirections([start,end],routeOptions)};this.printRoute=function(start,end,distanceUnit,route){var altColors=new Array("#ffffff","#eeeeee");var routeHolder=document.getElementById(this.routeHolderId);var routeHtml="";if(routeHolder==null||route==null||route.RouteLegs[0]==null){return }routeHtml="<div>";routeHtml+="<b>Found starting address:</b> <i>"+start+"</i></div>";routeHtml+="<div>";routeHtml+="<b>Found destination address:</b> <i>"+end+"</i></div>";routeHtml+="<div><br />";routeHtml+="<b>Total Distance:</b> <i>"+route.Distance.toFixed(2)+" "+(distanceUnit==VERouteDistanceUnit.Mile?"miles":"km")+"</i></div>";routeHtml+="<div>";routeHtml+="<b>Total Time:</b> <i>"+(route.Time<3600?Math.ceil(route.Time/60)+" minutes":parseInt(route.Time/3600)+" hours and "+Math.ceil((route.Time%3600)/60)+" minutes")+"</i></div><br />";routeHtml+="<table cellpadding='4' cellspacing='0' style='width:900px; margin:0 18px 30px 18px'>";routeHtml+="<tr style='color:white;'>";routeHtml+="  <td align='center' style='background-color: #4a4a4a'><b>#</b></td>";routeHtml+="  <td style='background-color: #4a4a4a'><b>Direction</b></td>";routeHtml+="  <td style='background-color: #4a4a4a'><b>"+(distanceUnit==VERouteDistanceUnit.Mile?"miles":"km")+"</b></td>";routeHtml+="  <td style='background-color: #4a4a4a'>&nbsp;</td>";routeHtml+="</tr>";var len=route.RouteLegs[0].Itinerary.Items.length;for(var i=0;i<len;i++){var turn=route.RouteLegs[0].Itinerary.Items[i];routeHtml+="<tr valign='middle'>";routeHtml+="  <td valign='top' align='center' style='background-color: "+altColors[i%2]+"'><img src='http://dev.virtualearth.net/mapcontrol/v6/i/bin/1.0.20070926140324.39/pins/"+(i>0&&i<len-1?"redcircle"+i:(i==0?"mapicon_start":"mapicon_end"))+".gif' /></td>";routeHtml+="  <td valign='top' style='background-color: "+altColors[i%2]+"'>"+turn.Text+"</td>";routeHtml+="  <td valign='top' style='background-color: "+altColors[i%2]+"'>"+(turn.Distance?turn.Distance.toFixed(2):"")+"</td>";routeHtml+="  <td valign='top' style='background-color: "+altColors[i%2]+"'>&nbsp;</td>";routeHtml+="</tr>"}routeHtml+="</table>";routeHolder.innerHTML=routeHtml;routeHolder.style.display=""};this.setZoomLevel=function(zm){this.map.SetZoomLevel(zm)};this.setMapView=function(){this.map.SetMapView(this.locsInMap)};this.setMapCenter=function(pid,zm){if(pid==null&&zm==null){var totalLat=0;var totalLong=0;var numOfLocs=this.locsInMap.length;for(i=0;i<numOfLocs;i++){totalLat+=parseFloat(this.locsInMap[i].Latitude);totalLong+=parseFloat(this.locsInMap[i].Longitude)}this.map.SetCenter(new VELatLong(totalLat/numOfLocs,totalLong/numOfLocs));return }if(zm!=null){this.map.SetCenterAndZoom(this.locsInMap[pid-1],zm)}else{this.map.SetCenter(this.locsInMap[pid-1])}};this.getUpperLeft=function(){var gmv=this.map.GetMapView();return gmv.TopLeftLatLong};this.getLowerRight=function(){var gmv=this.map.GetMapView();return gmv.BottomRightLatLong};this.showPushpinHover=function(id){var ppImg=document.getElementById("vepp_"+id.toString());var offset=new VEPixel(30,5);if(ppImg&&ppImg.className){ppImg.className=ppImg.className+"Select"}this.map.HideInfoBox();this.map.ShowInfoBox(this.shapesInMap[id-1],this.locsInMap[id-1],offset)};this.hidePushpinHover=function(id){var ppImg=document.getElementById("vepp_"+id.toString());if(ppImg&&ppImg.className){ppImg.className=ppImg.className.replace(/Select/g,"")}this.map.HideInfoBox(this.shapesInMap[id-1])};this.attachEvent=function(eventName,callBack){this.map.AttachEvent(eventName,callBack)};this.detachEvent=function(eventName,callBack){this.map.AttachEvent(eventName,callBack)};this.moveMap=function(newLoc,callBack){var location=newLoc;if(location.match("new york","i")==null&&location.match("ny","i")==null&&location.match("nj","i")==null){location+=", new york, NY"}location+=", USA";this.map.Find(null,location,null,null,null,null,null,null,null,null,callBack);return false};this.moveMapGeocodes=function(lat,lon,zoom){if(zoom==null){this.map.SetCenter(new VELatLong(lat,lon))}else{this.map.SetCenterAndZoom(new VELatLong(lat,lon),zoom)}};this.getCenterLat=function(){return this.map.GetCenter().Latitude};this.getCenterLon=function(){return this.map.GetCenter().Longitude};this.getZoomLevel=function(){return this.map.GetZoomLevel()};this.getMapStyle=function(){return this.map.GetMapStyle()};this.setMapStyle=function(s){var style;switch(s.toLowerCase()){case"a":style=VEMapStyle.Aerial;break;case"h":style=VEMapStyle.Hybrid;break;case"o":style=VEMapStyle.Birdseye;break;default:style=VEMapStyle.Road;break}this.map.SetMapStyle(style);return false}}function minMaxDashboard(){var dash=document.getElementById("lowerContainer");if(dash==null){return }if(dash.style.display!="none"){dash.style.display="none"}else{dash.style.display=""}}function mapIconRollover(icon){var className=icon.className;if(className.match(/select/i)){className=className.replace(/Select/g,"")}else{className+="Select"}icon.className=className}var regex=new RegExp("firefox/3","i");if(navigator.userAgent.match(regex)){var mouseEvt;if(typeof document.createEvent!=="undefined"){mouseEvt=document.createEvent("MouseEvents")}if(mouseEvt&&mouseEvt.__proto__&&mouseEvt.__proto__.__defineGetter__){mouseEvt.__proto__.__defineGetter__("pageX",function(){return this.clientX+window.pageXOffset});mouseEvt.__proto__.__defineGetter__("pageY",function(){return this.clientY+window.pageYOffset})}};﻿var offsetxpoint=-10; //Customize x offset of tooltip
var offsetypoint=20; //Customize y offset of tooltip
var ie=document.all;
var ns6=document.getElementById && !document.all;
var enabletip=false;
var tipobj=null;

function dhtmlEffectOnLoad() {
    tipobj = document.createElement("DIV");
    tipobj.id = "dhtmltooltip";
    document.body.appendChild( tipobj );
}

function ietruebody(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function ddrivetip(thetext, thecolor, thewidth){
	if ( tipobj == null ) {
		tipobj = document.createElement("DIV");
		tipobj.id = "dhtmltooltip";
		document.body.appendChild( tipobj );		
	}
    if (ns6||ie){
        if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px";
        if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor;
        tipobj.innerHTML=thetext;
        enabletip=true;
        return false;
    }
}

function positiontip(e){
    if (enabletip){
        var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
        var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
        //Find out how close the mouse is to the corner of the window
        var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20;
        var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20;

        var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000;
        
        //if the horizontal distance isn't enough to accomodate the width of the context menu
        if (rightedge<tipobj.offsetWidth)
        //move the horizontal position of the menu to the left by it's width
        tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px";
        else if (curX<leftedge)
        tipobj.style.left="5px";
        else
        //position the horizontal position of the menu where the mouse is positioned
        tipobj.style.left=curX+offsetxpoint+"px";

        //same concept with the vertical position
        if (bottomedge<tipobj.offsetHeight)
        tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px";
        else
        tipobj.style.top=curY+offsetypoint+"px";
        tipobj.style.visibility="visible";
    }
}

function hideddrivetip(){
    if (ns6||ie){
        enabletip=false;
        tipobj.style.visibility="hidden";
        tipobj.style.left="-1000px";
        tipobj.style.backgroundColor='';
        tipobj.style.width='';
    }
}

document.onmousemove=positiontip;

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr);
subobj.style.display=(subobj.style.display!="block")? "block" : "none";
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0); 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0);
subobj.style.left=xpos+"px";
subobj.style.top=ypos+"px";
return false;
}
else
return true;
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none";
}

var __monthslong=["January","February","March","April","May","June","July","August","September","October","November","December"];var __monthsshort=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];var __calImgPath="/image/calendar/";var __calendars=new Array();var __calDivId="nycCal";function Calendar(arrayID,uniqueName,dateFrom,dateTo){this.currDate=new Date();this.uniqueName=uniqueName;this.arrayID=arrayID;this.products=new Array();this.selectedDays=new Array();this.prodDesc="";this.dateFrom=dateFrom;this.dateTo=dateTo;this.startTally=new Array();this.maxDays=1;this.bottomMsg="Select a date from the calendar above";this.posDateColor="#808080"}Calendar.prototype.drawCal=function(nudgeMonth,alreadyLoaded){this.currDate.setMonth((this.currDate.getMonth()+nudgeMonth));var tmpNextMo=new Date(this.currDate.getFullYear(),(this.currDate.getMonth()+1),1);var calStr='<table cellpadding="0" cellspacing="0" border="0"><tr><td style="background:url('+__calImgPath+'ul.gif) no-repeat; height:6px;"></td><td style="background:url('+__calImgPath+'ur.gif) right top no-repeat; height:6px; width:6px;"></td></tr><tr><td style="background:url('+__calImgPath+'ml.gif) left top repeat-y; text-align:center; font-family:Tahoma; font-size:9pt; color:#808080; overflow:auto; padding-left:6px;" id="__calMessage"><table cellpadding="0" cellspacing="0" border="0"><tr><td width="100%" colspan="2" align="middle" style="padding-bottom:5px;"><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td align="left" style="font-size:9pt; color:#000000; text-align:left; cursor:pointer;" onClick="__calendars['+this.arrayID+'].drawCal((-1), true);"><img border=0 src="'+__calImgPath+'_left.gif"></td><td width="50%" align="left" style="padding:0px 16px 0px 0px; font-size:9pt; color:#000000; text-align:center; cursor:default;"><b><nobr>'+__monthslong[this.currDate.getMonth()]+" "+this.currDate.getFullYear()+'</nobr></b></td><td width="50%" align="right" style="padding:0px 0px 0px 16px; font-size:9pt; color:#000000; text-align:center; cursor:default;"><b><nobr>'+__monthslong[tmpNextMo.getMonth()]+" "+tmpNextMo.getFullYear()+'</nobr></b></td><td align="right" style="font-size:9pt; color:#000000; text-align:right; cursor:pointer;" onClick="__calendars['+this.arrayID+'].drawCal(1, true);"><img border=0 src="'+__calImgPath+'_right.gif"></td></tr></table></td></tr><tr><td valign="top"><table cellpadding="0" cellspacing="0" border="0"><tr><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">S</td><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">M</td><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">T</td><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">W</td><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">T</td><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">F</td><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">S</td></tr><tr>';this.currDate.setDate(1);var pMonth=new Date();pMonth.setFullYear(this.currDate.getFullYear(),this.currDate.getMonth(),(this.currDate.getDate()-1));var dCount=new Date();dCount.setFullYear(this.currDate.getFullYear(),(this.currDate.getMonth()+1),(this.currDate.getDate()-1));var dayCounter=0;for(var pMo=1;pMo<=this.currDate.getDay();pMo++){calStr+='<td align="middle" style="padding:2px; font-family:Tahoma; font-size:9pt; color:#AAAAAA; border-bottom:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; text-align:center; cursor:default;">&nbsp;</td>';dayCounter++}for(var cMD=0;cMD<dCount.getDate();cMD++){var validFrom=true;if(typeof(this.dateFrom)!="undefined"){if(this.dateFrom.getTime()>(new Date((this.currDate.getMonth()+1)+"/"+(this.currDate.getDate()+cMD)+"/"+this.currDate.getFullYear())).getTime()){validFrom=false}}var validTo=true;if(typeof(this.dateTo)!="undefined"){if(this.dateTo.getTime()<(new Date((this.currDate.getMonth()+1)+"/"+(this.currDate.getDate()+cMD)+"/"+this.currDate.getFullYear())).getTime()){validTo=false}}var dayInList=false;for(var dInd=0;dInd<this.selectedDays.length;dInd++){if(this.selectedDays[dInd][0]==this.currDate.getFullYear()&&this.selectedDays[dInd][1]==this.currDate.getMonth()&&this.selectedDays[dInd][2]==(this.currDate.getDate()+cMD)){dayInList=true}}if(validFrom==false||validTo==false){calStr+='<td align="middle" style="padding:2px; font-family:Tahoma; background:#EFEFEF; font-size:9pt; color:#808080; border-bottom:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; text-align:center; cursor:default;'}else{calStr+='<td id="__cal'+this.arrayID+"__"+this.currDate.getFullYear()+"-"+this.currDate.getMonth()+"-"+(this.currDate.getDate()+cMD)+'" align="middle" style="padding:2px; font-family:Tahoma; font-size:9pt; border-bottom:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; text-align:center; cursor:pointer;';if(dayInList){calStr+=" background:#006699; color:#FFFFFF;"}else{calStr+=" background:#FFFFFF; color:"+this.posDateColor+";"}}if(validFrom==false||validTo==false){calStr+=" text-decoration:line-through;"}if(validFrom==true&&validTo==true){calStr+='" onMouseOver="__calendars['+this.arrayID+"].toggleDayHilight(["+this.currDate.getFullYear()+","+this.currDate.getMonth()+","+(this.currDate.getDate()+cMD)+'], this, true);" '}if(validFrom==true&&validTo==true){calStr+='" onMouseOut="__calendars['+this.arrayID+"].toggleDayHilight(["+this.currDate.getFullYear()+","+this.currDate.getMonth()+","+(this.currDate.getDate()+cMD)+'], this, false);" onMouseDown="__calendars['+this.arrayID+"].toggleDay(["+this.currDate.getFullYear()+","+this.currDate.getMonth()+","+(this.currDate.getDate()+cMD)+"], this, 'down');\" onMouseUp=\"__calendars["+this.arrayID+"].toggleDay(["+this.currDate.getFullYear()+","+this.currDate.getMonth()+","+(this.currDate.getDate()+cMD)+"], this, 'up');\">"+(this.currDate.getDate()+cMD)+"</td>"}else{calStr+='">'+(this.currDate.getDate()+cMD)+"</td>"}dayCounter++;if((dayCounter%7)==0){calStr+="</tr>";if(cMD!=dCount.getDate()){"<tr>"}}}for(var eMo=1;eMo<=(6-dCount.getDay());eMo++){calStr+='<td align="middle" style="padding:2px; font-family:Tahoma; font-size:9pt; color:#AAAAAA; border-bottom:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-left:1px solid #FFFFFF; text-align:center; cursor:default;">&nbsp;</td>';dayCounter++}calStr+='</table></td><td valign="top" style="padding-left:5px;"><table cellpadding=0 cellspacing=0 border=0><tr><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">S</td><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">M</td><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">T</td><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">W</td><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">T</td><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">F</td><td align="middle" style="background:#EEEEEE url('+__calImgPath+'lightgray-gradient-ee.gif) bottom repeat-x; padding:1px; font-family:Tahoma; font-size:8pt; color:#000000; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; border-top:1px solid #EEEEEE; text-align:center; cursor:default;">S</td></tr><tr>';this.currDate.setMonth((this.currDate.getMonth()+1),1);var pMonth=new Date();pMonth.setFullYear(this.currDate.getFullYear(),this.currDate.getMonth(),(this.currDate.getDate()-1));var dCount=new Date();dCount.setFullYear(this.currDate.getFullYear(),(this.currDate.getMonth()+1),(this.currDate.getDate()-1));var dayCounter=0;for(var pMo=1;pMo<=this.currDate.getDay();pMo++){calStr+='<td align="middle" style="padding:2px; font-family:Tahoma; font-size:9pt; color:#AAAAAA; border-bottom:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; text-align:center; cursor:default;">&nbsp;</td>';dayCounter++}for(var cMD=0;cMD<dCount.getDate();cMD++){var validFrom=true;if(typeof(this.dateFrom)!="undefined"){if(this.dateFrom.getTime()>(new Date((this.currDate.getMonth()+1)+"/"+(this.currDate.getDate()+cMD)+"/"+this.currDate.getFullYear())).getTime()){validFrom=false}}var validTo=true;if(typeof(this.dateTo)!="undefined"){if(this.dateTo.getTime()<(new Date((this.currDate.getMonth()+1)+"/"+(this.currDate.getDate()+cMD)+"/"+this.currDate.getFullYear())).getTime()){validTo=false}}var dayInList=false;for(var dInd=0;dInd<this.selectedDays.length;dInd++){if(this.selectedDays[dInd][0]==this.currDate.getFullYear()&&this.selectedDays[dInd][1]==this.currDate.getMonth()&&this.selectedDays[dInd][2]==(this.currDate.getDate()+cMD)){dayInList=true}}if(validFrom==false||validTo==false){calStr+='<td align="middle" style="padding:2px; font-family:Tahoma; background:#EFEFEF; font-size:9pt; color:#808080; border-bottom:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; text-align:center; cursor:default;'}else{calStr+='<td id="__cal'+this.arrayID+"__"+this.currDate.getFullYear()+"-"+this.currDate.getMonth()+"-"+(this.currDate.getDate()+cMD)+'" align="middle" style="padding:2px; font-family:Tahoma; font-size:9pt; border-bottom:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-left:1px solid #EEEEEE; text-align:center; cursor:pointer;';if(dayInList){calStr+=" background:#006699; color:#FFFFFF;"}else{calStr+=" background:#FFFFFF; color:"+this.posDateColor+";"}}if(validFrom==false||validTo==false){calStr+=" text-decoration:line-through;"}if(validFrom==true&&validTo==true){calStr+='" onMouseOver="__calendars['+this.arrayID+"].toggleDayHilight(["+this.currDate.getFullYear()+","+this.currDate.getMonth()+","+(this.currDate.getDate()+cMD)+'], this, true);" '}if(validFrom==true&&validTo==true){calStr+='" onMouseOut="__calendars['+this.arrayID+"].toggleDayHilight(["+this.currDate.getFullYear()+","+this.currDate.getMonth()+","+(this.currDate.getDate()+cMD)+'], this, false);" onMouseDown="__calendars['+this.arrayID+"].toggleDay(["+this.currDate.getFullYear()+","+this.currDate.getMonth()+","+(this.currDate.getDate()+cMD)+"], this, 'down');\" onMouseUp=\"__calendars["+this.arrayID+"].toggleDay(["+this.currDate.getFullYear()+","+this.currDate.getMonth()+","+(this.currDate.getDate()+cMD)+"], this, 'up');\">"+(this.currDate.getDate()+cMD)+"</td>"}else{calStr+='">'+(this.currDate.getDate()+cMD)+"</td>"}dayCounter++;if((dayCounter%7)==0){calStr+="</tr>";if(cMD!=dCount.getDate()){"<tr>"}}}for(var eMo=1;eMo<=(6-dCount.getDay());eMo++){calStr+='<td align="middle" style="padding:2px; font-family:Tahoma; font-size:9pt; color:#AAAAAA; border-bottom:1px solid #CCCCCC; border-right:1px solid #CCCCCC; border-left:1px solid #FFFFFF; text-align:center; cursor:default;">&nbsp;</td>';dayCounter++}calStr+='</table></td></tr><tr><td colspan=2 id="__cal'+this.arrayID+'__message" align="left" style="font-family:Tahoma; color:#000000; font-size:9pt; padding:2px;">'+this.bottomMsg+'</td></tr></table></td><td style="background:url('+__calImgPath+'mr.gif) right top repeat-y; height:6px;"><img width="1" height="6" border=0 src="_blank.gif"></td></tr><tr><td style="background:url('+__calImgPath+'bl.gif) no-repeat; height:6px;"><img width="1" height="6" border=0 src="_blank.gif"></td><td style="background:url('+__calImgPath+'br.gif) right top no-repeat; height:6px; width:6px;"><img width="6" height="6" border=0 src="_blank.gif"></td></tr></table>';this.currDate.setMonth((this.currDate.getMonth()-1));if(typeof(alreadyLoaded)!="undefined"&&alreadyLoaded==true){document.getElementById(this.uniqueName).innerHTML=calStr}else{return'<div id="'+this.uniqueName+'">'+calStr+"</div>"}};Calendar.prototype.toggleDay=function(day,divBlock,buttonEvent){var dayInList=(-1);for(var dInd=0;dInd<this.selectedDays.length;dInd++){if(this.selectedDays[dInd][0]==day[0]&&this.selectedDays[dInd][1]==day[1]&&this.selectedDays[dInd][2]==day[2]){dayInList=dInd}}if(dayInList==(-1)&&this.startTally.length==0&&buttonEvent=="down"){if(this.selectedDays.length>=1){var oldDivBlock=document.getElementById("__cal"+this.arrayID+"__"+this.selectedDays[0][0]+"-"+this.selectedDays[0][1]+"-"+this.selectedDays[0][2]);if(oldDivBlock!=null){oldDivBlock.style.background="#FFFFFF";oldDivBlock.style.color=this.posDateColor}this.selectedDays=new Array();this.startTally=new Array()}divBlock.style.background="#006699";divBlock.style.color="#FFFFFF";this.selectedDays.push(day);this.startTally=day;this.toggleDayHilight(day,divBlock,true);this.selectedDays.sort(function(a,b){return(new Date(a[0],a[1],a[2])).getTime()-(new Date(b[0],b[1],b[2])).getTime()})}else{if(this.startTally.length>0&&buttonEvent=="up"){var countDays=1;var tallyDest=new Date(day[0],(parseInt(day[1])+0),day[2]);var tallyNew=new Date(this.startTally[0],(parseInt(this.startTally[1])+0),this.startTally[2]);var tallyPivot=new Date(this.startTally[0],(parseInt(this.startTally[1])+0),this.startTally[2]);while(tallyNew.getFullYear()!=tallyDest.getFullYear()||tallyNew.getMonth()!=tallyDest.getMonth()||tallyNew.getDate()!=tallyDest.getDate()){countDays++;if(tallyNew.getTime()<tallyDest.getTime()){tallyNew.setDate(tallyNew.getDate()+1)}else{tallyNew.setDate(tallyNew.getDate()-1)}var newDayInList=false;for(var dInd=0;dInd<this.selectedDays.length;dInd++){if(this.selectedDays[dInd][0]==tallyNew.getFullYear()&&this.selectedDays[dInd][1]==tallyNew.getMonth()&&this.selectedDays[dInd][2]==tallyNew.getDate()){newDayInList=true}}var newDivBlock=document.getElementById("__cal"+this.arrayID+"__"+tallyNew.getFullYear()+"-"+tallyNew.getMonth()+"-"+tallyNew.getDate());if(!newDayInList&&countDays<=this.maxDays&&newDivBlock){this.selectedDays.push([tallyNew.getFullYear(),tallyNew.getMonth(),tallyNew.getDate()]);this.selectedDays.sort(function(a,b){return(new Date(a[0],a[1],a[2])).getTime()-(new Date(b[0],b[1],b[2])).getTime()});newDivBlock.style.background="#006699";newDivBlock.style.color="#FFFFFF"}else{if(!newDayInList&&newDivBlock){newDivBlock.style.background="#FFFFFF";newDivBlock.style.color=this.posDateColor}}}this.startTally=new Array()}else{if(buttonEvent=="up"){var tallyNew=new Date(day[0],(parseInt(day[1])+0),day[2]);var tallyPrev=new Date(day[0],(parseInt(day[1])+0),day[2]);tallyPrev.setDate(tallyPrev.getDate()-1);var prevDayInList=false;var remDayInList=true;var remDayInListInd=(-1);for(var dInd=0;dInd<this.selectedDays.length;dInd++){if(this.selectedDays[dInd][0]==tallyPrev.getFullYear()&&this.selectedDays[dInd][1]==tallyPrev.getMonth()&&this.selectedDays[dInd][2]==tallyPrev.getDate()){prevDayInList=true}}if(!prevDayInList){while(remDayInList){tallyNew.setDate(tallyNew.getDate()+1);var newDivBlock=document.getElementById("__cal"+this.arrayID+"__"+tallyNew.getFullYear()+"-"+tallyNew.getMonth()+"-"+tallyNew.getDate());remDayInList=false;for(var rdInd=0;rdInd<this.selectedDays.length;rdInd++){if(this.selectedDays[rdInd][0]==tallyNew.getFullYear()&&this.selectedDays[rdInd][1]==tallyNew.getMonth()&&this.selectedDays[rdInd][2]==tallyNew.getDate()){remDayInListInd=rdInd;remDayInList=true}}if(remDayInList){this.selectedDays.splice(remDayInListInd,1);this.selectedDays.sort(function(a,b){return(new Date(a[0],a[1],a[2])).getTime()-(new Date(b[0],b[1],b[2])).getTime()});this.toggleDayHilight([tallyNew.getFullYear(),tallyNew.getMonth(),tallyNew.getDate()],newDivBlock,false)}}}if(dayInList!=(-1)){this.selectedDays.splice(dayInList,1);this.selectedDays.sort(function(a,b){return(new Date(a[0],a[1],a[2])).getTime()-(new Date(b[0],b[1],b[2])).getTime()});this.toggleDayHilight(day,divBlock,false)}this.startTally=new Array()}}}window.setTimeout("document.getElementById(__calDivId).style.display = 'none'",500)};Calendar.prototype.toggleDayHilight=function(day,divBlock,toggle){var dayInList=false;for(var dInd=0;dInd<this.selectedDays.length;dInd++){if(this.selectedDays[dInd][0]==day[0]&&this.selectedDays[dInd][1]==day[1]&&this.selectedDays[dInd][2]==day[2]){dayInList=true}}if(toggle){divBlock.style.background="#008FD6";divBlock.style.color="#FFFFFF"}else{if(dayInList){divBlock.style.background="#006699";divBlock.style.color="#FFFFFF"}else{divBlock.style.background="#FFFFFF";divBlock.style.color=this.posDateColor}}};var HotelCalendar={div:null,isInit:false,dateFrom:(parseInt((new Date()).getMonth())+1)+"/"+(new Date()).getDate()+"/"+(new Date()).getFullYear(),dateTo:(parseInt((new Date()).getMonth())+1)+"/"+(new Date()).getDate()+"/"+((new Date()).getFullYear()+1),curCalIdx:0,curInput:null,hideCalTO:null,init:function(){var me=this;this.div=document.getElementById(__calDivId);if(this.div==null){this.div=document.createElement("div");this.div.id=__calDivId;this.div.style.position="absolute";this.div.style.padding="8px";this.div.style.display="none";this.div.style.width="auto";this.div.style.height="auto";document.body.appendChild(this.div)}var isHotel=false;if($("input[name=checkin]").length>0){var newDateTo=new Date();var one_day=1000*60*60*24;newDateTo.setTime(newDateTo.getTime()+(one_day*330));this.dateTo=newDateTo.format("MM/dd/yyyy");isHotel=true}__calendars.push(new Calendar(0,"_checkinCal",new Date(this.dateFrom),new Date(this.dateTo)));__calendars.push(new Calendar(1,"_checkoutCal",new Date(this.dateFrom),new Date(this.dateTo)));if(isHotel){__calendars[0].bottomMsg="Select your Check-In Date Above";__calendars[1].bottomMsg="Select your Check-Out Date Above"}__calendars[0].posDateColor="#003366";__calendars[1].posDateColor="#003366";this.div.onmouseup=function(){if(__calendars[me.curCalIdx].selectedDays!=null&&__calendars[me.curCalIdx].selectedDays.length>0){var date=(parseInt(__calendars[me.curCalIdx].selectedDays[0][1])+1)+"/"+__calendars[me.curCalIdx].selectedDays[0][2]+"/"+__calendars[me.curCalIdx].selectedDays[0][0];if(me.curInput!=null){me.curInput.value=date;if(me.curInput.onchange){me.curInput.onchange()}}}};this.div.onmouseout=function(){eval("HotelCalendar.closeOnTimeout()")};this.div.onmouseover=function(){eval("HotelCalendar.clearTimeout()")};this.isInit=true},showCal:function(input,calIdx){if(!this.isInit){this.init()}var inputDate=new Date(input.value);if(inputDate.toString()=="Invalid Date"||inputDate.toString()=="NaN"){inputDate=new Date()}if(__calendars[calIdx].selectedDays==null||__calendars[calIdx].selectedDays.length==0){__calendars[calIdx].selectedDays[0]=new Array()}this.curCalIdx=calIdx;this.curInput=input;__calendars[calIdx].currDate=inputDate;__calendars[calIdx].selectedDays[0][0]=inputDate.getFullYear();__calendars[calIdx].selectedDays[0][1]=inputDate.getMonth();__calendars[calIdx].selectedDays[0][2]=inputDate.getDate();if(this.div.style.display!="none"){overlayclose(__calDivId)}if(this.div.style.display=="none"){overlay(input,__calDivId,"bottom");if(calIdx==1&&__calendars[0].selectedDays[0]!=null){__calendars[calIdx].dateFrom=new Date((parseInt(__calendars[0].selectedDays[0][1])+1)+"/"+__calendars[0].selectedDays[0][2]+"/"+__calendars[0].selectedDays[0][0])}this.div.innerHTML=__calendars[calIdx].drawCal(0)}this.div.innerHTML+="<!--[if lte IE 6.5]><iframe src='/secure/ok.aspx' class='cal-select-free'></iframe><![endif]-->";this.clearTimeout();this.hideCalTO=null},closeOnTimeout:function(){this.hideCalTO=window.setTimeout("HotelCalendar.closeCal()",1000)},clearTimeout:function(){if(this.hideCalTO!=null){window.clearTimeout(this.hideCalTO)}this.hideCalTO=null},closeCal:function(){if(document.getElementById(__calDivId)!=null){overlayclose(__calDivId)}}};﻿var NycHotelMapSearch = {
	checkinDateID : "checkinDate",
	checkoutDateID : "checkoutDate",
	addressTxtID : "addressTxt",
	neighborhoodSelID : "neighborhoodSel",
	roomSelID : "roomSel",
	currencySelID : "currencySel",
	areaTxtID : "areaTxt",
	pnlCatSch : "catSch",
	pnlCatSchTop : "catSchTop",
	pnlCatSchTopPath : "catSchTopPath",
	pnlCatSchOrg : "catSchOrg",
	pnlCatSchNav : "catSchNav",
	pnlSchPath : "catSchPath",
	pnlResultSec : "resultSec",
	pnlResults : "results",
	pnlResultPath : "resultPath",
	pnlResultLoc : "resultLoc",
	nfoTotalCount : "totalcount",
	pnlResultsNav : "resultsNav",
	pnlTopResultsNav : "topResultsNav",
	pnlLocSch : "locSch",
	pnlDateSch : "dateSch",
	locSchErrorID : "locSchError",
	locSchErrorBtmID : "locSchErrorBtm",
	moveMapText : "moveMapText",
	topTitleText : "topTitleText",
	featureType : 1,
	starType : 2,
	brandType : 3,
	
	mapCallBack : "",
	mapObj : null,
	pageSize : 20,
	catPageSize : 10,
	timeSqLat : 40.7558504573403,
	timeSqLon : -73.9864455393433,
	defaultZoom : 12,
	lastLat : 0,
	lastLon : 0,
	lastLocName : "",
	isDefaultMapped : false,
	lastSchPage : 1,
	
	curCheckin : "",
	curCheckout : "",
	curR1a : 1,
	curR2a : 0,
	curR3a : 0,
	curR4a : 0,
	curR5a : 0,
	curR6a : 0,
	curR7a : 0,
	curR8a : 0,
	curR1c : 0,
	curR2c : 0,
	curR3c : 0,
	curR4c : 0,
	curR5c : 0,
	curR6c : 0,
	curR7c : 0,
	curR8c : 0,
	curR1ca : "",
	curR2ca : "",
	curR3ca : "",
	curR4ca : "",
	curR5ca : "",
	curR6ca : "",
	curR7ca : "",
	curR8ca : "",
	curRooms : 1,
	curCurrency : "",
	curCats : null,
	featureID : 0,
	featureName : "",
	starID : 0,
	starName : "",
	brandID : 0,
	brandName : "",
	curCatID : 0,
	curCatName : "",
	curCenterLat : 0,
	curCenterLon : 0,
	curUpperLeftLat : 0,
	curUpperLeftLon : 0,
	curLowerRightLat : 0,
	curLowerRightLon : 0,
	curZoom : 12,
	curBirdseyeZoom : 1,
	curMapStyle : null,
	
	curAddress : "",
	curAddressLat : 0,
	curAddressLon : 0,
	curCacheKey : "",
	curCacheRes : null,
	isCacheRequested : false,
	curCacheTimeout : null,
	
	searchForHotelRate : function(type,catid,catname,checkin,checkout,rooms,
	r1a,r2a,r3a,r4a,r5a,r6a,r7a,r8a,r1c,r2c,r3c,r4c,r5c,r6c,r7c,r8c,r1ca,r2ca,
	r3ca,r4ca,r5ca,r6ca,r7ca,r8ca,currency,cachekey,cachelocation,isACallBack) {
		var roomSel = $("#" + NycHotelMapSearch.roomSelID);
		var currencySel = $("#" + NycHotelMapSearch.currencySelID);
		
	    if (NycHotelMapSearch.isDefaultMapped == true)
		    NycHotelMapSearch.isDefaultMapped = false;
		else
		{
		    $("#" + NycHotelMapSearch.locSchErrorID).empty();
		    $("#" + NycHotelMapSearch.locSchErrorBtmID).empty();
		}
		
		if ( type == null ) type = 0;
		if ( catid == null ) catid = -1;    
		if ( catname == null ) catname = "";
		if ( checkin == null ) checkin = $("#" + NycHotelMapSearch.checkinDateID).val();
		if ( checkout == null ) checkout = $("#" + NycHotelMapSearch.checkoutDateID).val();
		if ( rooms == null ) rooms = roomSel.find("option[selected]").val();
		if ( currency == null ) currency = currencySel.find("option[selected]").val();
		
		for (idx = 1; idx < 9; idx++)
		{
		    var adultSel = $("#adultSel" + idx);
		    var kidSel = $("#kidSel" + idx);
		    
		    switch (idx)
		    {
		        case 1:
		            if ( r1a == null ) r1a = adultSel.find("option[selected]").val();
		            if ( r1c == null ) r1c = kidSel.find("option[selected]").val();
		            if ( r1ca == null ) r1ca = NycHotelMapSearch.getChildAges(1, r1c);
		            break;
		        case 2:
		            if ( r2a == null ) r2a = adultSel.find("option[selected]").val();
		            if ( r2c == null ) r2c = kidSel.find("option[selected]").val();
		            if ( r2ca == null ) r2ca = NycHotelMapSearch.getChildAges(2, r2c);
		            break;
		        case 3:
		            if ( r3a == null ) r3a = adultSel.find("option[selected]").val();
		            if ( r3c == null ) r3c = kidSel.find("option[selected]").val();
		            if ( r3ca == null ) r3ca = NycHotelMapSearch.getChildAges(3, r3c);
		            break;
		        case 4:
		            if ( r4a == null ) r4a = adultSel.find("option[selected]").val();
		            if ( r4c == null ) r4c = kidSel.find("option[selected]").val();
		            if ( r4ca == null ) r4ca = NycHotelMapSearch.getChildAges(4, r4c);
		            break;
		        case 5:
		            if ( r5a == null ) r5a = adultSel.find("option[selected]").val();
		            if ( r5c == null ) r5c = kidSel.find("option[selected]").val();
		            if ( r5ca == null ) r5ca = NycHotelMapSearch.getChildAges(5, r5c);
		            break;
		        case 6:
		            if ( r6a == null ) r6a = adultSel.find("option[selected]").val();
		            if ( r6c == null ) r6c = kidSel.find("option[selected]").val();
		            if ( r6ca == null ) r6ca = NycHotelMapSearch.getChildAges(6, r6c);
		            break;
		        case 7:
		            if ( r7a == null ) r7a = adultSel.find("option[selected]").val();
		            if ( r7c == null ) r7c = kidSel.find("option[selected]").val();
		            if ( r7ca == null ) r7ca = NycHotelMapSearch.getChildAges(7, r7c);
		            break;
		        case 8:
		            if ( r8a == null ) r8a = adultSel.find("option[selected]").val();
		            if ( r8c == null ) r8c = kidSel.find("option[selected]").val();
		            if ( r8ca == null ) r8ca = NycHotelMapSearch.getChildAges(8, r8c);
		            break;
		        default:
		            break;
		        
		    }
		}
		
		if ( cachekey == null ) cachekey = "";
		if ( cachelocation == null ) cachelocation = "";
		
		NycHotelMapSearch.curCheckin = checkin;
		NycHotelMapSearch.curCheckout = checkout;
		NycHotelMapSearch.curRooms = rooms;
		NycHotelMapSearch.curCurrency = currency;
		NycHotelMapSearch.curR1a = r1a;
		NycHotelMapSearch.curR2a = r2a;
		NycHotelMapSearch.curR3a = r3a;
		NycHotelMapSearch.curR4a = r4a;
		NycHotelMapSearch.curR5a = r5a;
		NycHotelMapSearch.curR6a = r6a;
		NycHotelMapSearch.curR7a = r7a;
		NycHotelMapSearch.curR8a = r8a;
		NycHotelMapSearch.curR1c = r1c;
		NycHotelMapSearch.curR2c = r2c;
		NycHotelMapSearch.curR3c = r3c;
		NycHotelMapSearch.curR4c = r4c;
		NycHotelMapSearch.curR5c = r5c;
		NycHotelMapSearch.curR6c = r6c;
		NycHotelMapSearch.curR7c = r7c;
		NycHotelMapSearch.curR8c = r8c;
		NycHotelMapSearch.curR1ca = r1ca;
		NycHotelMapSearch.curR2ca = r2ca;
		NycHotelMapSearch.curR3ca = r3ca;
		NycHotelMapSearch.curR4ca = r4ca;
		NycHotelMapSearch.curR5ca = r5ca;
		NycHotelMapSearch.curR6ca = r6ca;
		NycHotelMapSearch.curR7ca = r7ca;
		NycHotelMapSearch.curR8ca = r8ca;
		
		if (type == NycHotelMapSearch.featureType)
		{
		    NycHotelMapSearch.featureID = catid;
		    NycHotelMapSearch.featureName = catname;
		}
		else if (type == NycHotelMapSearch.starType)
		{
		    NycHotelMapSearch.starID = catid;
		    NycHotelMapSearch.starName = catname;
		}
		else if (type == NycHotelMapSearch.brandType)
		{
		    NycHotelMapSearch.brandID = catid;
		    NycHotelMapSearch.brandName = catname;
		}
		else
		{
		    NycHotelMapSearch.featureID = 0;
		    NycHotelMapSearch.featureName = "";
		    NycHotelMapSearch.starID = 0;
		    NycHotelMapSearch.starName = "";
		    NycHotelMapSearch.brandID = 0;
		    NycHotelMapSearch.brandName = "";
		}
		
        jQuery.post("post.nyc",{_ns:"MapSearch",_a:1,_m:"SearchForHotelRate",fid:NycHotelMapSearch.featureID,
            stid:NycHotelMapSearch.starID,bid:NycHotelMapSearch.brandID,checkinDate:checkin,checkoutDate:checkout,
            "rooms":rooms,"r1a":r1a,"r2a":r2a,"r3a":r3a,"r4a":r4a,"r5a":r5a,"r6a":r6a,"r7a":r7a,"r8a":r8a,"r1c":r1c,
            "r2c":r2c,"r3c":r3c,"r4c":r4c,"r5c":r5c,"r6c":r6c,"r7c":r7c,"r8c":r8c,"r1ca":r1ca,"r2ca":r2ca,"r3ca":r3ca,
            "r4ca":r4ca,"r5ca":r5ca,"r6ca":r6ca,"r7ca":r7ca,"r8ca":r8ca,"currency":currency,
            fla:NycHotelMapSearch.curUpperLeftLat,flg:NycHotelMapSearch.curUpperLeftLon,
            tla:NycHotelMapSearch.curLowerRightLat,tlg:NycHotelMapSearch.curLowerRightLon,
            "cachekey":cachekey,"cachelocation":cachelocation},
	        function(res) { 
	            NycHotelMapSearch.curCacheRes = null;
                NycHotelMapSearch.curCacheKey = "";
	            NycHotelMapSearch.resultsHandler(type,catid,catname,checkin,checkout,rooms,r1a,r2a,r3a,r4a,r5a,r6a,r7a,r8a,
                                r1c,r2c,r3c,r4c,r5c,r6c,r7c,r8c,r1ca,r2ca,r3ca,r4ca,r5ca,r6ca,r7ca,r8ca,
                                currency,cachekey,cachelocation,res);
	        },"json");

	    
		return false;
	},
	
	// this function get the ages for a given room number
	getChildAges : function(room,numbOfKids) {
	    var el = document.forms[0].elements;
		var ages = ""; 
		
	    if ( numbOfKids > 0 ) 
	    {
			ages += el["r" + room + "ca"][0].value;
			for ( k = 1; k < numbOfKids; k++ ) 
			{
				ages += "," + el["r" + room + "ca"][k].value;
			}
        }
        
        return ages;
	},
	
	// this function show results unto the right side list and add pushpin...
	resultsHandler : function(type,catid,catname,checkin,checkout,rooms,r1a,r2a,r3a,r4a,r5a,r6a,r7a,r8a,
	                                r1c,r2c,r3c,r4c,r5c,r6c,r7c,r8c,r1ca,r2ca,r3ca,r4ca,r5ca,r6ca,r7ca,r8ca,
	                                currency,cachekey,cachelocation,res) {
	    var div = $("#" + NycHotelMapSearch.pnlResults).empty();    
	    var divPath = $("#" + NycHotelMapSearch.pnlResultPath).empty();    
		$("#" + NycHotelMapSearch.pnlResultSec).show();
		
		NycHotelMapSearch.mapObj.deleteAllPins();
		
		var pathHtml = "Hotels";
		
		if (type == 0)
		    pathHtml += " : Top Rated"
		else
		{
		    pathHtml += (NycHotelMapSearch.starID > 0 ? " : " + unescape(NycHotelMapSearch.starName) : "") 
		                        + (NycHotelMapSearch.brandID > 0 ? " : " + unescape(NycHotelMapSearch.brandName) : "") 
		                        + (NycHotelMapSearch.featureID > 0 ? " : " + unescape(NycHotelMapSearch.featureName) : "");
		}
                      
        divPath.html(pathHtml);
       
		if ( res != null && res.TotalCount > 0 ) {
			
			div.empty();
			
			var resultsList = "<table cellpadding='2' cellspacing='0'><tr valign='top'>";
					
			for( var i = 0; i < res.Records.length; i++ ) {
				var rec = res.Records[i];
				resultsList += "<td>" + (i+1) + ".</td><td style='width:250px;padding-right:35px'>" 
				            + rec.ListItemHtml; 
				resultsList += "</td>";
				for(var c=1; c< res.Records.length;c++)
				{
				    if(i+1 == c*2)
				    {
				        resultsList +="</tr><tr valign='top'>";
				    }
				}
				// add pushpin to the map
			    NycHotelMapSearch.addMapPushpin(rec, i);
			}
			
			resultsList += "</table></tr>";
			div.html(resultsList);
			
			NycHotelMapSearch.showResultsNav(res.CacheKey, res.CacheLocation, 
			        "NycHotelMapSearch.searchForHotelRate(" + type + "," + catid + ",\"" + catname + "\",\"" 
			        + checkin + "\",\"" + checkout + 
			        "\"," + rooms + "," + r1a + "," + r2a + "," + r3a + "," + r4a + "," + r5a + "," + r6a + "," + r7a
			         + "," + r8a + "," + r1c + "," + r2c + "," + r3c + "," + r4c + "," + r5c + "," + r6c + "," + r7c
			         + "," + r8c + ",\"" + r1ca + "\",\"" + r2ca + "\",\"" + r3ca + "\",\"" + r4ca + "\",\"" + r5ca 
			         + "\",\"" + r6ca + "\",\"" + r7ca + "\",\"" + r8ca + "\",\"" + currency + "\",");
		} else {
		    $("#" + NycHotelMapSearch.nfoTotalCount).empty();
		    $("#" + NycHotelMapSearch.pnlResultsNav).empty();
		    $("#" + NycHotelMapSearch.pnlLocSch).empty();
		    
		    div.html("<p style='color:Red; margin: 10px 0 10px 0;'>No matching results</p>");
		    
		    // zoom out and center back to Time Square when no result found after search by location.
		    if (parseFloat(NycHotelMapSearch.lastLat) == parseFloat(NycHotelMapSearch.mapObj.getCenterLat()) 
		    && parseFloat(NycHotelMapSearch.lastLon) == parseFloat(NycHotelMapSearch.mapObj.getCenterLon()))
		    {
		        NycHotelMapSearch.defaultMap();
		    }
		}	
		
		if (NycHotelMapSearch.lastLocName != "")
		    NycHotelMapSearch.getLandmarkRecord(NycHotelMapSearch.lastLocName);
		if (NycHotelMapSearch.curAddress != "")
		    NycHotelMapSearch.mapObj.addPin( NycHotelMapSearch.curAddressLat, NycHotelMapSearch.curAddressLon, 
		        "Address Search:", NycHotelMapSearch.curAddress + '<br /><br />' +  
                '<div style=\'line-height:20px;\'>' + 
                '<a href=\'\' onclick=\'NycHotelMapSearch.mapObj.setMapCenter(' 
                    + NycHotelMapSearch.mapObj.pinID + ', 17);  return false;\'>zoom to street level</a> | ' + 
                '<a href=\'\' onclick=\'NycHotelMapSearch.mapObj.setMapCenter(' 
                    + NycHotelMapSearch.mapObj.pinID + ', 12); return false;\'>zoom out</a></div><br />', 
                "/image/spacer.gif", "pushpinSolo");
                            
        NycHotelMapSearch.showResultLoc();
		// show location list
        NycHotelMapSearch.showLocations();	
        
        // save the current search for for map callback
        NycHotelMapSearch.mapCallBack = "NycHotelMapSearch.searchForHotelRate(" + type + "," + catid + ",'" + catname 
                + "','" + checkin + "','" + checkout + "'," + rooms + 
                "," + r1a + "," + r2a + "," + r3a + "," + r4a + "," + r5a + "," + r6a + "," + r7a + "," + r8a + 
		        "," + r1c + "," + r2c + "," + r3c + "," + r4c + "," + r5c + "," + r6c + "," + r7c + "," + r8c + 
		        ",'" + r1ca + "','" + r2ca + "','" + r3ca + "','" + r4ca + "','" + r5ca + "','" + r6ca + "','" + r7ca 
		        + "','" + r8ca
                + "','" + currency + "','','',true)";
	},
	
	showResultsNav : function(cachekey,cachelocation,schfunc) {
		var div = $("#" + NycHotelMapSearch.pnlResultsNav).empty();
		var topDiv = $("#" + NycHotelMapSearch.pnlTopResultsNav).empty();
			
		if ( cachekey == "" || cachelocation == "" ) {
			div.empty();
			return;
		}
		
	    var navHTML = "";
		
		navHTML += "<a href='' onclick='return " + schfunc 
		            + "\"" + cachekey + "\",\"" + cachelocation + "\");'>More&nbsp;Results...</a>";
		
		div.html(navHTML);
		topDiv.html(navHTML);
		
		
	},

	getCats : function() {
		var secid = 4;
		
		$("#" + NycHotelMapSearch.pnlCatSch).empty();
		$("#" + NycHotelMapSearch.pnlCatSchTopPath).empty();	
		$("#" + NycHotelMapSearch.pnlCatSchTop).empty();	
		
		jQuery.post("post.nyc",{_ns:"MapSearch",_a:1,_m:"GetCategoriesFor",sid:secid},
		    function(res) { 
				if (res != null && res.TotalCount > 0) {
					NycHotelMapSearch.curCats = res;
					NycHotelMapSearch.showCats(1);
				} else {
					NycHotelMapSearch.curCat = null;
				}
			},"json");
		
		NycHotelMapSearch.searchForHotelRate();
		
		return false;
	},
	
	showCats : function(page) {
	    $("#" + NycHotelMapSearch.pnlCatSchTopPath).empty();	
		$("#" + NycHotelMapSearch.pnlCatSchTop).empty();	
		
		if (page == 0 || NycHotelMapSearch.curCats == null ) {    
			NycHotelMapSearch.searchForHotelRate();
			return false;
		}

		$("#" + NycHotelMapSearch.pnlCatSch).show();
        $("#" + NycHotelMapSearch.pnlCatSchNav).hide();

        var showMoreLink = false;
		var div = $("#" + NycHotelMapSearch.pnlCatSch).empty();		
		var divTop = $("#" + NycHotelMapSearch.pnlCatSchTop).empty();		
		var resultsList = "<table cellpadding='2' cellspacing='0'>";
		
		var count = 1;
		var restoPriceIdx = 0;
		var lastCatName = "";
		var catType = 0;
			
		divTop.html("<p style='margin-top:4px;'><b>Refine these Results by:</b></p>");
		
        for (var i = 0; i < NycHotelMapSearch.curCats.TotalCount; i++) 
        {
			var cat = NycHotelMapSearch.curCats.Cats[i];
			
			if (cat.subcatid == NycHotelMapSearch.curCatID)
			    curCatName = cat.name;
			
			if (i == 0)
			{
			    resultsList += "<tr><td colspan='2'><b>By Star Rating</b></td></tr>";
			    catType = NycHotelMapSearch.starType;
			}
		    
			// found first price category, store the index and exits loop
			if (NycHotelMapSearch.curCats.SectionID == 6 && cat.name == "$")
			{
			    restoPriceIdx = i;
			    break;
			}
			    
			if (count - 1 == NycHotelMapSearch.catPageSize) 
			{
			    resultsList += "</table><table id='tblMoreCat' cellpadding='2' cellspacing='0' "
		                    + "style='display:none;'>";
	            showMoreLink = true;
			}
			
			resultsList += "<tr><td style='width:" + (NycHotelMapSearch.curCats.TotalCount >= 100 ? "23" : "15") + "px;'>" 
			            + count + ".</td><td><a href='' onclick='return NycHotelMapSearch.searchForHotelRate(" + catType + ","
			            + cat.subcatid + ",\"" + escape(cat.name) + "\",\"" 
			            + NycHotelMapSearch.curCheckin + "\",\"" + NycHotelMapSearch.curCheckout + "\"," 
			            + NycHotelMapSearch.curRooms + "," + NycHotelMapSearch.curR1a + "," + NycHotelMapSearch.curR2a 
			            + "," + NycHotelMapSearch.curR3a + "," + NycHotelMapSearch.curR4a + "," + NycHotelMapSearch.curR5a 
	                    + "," + NycHotelMapSearch.curR6a + "," + NycHotelMapSearch.curR7a + "," + NycHotelMapSearch.curR8a 
	                    + "," + NycHotelMapSearch.curR1c + "," + NycHotelMapSearch.curR2c + "," + NycHotelMapSearch.curR3c 
	                    + "," + NycHotelMapSearch.curR4c + "," + NycHotelMapSearch.curR5c + "," + NycHotelMapSearch.curR6c 
	                    + "," + NycHotelMapSearch.curR7c + "," + NycHotelMapSearch.curR8c + ",\"" + NycHotelMapSearch.curR1ca 
			            + "\",\"" + NycHotelMapSearch.curR2ca + "\",\"" + NycHotelMapSearch.curR3ca + "\",\"" 
			            + NycHotelMapSearch.curR4ca + "\",\"" + NycHotelMapSearch.curR5ca + "\",\"" 
	                    + NycHotelMapSearch.curR6ca + "\",\"" + NycHotelMapSearch.curR7ca + "\",\"" + NycHotelMapSearch.curR8ca + "\",\""
			            + NycHotelMapSearch.curCurrency + "\");'>" + cat.name + "</a></td></tr>";
		    
		    count++;
		    
		    // for hotel category, add a header "Search By Amenity" after "4 stars or higher"
		    if (NycHotelMapSearch.curCats.SectionID == 4 && cat.subcatid == 1445)
		    {
		        resultsList += "<tr><td colspan='2'><p style='margin-top:15px;'><b>By Amenity</b></p></td></tr>";
		        count = 1;
		        catType = NycHotelMapSearch.featureType;
		    }
		    
		    // for hotel category, add a header "Search By Brand" after "Wheelchair Accessible"
		    if (NycHotelMapSearch.curCats.SectionID == 4 && cat.subcatid == 8)
		    {
		        resultsList += "<tr><td colspan='2'><p style='margin-top:15px;'><b>By Brand</b></p></td></tr>";
		        count = 1;
		        catType = NycHotelMapSearch.brandType;
		    }
		    
		    lastCatName = cat.name;
		}
		
		resultsList += "</table>";
		
		if (showMoreLink)
        {    
            resultsList += "<div style='margin-left:110px;'>"
                    + "<a href='' id='catShowLink' onclick='$(&quot;#tblMoreCat,#catShowLink,#catHideLink&quot;).toggle(); return false;'>more...</a>"
                    + "<a href='' id='catHideLink' style='display:none;' onclick='$(&quot;#tblMoreCat,#catShowLink,#catHideLink&quot;).toggle(); return false;'>[ x ] close</a>"
                    + "</div>";
        }
        
		div.html(resultsList);
		
		return false;
	},
	
	showLocations : function() {
	    
	    jQuery.post("post.nyc",{_ns:"MapSearch",_a:1,_m:"GetGeocodes"},
			function(res) 
			{ 
			    var div = $("#" + NycHotelMapSearch.pnlLocSch).empty();
	            var divHTML = "<br /><p><b>Search By Neighborhood</b></p><table cellpadding='2' cellspacing='0'>";
	            var sel = $("#" + NycHotelMapSearch.neighborhoodSelID)[0];
	           
				if (res != null && res.TotalCount > 0) 
				{ 
				    var curBoro = "";
				    var selCount = 0;
				    
				    for ( j = sel.options.length - 1; j >= 0; j--)
				    {
				        sel.options[j] = null;
				    }
				    
					for( var i = 0; i < res.Geocodes.length; i++ ) 
					{ 
					    if (i == NycHotelMapSearch.catPageSize) 
					        divHTML += "</table><table id='tblMoreLoc' cellpadding='2' cellspacing='0' style='display:none;'>";
					
					    if (res.Geocodes[i].IsBorough)
					    {
					        curBoro = res.Geocodes[i].Neighborhood;
					        
					        if (res.Geocodes[i].Latitude == 0 && res.Geocodes[i].Longitude == 0)
					        {
					            divHTML += "<tr><td colspan='2'>" + res.Geocodes[i].Neighborhood + "</td></tr>";
					        
					            sel.options[selCount] = new Option(res.Geocodes[i].Neighborhood, "//landmarks");
					            selCount++;
					        }
					        else
					        {
					            divHTML += "<tr><td colspan='2'><a href='' onclick='return " 
	                                + "NycHotelMapSearch.moveMap(\"" + escape(res.Geocodes[i].Neighborhood) + "\"," 
	                                + res.Geocodes[i].Latitude + "," 
	                                + res.Geocodes[i].Longitude + ",12);'>" 
	                                + res.Geocodes[i].Neighborhood + "</a></td></tr>";
	                                
	                            sel.options[selCount] = new Option(res.Geocodes[i].Neighborhood, 
	                                    "NycHotelMapSearch.moveMap(\"" + escape(res.Geocodes[i].Neighborhood) + "\"," 
	                                    + res.Geocodes[i].Latitude + "," 
	                                    + res.Geocodes[i].Longitude + ",12)"); 
	                            selCount++;
	                        }
					    }
					    else
					    {
					        divHTML += "<tr valign='top'><td>&nbsp;&nbsp;-</td><td><a href='' onclick='return " 
	                                + "NycHotelMapSearch.moveMap(\"" + escape(res.Geocodes[i].Neighborhood) + "\"," 
	                                + res.Geocodes[i].Latitude + "," 
	                                + res.Geocodes[i].Longitude + ",14);'>" 
	                                + res.Geocodes[i].Neighborhood + "</a></td></tr>";
	                        
	                        if (curBoro.toLowerCase().match("manhattan") != null || curBoro.toLowerCase().match("landmarks") != null)         
	                        {
	                            sel.options[selCount] = new Option("- " + res.Geocodes[i].Neighborhood, 
	                                        "NycHotelMapSearch.moveMap(\"" + escape(res.Geocodes[i].Neighborhood) + "\"," 
	                                        + res.Geocodes[i].Latitude + "," 
	                                        + res.Geocodes[i].Longitude + ",14)");
	                            selCount++;
	                        }
	                    }
					}
				}
				else
				{
				    divHTML += "<tr><td>" + res.TotalCount + "</td></tr>";
				}
				
				divHTML += "</table>";
	    
	            if (res.TotalCount > NycHotelMapSearch.catPageSize)
	            {    
	                divHTML += "<div style='margin-left:100px;'>"
	                        + "<a href='' id='locShowLink' onclick='$(&quot;#tblMoreLoc,#locShowLink,#locHideLink&quot;).toggle(); return false;'>more...</a>"
	                        + "<a href='' id='locHideLink' style='display:none;' onclick='$(&quot;#tblMoreLoc,#locShowLink,#locHideLink&quot;).toggle(); return false;'>[ x ] close</a>"
	                        + "</div>";
		        }
		        
		        div.html(divHTML);
			},"json");

	    return false;
	},

	showResultLoc : function() {   
	    var div = $("#" + NycHotelMapSearch.pnlResultLoc).empty();
	    
	    if (parseFloat(NycHotelMapSearch.lastLat) == parseFloat(NycHotelMapSearch.mapObj.getCenterLat()) 
		&& parseFloat(NycHotelMapSearch.lastLon) == parseFloat(NycHotelMapSearch.mapObj.getCenterLon()))
		{
		    div.html("<i>Near <b>" + NycHotelMapSearch.lastLocName + "</b></i>");
		}
	},
	
	addMapPushpin : function(record, ppIdx, isLandmark) {
	    var url = "";
	    
	    if (isLandmark == null) isLandmark = false;
	    
	    if (record.SectionID == 4)
	        url = record.BookingUrl;
	    else
	        url = record.NycUrl;
	    // add pushpin to the map
	    NycHotelMapSearch.mapObj.addPin(record.Latitude, record.Longitude, 
	    (isLandmark ? '' : (ppIdx + 1) + '. ') + '<a href=\'' + url + '\' target=\'_blank\'>' + record.Name + '</a>', 
	    '<div class=\'mppDetail\'>' + 
		(record.Editorial != null && (record.Editorial + '').strip() != '' ? record.Editorial 
		    + ' <a href=\'' + url + '\' target=\'_blank\'>more</a>' + '<br /><br />' : '') + 
	    
	    '<table cellpadding=\'0\' cellspacing=\'0\'><tr valign=\'top\'><td>' + 
	    (record.SectionID == 4 && record.Thumbnail != "" ? '<img src=\'' + record.Thumbnail 
	        + '\' style=\'margin-right:6px;\' width=\'64px\' /></td><td>' : '') +
	    (record.Neighborhood != '' ? 'Neighborhood: ' + record.Neighborhood + '<br />' : '') +
	    (record.Address + "" != "" ? record.Address.replace(/\n/g, '<br />') + '<br />' : '') + 
	    (record.Phone != '' ? '<b>' + record.Phone + '</b><br />' : '') + 
	    '</td></tr></table><br />' + 
	    (record.ERating > 0 ? '<img src=\'/image/hotels/stars/' + Math.floor(record.ERating) + '.gif\' /> <i>editorial review</i><br /><br />' : '') +
	    
	    // hotel reservation button
	    (record.SectionID == 4 ? '<a class=\'sellButton\' target=\'_blank\' href=\'' + 
	        url + '\'>&nbsp;&nbsp;MAKE RESERVATION&nbsp;&nbsp;</a><br /><br />' : '') +
	    
	    '<div style=\'line-height:20px;\'>' + 
	    '<a href=\'' + url.replace(/editorial.aspx/g, "map_location.aspx") 
	        + '\' target=\'_blank\'>Get Directions</a> | ' +   
	    '<a href=\'\' onclick=\'return emailThisPage(&quot;' 
	        + record.NycPageTitle  + '&quot;, &quot;' + url + '&quot;);\'>Send to Friend</a><br />' +   
	    '<a href=\'\' onclick=\'NycHotelMapSearch.mapObj.setMapCenter(' 
	        + (ppIdx + 1) + ', 17);  return false;\'>zoom to street level</a> | ' + 
	    '<a href=\'\' onclick=\'NycHotelMapSearch.mapObj.setMapCenter(' 
	        + (ppIdx + 1) + ', 12); return false;\'>zoom out</a></div><br />' , 
	    '/image/spacer.gif', 'pushpin' + (isLandmark ? 'Solo' : (ppIdx + 1)));
	},
	
	moveMap : function(neighborhood, lat, lon, zm) {
	    if ( lat == null ) lat = 0;
		if ( lon == null ) lon = 0;
	    if ( zm == null ) zm = 12;
	    if (lat != 0 && lon != 0) 
		{
		    NycHotelMapSearch.mapObj.moveMapGeocodes(lat,lon,zm);
		    
		    // keep track of latest neighborhood jump
		    NycHotelMapSearch.lastLat = NycHotelMapSearch.mapObj.getCenterLat();
		    NycHotelMapSearch.lastLon = NycHotelMapSearch.mapObj.getCenterLon();
		    NycHotelMapSearch.lastLocName = unescape(neighborhood);
	
	        NycHotelMapSearch.curAddress = "";
	        NycHotelMapSearch.curAddressLat = 0;
	        NycHotelMapSearch.curAddressLon = 0;
	        
		    if (NycHotelMapSearch.mapCallBack == "")
		        NycHotelMapSearch.getCats();
		}
		
		return false;
	},
	
	// this function moves map back to original lat lon and zoom
	defaultMap : function() {
	    var errorMsg = $("#" + NycHotelMapSearch.locSchErrorID).empty();
	    var errorMsgBtm = $("#" + NycHotelMapSearch.locSchErrorBtmID).empty();
	    
	    NycHotelMapSearch.isDefaultMapped = true;
	    
	    NycHotelMapSearch.resetMap();
	    
	    errorMsg.html("(No Results found in " + NycHotelMapSearch.lastLocName + ")");
	    errorMsgBtm.html("(No Results found in " + NycHotelMapSearch.lastLocName + ")");
	    
	    // clear last location info
	    NycHotelMapSearch.lastLat = 0;
		NycHotelMapSearch.lastLon = 0;
		NycHotelMapSearch.lastLocName = "";
		
	    return false;
	},
	
	// reset map to original state
	resetMap : function() {
	    NycHotelMapSearch.mapObj.moveMapGeocodes(NycHotelMapSearch.timeSqLat, NycHotelMapSearch.timeSqLon, 
	        NycHotelMapSearch.defaultZoom);
	    NycHotelMapSearch.curAddress = "";
        NycHotelMapSearch.curAddressLat = 0;
        NycHotelMapSearch.curAddressLon = 0;
    	    
	    return false;
	},
	
	// record the current Map Info
	saveMapInfo : function() {
	    NycHotelMapSearch.curMapStyle = NycHotelMapSearch.mapObj.getMapStyle();
        
	    if (NycHotelMapSearch.curMapStyle != VEMapStyle.Birdseye)
	    {
	        NycHotelMapSearch.curZoom = NycHotelMapSearch.mapObj.getZoomLevel();
	        NycHotelMapSearch.curCenterLat = NycHotelMapSearch.mapObj.getCenterLat();
            NycHotelMapSearch.curCenterLon = NycHotelMapSearch.mapObj.getCenterLon();
            
            var upperLeft = NycHotelMapSearch.mapObj.getUpperLeft();
            var lowerRight = NycHotelMapSearch.mapObj.getLowerRight();
            NycHotelMapSearch.curUpperLeftLat = upperLeft.Latitude;
            NycHotelMapSearch.curUpperLeftLon = upperLeft.Longitude;
            NycHotelMapSearch.curLowerRightLat = lowerRight.Latitude;
            NycHotelMapSearch.curLowerRightLon = lowerRight.Longitude;
        }
        else
            NycHotelMapSearch.curBirdseyeZoom = NycHotelMapSearch.mapObj.getZoomLevel();
        
        return false;
	},
	
	getLandmarkRecord : function(name) {
	    jQuery.post("post.nyc",{_ns:"MapSearch",_a:1,_m:"GetLandmarkRecord","name":name},
	        function(res) {
	            if (res != null && res.Name != null)
                {
                    NycHotelMapSearch.addMapPushpin(res,0,true);
                }
	        },"json");
	},
	
	searchAddress : function() {
	    var address = $("#" + NycHotelMapSearch.addressTxtID);
	    
	    if (address.val().strip() != "")
	    {
	        NycHotelMapSearch.mapObj.moveMap(address.val(), 
	            function(e) {	        
	                NycHotelMapSearch.curAddress = address.val();
	                NycHotelMapSearch.curAddressLat = NycHotelMapSearch.mapObj.getCenterLat();
	                NycHotelMapSearch.curAddressLon = NycHotelMapSearch.mapObj.getCenterLon();
	                NycHotelMapSearch.mapObj.addPin( NycHotelMapSearch.mapObj.getCenterLat(), 
	                    NycHotelMapSearch.mapObj.getCenterLon(), "Address Search:",
                        address.val() + '<br /><br />' +  
                        '<div style=\'line-height:20px;\'>' + 
                        '<a href=\'\' onclick=\'NycHotelMapSearch.mapObj.setMapCenter(' 
                            + NycHotelMapSearch.mapObj.pinID + ', 17);  return false;\'>zoom to street level</a> | ' + 
                        '<a href=\'\' onclick=\'NycHotelMapSearch.mapObj.setMapCenter(' 
                            + NycHotelMapSearch.mapObj.pinID + ', 12); return false;\'>zoom out</a></div><br />', 
                        "/image/spacer.gif", "pushpinSolo");
	            }
	        );
	        
	        NycHotelMapSearch.lastLat = 0;
		    NycHotelMapSearch.lastLon = 0;
		    NycHotelMapSearch.lastLocName = "";
	    }
	    
	    return false;
	},
	
	checkinChange : function() {
        var today = new Date( Date() );
        var checkin = $("#checkinDate");
        var checkout = $("#checkoutDate");
        var isResetDate = false;
        var newCheckoutDate = new Date( Date() );
        
        if (!Date.isValid(checkin.val()))
        {
            alert("Check-in date is not valid!");
            
            isResetDate = true;   
        }
        
        var result = Date.compare(new Date(checkin.val()), today);
        
        // reset check-in check-out dates if it's not a valid date or check-in date is before today
        if (result < 0 || isResetDate)
        {
            checkin.val( today.format("MM/dd/yyyy") );
            newCheckoutDate.setDate(newCheckoutDate.getDate() + 2);
        }
        else
        {
            newCheckoutDate = new Date( checkin.val() );
            newCheckoutDate.setDate(newCheckoutDate.getDate() + 2);
        }
        
        checkout.val(newCheckoutDate.format("MM/dd/yyyy"));
                                
        return;
    },
    
    checkoutChange : function() {
        var today = new Date( Date() );
        var checkin = $("#checkinDate");
        var checkout = $("#checkoutDate");
        var isResetDate = false;
        
        if (!Date.isValid(checkout.val()))
        {
            alert("Check-out date is not valid!");
            
            isResetDate = true;   
        }
        
        var result = Date.compare(new Date(checkout.val()), new Date(checkin.val()));
        
        // reset check-out dates if it's not a valid date or check-out date is before check-in date
        if (result <= 0 || isResetDate)
        {
            var newCheckoutDate = new Date( checkin.val() );
            
            newCheckoutDate.setDate(newCheckoutDate.getDate() + 1);
            
            checkout.val(newCheckoutDate.format("MM/dd/yyyy"));
        }
        
        return;
    },
    
    roomChange : function() {
        var roomSel = $("#roomSel")[0];
        var rooms = roomSel.options[roomSel.selectedIndex].value;
        var roomNumber = roomSel.selectedIndex + 1;
        
        for (idx = 1; idx < 9; idx++)
        {
            var room = $("#room" + idx)[0];
            
            room.style.display = (idx <= rooms ? "" : "none");
            $("#adultSel"+idx)[0].selectedIndex = ( idx <= roomNumber ? 1 : 0 );
	        $("#kidSel"+idx)[0].selectedIndex = 0;
            NycHotelMapSearch.childChanged(roomSel.options[roomSel.selectedIndex], idx);
        }
    },
    
    childChanged : function(opt,rn) {
        var maxchild = 0;	
        // find out the max number of childs from each room
        for ( i = 1; i < 9; i++ ){
	        var val = $('#kidSel'+ i)[0];
	        if ( val != null ) if ( parseInt(val.value) > maxchild ) maxchild = parseInt(val.value);
        }
    	
        // show the text asking for child ages
        $('#childtext,#childtbl').css("display", (maxchild > 0 ? "" : "none"));
    	
        // whether to show the 2nd row of labels
        $('#carw2').css("display", (maxchild > 2 ? "" : "none"));
          
        // left search 3rd row
        $('#carw3').css("display", (maxchild > 4 ? "" : "none"));
            
        // set whether to show the lable
        for ( i = 1; i < 7; i++ ) {
            $( '#calbl'+i ).css("display", (maxchild >= i ? "" : "none"));
    	}
    	
        // find out the number of children
        var child = $('#kidSel' + rn);
        var childnum = parseInt(child.val());
        // now do the real job, show the room 'rn' (parameter) row
        $('#rmr1ca'+rn).css("display", (childnum > 0 ? "" : "none"));
        $('#rmr2ca'+rn).css("display", (childnum > 3 ? "" : "none"));
        $('#rmr2ca'+rn).css("display", (childnum > 2 ? "" : "none")); // left search
        $('#rmr3ca'+rn).css("display", (childnum > 4 ? "" : "none")); // left search
        for ( i = 1; i < 7; i++ ) {
	        if ( childnum >= i ) $( '#r' + rn + 'ca' + i ).show();
	        else {
		        $( '#r' + rn + 'ca' + i ).hide();
		        $('#r' + rn + 'ca' + i)[0].childNodes[0].selectedIndex = 0;
	        }
        }	
        return false;
    },
    
    hotelChildAgeCheck : function() {
        el = document.forms[0].elements;
        for ( i = 1; i < 9; i++ ) {
	        if ( el["kidSel"+i] != null ) {
		        var o = parseInt(el["kidSel"+i].value);
		        if ( o > 0 ) {
			        for ( k = 0; k < o; k++ ) {
				        if ( el["r"+i+"ca"][k].selectedIndex == 0 ) {
					        alert( "Please specify the ages of all children." );
					        return false;
				        }
			        }
		        }
	        }
        }
        return true;
    },
    
	callBackSearch : function(e) {
	    if (NycHotelMapSearch.mapCallBack) {
	        NycHotelMapSearch.mapObj.deleteAllPins(); 
	        eval(NycHotelMapSearch.mapCallBack); 
	    }
	},
	
	callBackSaveMap : function(e) {
	    NycHotelMapSearch.saveMapInfo();
	},
	
	init : function() {
	    NycHotelMapSearch.curMapStyle = VEMapStyle.Road;
	    NycHotelMapSearch.mapObj.attachEvent('onchangeview', NycHotelMapSearch.callBackSaveMap);
	    NycHotelMapSearch.mapObj.attachEvent('onchangeview', NycHotelMapSearch.callBackSearch);
	    NycHotelMapSearch.showLocations(); 
	    NycHotelMapSearch.saveMapInfo();
	    
	    NycHotelMapSearch.roomChange();
	}
}

