(function(){var A=new YAHOO.util.YUILoader({base:"",require:["dom","event","element"],loadOptional:false,combine:true,filter:"MIN",allowRollup:true,onSuccess:function(){County.Init()}});A.insert()})();County={Init:function(){YAHOO.util.Event.onAvailable("CitiesMap",this.InitializeMaps,this);YAHOO.util.Event.onAvailable("MapControls",this.InitualizeMapControls,this)},InitualizeMapControls:function(){var D=document.getElementById("district_tiles_unified");var C=document.getElementById("district_tiles_secondary");var E=document.getElementById("district_tiles_elementary");var A=document.getElementById("tile_types_cities");var B=document.getElementById("tile_types_districts");YAHOO.util.Event.addListener("district_tiles_unified","change",County.InitializeMaps);YAHOO.util.Event.addListener("district_tiles_secondary","change",County.InitializeMaps);YAHOO.util.Event.addListener("district_tiles_elementary","change",County.InitializeMaps);YAHOO.util.Event.addListener("tile_types_cities","change",County.InitializeMaps);YAHOO.util.Event.addListener("tile_types_districts","change",County.InitializeMaps)},InitializeMaps:function(){Global.CurrentOverlayColor=0;if(GBrowserIsCompatible()){var H=document.getElementById("district_tiles_unified");var F=document.getElementById("district_tiles_secondary");var I=document.getElementById("district_tiles_elementary");var J=document.getElementById("tile_types_cities");var C=document.getElementById("tile_types_districts");var G=false;if(typeof County.map=="undefined"){G=true}else{G=false}if(G){County.map=new GMap2(document.getElementById("CitiesMap"))}map=County.map;var A=new GLatLngBounds();if(G){map.setCenter(new GLatLng(parseFloat(County.Data.Latitude),parseFloat(County.Data.Longitude)),13);map.addControl(new GLargeMapControl())}var B=new GIcon();B.infoWindowAnchor=new GPoint(15,1);B.iconSize=new GSize(24,24);B.iconAnchor=new GPoint(13,13);B.image="/"+Global.RootUrl+"/images/icons/marker-circle-24.png";map.clearOverlays();if(J.checked){if(typeof County.Data.Polyline!="undefined"){County.NewCountyPolygon(County.Data,map,0.05,G?A:null)}for(var E=0;E<County.Cities.length;E++){var D=County.NewMarker(County.Cities[E],B,map);map.addOverlay(D);A.extend(D.getPoint())}}else{if(C.checked){if(I.checked){for(var E=0;E<County.ElementaryPolygons.length;E++){County.NewDistrictPolygon(County.ElementaryPolygons[E],map,G?A:null)}}if(F.checked){for(var E=0;E<County.SecondaryPolygons.length;E++){County.NewDistrictPolygon(County.SecondaryPolygons[E],map,G?A:null)}}if(H.checked){for(var E=0;E<County.UnifiedPolygons.length;E++){County.NewDistrictPolygon(County.UnifiedPolygons[E],map,G?A:null)}}}}if(G){map.setZoom(map.getBoundsZoomLevel(A));map.setCenter(A.getCenter())}}},NewMarker:function(D,C,E){var A=new GLatLng(parseFloat(D.Latitude),parseFloat(D.Longitude));var B=new GMarker(A,{icon:C});GEvent.addListener(B,"click",function(){location.href="/"+Global.RootUrl+"/state/"+Global.CleanStringForUrl(D.StateAbbr)+"/county/"+Global.CleanStringForUrl(D.CountyName)+"/city/"+Global.CleanStringForUrl(D.CityName)});GEvent.addListener(B,"mouseover",function(H){var F=null;var L=document.getElementById("CitiesMap");if(typeof D.HoverDom=="undefined"){D.HoverDom=document.createElement("div");D.HoverDom.id="MapHover_"+D.CountyFIPS;F=new YAHOO.util.Element(D.HoverDom);var K=document.createElement("div");var J=document.createElement("div");K.innerHTML=D.CityName;J.innerHTML="Population "+D.PopulationEstimate;K.className="Title";J.className="Subtitle";F.appendChild(K);F.appendChild(J);F.addClass("MapHover");F.appendTo(E.getPane(G_MAP_FLOAT_PANE))}else{F=new YAHOO.util.Element(D.HoverDom);F.setStyle("display","block")}F.fireQueue();F.setStyle("visibility","hidden");var O=E.fromLatLngToDivPixel(H);var I=E.fromLatLngToDivPixel(E.getBounds().getSouthWest()).x;var G=E.fromLatLngToDivPixel(E.getBounds().getSouthWest()).y-E.getSize().height;var N=0;var M=0;O.x-=I;O.y-=G;if(O.x>L.offsetWidth/2){N=(O.x+I-D.HoverDom.offsetWidth)-C.iconSize.width/2}else{N=(O.x+I)+C.iconSize.width/2}if(O.y-D.HoverDom.offsetHeight/2<4){M=(4+G)}else{if(O.y+D.HoverDom.offsetHeight/4>L.offsetHeight-4){M=(L.offsetHeight+G-D.HoverDom.offsetHeight-4)}else{M=(O.y+G-(D.HoverDom.offsetHeight/2))}}F.setStyle("left",N+"px");F.setStyle("top",M+"px");F.setStyle("visibility","visible")});GEvent.addListener(B,"mouseout",function(){HoverDom=new YAHOO.util.Element(D.HoverDom);HoverDom.setStyle("display","none")});return B},NewDistrictPolygon:function(F,E,D){var A=Global.BuildPolygon(E,F.Polyline,1,1,"#444444",true,0.6,true,D);for(var C=0;C<A.length;C++){var B=A[C];GEvent.addListener(B,"click",function(){location.href="/"+Global.RootUrl+"/state/"+Global.CleanStringForUrl(F.State)+"/county/"+Global.CleanStringForUrl(F.County)+"/city/"+Global.CleanStringForUrl(F.County)+"/district/"+Global.CleanStringForUrl(F.Name)});GEvent.addListener(B,"mouseover",function(S,Q,N,M){var J=new GLatLng(F.Latitude,F.Longitude);var G=null;var O=document.getElementById("CitiesMap");if(typeof F.HoverDom=="undefined"){F.HoverDom=document.createElement("div");F.HoverDom.id="MapHoverDistrict_"+F.ID;G=new YAHOO.util.Element(F.HoverDom);var L=document.createElement("div");var K=document.createElement("div");L.innerHTML=F.Name;K.innerHTML="";L.className="Title";K.className="Subtitle";G.appendChild(L);G.appendChild(K);G.addClass("MapHover");G.appendTo(E.getPane(G_MAP_FLOAT_PANE))}else{G=new YAHOO.util.Element(F.HoverDom);G.setStyle("display","block")}G.fireQueue();G.setStyle("visibility","hidden");var T=E.fromLatLngToDivPixel(J);var I=E.fromLatLngToDivPixel(E.getBounds().getSouthWest()).x;var H=E.fromLatLngToDivPixel(E.getBounds().getSouthWest()).y-E.getSize().height;var R=0;var P=0;T.x-=I;T.y-=H;if(T.x>O.offsetWidth/2){R=(T.x+I-F.HoverDom.offsetWidth)-24/2}else{R=(T.x+I)+24/2}if(T.y-F.HoverDom.offsetHeight/2<4){P=(4+H)}else{if(T.y+F.HoverDom.offsetHeight/4>O.offsetHeight-4){P=(O.offsetHeight+H-F.HoverDom.offsetHeight-4)}else{P=(T.y+H-(F.HoverDom.offsetHeight/2))}}G.setStyle("left",R+"px");G.setStyle("top",P+"px");G.setStyle("visibility","visible")});GEvent.addListener(B,"mouseout",function(){HoverDom=new YAHOO.util.Element(F.HoverDom);HoverDom.setStyle("display","none")})}},NewCityPolygon:function(F,G,B,E){var A=Global.BuildPolygon(G,F.Polyline,1,1,"#444444",true,B,true,E);for(var D=0;D<A.length;D++){var C=A[D];GEvent.addListener(C,"click",function(){location.href="/"+Global.RootUrl+"/state/"+Global.CleanStringForUrl(F.StateAbbr)+"/county/"+Global.CleanStringForUrl(F.CountyName)+"/city/"+Global.CleanStringForUrl(F.CityName)});GEvent.addListener(C,"mouseover",function(T,R,O,N){var K=new GLatLng(F.Latitude,F.Longitude);var H=null;var P=document.getElementById("CitiesMap");if(typeof F.HoverDom=="undefined"){F.HoverDom=document.createElement("div");F.HoverDom.id="MapHover_"+F.Fips;H=new YAHOO.util.Element(F.HoverDom);var M=document.createElement("div");var L=document.createElement("div");M.innerHTML=F.CityName;M.className="Title";L.className="Subtitle";H.appendChild(M);H.appendChild(L);H.addClass("MapHover");H.appendTo(G.getPane(G_MAP_FLOAT_PANE))}else{H=new YAHOO.util.Element(F.HoverDom);H.setStyle("display","block")}H.fireQueue();H.setStyle("visibility","hidden");var U=G.fromLatLngToDivPixel(K);var J=G.fromLatLngToDivPixel(G.getBounds().getSouthWest()).x;var I=G.fromLatLngToDivPixel(G.getBounds().getSouthWest()).y-G.getSize().height;var S=0;var Q=0;U.x-=J;U.y-=I;if(U.x>P.offsetWidth/2){S=(U.x+J-F.HoverDom.offsetWidth)-24/2}else{S=(U.x+J)+24/2}if(U.y-F.HoverDom.offsetHeight/2<4){Q=(4+I)}else{if(U.y+F.HoverDom.offsetHeight/4>P.offsetHeight-4){Q=(P.offsetHeight+I-F.HoverDom.offsetHeight-4)}else{Q=(U.y+I-(F.HoverDom.offsetHeight/2))}}H.setStyle("left",S+"px");H.setStyle("top",Q+"px");H.setStyle("visibility","visible")});GEvent.addListener(C,"mouseout",function(){HoverDom=new YAHOO.util.Element(F.HoverDom);HoverDom.setStyle("display","none")})}},NewCountyPolygon:function(D,E,B,C){var A=Global.BuildPolygon(E,D.Polyline,1,1,"#444444",true,0.2,true,C,"#865207")}};