Type.registerNamespace("SearchBrowse");SearchBrowse.GmDispatcher=function(){this.accoData=[];this.gmLister=null;this.gmMap=null};SearchBrowse.GmDispatcher.prototype={initialize:function(){if(this.gmLister){this.gmLister.initialize();this.accoData=[];if(this.gmLister.accoData){for(var a=0;a<this.gmLister.accoData.length;a++){if(this.gmLister.accoData[a]&&this.gmLister.accoData[a].hasCoords){this.accoData.push(this.gmLister.accoData[a])}}}}if(this.gmMap){this.gmMap.Init(this.accoData,"gmapMapContainer")}},registerLister:function(a){this.gmLister=a||new SearchBrowse.GmLister();this.gmLister.registerDispatcher(this)},registerMapComponent:function(a){this.gmMap=a||new SearchBrowse.GmMapMock();this.gmMap.registerDispatcher(this)},MouseOver:function(b,a){var c=SearchBrowse.GmDispatcher.getParams(b,a);switch(c.component){case"lister":if(this.gmMap){this.gmMap.MouseOver(c.id)}break;case"map":if(this.gmLister){this.gmLister.highlightItem(c)}break;default:Sys.Debug.trace("unknown component: "+c.component);break}},MouseOut:function(b,a){var c=SearchBrowse.GmDispatcher.getParams(b,a);switch(c.component){case"lister":if(this.gmMap){this.gmMap.MouseOut(c.id)}break;case"map":if(this.gmLister){this.gmLister.unhighlightItem(c)}break;default:Sys.Debug.trace("unknown component: "+c.component);break}},Click:function(b,a){var c=SearchBrowse.GmDispatcher.getParams(b,a);switch(c.component){case"lister":if(this.gmMap){this.gmMap.Click(c.id)}break;case"map":if(this.gmLister){this.gmLister.selectItem(jQuery.extend(c,{context:this.gmLister}))}break;default:Sys.Debug.trace("unknown component: "+c.component);break}}};SearchBrowse.GmDispatcher.getParams=function(a,c){if(!a&&!c){return}var b={elementId:"",component:"",id:"",context:""};jQuery.extend(b,a.data);jQuery.extend(b,c);if(!b.elementId){b.elementId=(a.target&&a.target.id)||"gmapListerItem_"+b.id}return b};SearchBrowse.GmDispatcher.registerClass("SearchBrowse.GmDispatcher");var gmDispatcher=null;SearchBrowse.GmLister=function(){this.accoData=null;this.gmDispatcher=null};SearchBrowse.GmLister.prototype={initialize:function(){var a=this;this.accoData=[];jQuery("#gmapListerContainer div.lister-item").each(function(){var d=jQuery(this);d.bind("mouseenter",{context:a},a.onMouseEnter);d.bind("mouseleave",{context:a},a.onMouseLeave);d.bind("click",{context:a},a.onClick);var b=SearchBrowse.Updater.buildDetailPageURL({element:this});d.find("a.lister-action-button, a.gmap-info-action").each(function(){this.href=b});var c=SearchBrowse.GmLister.getAccoData(this);a.accoData.push(c);d.find("h3.lister-item-title").each(function(){var g=jQuery(this);var e=0;g.find("img").each(function(){e+=jQuery(this).width()});var f=g.width()-e;g.find("strong.lister-item-display-name.meta-text-truncate").truncatePx({width:f,tail:4})})})},registerDispatcher:function(a){this.gmDispatcher=a},canBePassedToDispatcher:function(a){return(this.gmDispatcher&&a&&a.getAttribute("gmaps.hascoords")==="True")},onMouseEnter:function(b){var a=b.data.context;if(a){var c=SearchBrowse.GmLister.createParams(this,a);a.highlightItem(c);if(a.canBePassedToDispatcher(this)){a.gmDispatcher.MouseOver(b,c)}}},onMouseLeave:function(b){var a=b.data.context;if(a){var c=SearchBrowse.GmLister.createParams(this,a);a.unhighlightItem(c);if(a.canBePassedToDispatcher(this)){a.gmDispatcher.MouseOut(b,c)}}},onClick:function(b){var a=b.data.context;if(a){var c=SearchBrowse.GmLister.createParams(this,a);if(a.canBePassedToDispatcher(this)){a.gmDispatcher.Click(b,c)}a.selectItem(c)}},highlightItem:function(a){if(!a||!a.id){return}jQuery("#gmapListerItem_"+a.id).addClass("lister-selected-item");if(a.component==="map"){this.scrollInToView("gmapListerItem_"+a.id)}},unhighlightItem:function(a){if(!a||!a.id){return}jQuery("#gmapListerItem_"+a.id).removeClass("lister-selected-item")},selectItem:function(a){if(!a||!a.id||!a.elementId){return}this.highlightItem(a)},scrollInToView:function(d){var a=jQuery("#"+d+":parent");var c=jQuery("#gmapListerContainer");var b=10;a.prevAll("div.lister-item").each(function(){b+=this.clientHeight+2});c.stop();c.animate({scrollTop:b})}};SearchBrowse.GmLister.createParams=function(b,a){return{elementId:b.id,id:SearchBrowse.GmLister.getAccoId(b),component:"lister",context:a}};SearchBrowse.GmLister.getAccoId=function(a){return(a&&a.getAttribute("gmaps.id"))||""};SearchBrowse.GmLister.getAccoData=function(a){if(!a){return}return{elementId:a.id,id:a.getAttribute("gmaps.id")||"",rank:a.getAttribute("gmaps.rank")||"",htmlContent:jQuery("div.gmap-lister-item-data",a).html(),hasCoords:Boolean.parse(a.getAttribute("gmaps.hascoords")||"")||false,geoCoord:{latitude:a.getAttribute("gmaps.latitude")||"",longitude:a.getAttribute("gmaps.longitude")||""}}};SearchBrowse.GmLister.registerClass("SearchBrowse.GmLister");SearchBrowse.GmMapMock=function(){this.PlaceHolder="";this.AccoData=[];this.gmDispatcher=null};SearchBrowse.GmMapMock.prototype={Init:function(b,a){},registerDispatcher:function(a){this.gmDispatcher=a},MouseOver:function(a){},MouseOut:function(a){},Click:function(a){}};currentMarker=0;function MapComponent(){this.GMap=null;this.inMarkers=[];this.gmDispatcher=null;return true}MapComponent.prototype={PlaceHolder:"",AccoData:[],registerDispatcher:function(a){this.gmDispatcher=a},Init:function(e,d){this.PlaceHolder=jQuery("#"+d);this.PlaceHolder.css("width","738px");this.PlaceHolder.css("height","350px");this.AccoData=e;this.PlaceHolder.html("");if(GBrowserIsCompatible()){this.GMap=new GMap2(this.PlaceHolder.get(0));this.GMap.setCenter(new GLatLng(37.4419,-122.1419),13);this.GMap.addControl(new GLargeMapControl());this.GMap.addControl(new GMapTypeControl());GEvent.addListener(this.GMap,"zoomend",function(){if(currentMarker){this.removeOverlay(currentMarker.overlay)}})}for(var c in this.AccoData){var a=this.AccoData[c];var f=a.id;var b=new MarkerComponent();b.longitude=parseFloat(a.geoCoord["longitude"]);b.latitude=parseFloat(a.geoCoord["latitude"]);b.Map=this.GMap;b.inGmDispatcher=this.gmDispatcher;b.htmlContent=a.htmlContent;b.rank=a.rank;b.parent=this;b.init(f);this.addInMarker(b)}this.showMarkers()},MouseOver:function(b){var a=this.getMarkerById(b);a.doMouseOverAction(true)},MouseOut:function(b){var a=this.getMarkerById(b);a.doMouseOutAction()},Click:function(b){var a=this.getMarkerById(b);a.doMouseClickAction()},addInMarker:function(a){this.inMarkers.push(a)},showMarkers:function(){var a=this.inMarkers.length-1;var b=new GLatLngBounds();while(a>=0){this.GMap.addOverlay(this.inMarkers[a].marker);b.extend(new GLatLng(this.inMarkers[a].latitude,this.inMarkers[a].longitude));a--}this.GMap.setZoom(this.GMap.getBoundsZoomLevel(b));this.GMap.setCenter(b.getCenter())},getMarkerById:function(b){var a=this.inMarkers.length-1;while(a>=0){if(b==this.inMarkers[a].component_id){return this.inMarkers[a]}a--}return false}};function MarkerComponent(){this.point=null;this.longitude="";this.latitude="";this.iconType=null;this.icon=null;this.component_id=null;this.Map=null;this.htmlContent=null;this.parent=null;this.inGmDispatcher=null;this.oInfoWindowOptions={maxWidth:300};this.oldZoom=null;this.rank=null}MarkerComponent.prototype.init=function(a){this.point=new GLatLng(parseFloat(this.latitude),parseFloat(this.longitude));this.marker=this.createMarker(false);this.setNormalMarkerImportance();this.component_id=a;this.setBehaviours()};MarkerComponent.prototype.createMarker=function(a){if(a){return new GMarker(this.point,markerOptions={icon:this.getIcon(true),zIndexProcess:importanceOrder})}else{return new GMarker(this.point,markerOptions={icon:this.getIcon(false),zIndexProcess:importanceOrder})}};MarkerComponent.prototype.getIcon=function(a){var b=new GIcon();if(a){b.image="/App/Upload/Css/Images/SearchBrowse/gmaps/marker-active-"+this.rank+".png"}else{b.image="/App/Upload/Css/Images/SearchBrowse/gmaps/marker-inactive-"+this.rank+".png"}b.shadow="/App/Upload/Css/Images/SearchBrowse/gmaps/marker-shadow.png";b.iconSize=new GSize(30,30);b.shadowSize=new GSize(43,30);b.iconAnchor=new GPoint(6,30);b.infoWindowAnchor=new GPoint(1,30);return b};MarkerComponent.prototype.setBehaviours=function(){this.marker.parent=this;GEvent.addListener(this.marker,"click",function(){this.parent.doMouseClickAction();this.parent.inGmDispatcher.Click(this.parent.getEventData())});GEvent.addListener(this.marker,"mouseover",function(){this.parent.doMouseOverAction(false);this.parent.inGmDispatcher.MouseOver(this.parent.getEventData())});GEvent.addListener(this.marker,"mouseout",function(){this.parent.doMouseOutAction();this.parent.inGmDispatcher.MouseOut(this.parent.getEventData())})};MarkerComponent.prototype.getEventData=function(){var a=[];a.data=[];a.data["id"]=this.component_id;a.data["component"]="map";a.data["context"]=this.parent;return a};MarkerComponent.prototype.setNormalMarkerImportance=function(){this.marker.importance=GOverlay.getZIndex(this.marker.getPoint().lat())+1000000000};MarkerComponent.prototype.setHighMarkerImportance=function(){this.marker.importance=GOverlay.getZIndex(this.marker.getPoint().lat())+10000000000};MarkerComponent.prototype.doMouseOverAction=function(a){this.marker.setImage("/App/Upload/Css/Images/SearchBrowse/gmaps/marker-active-"+this.rank+".png");this.setHighMarkerImportance();this.marker.setLatLng(this.marker.getLatLng());if(a){}};MarkerComponent.prototype.doMouseOutAction=function(){this.marker.setImage("/App/Upload/Css/Images/SearchBrowse/gmaps/marker-inactive-"+this.rank+".png");this.setNormalMarkerImportance();this.marker.setLatLng(this.marker.getLatLng())};MarkerComponent.prototype.doMouseClickAction=function(){this.showInfoWindow();var a=new GPoint((this.Map.fromLatLngToDivPixel(this.marker.getLatLng()).x)+50,this.Map.fromLatLngToDivPixel(this.marker.getLatLng()).y);this.Map.panTo(this.Map.fromDivPixelToLatLng(a))};MarkerComponent.prototype.showInfoWindow=function(){if(typeof CustomPopupOverlay!=="undefined"){if(currentMarker){this.Map.removeOverlay(currentMarker.overlay)}if(!this.overlay){this.overlay=new CustomPopupOverlay(this.marker,this.htmlContent,this.Map)}currentMarker=this;this.Map.addOverlay(this.overlay)}};CustomPopupOverlay=function(a,b,c){this.marker=a;this.html=b;this.map=c};CustomPopupOverlay.prototype=new GOverlay();CustomPopupOverlay.prototype.initialize=function(b){var d=document.createElement("div");d.className="gmap-info-container";d.style.position="absolute";d.innerHTML=this.html;var a=370;var c=81;d.style.top=(b.fromLatLngToDivPixel(this.marker.getLatLng()).y-c)+"px";d.style.left=(b.fromLatLngToDivPixel(this.marker.getLatLng()).x+30)+"px";this._map=b;this._div=d;b.getPane(G_MAP_FLOAT_SHADOW_PANE).appendChild(d);jQuery(".gmap-info-closebutton").bind("click",{map:b},closeOverlay)};CustomPopupOverlay.prototype.remove=function(){this._div.parentNode.removeChild(this._div)};CustomPopupOverlay.prototype.redraw=function(){};function importanceOrder(c,a){return c.importance}function closeOverlay(a){if(currentMarker){a.data.map.removeOverlay(currentMarker.overlay);return false}};