(function(){var A=new YAHOO.util.YUILoader({base:"",require:["animation","carousel","connection","container","dom","event","fonts","history","selector","tabview"],loadOptional:false,combine:true,filter:"MIN",allowRollup:true,onSuccess:function(){City.Init()}});A.insert()})();City={Fresh:true,TabLocations:{overview:0,resident:1,schools:2,meetups:3,questions:4,businesses:5},Init:function(){YAHOO.util.Event.onAvailable("ListingsMap",this.InitializeMaps,this);YAHOO.util.Event.onAvailable("NeighborhoodTabs",this.InitializeHistory,this);YAHOO.util.Event.onAvailable("PanoramioPhotos",this.InitializeCarousel,this);YAHOO.util.Event.onAvailable("Meetups",this.InitializeMeetups,this)},InitializeMeetups:function(){var A=document.getElementById("Meetups");if(!A.firstChild){A.innerHTML="Loading...";var B=YAHOO.util.Connect.asyncRequest("GET","/"+City.RootUrl+"/Controls/Meetup.aspx?sname="+City.Data.StateAbbr+"&cname="+City.Data.CityName,{success:function(C){A.innerHTML=C.responseText}},null)}},InitializeCarousel:function(){var A=document.getElementById("PanoramioPhotos");if(!A.firstChild){A.innerHTML="Loading...";var C=YAHOO.util.Connect.asyncRequest("GET","/"+City.RootUrl+"/Controls/Panoramio.aspx?sfips="+City.Data.StateFIPS+"&cname="+City.Data.CityName,{success:function(D){A.innerHTML=D.responseText;City.InitializeCarousel()}},null)}else{if(document.getElementById("carousel")){var B=new YAHOO.widget.Carousel("PanoramioPhotos",{isCircular:true,animation:{speed:0.5},numVisible:10});B.on("click",City.ShowPhoto);B.render();B.show()}}},ShowPrevPhoto:function(B){var A=document.getElementById("panoramio_"+B);var C=document.getElementById("carousel");var D=null;if(!A.previousSibling){D=C.lastChild}else{D=A.previousSibling}City.ShowPhoto({target:D.firstChild})},ShowNextPhoto:function(C){var A=document.getElementById("panoramio_"+C);var D=document.getElementById("carousel");var B=null;if(!A.nextSibling){B=D.firstChild}else{B=A.nextSibling}City.ShowPhoto({target:B.firstChild})},ShowPhoto:function(A){if(A.target.nodeName=="IMG"){if(typeof City.CarouselDialog=="undefined"){document.getElementById("CarouselDialog").style.display="block";City.CarouselDialog=new YAHOO.widget.SimpleDialog("CarouselDialog",{width:"520px",fixedcenter:true,modal:true,visible:false,draggable:false});City.CarouselDialog.cfg.queueProperty("keylisteners",new YAHOO.util.KeyListener(document,{keys:27},{fn:City.CarouselDialog.hide,scope:City.CarouselDialog,correctScope:true}));City.CarouselDialog.render()}City.CarouselDialog.setBody("<div style='text-align:center'><a href='javascript:void(0)' onclick='City.ShowPrevPhoto("+A.target.getAttribute("photo_id")+")'><img src='/"+Global.RootUrl+"/images/left.gif' style='border:0' /></a>&nbsp;&nbsp;<a href='javascript:void(0)' onclick='City.ShowNextPhoto("+A.target.getAttribute("photo_id")+")'><img src='/"+Global.RootUrl+"/images/right.gif' style='border:0' /></a><br /><a href='"+A.target.getAttribute("photo_url")+"' target='_blank'><img src='"+A.target.getAttribute("src").replace("square","medium")+"' width='"+A.target.getAttribute("orig_width")+"' height='"+A.target.getAttribute("orig_height")+"' style='width:"+A.target.getAttribute("orig_width")+"px; height:"+A.target.getAttribute("orig_height")+"px;' /></a><br /><span class='carousel-dialog'>author: <a href='"+A.target.getAttribute("owner_url")+"' target='_blank'>"+A.target.getAttribute("owner_name")+"</a></span><br /><br />Photos provided by <a href='http://www.panoramio.com/' target='_blank'>Panoramio</a> are under the copyright of their owners.</div>");City.CarouselDialog.show();City.CarouselDialog.center()}},InitializeHistory:function(){var A=YAHOO.util.History.getBookmarkedState("tabview");var C=A||"tab-overview";YAHOO.util.History.register("tabview",C,function(D){City.Tabs.set("activeIndex",City.TabLocations[D.substr(4)])});YAHOO.util.History.onReady(function(){var D;City.InitializeTabs();D=YAHOO.util.History.getCurrentState("tabview");City.Tabs.set("activeIndex",City.TabLocations[D.substr(4)])});try{YAHOO.util.History.initialize("yui-history-field","yui-history-iframe")}catch(B){City.InitializeTabs()}},InitializeTabs:function(){var A=YAHOO.util.Selector.query("#NeighborhoodTabs ul li");this.Tabs=new YAHOO.widget.TabView("NeighborhoodTabs");this.Tabs.addListener("activeTabChange",this.HandleTabViewActiveTabChange);this.SchoolTabs=new YAHOO.widget.TabView("SchoolTabs")},ChangeShowListings:function(){this.InitializeMaps()},HandleTabViewActiveTabChange:function(E){var D,B,C=this.getTabIndex(E.newValue);for(var A in City.TabLocations){if(City.TabLocations[A]==C){D="tab-"+A}}try{B=YAHOO.util.History.getCurrentState("tabview");if(D!=B){YAHOO.util.History.navigate("tabview",D)}}catch(E){this.set("activeIndex",City.TabLocations[D.substr(4)])}},InitializeMaps:function(){if(GBrowserIsCompatible()){var E=new GLatLngBounds();Global.CurrentOverlayColor=0;if(typeof City.Map=="undefined"){City.Map=new GMap2(document.getElementById("ListingsMap"));City.Map.setCenter(new GLatLng(City.Data.Latitude,City.Data.Longitude),13);City.Map.addControl(new GSmallMapControl())}else{City.Map.clearOverlays()}var D=document.getElementById("ShowListings");var B=new GIcon();B.image="http://assets.diversesolutions.com/images/Beast/Markers-3/marker-small-house-green-normal.png";B.shadow="http://assets.diversesolutions.com/images/Beast/Markers-2/house_map_marker_shadow.png";B.iconSize=new GSize(21,26);B.shadowSize=new GSize(35,28);B.iconAnchor=new GPoint(10,26);if(typeof City.Data.Polyline!="undefined"){City.NewCityPolygon(City.Data,City.Map,0.6,D.checked?null:E)}if(D.checked){for(var C=0;C<City.LocalListings.length;C++){var A=City.NewMarker(City.LocalListings[C],B,City.Map);City.Map.addOverlay(A);E.extend(A.getPoint())}}if(City.Fresh){City.Map.setZoom(City.Map.getBoundsZoomLevel(E));City.Map.setCenter(E.getCenter())}City.Fresh=false}},NewMarker:function(D,C,E){var A=new GLatLng(D.Latitude,D.Longitude);var B=new GMarker(A,{icon:C});GEvent.addListener(B,"click",function(){location.href=D.Url});GEvent.addListener(B,"mouseover",function(I){var F=null;var H=null;var J=null;var G=null;if(typeof D.HoverDom=="undefined"){D.HoverDom=document.createElement("div");D.HoverDom.style.visibility="hidden";D.HoverDom.id="MapHover_"+D.PropertyID;E.getPane(G_MAP_FLOAT_PANE).appendChild(D.HoverDom);D.HoverDom.className="MapHover";F=document.createElement("img");if(D.PhotoCount>0){F.src="http://idx.diversesolutions.com/photos/"+D.FeedID+"/"+D.MlsNumber+"/0/thumb.aspx"}else{F.src="http://assets.diversesolutions.com/images/Beast/NoPhotoAvailable.gif"}YAHOO.util.Event.addListener(F,"load",function(){City.SetMarkerWidth(D,F,H,C,E,I)});D.HoverDom.appendChild(F);H=document.createElement("div");H.className="Title";H.innerHTML=D.Address+"<br />$"+Global.FormatPrice(D.Price);D.HoverDom.appendChild(H);G=document.createElement("div");G.className="Subtitle";G.innerHTML=D.Beds+" beds, "+Global.FormatBaths(D.Baths)+"<br />Size: "+Global.FormatPrice(D.ImprovedSqFt)+" sq ft<br />Lot size: "+Global.FormatPrice(D.LotSqFt)+" sq ft<br />";H.appendChild(G);J=document.createElement("div");J.className="Clear";D.HoverDom.appendChild(J);D.HoverDom.style.width=(104+H.offsetWidth)+"px";D.HoverDom.style.display="block"}else{D.HoverDom.style.display="block";F=D.HoverDom.childNodes[0];H=D.HoverDom.childNodes[1]}City.PositionMarker(D,F,H,C,E,I);City.WaitForImageSize(D,F,H,C,E,I);D.HoverDom.style.visibility="visible"});GEvent.addListener(B,"mouseout",function(){D.HoverDom.style.display="none"});return B},WaitForImageSize:function(E,B,C,A,F,D){if(E.HoverDom.style.display=="block"){if(B.offsetWidth==0){setTimeout(function(){City.WaitForImageSize(E,B,C,A,F,D)},100)}else{City.SetMarkerWidth(E,B,C,A,F,D)}}},SetMarkerWidth:function(E,B,C,A,F,D){if(B.offsetWidth>0&&C.offsetWidth>0){E.HoverDom.style.width=(B.offsetWidth+C.offsetWidth+10)+"px";E.HoverDom.style.width=(B.offsetWidth+C.offsetWidth+10)+"px";City.PositionMarker(E,B,C,A,F,D)}},PositionMarker:function(E,B,I,C,A,H){var D=document.getElementById("ListingsMap");var L=A.fromLatLngToDivPixel(H);var G=A.fromLatLngToDivPixel(A.getBounds().getSouthWest()).x;var F=A.fromLatLngToDivPixel(A.getBounds().getSouthWest()).y-A.getSize().height;var K=0;var J=0;L.x-=G;L.y-=F;if(L.x>D.offsetWidth/2){K=(L.x+G-E.HoverDom.offsetWidth)-C.iconSize.width/2}else{K=(L.x+G)+C.iconSize.width/2}if(L.y-E.HoverDom.offsetHeight/2-13<4){J=(4+F)}else{if(L.y+E.HoverDom.offsetHeight/4>D.offsetHeight-4){J=(D.offsetHeight+F-E.HoverDom.offsetHeight-4)}else{J=(L.y+F-(E.HoverDom.offsetHeight/2)-13)}}E.HoverDom.style.left=K+"px";E.HoverDom.style.top=J+"px"},NewCityPolygon:function(D,E,B,C){var A=Global.BuildPolygon(E,D.Polyline,1,1,"#444444",true,B,true,C)}};