YAHOO.nefMap=function(){return{setMap:function(firstmaptype,latitude,longitude,userMapType){if(GBrowserIsCompatible()){this.userMapType=!(userMapType)?"new":userMapType;this.map=new GMap2(document.getElementById("map"));this.map.addControl(new GSmallMapControl());this.map.addControl(new GMapTypeControl());this.map.setCenter(new GLatLng(parseFloat(latitude),parseFloat(longitude)));this.map.enableScrollWheelZoom();this.bounds=new GLatLngBounds();this.tooltip=document.createElement("div");this.map.getPane(G_MAP_FLOAT_PANE).appendChild(this.tooltip);this.tooltip.id="maptooltip";this.tooltip.style.visibility="hidden";this.currmarkers=[];this.ew=new EWindow(this.map,E_STYLE_7);this.map.addOverlay(this.ew);this.mapDiv=document.getElementById("map");if(firstmaptype){if(firstmaptype=="user"){var inside=document.createElement("div");inside.id="map";inside.style.margin="0px 0px 10px 0px";var toattach=document.getElementById("usemapcont");toattach.appendChild(inside)}}}else{toggleMap.showMapError("Your current browser settings do not allow you to use the mapping feature");return false}},createMarker:function(point,label,mlnum,type){var customIcon=this.makeIcon(type);var marker=new GMarker(point,{icon:customIcon});this.bounds.extend(marker.getLatLng());this.currmarkers.push(marker);marker.tooltip='<div class="tooltip"><nobr>'+label+"</nobr></div>";marker.mlnum=mlnum;var that=this;GEvent.addListener(marker,"mouseover",function(){that.showTooltip(marker)});GEvent.addListener(marker,"mouseout",function(){that.mapHideTip()});GEvent.addListener(marker,"click",function(){that.mapHideTip();that.makeWindow(mlnum,marker)});return marker},userHidemap:function(){var spanin=document.getElementById("openclose");spanin.setAttribute("onclick","userMapload();");spanin.innerHTML="Show Map +";var theparent=document.getElementById("usemapcont");theparent.removeChild(document.getElementById("map"))},mapHideTip:function(){if(this.tooltip){this.showPolygonsearchTooltip();this.tooltip.style.visibility="hidden"}},goToTip:function(num){var marker=this.currmarkers[num];this.map.panTo(new GLatLng(marker.getPoint().lat(),marker.getPoint().lng()));this.makeWindow(this.currmarkers[num].mlnum,marker)},popCheck:function(e){if(checkClick(e,document.getElementById("propmapwintxt"))){YAHOO.nefMap.ew.hide()}},showTooltip:function(marker){if(marker){this.hidePolygonsearchTooltip();var point=this.map.getCurrentMapType().getProjection().fromLatLngToPixel(this.map.fromDivPixelToLatLng(new GPoint(0,0),true),this.map.getZoom());var offset=this.map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),this.map.getZoom());var anchors=marker.getIcon().iconAnchor;var width=marker.getIcon().iconSize.width;var height=this.tooltip.clientHeight;var pos=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(offset.x-point.x-anchors.x+width,offset.y-point.y-anchors.y-height));pos.apply(this.tooltip);this.tooltip.innerHTML=marker.tooltip;this.tooltip.style.visibility="visible"}},hidePolygonsearchTooltip:function(){if(searchMap.isPolygonOnMap()){searchMap.hidePolyLabel()}},showPolygonsearchTooltip:function(){if(searchMap.isPolygonOnMap()){searchMap.showPolyLabel()}},jIn:function(req){var data=eval("("+req+")");if(data.allmark.length>0){for(var i=0;i<data.allmark.length;i++){var lat=parseFloat(data.allmark[i].markers.lat);var lon=parseFloat(data.allmark[i].markers.lon);var point=new GLatLng(lat,lon);var label=data.allmark[i].markers.address+"<br/>"+data.allmark[i].markers.price;var id=data.allmark[i].markers.mlnum;var uid=data.allmark[i].markers.uid;var add=this.createMarker(point,label,uid,data.type);this.map.addOverlay(add)}this.map.setCenter(this.bounds.getCenter());this.map.setZoom(this.map.getBoundsZoomLevel(this.bounds))}else{toggleMap.noListings()}},purgeMarkers:function(){if(typeof this.currmarkers!=="undefined"){for(var i=0;i<this.currmarkers.length;i++){this.map.removeOverlay(this.currmarkers[i])}this.currmarkers=[];this.ew.hide()}},updateMap:function(req){this.purgeMarkers();if(typeof this.currmarkers!=="undefined"){this.jIn(req)}toggleMap.removeErrors()},makeWindow:function(mlnum,marker){if(marker){var cmd=isNaN(mlnum)?"&cmd=mquery":"&cmd=fquery";var that=this;var callback={success:function(o){that.ew.openOnMarker(marker,o.responseText);var upperNode=document.getElementById("propmapwintxt");var firstNode=upperNode;var closeBtn=firstNode.getElementsByTagName("INPUT")[0];if(closeBtn.onclick!=="function"){closeBtn.onclick=function(){that.ew.hide()}}that.map.panTo(new GLatLng(marker.getPoint().lat(),marker.getPoint().lng()))}};YAHOO.util.Connect.asyncRequest("GET",DOC_ROOT+"actions.php?thecmd=single&mlnum="+mlnum+cmd,callback,null);this.tooltip.style.visibility="hidden"}},makeIcon:function(type){var gim=IMG_FOLDER+"map/"+type.toLowerCase()+".png";var tinyIcon=new GIcon();tinyIcon.image=gim;tinyIcon.shadow=IMG_FOLDER+"map/mm_20_shadow.png";tinyIcon.iconSize=new GSize(26,33);tinyIcon.shadowSize=new GSize(22,20);tinyIcon.iconAnchor=new GPoint(6,20);tinyIcon.infoWindowAnchor=new GPoint(1,1);return tinyIcon},zoomAndCenter:function(){this.map.checkResize();this.map.setCenter(this.bounds.getCenter());this.map.setZoom(this.map.getBoundsZoomLevel(this.bounds))},setMapType:function(type){switch(type.toLowercase()){case"address":this.mapType="address";break;case"standard":this.mapType="standard";break}}}}();var searchMap=function(){return{init:function(){return true},searchTypeTab:function(tab){toggleMap.toggleTypeTab(tab);switch(tab.id){case"map_by_address":this.byAddress();break;case"map_standard":this.byStandard();break}},byAddress:function(){if(this.isPolygonOnMap()){return true}else{if(toggleMap.isSideBarVisible()&&this.isPolygonOnMap()===false){return true}else{this.clearSearchPolygons()}}},byStandard:function(){if(this.isPolygonOnMap()){this.deleteSearchUrls();this.clearSearchPolygons();var self=this;var changeStandard=function(){var callback={success:function(ro){var ok=self.checkAjaxOk(ro);if(ok){self.ajaxDependentSuccess(ro)}}};YAHOO.util.Connect.asyncRequest("GET",UPDATE_FLDR+urlHandler.getCommitedUrl(),callback,null)};urlHandler.commitUrl("",changeStandard)}else{var rows=typeof QUERY_ROWS=="undefined"?0:getIntVal(QUERY_ROWS);if(YAHOO.nefMap.currmarkers.length==0||rows==0&&typeof QUERY_ROWS!=="undefined"){toggleMap.noListings();return true}}YAHOO.nefMap.zoomAndCenter()},deleteSearchUrls:function(){urlHandler.deleteUrlPart("address");urlHandler.deleteUrlPart("lat");urlHandler.deleteUrlPart("lon");urlHandler.deleteUrlPart("maptype");urlHandler.deleteUrlPart("radius");urlHandler.deleteUrlPart("address")},addressSearch:function(){var masterDiv=document.getElementById("address_input");var isRadiusRegex=/^[0-9.]+$/;var isCaRegex=/(,|\s)+ca$/i;var inputs=masterDiv.getElementsByTagName("input");var currentErrors=YAHOO.util.Dom.getElementsByClassName("form_error","DIV",masterDiv);for(var i=0;i<currentErrors.length;i++){masterDiv.removeChild(currentErrors[i])}for(var i=0;i<inputs.length;i++){var input=inputs[i];if(input.value==""||input.value==input.defaultValue){var errorPopup=buildSmallErrorPopup(input,"* Please fill box in","",-10,"");masterDiv.appendChild(errorPopup);var returnBool=false}}if(returnBool==false){return false}var location=inputs[1].value;if(isCaRegex.test(location)){location.replace(isCaRegex,"")}var radiusBox=inputs[2];if(!isRadiusRegex.test(radiusBox.value)){var errorPopup=buildSmallErrorPopup(radiusBox,"* Please enter a numeric radius","",-22,"");document.getElementById("address_input").appendChild(errorPopup);var returnBool=false}var formattedAddress=inputs[0].value+","+inputs[1].value;var mapType="byadd";if(returnBool==false){return false}else{urlHandler.replaceOrInsert("address",encodeURI(formattedAddress));urlHandler.replaceOrInsert("radius",encodeURI(parseFloat(radiusBox.value)));urlHandler.replaceOrInsert("maptype",mapType);var self=this;var addressMakeSearch=function(){var callback={success:function(ro){var Ok=self.checkAjaxOk(ro);if(Ok==true){self.addressSearchSuccess(ro.responseText);self.ajaxDependentSuccess(ro)}}};YAHOO.util.Connect.asyncRequest("GET",UPDATE_FLDR+urlHandler.getCommitedUrl(),callback,null)};urlHandler.commitUrl("",addressMakeSearch)}},checkAjaxOk:function(ro){eval(ro.responseText);if(typeof ERROR!=="undefined"){this.handleAjaxError(ERROR);return false}else{return true}},ajaxDependentSuccess:function(ro){YAHOO.searchLoad.handleAjaxSuccess(ro)},addressSearchSuccess:function(responseText){eval(responseText);if(typeof CENTER_OF_MAP=="undefined"){this.restartAddress()}else{var centerPoint=eval("("+CENTER_OF_MAP+")");var search_address=eval("("+USER_SEARCH_ADDRESS+")");if(this.isPolygonOnMap()){this.updateMapRadiusSearch(centerPoint.latitude,centerPoint.longitude,centerPoint.radius,search_address.location1,search_address.location2,centerPoint.type.toLowerCase(),QUERY_ROWS,MARKOBJ)}else{var rows=typeof QUERY_ROWS=="undefined"?0:getIntVal(QUERY_ROWS);if(rows==0){toggleMap.mapAddressSearchSucccess(search_address.location1,search_address.location2);document.getElementById("map_search_by_address").style.display="none";document.getElementById("map").style.display="none";toggleMap.noListings()}else{this.initialMapRadiusSearch(centerPoint.latitude,centerPoint.longitude,centerPoint.radius,search_address.location1,search_address.location2,centerPoint.type.toLowerCase())}}this.addressRestart=function(){if(typeof MARKOBJ=="undefined"&&typeof QUERY_ROWS=="undefined"){initialRadiusSearch()}else{this.initialMapRadiusSearch(centerPoint.latitude,centerPoint.longitude,centerPoint.radius,search_address.location1,search_address.location2,centerPoint.type.toLowerCase(),QUERY_ROWS,MARKOBJ)}}}},handleAjaxError:function(error){toggleMap.showMapError(error)},initialMapRadiusSearch:function(latitude,longitude,radius,address1,address2,searchType,queryRows,markerObject){toggleMap.removeErrors();if(this.isPolygonOnMap()==false){toggleMap.mapAddressSearchSucccess(address1,address2);var point=new GLatLng(parseFloat(latitude),parseFloat(longitude));var centerIconPass=new GIcon(G_DEFAULT_ICON);centerIconPass.dragCrossSize=new GSize(0,0);var outsideIconPass=new GIcon();outsideIconPass.iconSize=new GSize(25,25);outsideIconPass.iconAnchor=new GPoint(12,12);outsideIconPass.infoWindowAnchor=new GPoint(1,1);outsideIconPass.image=IMG_FOLDER+"map/cross.png";outsideIconPass.iconSize=new GSize(10,15);outsideIconPass.dragCrossSize=new GSize(0,0);document.getElementById("map_search_by_address").style.display="none";document.getElementById("map").style.display="block";var radiusSearchVars={map:YAHOO.nefMap.map,radius:parseFloat(radius),polygonType:"circle",circleCenter:point,centerIcon:centerIconPass,outsideIcon:outsideIconPass,elabelClassName:"MDR_labelStyle",polygonOptions:{polygonLineColor:"#0000ff",polygonLineWeight:1,polygonLineOpacity:0.67,polygonFillColor:"#0000ff",polygonFillOpacity:0.2}};this.polyDragControl=new MPolyDragControl(radiusSearchVars,true);this.polyDragControl.startFromKnownRadius()}else{this.updateMapRadiusSearch(latitude,longitude,radius,address1,address2,queryRows,markerObject)}},restartFromAddress:function(){toggleMap.removeErrors();if(typeof this.addressRestart=="undefined"){if(typeof initialRadiusSearch=="function"){initialRadiusSearch()}}else{this.addressRestart()}},updateMapRadiusSearch:function(latitude,longitude,radius,address1,address2,queryRows,markerObject){if(this.isPolygonOnMap()==false){return false}else{toggleMap.mapAddressSearchSucccess(address1,address2);var rows=typeof queryRows=="undefined"?0:getIntVal(queryRows);if(rows==0){toggleMap.noListings()}else{YAHOO.nefMap.updateMap(markerObject)}this.polyDragControl.FromKnownCoordinatesAndRadius(latitude,longitude,radius)}},inputRadiusSearch:function(latitude,longitude,radius,address1,address2){toggleMap.toggleTypeTab(document.getElementById("map_by_address"));if(this.isPolygonOnMap()){this.addressRestart=function(){toggleMap.mapAddressSearchSucccess(address1,address2);this.makeSearchByLatLon(latitude,longitude,radius);this.polyDragControl.FromKnownCoordinatesAndRadius(latitude,longitude,radius);document.getElementById("map_search_by_address").style.display="none";document.getElementById("map").style.display="block"};this.addressRestart()}else{this.initialMapRadiusSearch(latitude,longitude,radius,address1,address2)}},makeSearchByLatLon:function(latitude,longitude,radius){this.deleteSearchUrls();urlHandler.replaceOrInsert("lat",latitude);urlHandler.replaceOrInsert("lon",longitude);urlHandler.replaceOrInsert("maptype","latlon");urlHandler.replaceOrInsert("radius",radius);var self=this;var searchPointProcccess=function(){var callback={success:function(ro){var Ok=self.checkAjaxOk(ro);if(Ok==true){self.geoPointSearchSuccess(ro.responseText);self.ajaxDependentSuccess(ro)}}};YAHOO.util.Connect.asyncRequest("GET",UPDATE_FLDR+urlHandler.getCommitedUrl(),callback,null)};urlHandler.commitUrl("",searchPointProcccess)},geoPointSearch:function(){var latLon=this.polyDragControl.returnCircleCenter();var radius=this.polyDragControl.returnRadiusInMiles();this.makeSearchByLatLon(latLon.lat(),latLon.lng(),radius)},geoPointSearchSuccess:function(responseText){eval(responseText);var rows=typeof QUERY_ROWS=="undefined"?0:getIntVal(QUERY_ROWS);if(rows==0){toggleMap.noListings()}else{YAHOO.nefMap.updateMap(MARKOBJ)}},isPolygonOnMap:function(){return typeof this.polyDragControl=="object"?true:false},returnPolyObj:function(){return this.isPolygonOnMap()?this.polyDragControl:false},hidePolyLabel:function(){if(this.isPolygonOnMap()){this.polyDragControl.hideLabel()}},showPolyLabel:function(){if(this.isPolygonOnMap()){this.polyDragControl.showLabel()}},clearSearchPolygons:function(){if(this.isPolygonOnMap()){this.polyDragControl.clear();delete (this.polyDragControl)}},updateMapFromOther:function(markerObject){if(!this.isPolygonOnMap()){this.searchTypeTab(document.getElementById("map_standard"))}YAHOO.nefMap.updateMap(markerObject)},restartAddress:function(){toggleMap.setMapDiv(YAHOO.nefMap.map.getContainer());toggleMap.removeErrors();this.deleteSearchUrls();toggleMap.closeSearchByAddress();this.clearSearchPolygons();this.searchTypeTab(document.getElementById("map_by_address"));document.getElementById("address_input").getElementsByTagName("input")[0].focus()}}}();var toggleMap=function(){return{init:function(){this.mapSuper=document.getElementById("map_super");this.byAddressDiv=document.getElementById("map_search_by_address");this.mapContainer=document.getElementById("map_container");this.mapDiv=YAHOO.nefMap.map.getContainer();this.occMapDivs=[this.mapDiv,this.byAddressDiv];this.mapDivInitalHeight=parseInt(this.mapDiv.clientHeight);this.mapDivInitalWidth=parseInt(this.mapDiv.clientWidth);this.mapDivInitalBorder=this.mapDiv.style.border;this.mapDivShortWidth="530px";this.mapInfoDiv=document.getElementById("map_side_info");this.mapToggleDiv=document.getElementById("map_toggle_side_info");this.toggleArrowCont=this.mapToggleDiv.getElementsByTagName("p")[0];this.addressButtons=[document.getElementById("map_from_here_but"),document.getElementById("map_new_address_but"),document.getElementById("map_radius_but")];return true},toggleSize:function(g){var c=document.getElementById("togmap");var b=c.getElementsByTagName("span");var h=document.getElementById("expandmap");var f=document.getElementById("hidemap");var e=document.getElementById("reducemap");var a=document.getElementById("mapchoose");for(var d=0;d<b.length;d++){hide(b[d])}if(this.isSideBarVisible()){this.toggleMapInfoDiv("collapse")}switch(g.id.toLowerCase()){case"showmap":show(this.mapSuper);show(h);show(f);break;case"hidemap":hide(this.mapSuper);show(document.getElementById("showmap"));break;case"expandmap":this.mapContainer.style.height="500px";hide(h);show(e);break;case"reducemap":this.mapContainer.style.height=this.mapDivInitalHeight+"px";show(h);show(f);break}YAHOO.nefMap.map.checkResize()},isSideBarVisible:function(){return this.mapInfoDiv.style.display=="block"?true:false},toggleMapInfoDiv:function(a){var b=!a?null:a;this.mapToggleDiv.style.display="block";if(this.mapInfoDiv.style.display=="block"&&b==null||b=="collapse"){this.toggleArrowCont.innerHTML="&laquo;";this.mapInfoDiv.style.display="none";this.mapDiv.style.width=(this.mapDivInitalWidth-this.mapToggleDiv.clientWidth)+"px"}else{if(this.mapInfoDiv.style.display!=="block"&&b==null||b=="expand"){this.toggleArrowCont.innerHTML="&raquo;";this.mapInfoDiv.style.display="block";this.mapDiv.style.width=this.mapDivShortWidth}}this.mapDiv.style.borderLeft=this.mapDivInitalBorder;this.mapDiv.style.borderTop=this.mapDivInitalBorder;this.mapDiv.style.borderBottom=this.mapDivInitalBorder;this.mapDiv.style.borderRight=" 0 none";YAHOO.nefMap.map.checkResize()},toggleTypeTab:function(c){var a=(document.getElementById("map_actions")).getElementsByTagName("a");for(var b=0;b<a.length;b++){a[b].className=""}c.className="active";switch(c.id){case"map_by_address":if(this.mapInfoDiv.style.display=="block"){return true}else{this.mapDiv.style.display="none";this.byAddressDiv.style.display="block";this.searchType="address"}break;case"map_standard":this.mapDiv.style.display="block";this.byAddressDiv.style.display="none";this.searchType="standard";this.closeSearchByAddress();break}this.mapToggleDiv.style.display="none";this.mapInfoDiv.style.display="none"},mapAddressSearchSucccess:function(a,d){var c=(a.length==0?"From drop point":a)+"<br/>";c+=d.length>0?d:"";document.getElementById("map_side_location").innerHTML=c;var b=this;this.toggleMapInfoDiv()},closeSearchByAddress:function(){this.mapDiv.style.width=this.mapDivInitalWidth+"px";this.mapDiv.style.border=this.mapDivInitalBorder;this.mapToggleDiv.style.display="none";this.mapInfoDiv.style.display="none";YAHOO.nefMap.map.checkResize()},showMapError:function(c){var b=document.getElementById("map_actions");var a=document.getElementById("map_container");var d=document.createElement("div");d.id="map_error";d.innerHTML='<div id ="inner_map_error">'+c+"</div>";d.style.top=Top(b)+"px";d.style.left=Left(a)+"px";d.style.width=a.clientWidth+"px";d.style.height=a.clientHeight+b.clientHeight+"px";a.appendChild(d);d.style.display="block";YAHOO.util.Event.addListener(document,"click",this.closeMapErrorOn)},closeMapErrorOn:function(a){if(checkClick(a,document.getElementById("map_error"))){toggleMap.removeErrors();searchMap.restartAddress();YAHOO.util.Event.removeListener(document,"click",toggleMap.closeMapErrorOn)}},clearMapError:function(){toggleMap.removeErrors();searchMap.restartAddress()},noListings:function(){YAHOO.nefMap.purgeMarkers();this.removeErrors();if(this.isSideBarVisible()){this.addressButtons[0].disabled=true;this.addressButtons[2].disabled=true}if(this.mapDiv.id!=="no_listings"){var k=document.createElement("div");k.id="no_listings";this.mapContainer.insertBefore(k,this.mapDiv);k.innerHTML="<p>There are no mappable listings available for this search</p>";show(k);this.mapDiv=k}show(this.mapDiv);for(var c=0;c<this.occMapDivs.length;c++){hide(this.occMapDivs[c])}if(this.isSideBarVisible()){this.toggleMapInfoDiv("expand")}var a=document.getElementById("map_standard");var h=this;var e=function(l){h.setMapDiv(YAHOO.nefMap.map.getContainer());hide(h.mapDiv);h.removeErrors();var j=getTarget(l);if(j.id==h.addressButtons[1].id){searchMap.restartAddress()}else{h.toggleTypeTab(j)}YAHOO.util.Event.removeListener(h.addressButtons[1],"click",e);YAHOO.util.Event.removeListener(a,"click",e)};var d=[a,this.addressButtons[1]];for(var c=0;c<d.length;c++){var f=YAHOO.util.Event.getListeners(d[c]);if(f!==null){YAHOO.util.Event.purgeElement(d[c],false,"click");YAHOO.util.Event.addListener(d[c],"click",e);for(var b=0;b<f.length;b++){var g=f[b];YAHOO.util.Event.addListener(d[c],g.type,g.fn,g.obj,g.adjust)}}else{YAHOO.util.Event.addListener(d[c],"click",e)}}},setMapDiv:function(a){this.mapDiv=a},removeErrors:function(){this.makeAddressButtonsVisible();var b=document.getElementById("no_listings");var a=document.getElementById("map_error");if(isObject(b)&&this.mapDiv.id!=="no_listings"){b.parentNode.removeChild(b)}if(isObject(a)){YAHOO.util.Event.removeListener(document,"click",this.closeMapErrorOn);a.parentNode.removeChild(a)}show(this.mapDiv);YAHOO.nefMap.map.checkResize()},makeAddressButtonsVisible:function(){for(i in this.addressButtons){this.addressButtons[i].disabled=false}}}}();function showSmallMap(e,b){var g=document.getElementById("small_map_show");var d=g.getElementsByTagName("IMG")[1];d.src=(e.getElementsByTagName("SPAN")[0].innerHTML).replace(/&amp;/ig,"&");g.style.top=(Top(e)+e.offsetHeight)+"px";g.style.left=Left(e)+"px";var f=function(){g.style.display="none";YAHOO.util.Event.removeListener(document,"click",c)};var c=function(h){if(checkClick(h,document.getElementById("small_map_show"))){f()}};var a=g.getElementsByTagName("IMG")[0];if(typeof a.onclick!=="function"){a.onclick=function(){f();return false}}YAHOO.util.Event.addListener(document,"click",c);g.style.display="block"}function confirmMap(type){var url=USR_FLDR+"useractions.php?thecmd=mapsave&save="+type+"&pg=search";var callback={success:function(ro){var data=eval("("+ro.responseText+")");var boxdiv=document.getElementById("mapchoose");var classes=boxdiv.getElementsByTagName("div");if(data.ret==1){classes[0].style.display="none";classes[1].style.display="block"}else{if(data.ret==2){mustLogin(classes[0])}}}};YAHOO.util.Connect.asyncRequest("GET",url,callback,null)}function getLatLonFromPixel(a,e,d){var b=getSwPixel(d);var c=getNePixel(d);return d.getCurrentMapType().getProjection().fromPixelToLatLng(new GPoint(b.x+a,c.y+e),d.getZoom())}function getCenterPixel(a){return a.getCurrentMapType().getProjection().fromLatLngToPixel(a.getCenter(),a.getZoom())}function getSwPixel(a){return a.getCurrentMapType().getProjection().fromLatLngToPixel(a.getBounds().getSouthWest(),a.getZoom())}function getNePixel(a){return a.getCurrentMapType().getProjection().fromLatLngToPixel(a.getBounds().getNorthEast(),a.getZoom())}MPolyDragControl=function(b,a){this.isKnownRadius=a;this.polygonType=b.polygonType?b.polygonType:"rectangle";this.map=b.map?b.map:null;if(b.polygonOptions){this.polygonOptions=b.polygonOptions}else{this.polygonOptions={polygonLineColor:"#0000ff",polygonLineWeight:1,polygonLineOpacity:1,polygonFillColor:"#0000ff",polygonFillOpacity:0.2}}this.unitDivisor=2589988.11;this.initialize(b)};MPolyDragControl.prototype.initialize=function(a){this.polyInitialized=false;this.bounds=null;this.centerIcon=a.centerIcon;this.outsideIcon=a.outsideIcon;this.polygonOptions=a.polygonOptions;this.centerMarker;this.outsideMarker;this.clear();if(typeof a.htmlFunction=="function"){this.htmlFunction=a.htmlFunction}else{this.htmlFunction=this.proccessHtmlFunction}if(this.isKnownRadius===true){this.circleCenter=a.circleCenter;this.radius=this.convertMilesToMeters(a.radius)}else{this.circleCenter;this.radius}this.floatingLabel=new ELabel(this.map.getCenter(),"Label text",a.elabelClassName,new GSize(10,20),0,true,-100000000);this.floatingLabel.hide();this.map.addOverlay(this.floatingLabel);this.self=this;this.setMapToRun()};MPolyDragControl.prototype.startFromKnownRadius=function(){this.updateCircle("",true);this.getParams()};MPolyDragControl.prototype.FromKnownCoordinatesAndRadius=function(c,b,a){this.centerMarker.setLatLng(new GLatLng(parseFloat(c),parseFloat(b)));this.radius=this.convertMilesToMeters(parseFloat(a));this.updateCircle(this.radius,true);this.outsideMarker.setLatLng(this.getOutsideMarkerPoint());this.floatingLabel.setPoint(this.outsideMarker.getLatLng());this.getParams()};MPolyDragControl.prototype.hideLabel=function(){this.floatingLabel.hide()};MPolyDragControl.prototype.showLabel=function(){this.floatingLabel.show()};MPolyDragControl.prototype.getOutsideMarkerPoint=function(){var a=30;var c=this.convertMetersToKilometers(this.radius);var b=getLatitudeLongitudeFromDistance(this.circleCenter.lat(),this.circleCenter.lng(),a,c);return new GLatLng(parseFloat(b[0]),parseFloat(b[1]))};MPolyDragControl.prototype.setMapToRun=function(){var a=this.self;if(this.isKnownRadius===true){this.centerMarker=new GMarker(this.circleCenter,{icon:a.centerIcon,draggable:true,bouncy:false,dragCrossMove:true,autoPan:true});this.map.addOverlay(this.centerMarker);GEvent.addListener(this.centerMarker,"dragstart",function(){a.centerMarkerDragStart(this)});GEvent.addListener(this.centerMarker,"drag",function(){a.centerMarkerDrag(this)});GEvent.addListener(this.centerMarker,"dragend",function(){a.centerMarkerDragEnd(this)});var b=this.getOutsideMarkerPoint();this.outsideMarker=new GMarker(b,{icon:a.outsideIcon,draggable:true,bouncy:false,dragCrossMove:true});this.map.addOverlay(this.outsideMarker);GEvent.addListener(this.outsideMarker,"dragstart",function(){a.dragStart(this)});GEvent.addListener(this.outsideMarker,"drag",function(){a.drag(this)});GEvent.addListener(this.outsideMarker,"dragend",function(){a.dragEnd(this)});this.polygonOnMap=new GPolygon([this.circleCenter,this.circleCenter,this.circleCenter,this.circleCenter,this.circleCenter],this.polygonOptions.polygonLineColor,this.polygonOptions.polygonLineWeight,this.polygonOptions.polygonLineOpacity,this.polygonOptions.polygonFillColor,this.polygonOptions.polygonFillOpacity);this.map.addOverlay(this.polygonOnMap)}else{GEvent.addListener(this.map,"click",function(e,d,f){a.mapClick(d)})}};MPolyDragControl.prototype.centerMarkerDragStart=function(){};MPolyDragControl.prototype.centerMarkerDragEnd=function(){document.getElementById("map_side_location").innerHTML="From marker drop point"};MPolyDragControl.prototype.centerMarkerDrag=function(){var a=30;var c=this.convertMetersToKilometers(this.radius);var b=getLatitudeLongitudeFromDistance(this.circleCenter.lat(),this.circleCenter.lng(),a,c);this.outsideMarker.setLatLng(new GLatLng(parseFloat(b[0]),parseFloat(b[1])));this.updateCircle(this.radius,false);this.getParams()};MPolyDragControl.prototype.dragStart=function(){};MPolyDragControl.prototype.drag=function(){if(this.polygonType=="circle"){this.updateCircle()}else{if(this.polygonType=="rectangle"){this.updateRectangle()}}};MPolyDragControl.prototype.dragEnd=function(){this.getParams()};MPolyDragControl.prototype.updateRectangle=function(){var b=this.self;var a=b.centerMarker.getLatLng();var h=b.outsideMarker.getLatLng();b.bounds=null;b.bounds=new GLatLngBounds();if(a.lat()<=h.lat()&&a.lng()<=h.lng()){var g=a;var f=h}else{if(a.lat()<=h.lat()&&a.lng()>=h.lng()){var g=a;var f=h}else{if(a.lat()>=h.lat()&&a.lng()>=h.lng()){var g=a;var f=h}else{if(a.lat()>=h.lat()&&a.lng()<=h.lng()){var g=a;var f=h}}}}b.bounds.extend(g);b.bounds.extend(f);var g=this.bounds.getSouthWest();var f=new GLatLng(this.bounds.getNorthEast().lat(),this.bounds.getSouthWest().lng());var e=this.bounds.getNorthEast();var d=new GLatLng(this.bounds.getSouthWest().lat(),this.bounds.getNorthEast().lng());var c=Array(g,f,e,d,g);b.drawPoly(c)};MPolyDragControl.prototype.updateCircle=function(fixed,isStart){this.circleCenter=this.centerMarker.getLatLng();if(typeof fixed!=="undefined"&&isFinite(parseFloat(fixed))){this.radius=fixed}else{this.radius=this.centerMarker.getLatLng().distanceFrom(this.outsideMarker.getLatLng())}var points=[];var tempBounds=[];with(Math){var d=this.radius/6378800;var lat1=(PI/180)*this.circleCenter.lat();var lng1=(PI/180)*this.circleCenter.lng();for(var a=0;a<361;a+=10){var tc=(PI/180)*a;var y=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc));var dlng=atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin(lat1)*sin(y));var x=((lng1-dlng+PI)%(2*PI))-PI;var point=new GLatLng(parseFloat(y*(180/PI)),parseFloat(x*(180/PI)));points.push(point);if(isStart){if(a==90||a==180||a==360||a==270){tempBounds.push(point)}}}}this.drawPoly(points);if(isStart){var circleBounds=new GLatLngBounds();for(var i=0;i<tempBounds.length;i++){circleBounds.extend(tempBounds[i])}this.map.checkResize();this.map.setCenter(this.centerMarker.getLatLng());this.map.setZoom(this.map.getBoundsZoomLevel(circleBounds))}};MPolyDragControl.prototype.returnCircleCenter=function(){return new GLatLng(this.circleCenter.lat(),this.circleCenter.lng())};MPolyDragControl.prototype.returnRadiusInMiles=function(){return this.convertMetersToMiles(this.radius).toFixed(2)};MPolyDragControl.prototype.convertMetersToKilometers=function(a){return a*0.001};MPolyDragControl.prototype.convKilometersToMiles=function(a){return a/1.609344};MPolyDragControl.prototype.convertMetersToMiles=function(a){return a*0.00062137119};MPolyDragControl.prototype.convertMilesToMeters=function(a){return a*1609.344};MPolyDragControl.prototype.drawPoly=function(b){if(this.polygonOnMap){this.map.removeOverlay(this.polygonOnMap);this.polygonOnMap=null}this.polygonOnMap=new GPolygon(b,this.polygonOptions.polygonLineColor,this.polygonOptions.polygonLineWeight,this.polygonOptions.polygonLineOpacity,this.polygonOptions.polygonFillColor,this.polygonOptions.polygonFillOpacity);this.map.addOverlay(this.polygonOnMap);var c=(this.polygonOnMap.getArea()/this.unitDivisor).toFixed(2);if(this.polygonType=="circle"){var a=this.circleHtmlFunction(this.circleCenter.lat().toFixed(5),this.circleCenter.lng().toFixed(5),(this.radius/1609).toFixed(2),c)}else{a+="Lat:&nbsp;"+this.bounds.getSouthWest().lat().toFixed(5)+"&nbsp;to&nbsp;"+this.bounds.getNorthEast().lat().toFixed(5)+"<br>";a+="Lon:&nbsp;"+this.bounds.getSouthWest().lng().toFixed(5)+"&nbsp;to&nbsp;"+this.bounds.getNorthEast().lng().toFixed(5)+"<br>"}this.floatingLabel.setContents(a);this.floatingLabel.setPoint(this.outsideMarker.getLatLng());this.floatingLabel.show()};MPolyDragControl.prototype.circleHtmlFunction=function(g,f,a,e,c){var b=document.getElementById("update_location_info");var d="";d+="Radius:&nbsp;"+a+"&nbsp;mi.<br>";d+="Area:&nbsp;"+e+"&nbsp;sq.mi.";b.innerHTML=d;return d};MPolyDragControl.prototype.squareHtmlFunction=function(c,d,e,f,b){var a="";a+="Lat:&nbsp;"+c+"&nbsp;to&nbsp;"+e+"<br>";a+="Lon:&nbsp;"+d+"&nbsp;to&nbsp;"+e+"<br>";a+="Area:&nbsp;"+b+"&nbsp;sq.mi."};MPolyDragControl.prototype.clear=function(){if(this.polygonOnMap){this.map.removeOverlay(this.polygonOnMap);this.polygonOnMap=null}if(this.centerMarker){this.map.removeOverlay(this.centerMarker);this.centerMarker=null}if(this.outsideMarker){this.map.removeOverlay(this.outsideMarker);this.outsideMarker=null}if(this.floatingLabel){this.floatingLabel.hide()}};MPolyDragControl.prototype.getParams=function(){var a="";if(this.polygonType=="circle"){a+="centerLat="+this.circleCenter.lat().toFixed(5)+"&centerLon="+this.circleCenter.lng().toFixed(5);a+="&radius="+(this.radius/1609.344).toFixed(2)}else{a+="lat1="+this.bounds.getSouthWest().lat().toFixed(5)+"&lat2="+this.bounds.getNorthEast().lat().toFixed(5);a+="&lon1="+this.bounds.getSouthWest().lng().toFixed(5)+"&lon2="+this.bounds.getNorthEast().lng().toFixed(5)}return a};MPolyDragControl.prototype.setType=function(a){this.polygonType=polygonType;if(this.polygonOnMap){this.drag();this.dragEnd()}};MPolyDragControl.prototype.show=function(){this.polygonOnMap.show()};MPolyDragControl.prototype.hide=function(){this.polygonOnMap.hide()};MPolyDragControl.prototype.isVisible=function(){return !this.polygonOnMap.isHidden()};function getLatitudeLongitudeFromDistance(latitude,longitude,brng,d){var lat=latitude;var lon=longitude;var R=6371;with(Math){var lat1=lat*PI/180;var lon1=lon*PI/180;var brng=brng*PI/180;var lat2=asin(sin(lat1)*cos(d/R)+cos(lat1)*sin(d/R)*cos(brng));var lon2=lon1+atan2(sin(brng)*sin(d/R)*cos(lat1),cos(d/R)-sin(lat1)*sin(lat2));lon2=(lon2+PI)%(2*PI)-PI;if(isNaN(lat2)||isNaN(lon2)){return false}else{var lat2=lat2*180/PI;var lon2=lon2*180/PI}return[lat2,lon2]}}function EStyle(b,a,e,d){this.stemImage=b;this.stemSize=a;this.boxClass=e;this.boxOffset=d;var c=navigator.userAgent.toLowerCase();var f=5;if(c.indexOf("opera")>-1){f=3}if(c.indexOf("firefox")>-1){f=0}if(c.indexOf("safari")>-1){f=5}if((c.indexOf("msie")>-1)&&(c.indexOf("opera")<1)){f=0}this.fudge=f}var E_STYLE_1=new EStyle(IMG_FOLDER+"map/stem1.png",new GSize(81,87),"estyle1",new GPoint(-30,87-3));var E_STYLE_2=new EStyle(IMG_FOLDER+"map/stem2.png",new GSize(81,87),"estyle2",new GPoint(-30,87-1));var E_STYLE_3=new EStyle(IMG_FOLDER+"map/stem3.png",new GSize(81,87),"estyle3",new GPoint(-30,87-10));var E_STYLE_4=new EStyle(IMG_FOLDER+"map/stem3.png",new GSize(81,87),"estyle4",new GPoint(-30,87-10));var E_STYLE_5=new EStyle(IMG_FOLDER+"map/stem1.png",new GSize(81,87),"estyle5",new GPoint(-30,87-3));var E_STYLE_6=new EStyle(IMG_FOLDER+"map/stem6.png",new GSize(100,50),"estyle6",new GPoint(100-2,20));var E_STYLE_7=new EStyle(IMG_FOLDER+"map/stem7.png",new GSize(25,25),"estyle2",new GPoint(-10,24));function EWindow(c,b){this.map=c;this.estyle=b;this.visible=false;this.ie=false;var a=navigator.userAgent.toLowerCase();this.ie=a.indexOf("msie")>-1&&a.indexOf("opera")<1?true:false}EWindow.prototype=new GOverlay();EWindow.prototype.initialize=function(c){var b=document.createElement("div");b.style.position="absolute";c.getPane(G_MAP_FLOAT_SHADOW_PANE).appendChild(b);var a=document.createElement("div");a.style.position="absolute";a.style.width=this.estyle.stemSize.width+"px";c.getPane(G_MAP_FLOAT_SHADOW_PANE).appendChild(a);this.div1=b;this.div2=a};EWindow.prototype.openOnMap=function(b,c,f,d){this.offset=f||new GPoint(0,0);this.point=b;this.div1.innerHTML='<div class="'+this.estyle.boxClass+'"><nobr>'+c+"</nobr></div>";if(this.ie&&this.estyle.stemImage.toLowerCase().indexOf(".png")>-1){var a="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.estyle.stemImage+"', sizingMethod='scale');";this.div2.innerHTML='<div style="height:'+this.estyle.stemSize.height+"px; width:"+this.estyle.stemSize.width+"px; "+a+'" ></div>'}else{this.div2.innerHTML='<img src="'+this.estyle.stemImage+'" width="'+this.estyle.stemSize.width+'" height="'+this.estyle.stemSize.height+'">'}var e=GOverlay.getZIndex(this.point.lat());this.div1.style.zIndex=e+d;this.div2.style.zIndex=e+d+1;this.visible=true;this.show();this.redraw(false)};EWindow.prototype.openOnMarker=function(b,d,f){var e=b.getIcon().iconAnchor.x-b.getIcon().infoWindowAnchor.x;var c=b.getIcon().iconAnchor.y-b.getIcon().infoWindowAnchor.y;var a=typeof f=="undefined"?0:parseInt(f);this.openOnMap(b.getPoint(),d,new GPoint(e,c),f)};EWindow.prototype.redraw=function(a){if(!this.visible){return}var b=this.map.fromLatLngToDivPixel(this.point);this.div2.style.left=(b.x+this.offset.x)+"px";this.div2.style.bottom=(-b.y+this.offset.y-this.estyle.fudge)+"px";this.div1.style.left=(b.x+this.offset.x+this.estyle.boxOffset.x)+"px";this.div1.style.bottom=(-b.y+this.offset.y+this.estyle.boxOffset.y)+"px"};EWindow.prototype.remove=function(){this.div1.parentNode.removeChild(this.div1);this.div2.parentNode.removeChild(this.div2);this.visible=false};EWindow.prototype.copy=function(){return new EWindow(this.map,this.estyle)};EWindow.prototype.show=function(){this.div1.style.display="";this.div2.style.display="";this.visible=true};EWindow.prototype.hide=function(){this.div1.style.display="none";this.div2.style.display="none";YAHOO.util.Event.removeListener(document,"click",YAHOO.nefMap.popCheck);this.visible=false};EWindow.prototype.isHidden=function(){return !this.visible};EWindow.prototype.supportsHide=function(){return true};EWindow.prototype.zindex=function(a){var b=GOverlay.getZIndex(this.point.lat());this.div1.style.zIndex=b+a;this.div2.style.zIndex=b+1+a};YAHOO.smallMap=function(){return{setSmallMap:function(c,a){if(GBrowserIsCompatible()){this.smMap=new GMap2(document.getElementById("small_map"));this.smMap.addControl(new GSmallZoomControl());this.smMap.setCenter(new GLatLng(parseFloat(c),parseFloat(a)),15)}else{var b=document.getElementById("small_map");b.className="error";b.innerHTML="Your current browser settings do not allow you to use the mapping feature";return false}},moveSmallMap:function(d,c,e){var b=YAHOO.util.Dom.getElementsByClassName("open_map_button","LI","prac");if(b.length>0){YAHOO.smallMap.close()}if(typeof this.smMarker=="undefined"){this.smMarker=new GMarker(new GLatLng(parseFloat(c),parseFloat(e)));this.smMap.addOverlay(this.smMarker)}else{this.smMarker.setLatLng(new GLatLng(parseFloat(c),parseFloat(e)))}var a=document.getElementById("small_map_cont");a.style.left=Left(d)-110+"px";a.style.top=Top(d)-d.offsetHeight+30+"px";a.style.display="block";this.smMap.checkResize();this.smMap.panTo(this.smMarker.getLatLng());d.innerHTML="<strong>close map</strong>";d.setAttribute("onclick","javascript:YAHOO.smallMap.close(this);");YAHOO.util.Dom.addClass(d,"open_map_button");YAHOO.util.Event.addListener(document,"click",YAHOO.smallMap.popCheck)},popCheck:function(a){if(checkClick(a,document.getElementById("small_map_cont"))){YAHOO.smallMap.close()}},close:function(){var a=document.getElementById("small_map_cont");a.style.display="none";var b=YAHOO.util.Dom.getElementsByClassName("open_map_button","LI","prac")[0];YAHOO.util.Dom.removeClass(b,"open_map_button");b.innerHTML="Map";var c=this.smMarker.getLatLng();b.setAttribute("onclick","javascript:event.cancelBubble=true;YAHOO.smallMap.moveSmallMap(this,'"+c.lat()+"','"+c.lng()+"');");YAHOO.util.Event.removeListener(document,"click",YAHOO.smallMap.popCheck)}}}();