function loadMarkers(k){var g=document.getElementById("map");om=new OverlayMessage(g);om.Set('<b>Loading Storm Reports...</b><br><img src="images/loading.gif" alt="loading"/>');map.clearOverlays();var j=document.getElementById("daterange").value;var h=getUTCTime();var f=getUTCDate();if(j=="Click to Select Date Range..."||j==""){utcshortdate=f.substring(2);ShowPolylines(utcshortdate,h);IssuedWatches()}else{var c=j.substring(2);ShowPolylines(c,h)}var i=getLongDate();if(i==j){showRadar();showWarnings();showWatches();if(!useRadar){hideRadar()}else{showRadar()}if(!useWarnings){hideWarnings()}else{showWarnings()}}if(!useOutlook){setTimeout("hideConvectiveOutlook();",1250)}var d,e=[];hailcount=0;windcount=0;torncount=0;totalcount=0;var a=new GLatLngBounds();var b=k;GDownloadUrl(b,function(K){var p=GXml.parse(K);var H=p.documentElement.getElementsByTagName("marker");var m,r,F,t,K,u,I,v,B,o,J,l,A,G,C;var z,y,q,x,D,s=[];for(var E=0;E<H.length;E++){B=new GLatLng(parseFloat(H[E].getAttribute("lat")),parseFloat(H[E].getAttribute("lng")));icon=H[E].getAttribute("icon");r=H[E].getAttribute("address");F=H[E].getAttribute("county");t=H[E].getAttribute("state");K=H[E].getAttribute("data");u=H[E].getAttribute("comments");I=H[E].getAttribute("date");v=H[E].getAttribute("time");m=H[E].getAttribute("timestamp");o=H[E].getAttribute("zipcode");J=H[E].getAttribute("population");l=H[E].getAttribute("pop_growth");A=H[E].getAttribute("pop_density");G=H[E].getAttribute("median_age");C=H[E].getAttribute("median_income");z=H[E].getAttribute("col_index");y=H[E].getAttribute("median_home_age");q=H[E].getAttribute("median_home_value");x=H[E].getAttribute("home_market_value_url");D=H[E].getAttribute("home_rent_v_own_url");s.push(createMarker(B,icon,r,F,t,K,u,I,v,E,o,J,l,A,G,C,z,y,q,x,D));if(icon=="WIND"){windcount++}else{if(icon=="HAIL"){hailcount++}else{torncount++}}a.extend(B)}if(m){var n=new Date(m*1000);var w=n.toDateString()+" "+n.toTimeString();update_date=w.split(" GMT");w=update_date[0]}else{var n=new Date();var w=n.toDateString()+" "+n.toTimeString();update_date=w.split(" GMT");w=update_date[0]+" CDT"}myCluster=new ClusterMarker(map,{markers:s});myCluster.refresh();if(!useCluster){myCluster.clusteringEnabled=!myCluster.clusteringEnabled;myCluster.refresh(true)}totalcount=hailcount+windcount+torncount;document.getElementById("counts").innerHTML="<b>Tornadoes: </b>"+torncount+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Wind: </b>"+windcount+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Hail: </b>"+hailcount;document.getElementById("totals").innerHTML="<b>Total Reports: </b>"+totalcount;document.getElementById("update").innerHTML="<b>Last map update: </b>"+w;if(!useMapInter){if(totalcount>0){map.setZoom(map.getBoundsZoomLevel(a));map.setCenter(a.getCenter())}}om.Clear();if(useMapInter==2){mapHome()}})}function clearMarkers(){map.clearOverlays()}function mapHome(){var c=new GIcon();c.image="images/house.png";c.iconSize=new GSize(35,35);c.shadow="images/houseshadow.png";c.shadowSize=new GSize(52,35);c.iconAnchor=new GPoint(17,35);var a=new GLatLng(homelat,homelng);var b=new GMarker(a,c);map.addOverlay(b)}function createMarker(r,x,d,u,e,C,g,z,h,q,b,B,a,p,v,s,o,n,c,j,t){if(x=="WIND"){bgcolor="#7add7a";wind=C.substring(0,3);wind=(wind.replace(/^\s+|\s+$/g,""));if(wind=="UNK"){wind="";C="Wind : Unmeasured"}else{C="Wind : "+wind+"MPH"}var y={width:30,height:30,primaryColor:"#7add7a",label:wind.toString(),labelSize:0,labelColor:"#FFFFFF",shape:"circle"};var x=MapIconMaker.createFlatIcon(y)}else{if(x=="TORNADO"){bgcolor="#e60000";C="Tornado";var A={width:30,height:30,primaryColor:"#e60000",labelColor:"#FFFFFF",shape:"circle"};var x=MapIconMaker.createFlatIcon(A)}else{bgcolor="#344edb";if(C<1){C=C.substring(1,4)}C=C+'"';hail=C;C="Hail : "+C;var D={width:30,height:30,primaryColor:"#344edb",label:hail.toString(),labelSize:0,labelColor:"#FFFFFF",shape:"circle"};var x=MapIconMaker.createFlatIcon(D)}}var m='<table style="width:320px;background-color:#FFFFFF;font-family:Calibri,Verdana;"><tr><td colspan=2 style="background-color:'+bgcolor+';color:#FFFFFF;text-align:center"><span style="font-size:12pt;font-weight:bold">'+C+'</span></td></tr><tr><td style="vertical-align:top;font-size:9pt;font-family:Arial;display:block;">Comments:</td><td style="font-size:9pt;font-weight:bold">'+g+'</td></tr><tr><td style="vertical-align:top;font-size:9pt;font-family:Arial;display:block;">Address:</td><td style="font-size:9pt;font-weight:bold">'+d+'</td></tr><tr><td style="font-size:9pt;font-family:Arial;display:block;">&nbsp;</td><td style="font-size:9pt;font-weight:bold">'+u+", "+e+'</td></tr><tr><td style="font-size:9pt;font-family:Arial;display:block;">Reported: </td><td style="font-size:9pt;font-weight:bold">'+z+" "+h+'</td></tr><tr><td style="font-size:9pt;font-family:Arial;display:block;">Location: </td><td style="font-size:9pt;font-weight:bold">'+r+"</td></tr></table>";var l='<table style="width:320px;background-color:#FFFFFF;font-family:Calibri,Verdana;"><tr><td colspan=2 style="background-color:'+bgcolor+';color:#FFFFFF;text-align:center"><span style="font-size:12pt;font-weight:bold">Demographics for '+b+'</span></td></tr><tr><td style="vertical-align:top;font-size:9pt;font-family:Arial;display:block;">Population</td><td style="font-size:9pt;font-weight:bold">'+B+'</td></tr><tr><td style="vertical-align:top;font-size:9pt;font-family:Arial;display:block;">Population growth:</td><td style="font-size:9pt;font-weight:bold">'+a+'</td></tr><tr><td style="font-size:9pt;font-family:Arial;display:block;">Population Density</td><td style="font-size:9pt;font-weight:bold">'+p+'</td></tr><tr><td style="font-size:9pt;font-family:Arial;display:block;">Median Age:</td><td style="font-size:9pt;font-weight:bold">'+v+'</td></tr><tr><td style="font-size:9pt;font-family:Arial;display:block;">Median Income:</td><td style="font-size:9pt;font-weight:bold">'+s+'</td></tr><tr><td style="font-size:9pt;font-family:Arial;display:block;">Cost of Living Index:</td><td style="font-size:9pt;font-weight:bold">'+o+'</td></tr><tr><td style="font-size:9pt;font-family:Arial;display:block;">Median Home Age</td><td style="font-size:9pt;font-weight:bold">'+n+'</td></tr><tr><td style="font-size:9pt;font-family:Arial;display:block;">Median Home Value:</td><td style="font-size:9pt;font-weight:bold">'+c+"</td></tr></table>";var k='<table style="width:320px;background-color:#FFFFFF;font-family:Calibri,Verdana;"><tr><td colspan=2 style="background-color:'+bgcolor+';color:#FFFFFF;text-align:center"><span style="font-size:12pt;font-weight:bold">1-Year Market Value</span></td></tr><tr><td><img src="'+j+'"></td><td></td></tr></table>';var i='<table style="width:350px;background-color:#FFFFFF;font-family:Calibri,Verdana;"><tr><td colspan=2 style="background-color:'+bgcolor+';color:#FFFFFF;text-align:center"><span style="font-size:12pt;font-weight:bold">Renters vs. Owners</span></td></tr><tr><td><img src="'+t+'"></td><td></td></tr></table>';var w=[];w.push(new GInfoWindowTab("Storm Report",m));w.push(new GInfoWindowTab("Details",l));w.push(new GInfoWindowTab("Home Values",k));w.push(new GInfoWindowTab("Rent vs Own",i));var f=new GMarker(r,x);GEvent.addListener(f,"click",function(){f.openInfoWindowTabsHtml(w)});return f}function advBuildDownloadLink(k){if(document.getElementById("daterange").value!="Click to Select Date Range..."){if(isValidZipCode(document.getElementById("zipcode").value)){hideRadar();hideWarnings();hideWatches();daterange=document.getElementById("daterange").value;daterange_result=daterange.split(" - ");if(!daterange_result[1]){daterange_result[1]=daterange_result[0]}var b=formatDate(new Date(getDateFromFormat(daterange_result[0],"yyyyMMdd")),"MMM d, y");var a=formatDate(new Date(getDateFromFormat(daterange_result[1],"yyyyMMdd")),"MMM d, y");var c=new Array();var l=document.forms.grabdate_form2.elements.states;document.getElementById("dates").innerHTML="Showing Reports between "+b+" and "+a;var g=document.getElementById("zipcode").value;var f=document.getElementById("radius").value;while(l.selectedIndex!=-1){if(l.selectedIndex!=0){c.push(l.options[l.selectedIndex].value)}l.options[l.selectedIndex].selected=false}var j="";for(var d=0;d<c.length;d++){if(d+1==c.length){j+=c[d]}else{j+=c[d]+"-"}}var e=k.showtypes.value;var h="xml.php?daterange="+daterange_result[0]+" - "+daterange_result[1];h+="&showtypes="+e;h+="&states="+j;h+="&zipcode="+g;h+="&radius="+f;myCluster.removeMarkers();loadMarkers(h)}else{$.prompt("Improperly formatted ZipCode!",{prefix:"cleanblue"})}}else{$.prompt("Please select a specific date or daterange to search with!",{prefix:"cleanblue"})}}function isValidZipCode(b){if(!b){return 1}else{var a=/^\d{5}([\-]\d{4})?$/;return(a.test(b))}}function ShowPolylines(c,a){var b="polylines.php?date="+c+"&time="+a;GDownloadUrl(b,function(g){var d=GXml.parse(g);var f=d.documentElement.getElementsByTagName("polyline");for(var e=0;e<f.length;e++){OutlookType=f[e].getAttribute("OutlookType");OutlookCategory=f[e].getAttribute("OutlookCategory");OutlookPercent=f[e].getAttribute("OutlookPercent");LatandLong=f[e].getAttribute("LatandLong");Levels=f[e].getAttribute("Levels");PolylineLevels=LevelsCalc("B",Levels);if(OutlookType=="CATEGORICAL"){if(OutlookCategory=="TSTM"){TSTMencodedPolyline_Array[TSTMPolylineCount]=new GPolyline.fromEncoded({color:"#B47F00",weight:8,points:LatandLong,levels:PolylineLevels,zoomFactor:32,numLevels:4});map.addOverlay(TSTMencodedPolyline_Array[TSTMPolylineCount]);TSTMPolylineCount++}else{if(OutlookCategory=="SLGT"){SLGTencodedPolyline_Array[SLGTPolylineCount]=new GPolyline.fromEncoded({color:"#008b00",weight:8,points:LatandLong,levels:PolylineLevels,zoomFactor:32,numLevels:4});map.addOverlay(SLGTencodedPolyline_Array[SLGTPolylineCount]);SLGTPolylineCount++}else{if(OutlookCategory=="MDT"){MDTencodedPolyline_Array[MDTPolylineCount]=new GPolyline.fromEncoded({color:"#FF0000",weight:6,points:LatandLong,levels:PolylineLevels,zoomFactor:32,numLevels:4});map.addOverlay(MDTencodedPolyline_Array[MDTPolylineCount]);MDTPolylineCount++}else{if(OutlookCategory=="HIGH"){HIGHencodedPolyline_Array[HIGHPolylineCount]=new GPolyline.fromEncoded({color:"#ff17ff",weight:4,points:LatandLong,levels:PolylineLevels,zoomFactor:32,numLevels:4});map.addOverlay(HIGHencodedPolyline_Array[HIGHPolylineCount]);HIGHPolylineCount++}else{}}}}}}})}function IssuedWatches(){var a="watches.php";GDownloadUrl(a,function(e){var b=GXml.parse(e);var d=b.documentElement.getElementsByTagName("polyline");for(var c=0;c<d.length;c++){WatchType=d[c].getAttribute("watch_type");LatandLong=d[c].getAttribute("polylines");Levels=d[c].getAttribute("levels");PolylineLevels=LevelsCalc("B",Levels);if(WatchType=="Severe"){WatchPolyline_Array[WatchPolylineCount]=new GPolyline.fromEncoded({color:"#0000FE",weight:4,points:LatandLong,levels:PolylineLevels,zoomFactor:32,numLevels:4});map.addOverlay(WatchPolyline_Array[WatchPolylineCount]);WatchPolylineCount++}else{WatchPolyline_Array[WatchPolylineCount]=new GPolyline.fromEncoded({color:"#FE0000",weight:4,points:LatandLong,levels:PolylineLevels,zoomFactor:32,numLevels:4});map.addOverlay(WatchPolyline_Array[WatchPolylineCount]);WatchPolylineCount++}}})}function LevelsCalc(d,a){var c=[];for(var b=0;(1<<b)<=a;b++){if((1<<b)&a){c.push(d)}d+=d}return c.join("")}function ShowWarnings(){var a=new GTileLayer(new GCopyrightCollection(""),1,17);a.getTileUrl=function(g,j){var b=new GPoint(g.x*256,(g.y+1)*256);var i=new GPoint((g.x+1)*256,g.y*256);var h=G_NORMAL_MAP.getProjection().fromPixelToLatLng(b,j);var d=G_NORMAL_MAP.getProjection().fromPixelToLatLng(i,j);var c=new Date();var f=c.getTime();var e="http://mesonet.agron.iastate.edu/cgi-bin/wms/us/wwa.cgi?";e+="&request=GetMap&service=WMS&version=1.1.1&layers=warnings_p&styles=";e+="&format=image/gif&bgcolor=0x333333&transparent=true&srs=EPSG:4326";e+="&bbox="+h.x+","+h.y+","+d.x+","+d.y;e+="&width=256&height=256";return e};a.getOpacity=function(){return 0.5};a.isPng=function(){return false};warningoverlay=new GTileLayerOverlay(a);map.addOverlay(warningoverlay);warningsShown=true}function ShowRadar(){var a=new GTileLayer(new GCopyrightCollection(""),1,17);a.getTileUrl=function(g,j){var b=new GPoint(g.x*256,(g.y+1)*256);var i=new GPoint((g.x+1)*256,g.y*256);var h=G_NORMAL_MAP.getProjection().fromPixelToLatLng(b,j);var d=G_NORMAL_MAP.getProjection().fromPixelToLatLng(i,j);var c=new Date();var f=c.getTime();var e="http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi?";e+="&request=GetMap&service=WMS&version=1.1.1&layers=nexrad-n0r&styles=";e+="&format=image/gif&bgcolor=0x333333&transparent=true&srs=EPSG:4326";e+="&bbox="+h.x+","+h.y+","+d.x+","+d.y;e+="&width=400&height=400&reaspect=false&cachetime="+f;bbox=h.x+" "+h.y+" "+d.x+" "+d.y;return e};a.getOpacity=function(){return 0.5};a.isPng=function(){return false};radaroverlay=new GTileLayerOverlay(a);map.addOverlay(radaroverlay);radarShown=true}function getUTCTime(){now=new Date();var a=now.getUTCHours();var b=now.getUTCMinutes();if(a<10){a="0"+a}if(b<10){b="0"+b}utctime=a+""+b;return utctime}function getUTCDate(){now=new Date();var a=now.getUTCFullYear();var b=a;var c=now.getUTCMonth()+1;if(c<10){c="0"+c}var d=now.getUTCDate();if(d<10){d="0"+d}utcfulldate=a+""+c+""+d;return utcfulldate}function getLongDate(){tDate=new Date();var a=tDate.getDate();if(a<10){a="0"+a}var c=tDate.getMonth()+1;if(c<10){c="0"+c}var b=tDate.getFullYear();yyyymmdd=b+""+c+""+a;return yyyymmdd}function getShortDate(){tDate=new Date();var a=tDate.getDate();if(a<10){a="0"+a}var c=tDate.getMonth()+1;if(c<10){c="0"+c}var b=tDate.getYear()-100;yymmdd="0"+b+""+c+""+a;return yymmdd}function getCurrentTime(){tDate=new Date();localtime=tDate.getTime();localOffset=tDate.getTimezoneOffset()*60000;utc=localtime+localOffset;offset=-5;tCentral=utc+(3600000*offset);nd=new Date(tCentral);var a=nd.getHours();var b=nd.getMinutes();if(a<10){a="0"+a}if(b<10){b="0"+b}centraltime=a+""+b;return centraltime}function showRadar(){if(radaroverlay.isHidden()){radaroverlay.show()}}function hideRadar(){if(!radaroverlay.isHidden()){radaroverlay.hide()}}function refreshRadar(){if(radarShown){map.removeOverlay(radaroverlay);map.addOverlay(radaroverlay)}}function showWarnings(){if(warningoverlay.isHidden()){warningoverlay.show()}}function hideWarnings(){if(!warningoverlay.isHidden()){warningoverlay.hide()}}function refreshWarnings(){if(warningsShown){map.removeOverlay(warningoverlay);map.addOverlay(warningoverlay)}}function showWatches(){for(var a=0;a<WatchPolylineCount;a++){map.addOverlay(WatchPolyline_Array[a])}}function hideWatches(){for(var a=0;a<WatchPolylineCount;a++){map.removeOverlay(WatchPolyline_Array[a])}}function showConvectiveOutlook(){for(var a=0;a<TSTMPolylineCount;a++){map.addOverlay(TSTMencodedPolyline_Array[a])}for(var a=0;a<SLGTPolylineCount;a++){map.addOverlay(SLGTencodedPolyline_Array[a])}for(var a=0;a<MDTPolylineCount;a++){map.addOverlay(MDTencodedPolyline_Array[a])}for(var a=0;a<HIGHPolylineCount;a++){map.addOverlay(HIGHencodedPolyline_Array[a])}}function hideConvectiveOutlook(){for(var a=0;a<TSTMPolylineCount;a++){map.removeOverlay(TSTMencodedPolyline_Array[a])}for(var b=0;b<SLGTPolylineCount;b++){map.removeOverlay(SLGTencodedPolyline_Array[b])}for(var c=0;c<MDTPolylineCount;c++){map.removeOverlay(MDTencodedPolyline_Array[c])}for(var d=0;d<HIGHPolylineCount;d++){map.removeOverlay(HIGHencodedPolyline_Array[d])}}function toggleClustering(){if(useCluster){useCluster=0;myCluster.clusteringEnabled=!myCluster.clusteringEnabled;myCluster.refresh(true)}else{useCluster=1;myCluster.clusteringEnabled=!myCluster.clusteringEnabled;myCluster.refresh(true)}};