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;var offsetypoint=20;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;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(rightedge<tipobj.offsetWidth){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{tipobj.style.left=curX+offsetxpoint+"px"}}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;var browser=navigator.appName;while(parentEl!=null){if(browser==="Microsoft Internet Explorer"&&parentEl.getAttribute("id")==="nycPopupDiv"){totaloffset=(offsettype=="left")?totaloffset+parentEl.offsetLeft:totaloffset+$("#nycPopupDiv").offset().top}else{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 NycEventMapSearch = {
	schTxtID : "schTxt",
	addressTxtID : "addressTxt",
	dateToID : "dateTo",
	dateFromID : "dateFrom",
	neighborhoodSelID : "neighborhoodSel",
	areaTxtID : "areaTxt",
	pnlCatSch : "catSch",
	pnlCatSchTop : "catSchTop",
	pnlCatSchTopPath : "catSchTopPath",
	pnlCatSchOrg : "catSchOrg",
	pnlCatSchNav : "catSchNav",
	pnlSchPath : "catSchPath",
	pnlResultSec : "resultSec",
	pnlResultDate : "resultDate",
	pnlResults : "results",
	pnlResultPath : "resultPath",
	pnlResultLoc : "resultLoc",
	nfoTotalCount : "totalcount",
	pnlResultsNav : "resultsNav",
	pnlLocSch : "locSch",
	pnlDateSch : "dateSch",
	locSchErrorID : "locSchError",
	locSchErrorBtmID : "locSchErrorBtm",
	
	mapCallBack : "",
	mapObj : null,
	pageSize : 20,
	catPageSize : 10,
	timeSqLat : 40.7558504573403,
	timeSqLon : -73.9864455393433,
	defaultZoom : 12,
	lastLat : 0,
	lastLon : 0,
	lastLocName : "",
	isDefaultMapped : false,
	lastSchPage : 1,
	lastMessages : "",
	
	curDateTo : "",
	curDateFrom : "",
	curCats : null,
	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,
	
	searchEvent : function(catid,catname,bitnum,eventDateFrom,eventDateTo,pagenum,isACallBack) {
		var fromLatLong = NycEventMapSearch.mapObj.getUpperLeft();
		var toLatLong = NycEventMapSearch.mapObj.getLowerRight();
	    var secid = 30;
	    
	    if (NycEventMapSearch.isDefaultMapped == true)
		    NycEventMapSearch.isDefaultMapped = false;
		else
		{
		    $("#" + NycEventMapSearch.locSchErrorID).empty();
		    $("#" + NycEventMapSearch.locSchErrorBtmID).empty();
		}
		    
		if ( catid == null ) catid = -1;
		if ( pagenum == null ) pagenum = 1;
		if ( catname == null ) catname = "";
		if ( eventDateTo == null ) eventDateTo = $("#" + NycEventMapSearch.dateToID).val();
		if ( eventDateFrom == null ) eventDateFrom = $("#" + NycEventMapSearch.dateFromID).val();
		if ( bitnum == null ) bitnum = 0;
	    
	    NycEventMapSearch.lastSchPage = pagenum;
	    
	    jQuery.post("post.nyc",{_ns:"MapSearch",_a:1,_m:"SearchForSection",sid:secid,cid:catid,sbn:bitnum,edf:eventDateFrom,
	        edt:eventDateTo,p:pagenum,ps:NycEventMapSearch.pageSize,fla:NycEventMapSearch.curUpperLeftLat,
	        flg:NycEventMapSearch.curUpperLeftLon,tla:NycEventMapSearch.curLowerRightLat,tlg:NycEventMapSearch.curLowerRightLon}, 
			function(res) { 
			    var div = $("#" + NycEventMapSearch.pnlResults).empty();    
			    var divPath = $("#" + NycEventMapSearch.pnlResultPath).empty();    
			    var resultDate = $("#" + NycEventMapSearch.pnlResultDate).empty(); 
			    
				$("#" + NycEventMapSearch.pnlResultSec).show();
				
		        // save the curEventDate
		        NycEventMapSearch.curDateTo = eventDateTo;
		        NycEventMapSearch.curDateFrom = eventDateFrom;
		        
				NycEventMapSearch.showResultLoc();
				NycEventMapSearch.mapObj.deleteAllPins();
				
		        var dateName = "";
		        
		        if (Date.isValid(eventDateFrom) && Date.isValid(eventDateTo))
		        {
		            var dateFromObj = new Date(eventDateFrom);
		            var dateToObj = new Date(eventDateTo);
		            var today = new Date();
		            var tomorrow = new Date();
		            tomorrow.setDate(today.getDate() + 1);
		            
		            if (Date.compare(dateFromObj, today) == 0)
		                dateName += "Today";
		            else if (Date.compare(dateFromObj, tomorrow) == 0)
		                dateName += "Tomorrow";
		            else 
		                dateName += dateFromObj.toDateString();
		                
		            if (Date.compare(dateToObj, dateFromObj) > 0)
		            {
		                dateName += " - ";
		                
		                if (Date.compare(dateToObj, tomorrow) == 0)
		                    dateName += "Tomorrow";
		                else 
		                    dateName += dateToObj.toDateString();
		            }
		            
	                dateName = dateName.replace(/\s/g, "&nbsp;");	            
    		        resultDate.html("Date Searched: " + dateName);	
    		        
    		        // update event search box dates
	                $("#" + NycEventMapSearch.dateFromID).val( (dateFromObj.getMonth() + 1) + "/" + dateFromObj.getDate() + "/" + dateFromObj.getFullYear() );
	                $("#" + NycEventMapSearch.dateToID).val( (dateToObj.getMonth() + 1) + "/" + dateToObj.getDate() + "/" + dateToObj.getFullYear() );
		        }	
		
				if (NycEventMapSearch.curCats != null)
			        divPath.html( NycEventMapSearch.curCats.SectionName + (catname != "" ? " : " + unescape(catname) : "") 
			                            + (catname == "" && dateName == "" ? " : Top Rated" : "") );
			        
				if ( res != null && res.TotalCount > 0 ) {
					$("#" + NycEventMapSearch.pnlResultSec).show();
					
					$("#" + NycEventMapSearch.nfoTotalCount).html("(" + res.TotalCount + " found)");
					
					div.empty();
					
					var resultsList = "<table cellpadding='2' cellspacing='0' class='regularLighterGrey'>";
							
					for( var i = 0; i < res.Records.length; i++ ) {
						var rec = res.Records[i];
						resultsList += "<tr valign='top'><td>" + (i+1) + ".</td><td><a target='_blank' href='" + rec.NycUrl 
						              + "' onmouseout='map.hidePushpinHover(" + (i + 1) + ")' onmouseover='map.showPushpinHover(" + (i + 1) + ")'>" 
						              + rec.Name + "</a>" 
						              + (Math.floor(rec.ERating) > 0 ? "<br />rating: <img src='/image/hotels/stars/" + Math.floor(rec.ERating) + ".gif' />" : ""); 
						resultsList += "</td></tr>";
						
						// add pushpin to the map
					    NycEventMapSearch.addMapPushpin(rec, i);
					}
					
					resultsList += "</table>";
					div.html(resultsList);
					
					NycEventMapSearch.showResultsNav(res.TotalCount, res.PageNum, "NycEventMapSearch.searchEvent(" + catid 
					                + ",\"" + catname + "\"," + bitnum + ",\"" + eventDateFrom + "\",\"" + eventDateTo + "\",");
				} else {
				    $("#" + NycEventMapSearch.nfoTotalCount).empty();
				    $("#" + NycEventMapSearch.pnlResultsNav).empty();
				    $("#" + NycEventMapSearch.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(NycEventMapSearch.lastLat) == parseFloat(NycEventMapSearch.mapObj.getCenterLat()) 
				    && parseFloat(NycEventMapSearch.lastLon) == parseFloat(NycEventMapSearch.mapObj.getCenterLon()))
				    {
				        NycEventMapSearch.defaultMap();
				    }
				}	
				
				if (NycEventMapSearch.lastLocName != "")
				    NycEventMapSearch.getLandmarkRecord(NycEventMapSearch.lastLocName);
				if (NycEventMapSearch.curAddress != "")
				    NycEventMapSearch.mapObj.addPin( NycEventMapSearch.curAddressLat, NycEventMapSearch.curAddressLon, "Address Search:", 
				                    NycEventMapSearch.curAddress + '<br /><br />' +  
	                                '<div class=\'mppDetail\' style=\'line-height:20px;\'>' + 
	                                '<a class=\'regularDarkGrey\' href=\'\' onclick=\'map.setMapCenter(' 
	                                    + NycEventMapSearch.mapObj.pinID + ', 17);  return false;\'>zoom to street level</a> | ' + 
	                                '<a class=\'regularDarkGrey\' href=\'\' onclick=\'map.setMapCenter(' 
	                                    + NycEventMapSearch.mapObj.pinID + ', 12); return false;\'>zoom out</a></div><br />', 
	                                "/image/spacer.gif", "pushpinSolo");
				    
				// rewrite category list
				NycEventMapSearch.showCats(1);
					                    
				// show location list
	            NycEventMapSearch.showLocations();	
	            
	            // show date list
	            NycEventMapSearch.showDates();	
	            
	            NycEventMapSearch.lastMessages = "";
	            // save messages for debug use.
	            if ( res != null)
			        NycEventMapSearch.lastMessages = res.Messages;
			}, "json");
		
		
		// save the current search for for map callback
		NycEventMapSearch.mapCallBack = "NycEventMapSearch.searchEvent(" + catid + ",\"" + catname + "\"," + bitnum + ",\"" + eventDateFrom + "\",\"" + eventDateTo + "\",null,true)";
		NycEventMapSearch.curCatID = catid;
		NycEventMapSearch.curCatName = catname;
		
		return false;
	},
	
	showResultsNav : function(total,pagenum,schfunc) {
		var div = $("#" + NycEventMapSearch.pnlResultsNav).empty();
		var numOfPage = Math.ceil( total / NycEventMapSearch.pageSize );
		var navPageSize = 7;
		var start = 0;
		var end = 0;
			
		if ( numOfPage <= 1 ) {
			div.empty();
			return;
		}
		
		// page nav will only show 8 pages at a time...
		if ( numOfPage > navPageSize) {
		    if (pagenum <= (navPageSize + 1) / 2) {
		        start = 1;
		        end = navPageSize + 1;
		    }
		    else {
		        start = pagenum - 4;
		        end = (start + navPageSize < numOfPage  + 1 ? start + navPageSize : numOfPage + 1);
		    }
		}
		else {
		    start = 1;
		    end = numOfPage + 1;
		}
	    
	    var navHTML = "";
		navHTML = "Page:";
		if (pagenum > 1) { 
			navHTML += "&nbsp;<a href='' class='regularBlue' onclick='return " + schfunc + (pagenum-1) + ");'><</a>";
		}
		
		if (start > 1) {
	        navHTML += "&nbsp;...";
	    }
		    
		var i = 1;
		for (i = start; i < end; i++) {
			if ( i == pagenum ) {
				navHTML += "&nbsp;<b>" + i + "</b>";
			} else {
				navHTML += "&nbsp;<a href='' onclick='return " + schfunc + i + ");'>" + (i) + "</a>";
			}
		}
		
		if (end - 1 < numOfPage) {
		    navHTML += "&nbsp;...";
		} 
		
		if ( pagenum < numOfPage ) { 
			navHTML += "&nbsp;<a href='' onclick='return " + schfunc + (pagenum+1) + ");'>></a>";
		}
		
		div.html(navHTML);
	},

	getCats : function() {
		var secid = 30;
		
		$("#" + NycEventMapSearch.pnlCatSch).empty();
		$("#" + NycEventMapSearch.pnlCatSchTopPath).empty();	
		$("#" + NycEventMapSearch.pnlCatSchTop).empty();	
		
		jQuery.post("post.nyc",{_ns:"MapSearch",_a:1,_m:"GetCategoriesFor",sid:secid},
			function(res) { 
				if (res != null && res.TotalCount > 0) {
					NycEventMapSearch.curCats = res;
					NycEventMapSearch.showCats(1);
				} else {
					NycEventMapSearch.curCat = null;
				}
			}, "json");
		
		NycEventMapSearch.searchEvent();
		
		return false;
	},
	
	showCats : function(page) {
	    $("#" + NycEventMapSearch.pnlCatSchTopPath).empty();	
		$("#" + NycEventMapSearch.pnlCatSchTop).empty();	
		
		if (page == 0 || NycEventMapSearch.curCats == null ) {    
			NycEventMapSearch.showCatsPath(1);
			NycEventMapSearch.searchEvent(null,1);
			return false;
		}

        $("#" + NycEventMapSearch.pnlCatSchNav).hide();

        var showMoreLink = false;
		var div = $("#" + NycEventMapSearch.pnlCatSch).empty();		
		var divTop = $("#" + NycEventMapSearch.pnlCatSchTop).empty();		
		var resultsList = "<table cellpadding='2' cellspacing='0'>";
		
		var count = 1;
		var restoPriceIdx = 0;
		var lastCatName = "";
			
		divTop.html("<p style='margin-top:4px;'><b>Search By Category</b></p>");
		
        for (var i = 0; i < NycEventMapSearch.curCats.TotalCount; i++) 
        {
			var cat = NycEventMapSearch.curCats.Cats[i];
			
			if (cat.subcatid == NycEventMapSearch.curCatID)
			    curCatName = cat.name;
			   
			if (count - 1 == NycEventMapSearch.catPageSize) 
			{
		        resultsList += "</table><table id='tblMoreCat' cellpadding='2' cellspacing='0' "
		                    + "style='display:none;'>";
	            showMoreLink = true;       
			}
			
			resultsList += "<tr><td style='width:" + (NycEventMapSearch.curCats.TotalCount >= 100 ? "23" : "15") + "px;'>" 
			            + count + ".</td><td><a href='' onclick='return " 
			            + "NycEventMapSearch.searchEvent(" 
			            + cat.subcatid + ",\"" + escape(cat.name) + "\"," 
			            + (cat.field.toLowerCase().indexOf("bit") > -1 ? cat.field.substring(cat.field.indexOf("_") + 1) : "null") 
			            + ",\"" + NycEventMapSearch.curDateFrom + "\",\"" + NycEventMapSearch.curDateTo + "\",1);'>" + cat.name + "</a></td></tr>";
		    
		    count++;
		    
		    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;
	},
	
	// add dates search link after category list for events
    showDates : function() {
	    var div = $("#" + NycEventMapSearch.pnlDateSch).empty();	
	    
        var resultsList = "<p style='margin-top:20px;'><b>Search By Date</b></p><table cellpadding='2' cellspacing='0'>";
        
        for (i = 0; i < 21; i++)
        {
            var iDate = new Date();
            iDate.setDate(iDate.getDate() + i);
            var iDateName = (i == 0 ? "Today" : (i == 1 ? "Tomorrow" : iDate.toDateString()));
            
            if (i == 10)
                resultsList += "</table><table id='tblMoreDate' cellpadding='2' cellspacing='0' style='display:none;'>";
                
            resultsList += "<tr><td>&nbsp;&nbsp;- </td><td><a href='' class='boldDarkGrey' onclick='return NycEventMapSearch.searchEvent(" 
                        + NycEventMapSearch.curCatID + ",\"" + escape(NycEventMapSearch.curCatName) + "\",null,\"" 
                        + iDate.toDateString() + "\",\"" + iDate.toDateString() + "\",1);'>" + iDateName + "</a></td></tr>";
        }
        
        resultsList += "</table>";
        
        resultsList += "<div style='margin-left:110px;'>"
                    + "<a href='' id='dateShowLink' onclick='$(&quot;#tblMoreDate,#dateShowLink,#dateHideLink&quot;).toggle(); return false;'>more...</a>"
                    + "<a href='' id='dateHideLink' style='display:none;' onclick='$(&quot;#tblMoreDate,#dateShowLink,#dateHideLink&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 = $("#" + NycEventMapSearch.pnlLocSch).empty();
	            var divHTML = "<br /><p><b>Search By Neighborhood</b></p><table cellpadding='2' cellspacing='0'>";
	            var sel = $("#" + NycEventMapSearch.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 == NycEventMapSearch.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 " 
	                                + "NycEventMapSearch.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, 
	                                    "NycEventMapSearch.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 " 
	                                + "NycEventMapSearch.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, 
	                                        "NycEventMapSearch.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 > NycEventMapSearch.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;
	},
	
	showCatsNav : function(pagenum,numOfPage) {
		$("#" + NycEventMapSearch.pnlCatSchNav).show();
		var div = $("#" + NycEventMapSearch.pnlCatSchNav).empty();
		var navPageSize = 8;
		var start = 0;
		var end = 0;
		var html = "";
		
		// page nav will only show 10 pages at a time...
		if ( numOfPage > navPageSize) {
		    if (pagenum <= navPageSize / 2) {
		        start = 1;
		        end = navPageSize + 1;
		    }
		    else {
		        start = pagenum - 4;
		        end = (start + navPageSize < numOfPage  + 1 ? start + navPageSize : numOfPage + 1);
		    }
		}
		else {
		    start = 1;
		    end = numOfPage + 1;
		}
		
		html = "Page: ";
		if (pagenum > 1) { 
			html += " <a href='' onclick='return NycEventMapSearch.showCats(" + (pagenum-1) + ");'><</a>";
		}
		
		var i = 1;
		for (i = start; i < end; i++) {
			if ( i == pagenum ) {
				html += " <b>" + i + "</b>";
			} else {
				html += " <a href='' onclick='return NycEventMapSearch.showCats(" + i + ");'>" + (i) + "</a>";
			}
		}
		
		if ( pagenum < numOfPage ) { 
			html += " <a href='' onclick='return NycEventMapSearch.showCats(" + (pagenum+1) + ");'>></a>";
		}
		
		div.html(html);
	},

	showCatsPath : function(all,cat,catname,subcatname) {
		var div = $("#" + NycEventMapSearch.pnlSchPath).empty();
		var divCat = $("#" + NycEventMapSearch.pnlCatSchTopPath).empty();
		
        var pathHtml = "";
		if ( all ) {
			pathHtml = "All";
			$("#" + NycEventMapSearch.pnlCatSchOrg).show();
			$("#" + NycEventMapSearch.pnlCatSch).hide();
			$("#" + NycEventMapSearch.pnlCatSchNav).hide();
			return false;
		} else {
			pathHtml = "<a href='' onclick='return NycEventMapSearch.showCats(0)'>All</a>";
		}
		if ( cat && !subcatname ) {
			pathHtml += " > " + unescape(catname);
		} else {
			pathHtml += " > <a href='' onclick='return NycEventMapSearch.getCats(" + cat + ")'>" + unescape(catname) + "</a>";
		}
		
		if ( subcatname ) {
			pathHtml += " > " + unescape(subcatname);
		}
		
		div.html(pathHtml);
		divCat.htm(pathHtml);
		
		return false;
	},
	
	showResultLoc : function() {   
	    var div = $("#" + NycEventMapSearch.pnlResultLoc).empty();
	    
	    if (parseFloat(NycEventMapSearch.lastLat) == parseFloat(NycEventMapSearch.mapObj.getCenterLat()) 
		&& parseFloat(NycEventMapSearch.lastLon) == parseFloat(NycEventMapSearch.mapObj.getCenterLon()))
		{
		    div.html("<i>Near <b>" + NycEventMapSearch.lastLocName + "</b></i>");
		}
	},
	
	addMapPushpin : function(record, ppIdx, isLandmark) {
	    if (isLandmark == null) isLandmark = false;
	   
	    // add pushpin to the map
	    NycEventMapSearch.mapObj.addPin(record.Latitude, record.Longitude, 
	    (isLandmark ? '' : (ppIdx + 1) + '. ') + '<a href=\'' + record.NycUrl + '\' target=\'_blank\'>' + record.Name + '</a>', 
	    '<div class=\'mppDetail\'' + 
		(record.Editorial != null && (record.Editorial + '').strip() != '' ? record.Editorial 
		    + ' <a href=\'' + record.NycUrl + '\' target=\'_blank\'>more</a>' + '<br /><br />' : '') + 
	    (record.SectionID == 30 && record.Venue + '' != '' ? 'Venue: <b>' + record.Venue + '</b><br />' : '') +
	    
	    '<table cellpadding=\'0\' cellspacing=\'0\'><tr valign=\'top\'><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 />' : '') +
	    
	    // ticket button
	    (record.BookingUrl != '' ? '<a class=\'sellButton\' target=\'_blank\' href=\'' + 
	        record.BookingUrl + '\'>&nbsp;&nbsp;BUY TICKETS&nbsp;&nbsp;</a><br /><br />' : '') +
	    '<div style=\'line-height:20px;\'>' + 
	    '<a  href=\'' + record.NycUrl.replace(/editorial.aspx/g, "map_location.aspx") 
	        + '\' target=\'_blank\'>Get Directions</a> | ' +   
	    '<a href=\'\' onclick=\'return emailThisPage(&quot;' 
	        + record.NycPageTitle  + '&quot;, &quot;' + record.NycUrl + '&quot;);\'>Send to Friend</a><br />' +   
	    '<a href=\'\' onclick=\'NycEventMapSearch.mapObj.setMapCenter(' 
	        + (ppIdx + 1) + ', 17);  return false;\'>zoom to street level</a> | ' + 
	    '<a href=\'\' onclick=\'NycEventMapSearch.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) 
		{
		    NycEventMapSearch.mapObj.moveMapGeocodes(lat,lon,zm);
		    
		    // keep track of latest neighborhood jump
		    NycEventMapSearch.lastLat = NycEventMapSearch.mapObj.getCenterLat();
		    NycEventMapSearch.lastLon = NycEventMapSearch.mapObj.getCenterLon();
		    NycEventMapSearch.lastLocName = unescape(neighborhood);
		    
		    NycEventMapSearch.curAddress = "";
	        NycEventMapSearch.curAddressLat = 0;
	        NycEventMapSearch.curAddressLon = 0;
	        
	        if (NycEventMapSearch.mapCallBack == "")
		        NycEventMapSearch.getCats();
		}
		
		NycEventMapSearch.getLandmarkRecord(NycEventMapSearch.lastLocName);
		
		return false;
	},
	
	// this function moves map back to original lat lon and zoom
	defaultMap : function() {
	    var errorMsg = $("#" + NycEventMapSearch.locSchErrorID).empty();
	    var errorMsgBtm = $("#" + NycEventMapSearch.locSchErrorBtmID).empty();
	    
	    NycEventMapSearch.isDefaultMapped = true;
	    
	    NycEventMapSearch.resetMap();
	    
	    errorMsg.html("(No Results found in " + NycEventMapSearch.lastLocName + ")");
	    errorMsgBtm.html("(No Results found in " + NycEventMapSearch.lastLocName + ")");
	    
	    // clear last location info
	    NycEventMapSearch.lastLat = 0;
		NycEventMapSearch.lastLon = 0;
		NycEventMapSearch.lastLocName = "";
		
	    return false;
	},
	
	// reset map to original state
	resetMap : function() {
	    NycEventMapSearch.mapObj.moveMapGeocodes(NycEventMapSearch.timeSqLat, NycEventMapSearch.timeSqLon, NycEventMapSearch.defaultZoom);
	    NycEventMapSearch.curAddress = "";
        NycEventMapSearch.curAddressLat = 0;
        NycEventMapSearch.curAddressLon = 0;
    	    
	    return false;
	},
	
	// record the current Map Info
	saveMapInfo : function() {
	    NycEventMapSearch.curMapStyle = NycEventMapSearch.mapObj.getMapStyle();
        
	    if (NycEventMapSearch.curMapStyle != VEMapStyle.Birdseye)
	    {
	        NycEventMapSearch.curZoom = NycEventMapSearch.mapObj.getZoomLevel();
	        NycEventMapSearch.curCenterLat = NycEventMapSearch.mapObj.getCenterLat();
            NycEventMapSearch.curCenterLon = NycEventMapSearch.mapObj.getCenterLon();
            
            var upperLeft = NycEventMapSearch.mapObj.getUpperLeft();
            var lowerRight = NycEventMapSearch.mapObj.getLowerRight();
            NycEventMapSearch.curUpperLeftLat = upperLeft.Latitude;
            NycEventMapSearch.curUpperLeftLon = upperLeft.Longitude;
            NycEventMapSearch.curLowerRightLat = lowerRight.Latitude;
            NycEventMapSearch.curLowerRightLon = lowerRight.Longitude;
        }
        else
            NycEventMapSearch.curBirdseyeZoom = NycEventMapSearch.mapObj.getZoomLevel();
        
        return false;
	},
	
	// this function construct current map search querystring and pop up email page
	emailThisMap : function() {
	    var url = "/events/mapsearch.aspx";
	    var isTextSearch = false;
	    
	    // map position and zoom level
	    url += "?lat=" + NycEventMapSearch.curCenterLat;
	    url += "&lon=" + NycEventMapSearch.curCenterLon;
	    url += "&z=" + NycEventMapSearch.curZoom;
	    url += "&ms=" + NycEventMapSearch.curMapStyle.toString();
	    url += "&bz=" + NycEventMapSearch.curBirdseyeZoom;

        var param = NycEventMapSearch.mapCallBack.replace(/NycEventMapSearch.searchEvent\(/g, "").replace(/\)/g, "").split(',');
        var secid = 0;
        
        if (NycEventMapSearch.curCats != null)
            url += "&sid=30";
            
        if (param.length > 0 && parseInt(param[0]) > 0)
            url += "&cid=" + param[0].strip();
        
        if (param.length > 1 && parseInt(param[0]) > 0)
            url += "&cn=" + escape(unescape(param[1].replace(/\"/g, "").replace(/'/g, ""))).strip();
            
        if (param.length > 2 && parseInt(param[2]) > 0)
            url += "&b=" + param[2].strip();
            
        url += "&p=" + NycEventMapSearch.lastSchPage;
        
        var dateFrom =escape(unescape(param[3].replace(/\"/g, "").replace(/'/g, ""))).strip();
        
        if (dateFrom != "")
            url += "&df=" + dateFrom;
            
        var dateTo = escape(unescape(param[4].replace(/\"/g, "").replace(/'/g, ""))).strip();
        
        if (dateTo != "")
            url += "&dt=" + dateTo;
       
	    // pop up email page
	    window.open("/emailthispage.aspx?title=" + escape("NYC.Com - Map Search") + "&url=" + escape(url) + "&titlesubject=1", "email", "height=650,width=550");
	    
	    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)
                {
                    NycEventMapSearch.addMapPushpin(res,0,true);
                }
	        },"json");   
	},
	
	searchAddress : function(address) {
	    if (address == null) address = $("#" + NycEventMapSearch.addressTxtID);
	    
	    if (address.val().strip() != "")
	    {
	        NycEventMapSearch.mapObj.moveMap(address.val(), 
	            function(e) {	        
	                NycEventMapSearch.curAddress = address.val();
	                NycEventMapSearch.curAddressLat = NycEventMapSearch.mapObj.getCenterLat();
	                NycEventMapSearch.curAddressLon = NycEventMapSearch.mapObj.getCenterLon();
	                NycEventMapSearch.mapObj.addPin( NycEventMapSearch.mapObj.getCenterLat(), NycEventMapSearch.mapObj.getCenterLon(), "Address Search:", 
                                    address.val() + '<br /><br />' +  
	                                '<div class=\'reverseRollOverLink\' style=\'line-height:20px;\'>' + 
	                                '<a class=\'regularDarkGrey\' href=\'\' onclick=\'NycEventMapSearch.mapObj.setMapCenter(' 
	                                    + NycEventMapSearch.mapObj.pinID + ', 17);  return false;\'>zoom to street level</a> | ' + 
	                                '<a class=\'regularDarkGrey\' href=\'\' onclick=\'NycEventMapSearch.mapObj.setMapCenter(' 
	                                    + NycEventMapSearch.mapObj.pinID + ', 12); return false;\'>zoom out</a></div><br />', 
                                    "/image/spacer.gif", "pushpinSolo");
	            }
	        );
	        
	        NycEventMapSearch.lastLat = 0;
		    NycEventMapSearch.lastLon = 0;
		    NycEventMapSearch.lastLocName = "";
	    }
	    
	    return false;
	},
	
	callBackSearch : function(e) {
	    if (NycEventMapSearch.mapCallBack) {
	        NycEventMapSearch.mapObj.deleteAllPins(); 
	        eval(NycEventMapSearch.mapCallBack); 
	    }
	},
	
	callBackSaveMap : function(e) {
	    NycEventMapSearch.saveMapInfo();
	},
	
	init : function(secid,catid,catname,mappedbitID,dateFrom,dateTo,page,mapStyle,birdseyeZoom) {
	    NycEventMapSearch.curMapStyle = VEMapStyle.Road;
	    NycEventMapSearch.mapObj.attachEvent('onchangeview', NycEventMapSearch.callBackSaveMap);
	    NycEventMapSearch.mapObj.attachEvent('onchangeview', NycEventMapSearch.callBackSearch);
	    NycEventMapSearch.showLocations(); 
	    NycEventMapSearch.saveMapInfo();
	    
	    if (secid > 0) {
	        NycEventMapSearch.getCats();
	        
	        if (catid > 0) {
	            NycEventMapSearch.searchEvent(catid,catname,mappedbitID,dateFrom,
	                dateTo,( page > 0 ? page : 1 ));
	        }
	    }
	    
	    if (dateFrom != "")
	        $("#dateFrom").val(Date.parseNYC(dateFrom).format("MM/dd/yyyy"));  
	    if (dateTo != "")
	        $("#dateTo").val(Date.parseNYC(dateTo).format("MM/dd/yyyy"));
	        
	    if (mapStyle != "") {
	        NycEventMapSearch.mapObj.setMapStyle(mapStyle);
	        if (mapStyle == VEMapStyle.Birdseye)
	        NycEventMapSearch.mapObj.setZoomLevel(birdseyeZoom);
	    }
	},
	
	dateFromChange : function() {
        var today = new Date( Date() );
        var fromDate = $("#dateFrom");
        var toDate = $("#dateTo");
        var isResetDate = false;
        var newDateFrom = new Date( Date() );
        
        if (!Date.isValid(fromDate.val()))
        {
            alert("FROM date is not valid!");
            
            isResetDate = true;   
        }
        
        var result = Date.compare(new Date(fromDate.value), 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)
        {
            fromDate.val( today.format("MM/dd/yyyy") );
            
            newDateFrom.setDate(newDateFrom.getDate() + 1);
        }
        else
        {
            newDateFrom = new Date( fromDate.val() );
            newDateFrom.setDate(newDateFrom.getDate());
        }
        
        toDate.val( newDateFrom.format("MM/dd/yyyy") );
                                
        return;
    },
    
    dateToChange : function() {
        var today = new Date( Date() );
        var fromDate = $("#dateFrom");
        var toDate = $("#dateTo");
        var isResetDate = false;
        
        if (!Date.isValid(toDate.val()))
        {
            alert("TO date is not valid!");
            
            isResetDate = true;   
        }
        
        var result = Date.compare(new Date(toDate.val()), new Date(fromDate.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 newDateFrom = new Date( fromDate.val() );
            
            newDateFrom.setDate(newDateFrom.getDate());
            
            toDate.val( newDateFrom.format("MM/dd/yyyy") );
        }
        
        return;
    }
}

