var Hmap={qs:"",mapObj:null,mapID:"searchMap",hotels:[],addHotel:function(lat,lng,name,burl){var curIdx=Hmap.hotels.length;var ht={lat:lat,lng:lng,name:name,burl:burl};ht=Hmap.fetchHotel(ht,curIdx);Hmap.hotels.push(ht);return},drawMap:function(){Hmap.mapObj=new NycVEMap(Hmap.mapID,null,null,17,null,null);Hmap.mapObj.getMap(function(){Hmap.mapObj.map.AttachEvent("onmouseover",function(e){if(e.elementID){return true}});Hmap.mapObj.map.AttachEvent("onmouseout",function(e){if(e.elementID){return true}});Hmap.mapObj.map.AttachEvent("onclick",function(e){if(e.elementID){var shape=Hmap.mapObj.map.GetShapeByID(e.elementID);var offset=new VEPixel(30,5);if(shape){Hmap.mapObj.map.ShowInfoBox(shape,shape.GetPoints()[0],offset)}}});for(var idx=0;idx<Hmap.hotels.length;idx++){var ht=Hmap.hotels[idx];var title=Hmap.getTitle(ht);var customIcon="<div class='"+(ht.hasP?"veIconHotelHot":"veIconHotel")+"' onmouseover='Hmap.iconRollover(this)' onmouseout='Hmap.iconRollover(this)'><span>"+ht.lowRate+"</span></div>";var detail=Hmap.getDetail(ht,idx,Hmap.mapObj.getNextPinID());Hmap.mapObj.addPin(ht.lat,ht.lng,title,detail,"","","","",customIcon)}Hmap.mapObj.setMapView()})},getTitle:function(ht){var h=[];if(!ht.isGDS){h.push("<img src='/image/hotels/e_saver.jpg' style='position:absolute; top:10px; left:220px;' />")}if(ht.hasP){h.push("<img src='/image/hotels/hotdeal.gif' style='position:absolute; top:10px; left:15px;' />")}h.push("<br />");h.push("<a href='"+ht.burl+"editorial_review.aspx?"+ht.qs+"#RecordImage' ");h.push("class='recordTitle'>"+ht.name+"</a>");if(!String.isNullOrEmpty(ht.stars)){h.push("<br /><img src='"+ht.stars+"' style='width:70px; height:auto;' />")}return h.join("")},getDetail:function(ht,idx,ppIdx){var h=[];h.push("<div>"+ht.desc+"</div><br />");h.push("<table cellpadding='0' cellspacing='0'><tbody><tr valign='top'>");h.push("<td>");if(ht.img){h.push("<img src='"+ht.img+"' style='margin-right:6px; width:64px;' />")}h.push("</td>");h.push("<td>"+ht.addr+"</td>");h.push("</tr></tbody></table><br />");h.push("<table cellpadding='2' cellspacing='2' class='rateTable'><tbody>");h.push("<tr valign='bottom'>");h.push("<td class='rtRoomTop'>Room Type</td>");if(h.isGDS){h.push("<td class='rtRoomTop' style='color:black;' colspan='2'><b>Avg Nightly Rate</b><br/>per night, per room</td>")}else{h.push("<td class='rtRoomTop' style='color:black;' colspan='2'><b>Avg Nightly Rate</b><br/>starting from</td>")}h.push("</tr>");for(var idx=0;idx<ht.rate.length;idx++){h.push("<tr valign='middle'>");h.push("<td class='rtBodyRoom'>");h.push(ht.rate[idx].room);h.push("</td>");h.push("<td class='rtBodyAPrice'>");h.push(ht.rate[idx].price);h.push("</td>");h.push("<td class='rtBodyBook'>");h.push(ht.rate[idx].book);h.push("</td>");h.push("</tr>")}h.push("</tbody></table><br /><br />");h.push("<div class='reverseRollOverLink' style='line-height:20px;'>");h.push("<a class='regularDarkGrey' target='_blank' href='"+ht.burl+"map_location.aspx'>Get Directions</a>");h.push(" | <a class='regularDarkGrey' href='javascript://email this hotel' onclick='return Hmap.popEmail("+idx+")'>Send to Friend</a>");h.push("<br />");h.push("<a class='regularDarkGrey' href='javascript://zoom to street level' onclick='Hmap.zoomTo(\"Hmap.mapObj\","+ppIdx+", 17,"+idx+");'>zoom to street level</a>");h.push(" | <a class='regularDarkGrey' href='javascript://zoom out' onclick='Hmap.zoomTo(\"Hmap.mapObj\","+ppIdx+", 12,"+idx+");'>zoom out</a>");h.push("<!--[if lte IE 6.5]><iframe class='cal-select-free'></iframe><![endif]-->");return h.join("")},fetchHotel:function(ht,idx){var hotelItem=$($(".hotelItem")[idx]);ht.hasP=hotelItem.find("img[alt=Hot Deal]").length>0;ht.lowRate="";if(hotelItem.find(".hotelItemTopPrice").length>0){ht.lowRate=hotelItem.find(".hotelItemTopPrice").html()}if(!String.isNullOrEmpty(ht.lowRate)){ht.lowRate=ht.lowRate.replace(/([0-9\.]*$)/,Math.ceil(ht.lowRate.match(/([0-9\.]*$)/)[0]))}ht.desc="";if(hotelItem.find(".hotelInfoDesc").length>0){ht.desc=hotelItem.find(".hotelInfoDesc").html().replace("more hotel info","more").replace('class="h"','class="recordTitle"')}ht.stars="";if(hotelItem.find("img[src^=/image/hotels/stars]").length>0){ht.stars=hotelItem.find("img[src^=/image/hotels/stars]").attr("src")}ht.img="";if(hotelItem.find("img.himg").length>0){ht.img=hotelItem.find("img.himg").attr("src")}ht.addr="";if(hotelItem.find("table.hAddr").length>0){hotelItem.find("table.hAddr td").each(function(){ht.addr+=this.innerHTML+"<br />"})}ht.isGDS=hotelItem.find("a:contains(Click for detail)").length>0;ht.rate=[];hotelItem.find("td.rtBodyRoom").each(function(){var rate={};rate.room=this.innerHTML;ht.rate.push(rate)});var prices=hotelItem.find("td.rtBodyAPrice");for(var nIdx=0;nIdx<prices.length;nIdx++){ht.rate[nIdx].price=prices[nIdx].innerHTML}var books=hotelItem.find("td.rtBodyBook");for(var nIdx=0;nIdx<books.length;nIdx++){ht.rate[nIdx].book=books[nIdx].innerHTML}return ht},iconRollover:function(icon){var className=icon.className;if(className.match(/select/i)){className=className.replace(/Select/g,"")}else{className+="Select"}icon.className=className},zoomTo:function(mapvarname,idx,lvl,locIdx){var ht=Hmap.hotels[locIdx];eval(mapvarname+".setMapCenter("+idx+","+lvl+");");return false},popEmail:function(locIdx){var ht=Hmap.hotels[locIdx];emailThisPage("NYC.com - Hotels - "+ht.name+" from "+ht.lowRate,ht.burl+"editorial_review.aspx?"+Hmap.qs,true);return false}};var Hpnl={showRooms:function(anchor){var jAnchor=$(anchor);jAnchor.parent().siblings(".rateTable").find("tr:hidden").show();jAnchor.hide();return}};