﻿LNJS.SearchManager.prototype._getRetInst=function(){return'</PFRequestData>';};LNJS.SearchManager.prototype.showItemPinProfile=function(idx1,idx2){var pData=this.pData.items[idx1];if(pData==null)return;if(LNJS.User.rAID.a()){LNJS.Page.SearchMgr.showPinProfile(idx1,idx2);return;}if(LNJS.Page.MapMgr.isBirdsEye()){var mapWidth=LNJS.Page.MapMgr.mapWidth()/2;var mapHeight=LNJS.Page.MapMgr.mapHeight()/2;var Center=LNJS.Page.MapMgr.pixelToLatLong(new VEPixel(mapWidth,mapHeight));}else{var Center=LNJS.Page.MapMgr.getCenter();}if(Center.Latitude.round(4)==pData.lat.round(4)&&Center.Longitude.round(4)==pData.lon.round(4)){LNJS.Page.SearchMgr.showPinProfile(idx1,idx2);}else{LNJS.Page.SearchMgr.showProfileAfterChange=[idx1,idx2];LNJS.Page.MapMgr.setCenterAndZoom(new VELatLong(pData.lat,pData.lon),LNJS.Page.MapMgr.getZoomLevel());}};LNJS.SearchManager.prototype.showPinProfile=function(idx1,idx2){if(LNJS.Page.isClusterSearch){window.location=$('i'+idx1).href;return;}if(LNJS.Page.SearchMgr.pinIndex==idx1&&Element.visible(LNJS.Page.SearchMgr.popup))return;if(Element.visible(LNJS.Page.SearchMgr.popup))this.hidePinProfile();if(this.pData==null)return;this._hiliteItem(false);this.pinIndex=idx1;this._hiliteItem(true);var pData=this.pData.items[idx1];if(pData==null)return;idx2=pData.idx2;var oPin=LNJS.Page.MapMgr.getShapeByIndex(idx2);if(oPin==null)return;var mpid=oPin.LN.MPID;LNJS.Page.SearchMgr.pinCallOutNum=LNJS.Page.MapMgr.checkXY({vepin:oPin,popup:LNJS.Page.SearchMgr.popup});LNJS.Page.SearchMgr._getProfile_callback(idx1,idx2);};LNJS.SearchManager.prototype._getProfile_callback=function(idx1,idx2){if(!LNJS.Page.SearchMgr.pData)return;if(idx1>LNJS.Page.SearchMgr.pData.length){LNJS.Trace.error('Error pin index to high '+idx1);return;}LNJS.Page.SearchMgr.popup.style.visibility='hidden';Element.show(LNJS.Page.SearchMgr.popup);html=LNJS.Page.SearchMgr._getProfileHtml(idx1,idx2,false);if(html)Element.innerHTML(LNJS.Page.SearchMgr.popup,html);var oPin=LNJS.Page.MapMgr.getShapeByIndex(idx2);LNJS.Page.MapMgr.checkXY({vepin:oPin,popup:LNJS.Page.SearchMgr.popup});oPin=null;setTimeout((function(){if(LNJS.Page.MapMgr.getZoomLevel()>=16||LNJS.Page.MapMgr.isBirdsEye())Element.hide('zoomtostreet');if(LNJS.Page.EL.ToolTip)Element.hide(LNJS.Page.EL.ToolTip);LNJS.Page.SearchMgr.popup.style.visibility='visible';}).bind(this),10);};LNJS.SearchManager.prototype.showNewListingPinProfile=function(idx1,idx2){if(Element.visible(LNJS.Page.SearchMgr.popup))this.hidePinProfile();var oPin=LNJS.Page.MapMgr.getShapeByIndex(idx2);if(oPin==null)return;LNJS.Page.SearchMgr.pinCallOutNum=LNJS.Page.MapMgr.checkXY({vepin:oPin,popup:LNJS.Page.SearchMgr.popup});if(isNaN(LNJS.Page.SearchMgr.pinCallOutNum))return;LNJS.Page.SearchMgr.popup.style.visibility='hidden';Element.show(LNJS.Page.SearchMgr.popup);html=LNJS.Page.SearchMgr._getProfileHtml(idx1,idx2,true);if(html)Element.innerHTML(LNJS.Page.SearchMgr.popup,html);var oPin=LNJS.Page.MapMgr.getShapeByIndex(idx2);LNJS.Page.MapMgr.checkXY({vepin:oPin,popup:LNJS.Page.SearchMgr.popup});oPin=null;setTimeout((function(){LNJS.Page.SearchMgr.popup.style.visibility='visible';}).bind(this),10);};LNJS.SearchManager.prototype.saveMP=function(mpid){if(!LNJS.User.iAID){alert("You must be logged in to use this feature.");return;}if(LNJS.Ajax.ActiveAjaxGroupRequestsCount["SaveMP"]>0){LNJS.Trace.warn('SaveMP() Save MP in progress... exiting!');return;}$('SaveProp').innerHTML='<div class="wait">Saving... Please wait</div>';var options=new Object();options.SOAPMethod='SaveMasterPropertyGroupItem';options.SOAPNamespace='http://www.loopnet.com/WebServices';options.queueLength=1;options.groupName='SaveMP';options.onSuccess=function(req){LNJS.Page.SearchMgr._SaveMP_callback(req);};options.postBody=GetSoapInput('<PFRequestData><MasterProperty MasterPropertyID="'+mpid+'" /></PFRequestData>',options.SOAPMethod,options.SOAPNamespace);LNJS.Ajax.post('/xNet/MainSite/WebServices/CommercialSearch/Save.asmx',options);};LNJS.SearchManager.prototype._SaveMP_callback=function(req){if(LNJS.Ajax.ActiveAjaxGroupRequestsCount["SaveMP"]>0){LNJS.Trace.warn('_SaveMP_callback() Save MP in progress... exiting!');return;}if(req.ReturnCode=='0'){$('SaveProp').innerHTML='<div class="result">This property has been saved to <a href="/xNet/MainSite/Research/SavedProperties.aspx">My Watch List</a></div>';}else{alert('Sorry!\nWe were unable to save your property at this time. Please try again later.')}};LNJS.SearchManager.prototype.showProfile=function(index,linkcode){var url=LNJS.Page.SearchMgr._getMPProfileUrl(index);var w_height=(screen.height?screen.height:620);var w_newHeight=(w_height>620?w_height:620);if(linkcode)url+='&linkcode='+linkcode;LNJS.Page.openWindow({url:url,features:"width=800,height="+w_newHeight+",top=30,left=30,toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=no,screenX=200,screenY=200"});};LNJS.SearchManager.prototype.toolTip=function(idx1,idx2,e){var newevent=(e)?e:window.event;if(!LNJS.Page.SearchMgr.pData||!LNJS.Page.SearchMgr.pData)return;if(LNJS.Page.SearchMgr.pinIndex==idx1&&Element.visible(LNJS.Page.SearchMgr.popup))return;var pData=LNJS.Page.SearchMgr.pData.items[idx1];idx2=pData.idx2;var shape=LNJS.Page.MapMgr.getShapeByIndex(idx2);if(newevent.type=='mouseout'||newevent.type=='hide'){if(LNJS.Page.EL.ToolTip)Element.hide(LNJS.Page.EL.ToolTip);LNJS.Page.SearchMgr._hilitePin(shape,false);}else{LNJS.Page.SearchMgr._hilitePin(shape,true);var pData=LNJS.Page.SearchMgr.pData.items[idx1];if(!pData)return;var html=new StringBuilder();if(LNJS.Page.isClusterSearch){html.append("<dl class='pin-tooltip'><dt>"+pData.name+"</dt>");html.append("<dd>"+pData.count.toString().addCommas()+((pData.count==1)?" Property":" Properties")+"</dd>");}else{html.append("<dl class='pin-tooltip'><dt>"+pData.ad1+", "+pData.city+", "+pData.state+"</dt>");html.append("<dd>"+_cat[pData.type][0]+"</dd>");}if(LNJS.Page.EL.ToolTip)LNJS.Page.EL.ToolTip.style.visibility='hidden';if(LNJS.Page.EL.ToolTip)Element.show(LNJS.Page.EL.ToolTip);if(LNJS.Page.EL.ToolTip)LNJS.Page.EL.ToolTip.innerHTML=html.toString()+"</dl>";setTimeout((function(){var mapOffset=Position.cumulativeOffset(LNJS.Page.MapMgr.container);var mapSize=Element.getDimensions(LNJS.Page.MapMgr.container);pinOffset=Position.cumulativeOffset(LNJS.Page.MapMgr.getShapeElByIndex(idx2));if(LNJS.Page.EL.ToolTip)LNJS.Page.EL.ToolTip.style.top=(pinOffset[1]-13)+'px';if(pinOffset[0]<(mapOffset[0]+(mapSize.width/2))){if(LNJS.Page.EL.ToolTip)LNJS.Page.EL.ToolTip.style.left=pinOffset[0]+28+'px';}else{if(LNJS.Page.EL.ToolTip)LNJS.Page.EL.ToolTip.style.left=pinOffset[0]-(LNJS.Page.EL.ToolTip.offsetWidth-2)+'px';}if(LNJS.Page.EL.ToolTip)LNJS.Page.EL.ToolTip.style.visibility='visible';pData=shape=null;}).bind(this),5);data=html=null;}};LNJS.SearchManager.prototype.updateCriteria=function(e){if(!LNJS.User.rAID.a())return;LNJS.Page.hideMsg();this.CritMgr.Criteria.Category=this._getSelectedCatIds().join(",");if(LNJS.Page.MapMgr.isBirdsEye()){var mapWidth=LNJS.Page.MapMgr.mapWidth();var mapHeight=LNJS.Page.MapMgr.mapHeight();var oTopLeftLatLong=LNJS.Page.MapMgr.pixelToLatLong(new VEPixel(0,0));var oTopRightLatLong=LNJS.Page.MapMgr.pixelToLatLong(new VEPixel(mapWidth,0));var oBottomLeftLatLong=LNJS.Page.MapMgr.pixelToLatLong(new VEPixel(0,mapHeight));var oBottomRightLatLong=LNJS.Page.MapMgr.pixelToLatLong(new VEPixel(mapWidth,mapHeight));var Orientation=LNJS.Page.MapMgr.getBirdseyeScene().GetOrientation();switch(Orientation){case'North':oTopLatLong=oTopLeftLatLong;oBottomLatLong=oBottomRightLatLong;break;case'West':oTopLatLong=oTopRightLatLong;oBottomLatLong=oBottomLeftLatLong;break;case'South':oTopLatLong=oBottomRightLatLong;oBottomLatLong=oTopLeftLatLong;break;case'East':oTopLatLong=oBottomLeftLatLong;oBottomLatLong=oTopRightLatLong;break;}oLatLongRect=new VELatLongRectangle(oTopLatLong,oBottomLatLong);mapWidth=mapHeight=oTopLeftLatLong=oTopRightLatLong=oBottomLeftLatLong=oBottomRightLatLong=Orientation=oTopLatLong=oBottomLatLong=null;}else{oLatLongRect=LNJS.Page.MapMgr.getMapView();}this.CritMgr.Criteria.Latitude.Min=oLatLongRect.BottomRightLatLong.Latitude;this.CritMgr.Criteria.Latitude.Max=oLatLongRect.TopLeftLatLong.Latitude;this.CritMgr.Criteria.Longitude.Min=oLatLongRect.TopLeftLatLong.Longitude;this.CritMgr.Criteria.Longitude.Max=oLatLongRect.BottomRightLatLong.Longitude;LNJS.Page.SearchMgr.performSearch();};LNJS.SearchManager.prototype.SearchDataHandler=function(){this.CritMgr.Criteria.rMID=LNJS.User.rMID;this.CritMgr.Criteria.rAID=LNJS.User.rAID;this.CritMgr.Criteria.rPID=LNJS.User.rPID;this.CritMgr.Criteria.ZoomLevel=LNJS.Page.MapMgr.getZoomLevel();this.CritMgr.Criteria.MapStyle=LNJS.Page.MapMgr.getMapStyle();LNJS.Page.isClusterSearch=(!LNJS.Page.MapMgr.isBirdsEye()&&(this.CritMgr.Criteria.ZoomLevel>0&&this.CritMgr.Criteria.ZoomLevel<10));var options=({queueLength:1,SOAPMethod:'PerformSearch',SOAPNamespace:'http://www.loopnet.com/WebServices',postBody:GetSoapInput('<PFRequestData>'+this.CritMgr.Criteria.toXml()+this._getRetInst(),'PerformSearch','http://www.loopnet.com/WebServices',-1,true),groupName:'performSearch',onComplete:LNJS.Page.SearchMgr._MPSearch_callback});var url='/xNet/MainSite/WebServices/CommercialSearch/Search.asmx';return[options,url];};LNJS.SearchManager.prototype._getSelectedCatIds=function(){var selected=[];indx=this.searchTypes.getByValue(this.searchType)[0];if(indx==-1){LNJS.Trace.warn('_getSelectedCatIds() Unknown searchType: '+this.searchType);return selected;}return this.selectedCats[indx];};LNJS.SearchManager.prototype._getSEOCatName=function(){switch(this.CritMgr.Criteria.Category){case"":return"Property-Records";case"30":return"Health-Care-Property-Records";case"40":return"Industrial-Property-Records";case"60":return"Hotels-Motel-Property-Records";case"70":return"Multifamily-Property-Records";case"80":return"Office-Property-Records";case"90":return"Retail-Property-Records";case"100":return"Senior-Housing-Property-Records";case"110":return"Shopping-Center-Property-Records";case"120":return"Special-Purpose-Property-Records";case"130":return"Sport-Entertainment-Property-Records";}};LNJS.SearchManager.prototype._initFromServerSearch=function(ServerSearchResults){LNJS.Page.loadingSearch=true;this.haveResultList=true;this._clearPins();this.pData=ServerSearchResults;this._plotPins();var l=[];if(!LNJS.isNull(this.pData)&&this.pData.resultCount>0){if(LNJS.User.rAID.a()){var resulttext=(this.pData.resultCount==100)?"100+":this.pData.resultCount;switch(resulttext){case 1:resulttext+=' Property';break;default:resulttext+=' Properties';break;}if(LNJS.User.rAID=="744327356"&&LNJS.User.rMID!="847296026")Element.innerHTML(this.resultCount,resulttext+' Found<em class="betaTag">BETA</em>');else Element.innerHTML(this.resultCount,resulttext+' Found');}for(x=0;x<this.pData.resultCount;x++){p=this.pData.items[x];l.push(new VELatLong(p.lat,p.lon));p=null;}if(this.newAddressLoc)l.push(new VELatLong(window.addressLat,window.addressLon));LNJS.Page.MapMgr.setMapView(l);l=null;}else{Element.innerHTML(this.resultCount,"No Properties Found");if(this.newAddressLoc){l.push(new VELatLong(window.addressLat,window.addressLon));LNJS.Page.MapMgr.setMapView(l);l=null;}LNJS.Page.loadingSearch=false;this._renderResultList();}};LNJS.SearchManager.prototype._initFromServerClusterSearch=function(ServerClusterSearchResults){LNJS.Page.loadingSearch=true;LNJS.Page.isClusterSearch=true;this.haveResultList=true;this._clearPins();this.pData=ServerClusterSearchResults;this._plotPins();var l=[];if(this.pData.resultCount>0){for(x=0;x<this.pData.resultCount;x++){p=this.pData.items[x];l.push(new VELatLong(p.lat,p.lon));p=null;}LNJS.Page.MapMgr.setMapView(l);l=null;}else{Element.innerHTML(this.resultCount,"No Properties Found");LNJS.Page.loadingSearch=false;this._renderResultList();}};LNJS.SearchManager.prototype._MPSearch_callback=function(oReq){if(LNJS.Ajax.ActiveAjaxGroupRequestsCount["performSearch"]>0){LNJS.Trace.warn('_MPSearch_callback() Search in progress... exiting!');return;}if(oReq.ReturnCode=='0'){var sSearchResults=LNJS.Xml.getText(oReq.responseXML.documentElement.selectSingleNode("//SearchResults"));if(!LNJS.isNull(sSearchResults)){LNJS.Page.SearchMgr._clearPins();LNJS.Page.SearchMgr._setResults(sSearchResults,"pData");LNJS.Page.SearchMgr._plotPins();if(LNJS.Page.SearchMgr.pData.resultCount>0){if(!LNJS.Page.isClusterSearch){if(LNJS.Page.SearchMgr.resultCount){var resulttext=(LNJS.Page.SearchMgr.pData.resultCount==100)?"100+":LNJS.Page.SearchMgr.pData.resultCount;switch(resulttext){case 1:resulttext+=' Property';break;default:resulttext+=' Properties';break;}if(LNJS.User.rAID=="744327356"&&LNJS.User.rMID!="847296026")Element.innerHTML(LNJS.Page.SearchMgr.resultCount,resulttext+' Found<em class="betaTag">BETA</em>');else Element.innerHTML(LNJS.Page.SearchMgr.resultCount,resulttext+' Found');}}LNJS.Page.SearchMgr._renderResultList();}else{if(LNJS.Page.SearchMgr.resultCount)Element.innerHTML(LNJS.Page.SearchMgr.resultCount,"No Properties Found. <a href='/xNet/MainSite/Research/'>Modify Search</a>");LNJS.Page.SearchMgr._renderResultList();}}else{throw LNJS.Page.SearchMgr.Err(LNJS.Page.SearchMgr.__className+": MapPoints node missing!");}}else{if(oReq.ReturnCode=='-100'){window.location='/xNet/MainSite/User/session/loginblock.aspx';}else{throw LNJS.Page.SearchMgr.Err(LNJS.Page.SearchMgr.__className+": return code not 0!");}}};LNJS.SearchManager.prototype.attachMapEvents=function(oMapMgr){oMapMgr.attachEvent("onmouseout",this._moveShapeBack);oMapMgr.attachEvent("onmouseover",this._moveShapeUp);oMapMgr.attachEvent("onclick",this._shapeClick);oMapMgr.attachEvent("onstartpan",this._startPan);oMapMgr.attachEvent("onendpan",this._endPan);oMapMgr.attachEvent("onobliquechange",this._obliqueChange);oMapMgr.attachEvent("onchangeview",this._changeView);oMapMgr.attachEvent("onstartzoom",this._startZoom);oMapMgr.attachEvent("onendzoom",this._endZoom);};LNJS.SearchManager.prototype._validEvent=function(additionalcheck){if(LNJS.isNull(additionalcheck))additionalcheck=true;if(!additionalcheck)return false;return true;};LNJS.SearchManager.prototype._moveShapeBack=function(e){if(e.elementID){var shape=LNJS.Page.MapMgr.getShapeByID(e.elementID);if(shape){LNJS.Page.SearchMgr.toolTip(shape.LN.idx1,shape.GetIndex(),{type:'hide'});LNJS.Page.SearchMgr.pinHoverIndex=-1;}shape=null;return false;}};LNJS.SearchManager.prototype._moveShapeUp=function(e){if(e.elementID){var shape=LNJS.Page.MapMgr.getShapeByID(e.elementID);if(shape){if(LNJS.Page.SearchMgr.pinHoverIndex!=shape.LN.idx1){LNJS.Page.SearchMgr.pinHoverIndex=shape.LN.idx1;LNJS.Page.SearchMgr.toolTip(shape.LN.idx1,shape.GetIndex(),{type:'show'});}}shape=null;return false;}};LNJS.SearchManager.prototype._shapeClick=function(e){if(e.elementID){var shape=LNJS.Page.MapMgr.getShapeByID(e.elementID);if(shape){if(shape.LN.MPID==0){LNJS.Page.SearchMgr.showNewListingPinProfile(shape.LN.idx1,shape.GetIndex());}else{LNJS.Page.SearchMgr.showPinProfile(shape.LN.idx1,shape.GetIndex());}}shape=null;return false;}};LNJS.SearchManager.prototype._startPan=function(e){if(!LNJS.Page)return;if(!LNJS.Page.SearchMgr._validEvent())return;LNJS.Page.SearchMgr.hidePinProfile();if(LNJS.Page.EL.ToolTip)Element.hide(LNJS.Page.EL.ToolTip);LNJS.Page.hideMsg();if(!LNJS.Page.SearchMgr.lastMapEvent)LNJS.Page.SearchMgr.lastMapEvent=e;};LNJS.SearchManager.prototype._endPan=function(e){if(!LNJS.Page)return;if(!LNJS.Page.SearchMgr._validEvent(!LNJS.Page.SearchMgr._isPD())){LNJS.Page.Log.LogMapPan();return;}if(!LNJS.GV(LNJS.ServiceSourceCode,false)){if(e.mapStyle==Msn.VE.MapStyle.Oblique){LNJS.ServiceSourceCode=LNJS.ServiceSource.ObliqueMapPan;}else{LNJS.ServiceSourceCode=LNJS.ServiceSource.MapPan;}}if(!LNJS.Page.loadingSearch&&LNJS.User.rAID.a())LNJS.Page.SearchMgr.updateCriteria(e);LNJS.Page.loadingSearch=false;LNJS.ServiceSourceCode=LNJS.ServiceSource.Clear;};LNJS.SearchManager.prototype._startZoom=function(e){if(!LNJS.Page)return;if(!LNJS.Page.SearchMgr._validEvent())return;LNJS.Page.hideMsg();LNJS.Page.SearchMgr.hidePinProfile();if(LNJS.Page.EL.ToolTip)Element.hide(LNJS.Page.EL.ToolTip);if(!LNJS.Page.SearchMgr.lastMapEvent)LNJS.Page.SearchMgr.lastMapEvent=e;};LNJS.SearchManager.prototype._endZoom=function(e){if(!LNJS.Page)return;if(!LNJS.GV(LNJS.ServiceSourceCode,null)){if(e.mapStyle==Msn.VE.MapStyle.Oblique){if(!LNJS.Page.SearchMgr.lastMapEvent){LNJS.Page.SearchMgr.lastMapEvent=e;}else if(LNJS.Page.SearchMgr.lastMapEvent.mapStyle!=e.mapStyle){LNJS.Page.Log.LogMapStyle(e.mapStyle);}else if(e.zoomLevel<LNJS.Page.SearchMgr.lastZoomLevel){LNJS.ServiceSourceCode=LNJS.ServiceSource.ObliqueMapZoomOut;}else{LNJS.ServiceSourceCode=LNJS.ServiceSource.ObliqueMapZoomIn;}LNJS.Page.SearchMgr.lastMapEvent=e;}else{if(e.zoomLevel<LNJS.Page.SearchMgr.lastZoomLevel){LNJS.ServiceSourceCode=LNJS.ServiceSource.MapZoomOut;}else{LNJS.ServiceSourceCode=LNJS.ServiceSource.MapZoomIn;}}}if(!LNJS.Page.SearchMgr._validEvent()){LNJS.Page.Log.LogMapZoom(e.zoomLevel<LNJS.Page.SearchMgr.lastZoomLevel);LNJS.Page.SearchMgr.lastZoomLevel=e.zoomLevel;return;}if(!LNJS.Page.loadingSearch&&LNJS.User.rAID.a())LNJS.Page.SearchMgr.updateCriteria(e);LNJS.Page.loadingSearch=false;LNJS.ServiceSourceCode=LNJS.ServiceSource.Clear;};LNJS.SearchManager.prototype._obliqueChange=function(e){if(!LNJS.Page)return;if(!LNJS.Page.SearchMgr.lastMapEvent){LNJS.Page.SearchMgr.lastMapEvent=e;}else{if(LNJS.Page.SearchMgr.lastMapEvent.mapStyle==e.mapStyle&&LNJS.Page.SearchMgr.lastMapEvent.birdseyeSceneOrientation!=e.birdseyeSceneOrientation){LNJS.ServiceSourceCode=LNJS.ServiceSource.ObliqueMapOrientationChange;LNJS.Page.SearchMgr.lastMapEvent=e;}else if(LNJS.Page.SearchMgr.lastMapEvent.mapStyle==e.mapStyle&&LNJS.Page.SearchMgr.lastMapEvent.birdseyeSceneID!=e.birdseyeSceneID){LNJS.ServiceSourceCode=LNJS.ServiceSource.ObliqueMapTileChange;LNJS.Page.SearchMgr.lastMapEvent=e;}}if(!LNJS.Page.SearchMgr._validEvent(!LNJS.Page.SearchMgr._isPD())){LNJS.ServiceSourceCode=LNJS.ServiceSource.Clear;return;}if(LNJS.User.rAID.a())LNJS.Page.SearchMgr.updateCriteria(e);LNJS.ServiceSourceCode=LNJS.ServiceSource.Clear;};LNJS.SearchManager.prototype._changeView=function(e){if(!LNJS.Page)return;if(!LNJS.Page.SearchMgr._validEvent())return;LNJS.Page.SearchMgr.hidePinProfile();if(!LNJS.Page.SearchMgr.lastMapEvent){LNJS.Page.SearchMgr.lastMapEvent=e;}else{if(LNJS.Page.SearchMgr.lastMapEvent.mapStyle!=e.mapStyle){LNJS.Page.Log.LogMapStyle(e.mapStyle);LNJS.Page.SearchMgr.lastMapEvent=e;}}if(!LNJS.Page.SearchMgr.EvtFromHistory){if(LNJS.Page.SearchMgr.options.trackHistory)LNJS.Page.SearchMgr._trackHistory(e);}else{LNJS.Page.SearchMgr.EvtFromHistory=false;}if(LNJS.Page.SearchMgr.showProfileAfterChange){setTimeout((function(){var Indexes=LNJS.Page.SearchMgr.showProfileAfterChange;if(Indexes){LNJS.Page.SearchMgr.showPinProfile(Indexes[0],Indexes[1]);}LNJS.Page.SearchMgr.showProfileAfterChange=null;}).bind(this),30);}LNJS.Page.loadingSearch=false;};LNJS.SearchManager.prototype._trackHistory=function(mapEvent){if(!LNJS.Page)return;if(!LNJS.Page.SearchMgr.options.trackHistory)return;var centerLatLon=null;if(LNJS.Page.MapMgr.isBirdsEye()){var mapWidth=LNJS.Page.MapMgr.mapWidth();var mapHeight=LNJS.Page.MapMgr.mapHeight();centerLatLon=LNJS.Page.MapMgr.pixelToLatLong(new VEPixel((mapWidth/2),(mapHeight/2)));mapWidth=mapHeight=null;}else{centerLatLon=LNJS.Page.MapMgr.getCenter();}$('HistoryState').innerHTML+='<font color=red><br>center:<br>'+typeof(centerLatLon)+'<br>'+centerLatLon+'</font>';if(centerLatLon!=null){mapState=LNJS.Base64.encode(mapEvent.zoomLevel+'|'+mapEvent.mapStyle+'|'+LNJS.Util.createEncodings([centerLatLon]));LNJS.History.addHistory(mapState);}};LNJS.SearchManager.prototype._renderResultList=function(){var rlist=new StringBuilder();var count=LNJS.isNull(this.pData)?0:this.pData.resultCount;var xx=0;if(count>0){for(var i=this.pageIndex;i<count;i++){m=this.pData.items[i];this._buildHTML(i,xx,m,rlist);xx++;}}Element.innerHTML(this.resultcont,rlist.toString());if(count==0){if(LNJS.User.rAID=="744327356"&&LNJS.User.rMID!="847296026")Element.innerHTML(this.resultcont,"<div class=\"csResultsMsg\"><p><strong>No results found. Remember that this Beta is limited to Sacramento MSA properties.</strong></p><a href=\"/xNet/MainSite/Research/\" title=\"Start New Search\">Start a new search</a><br/><br/>Is there a commercial building here that you would like to add? <a href='/xNet/MainSite/Research/AddEdit/AddEdit.aspx' title='Add a Property'>Add a Property</a></div>");else Element.innerHTML(this.resultcont,"<div class=\"csResultsMsg\"><p><strong>No results found.</strong></p><a href=\"/xNet/MainSite/Research/\" title=\"Start New Search\">Start a new search</a><br/><br/>Is there a commercial building here that you would like to add? <a href='/xNet/MainSite/Research/AddEdit/AddEdit.aspx' title='Add a Property'>Add a Property</a></div>");}this.resultcont.scrollTop=0;setTimeout((function(){this.haveResultList=true;}).bind(this),10);};LNJS.SearchManager.prototype._findItemByLatLon=function(arg){var count=LNJS.isNull(this.pData)?0:this.pData.resultCount;if(count>0){for(var i=this.pageIndex;i<count;i++){p=this.pData.items[i];if(p.lat==arg.lat&&p.lon==arg.lon){return{idx1:i,idx2:p.idx2};}p=null;}}};LNJS.SearchManager.prototype._plotPins=function(){if(!LNJS.isNull(this.pData)){if(this._isMLS()&&this.pData.resultCount>0){if(!LNJS.User.rPID.x()&&!LNJS.Page.x){if(this._isFL()&&LNJS.User.iRID==70)return;if(typeof libinit!='undefined')libinit();LNJS.Page.x=true;}}this.haveAddressLoc=false;x=0;address=$('QS_InputField');var searchAdd1=(address!=null)?address.value:'';var icontype=(LNJS.Page.EL.IconType)?LNJS.Page.EL.IconType.options[LNJS.Page.EL.IconType.selectedIndex].value:"Default";for(var i=this.pageIndex;i<this.pData.resultCount;i++){var p=this.pData.items[i];if(LNJS.isNull(p.lat)||LNJS.isNull(p.lon)){LNJS.Trace.warn('_plotPins() Listing '+mpid+' does not have a lat/lon!');}else{var classname=this.getPinClassName(p,icontype);var oPin=new VEShape(VEShapeType.Pushpin,new VELatLong(p.lat,p.lon));oPin.LN=new Object();oPin.LN.idx1=i;oPin.orgZIndex=this._getZIndex(p,i);if(LNJS.Page.isClusterSearch){pinid=i;}else{oPin.LN.MPID=pinid=p.mpid;if(LNJS.Page.isAddressSearch&&!this.haveAddressLoc){if(compairAdd1(p.ad1,p.city,p.state,searchAdd1)){this.haveAddressLoc=true;var idx1=i,idx2=x;setTimeout((function(){LNJS.Page.SearchMgr.showPinProfile(idx1,idx2);}).bind(this),100);}}}oPin.SetCustomIcon("<div id='p"+pinid+"' class='"+classname+"'><!--"+(1+i)+"--></div>");oPin.SetZIndex(oPin.orgZIndex);LNJS.Page.MapMgr.addShape(oPin);p.idx2=x;x++;}}p=null;}if(LNJS.Page.isAddressSearch&&!this.haveAddressLoc&&!LNJS.Page.isAddressSearchHide){if($('msgcont2'))return;this.newAddressLoc=true;var classname="pinBox newListingPin";var oPin=new VEShape(VEShapeType.Pushpin,new VELatLong(window.addressLat,window.addressLon));oPin.LN=new Object();oPin.LN.MPID=0;oPin.LN.idx1=(1+this.pData.resultCount);oPin.orgZIndex=1401;oPin.SetCustomIcon("<div id='p0' class='"+classname+"'></div>");oPin.SetZIndex(oPin.orgZIndex);LNJS.Page.MapMgr.addShape(oPin);setTimeout((function(){LNJS.Page.SearchMgr.showNewListingPinProfile((1+this.pData.resultCount),x,true);LNJS.Page.isAddressSearchHide=true;}).bind(this),100);}LNJS.Page.hideUpdatingMapMsg();};LNJS.SearchManager.prototype.getPinClassName=function(p,IconType){if(LNJS.Page.isClusterSearch){return"pinBox clusterPin";}var classname="premiumPin";switch(IconType){case"Photo":classname="hasPhoto";if(!p.img){classname="noPhoto";}break;case"Status":classname="notActiveInContract";if(!LNJS.isNull(p.status)&&((p.status.indexOf('Active')!=-1)||(p.status.indexOf('In-Contract')!=-1))){classname="ActiveInContract";}else if(!LNJS.isNull(p.soldstatus)&&p.soldstatus.indexOf('Sold')!=-1){classname="RecentlySold";}break;case"History":classname="hasPhoto";if((p.status.indexOf('Other Property')!=-1)){classname="noPhoto";}break;}return"pinBox "+classname;},LNJS.SearchManager.prototype._hilitePin=function(shape,hilite){var pinid=(LNJS.Page.isClusterSearch)?shape.LN.idx1:shape.LN.MPID;if(hilite){if(shape){shape.SetZIndex(this.showcaseZ+1);var oPin=$('p'+pinid);if(oPin&&oPin.className.indexOf("Hilite")==-1){oPin.className=oPin.className+"Hilite";}oPin=null;}}else{if(shape){shape.SetZIndex(shape.orgZIndex);var oPin=$('p'+pinid);if(oPin){oPin.className=oPin.className.replace("Hilite","");}oPin=null;}}};LNJS.SearchManager.prototype._hiliteItem=function(hilite){if(!(!LNJS.isNull(this.pData)&&this.pinIndex!=-1))return;var p=this.pData.items[this.pinIndex];var shape=LNJS.Page.MapMgr.getShapeByIndex(p.idx2);var item=$('i'+this.pinIndex);this._hilitePin(shape,hilite);p=shape=item=null;};LNJS.SearchManager.prototype._buildHTML=function(i,xx,m,html){if(LNJS.Page.isClusterSearch){html.append('<div class="csResultsItem clearfix">');html.append('<dl>');html.append('<dt><a href="/research/'+m.name.replace(', ',',').replace(/\s/g,'-')+'/'+this._getSEOCatName()+'/" id="i'+i+'" title="'+m.name+'">'+m.name+'</a></dt>');html.append('<dd>'+m.count.toString().addCommas()+' Properties</dd>');html.append('</dl>');html.append('</div>');}else{url='/images/commSearch/PhotoNotAvailable60x45.gif';if(m.img)url='/Attachments/'+m.img;html.append('<div id="div'+i+'" class="csResultsItem clearfix" onclick="LNJS.Page.SearchMgr.showPinProfile('+i+','+xx+');" onmouseover="LNJS.Page.SearchMgr.itemHover('+i+','+xx+',event)" onmouseout="LNJS.Page.SearchMgr.itemHover('+i+','+xx+',event)">');html.append('<a href="javascript://" class="csProfileThumb"><img src="'+LNJS.contentProviderUrl+url+'" alt="'+m.ad1+'" /><!--<em>'+(1+m.i)+'</em>--></a>');html.append('<dl id="i'+i+'">');html.append('<dt><a href="'+this._getMPProfileUrl(i)+'" target="_blank" title="'+m.ad1+'">'+m.ad1+'</a></dt>');html.append('<dd>'+m.city+', '+m.state+'</dd>');html.append('<dd>'+_cat[m.type][0]+'</dd>');if(m.status)html.append('<dd>'+m.status+'</dd>');if(LNJS.User.rMID.m())html.append('<dd>MPID: '+m.tid+'</dd>');html.append('</dl>');html.append('</div>');}};LNJS.SearchManager.prototype._LoadResultImg=function(){var count=LNJS.isNull(this.pData)?0:this.pData.resultCount;if(count>0){for(var i=7;i<count;i++){img=$('img'+i);if(img){var m=this.pData.items[i];if(m){url='/images/commSearch/PhotoNotAvailable60x45.gif';if(m.img)url='/Attachments/'+m.img;img.src=LNJS.contentProviderUrl+url;}m=img=null;}}}};LNJS.SearchManager.prototype._getMPProfileUrl=function(index){if(!LNJS.Page.SearchMgr.pData)return"";var url="";var m=LNJS.Page.SearchMgr.pData.items[index];if(m){address=m.ad1+" "+m.city+" "+m.state+" "+m.zip;url="/"+address.replace(/[^a-z0-9\\s]/ig," ").trim().replace(/\s+/ig,"-")+"-Property-Record_"+m.mpid+"/";m=null;}return url;};LNJS.SearchManager.prototype._getProfileHtml=function(i,xx,newListing){var m=LNJS.Page.SearchMgr.pData.items[i];url='/images/commSearch/PhotoNotAvailable100x75.gif';if(m&&m.img)url='/Attachments/'+m.img;var html=new StringBuilder();html.append('<div class="pinprofilecontainer');if(newListing)html.append(' pinprofileMessaging');html.append('">');html.append('<div class="c'+LNJS.Page.SearchMgr.pinCallOutNum+'"> </div>');html.append('<table cellspacing="0" class="pinprofiletbl">');html.append('<tr>');html.append('<td class="pinprofiletop"></td>');html.append('</tr>');html.append('<tr>');html.append('<td class="pinprofilemain">');html.append('<table border="0" cellspacing="0" class="pinprofilecontent">');html.append('<tr>');html.append('<td colspan="2">');html.append('<a href="javascript:LNJS.Page.SearchMgr.hidePinProfile();" class="pinprofileclose" title="Close">');html.append('<img src="'+LNJS.contentProviderUrl+'/images/search/map/pinprofileclose2.gif" border="0" alt="Close" />');html.append('</a>');if(newListing){html.append('<a href="/xNet/MainSite/Research/AddEdit/AddEdit.aspx?address=\''+window.addrSuggestion+'\'">');address=$('QS_InputField');html.append('<h4>'+((address!=null)?address.value:'')+'</h4>');}else{html.append('<a href="'+LNJS.Page.SearchMgr._getMPProfileUrl(i)+'" target="_blank" title="'+m.ad1+'">');html.append('<h4>'+m.ad1+'</h4>');}html.append('</a>');html.append('</td>');html.append('</tr>');if(newListing){html.append('<tr>');html.append('<td>');html.append('<div class="csResultsSearchMsg csResultsNoSuchProperty">This property does not exist in the system. If you know about this property, add it and receive credit for your contribution.</div>');html.append('</td>');html.append('</tr>');html.append('<tr>');html.append('<td colspan="2" class="pinprofilefooter">');html.append('<table width="100%" cellpadding="0" cellspacing="0">');html.append('<tr>');html.append('<td align="right"><a href="/xNet/MainSite/Research/AddEdit/AddEdit.aspx?address=\''+window.addrSuggestion+'\'" title="Add Property"><img src="'+LNJS.contentProviderUrl+'/images/buttons/btn_AddPropertySmRed.gif" alt="Add Property" border="0"></a></td>');html.append('</tr>');html.append('</table>');html.append('</td>');html.append('</tr>');}else{html.append('<tr>');html.append('<td width="100" style="width:100px;">');html.append('<a href="'+LNJS.Page.SearchMgr._getMPProfileUrl(i)+'" target="_blank">');html.append('<img src="'+LNJS.contentProviderUrl+url+'" width="100px" height="75px" class="pinprofilephoto" />');html.append('</a>');html.append('</td>');html.append('<td width="80%" valign="top" align="left">');html.append('<ul class="pinprofilestats_true">');html.append('<li class="firststat">'+m.city+', '+m.state+'</li>');html.append('<li>'+_cat[m.type][0]+'</li>');if(m.status)html.append('<li>'+m.status+'</li>');if(LNJS.User.rMID.m())html.append('<li>MPID: '+m.tid+'</li>');html.append('</ul>');if(LNJS.User.rAID.a()){html.append('<div id="SaveProp">');html.append('<a title="Save this property" class="csSaveProperty" href="javascript:LNJS.Page.SearchMgr.saveMP(\''+m.mpid+'\');">Save this property</a>');html.append('</div>');}html.append('</td>');html.append('</tr>');html.append('<tr>');html.append('<td colspan="2" class="pinprofilefooter">');html.append('<table cellpadding="0" cellspacing="0" width="100%">');html.append('<tr>');html.append('<td align="left" width="50%">');html.append('<a id="zoomtostreet" href="javascript:void(0);" onclick="LNJS.Page.zoomToStreet('+i+');" title="Zoom to Street" class="zoomtostreet">');html.append('Zoom to Street');html.append('</a>');html.append('</td>');html.append('<td align="right">');html.append('<a href="'+LNJS.Page.SearchMgr._getMPProfileUrl(i)+'" target="_blank" title="View Details">');html.append('<img src="'+LNJS.contentProviderUrl+'/images/search/map/pinprofile-ViewDetails.gif" border="0" alt="View Details" />');html.append('</a>');html.append('</td>');html.append('</tr>');html.append('</table>');html.append('</td>');html.append('</tr>');}html.append('</table>');html.append('</td>');html.append('</tr>');html.append('<tr>');html.append('<td class="pinprofilebottom"></td>');html.append('</tr>');html.append('</table>');html.append('</div>');return html.toString();};LNJS.SearchManager.prototype.itemHover=function(idx1,idx2,e){if(LNJS.Page.SearchMgr.pData==null)return;if(LNJS.isNull(LNJS.Page.SearchMgr.pData))return;if(typeof LNJS.Page.SearchMgr.pData=='undefined')return;if(LNJS.Page.SearchMgr.pData.items[idx1]==null)return;p=LNJS.Page.SearchMgr.pData.items[idx1];pinid=(LNJS.Page.isClusterSearch)?idx1:p.mpid;p=null;LNJS.Page.toggle(e,{index:idx1,element:$('p'+pinid),showpause:100,hidepause:100,call:function(e,args){if(!LNJS.Page.SearchMgr.pData)return;if(LNJS.Page.SearchMgr.pData.items[idx1]==null)return;LNJS.Page.SearchMgr.toolTip(idx1,idx2,e);}});};function compairAdd1(MPAdd1,MPCity,MPState,SearchAdd1){if((MPAdd1+', '+MPCity+', '+MPState)==SearchAdd1)return true;var streetNum=/^\d+(?:\w+\.?)/i;mNum=String(MPAdd1.match(streetNum)).trim();sNum=String(SearchAdd1.match(streetNum)).trim();if((mNum==sNum)&&(SearchAdd1.toUpperCase().indexOf(MPCity.toUpperCase())!=-1)){if(SearchAdd1.toUpperCase().indexOf(getStreetName(MPAdd1,mNum))!=-1)return true;}return false;};function getStreetName(Ad1,mNum){var streetDir=/\s(EAST|E\.?|WEST|W\.?|NORTH|N\.?|SOUTH|S\.?)\s/i;var streetType=/\s(STREET|ST|DRIVE|DR|AVENUE|AVE|ROAD|RD|LOOP|COURT|CT|CIRCLE|LANE|LN|BOULEVARD|BLVD)\.?\s*/i;var streetPlace=/(SUITE|APT|BLDG|DEPT|FL|HNGR|LOT|PIER|RM|S(?:LIP|PC|T(?:E|OP))|TRLR|UNIT)\.?\s*[a-zA-Z0-9\-]+/i;var suiteNumber=/#\.?\s*[a-zA-Z0-9\-\s]*/i;Ad1=Ad1.replace(streetDir,'');Ad1=Ad1.replace(streetType,'');Ad1=Ad1.replace(streetPlace,'');Ad1=Ad1.replace(suiteNumber,'');Ad1=Ad1.replace(mNum,'');return Ad1.trim().toUpperCase();}function addCommas(nStr){nStr+='';x=nStr.split('.');x1=x[0];x2=x.length>1?'.'+x[1]:'';var rgx=/(\d+)(\d{3})/;while(rgx.test(x1)){x1=x1.replace(rgx,'$1'+','+'$2');}return x1+x2;}