function SevereLayer(){}SevereLayer.prototype.initialize=function(C,B,D,A){this.map_=C;this.name_=B;this.sidebarPrefix_=D;this.options_=A||{};this.layer_=new Severe(this.name_,this.sidebarPrefix_,this.options_);this.streets_=this.options_.streets||null;GEvent.bind(this.layer_,"loadstart",this,function(){GEvent.trigger(this,"loadstart")});GEvent.bind(this.layer_,"loadend",this,function(){GEvent.trigger(this,"loadend")});GEvent.bind(this.layer_,"loaderror",this,function(E){GEvent.trigger(this,"loaderror",E)});GEvent.bind(this.layer_,"settingschanged",this,function(){GEvent.trigger(this,"settingschanged")})};SevereLayer.prototype.toggle=function(A){if(A){this.map_.addOverlay(this.layer_);this.layer_.rememberToggleState(true);this.layer_.redrawOnMoveEnd();if(this.streets_){this.streets_.attachTo(this.name_)}this.layer_.toggle(A)}else{this.layer_.toggle(A);this.layer_.removeOverlays();if(this.streets_){this.streets_.detachFrom(this.name_)}this.layer_.rememberToggleState(false);this.map_.removeOverlay(this.layer_)}};SevereLayer.prototype.toQueryString=function(){return this.layer_.toQueryString()};SevereLayer.prototype.toPrefsObject=function(){return this.layer_.toPrefsObject()};Severe.prototype=new WUI_ImageLayer();function Severe(B,C,A){WUI_ImageLayer.call(this,B,C,A);this.loadingData_=false;this.requestedAnotherData_=false;this.overlays_=[];this.listeners_=[];this.requestDataInterval=60*1000;this.requestDataTimer=null;this.dataNeedsUpdate=true;this.selmarker=null;this.displayAreaTab=this.options_.displayAreaTab||null;this.display_=this.getDisplayProperties();this.clickable_=true;if(A.clickable==false){this.clickable_=false}}Severe.prototype.copy=function(){if(this.debug_==1){GLog.write("Severe::copy")}return new Severe(this.name_,this.sidebarPrefix_,this.options_)};Severe.prototype.toggle=function(A){if(A){if(this.clickable_){this.addClickListeners()}this.disabled_=false;this.requestDataTimerRestart(this.requestDataInterval);this.requestData();this.mapMovedListenerData_=GEvent.bind(this.map_,"moveend",this,function(){if(this.dataNeedsUpdate==true){this.requestData();this.dataNeedsUpdate=false}})}else{GEvent.removeListener(this.mapMovedListenerData_);this.requestDataTimerStop();this.removeClickListeners();this.mouseOut(null)}};Severe.prototype.getURL=function(){var P=this.map_.getSize();var E=P.width;var O=P.height;var B=Math.floor(E*this.extraImageLoadFactor_);var Q=Math.floor(O*this.extraImageLoadFactor_);var N=Math.floor((B-E)/2);var M=Math.floor((Q-O)/2);var J=this.map_.fromContainerPixelToLatLng(new GPoint(0-N,0-M));var D=this.map_.fromContainerPixelToLatLng(new GPoint(E+N,O+M));var I=J.lat();var L=D.lng();var G=D.lat();var K=J.lng();if(K>L){K-=360}var A="http://wumaps.wunderground.com/cgi-bin/mapgen?theme=severe&stdout=1&size="+B+"x"+Q+"&minlat="+G+"&minlon="+K+"&maxlat="+I+"&maxlon="+L+"&proj=automerc&format=gif&alpha=1";var C=new Date();var F=C.getTime();var H=Math.floor(F/60000);A+="&rand="+H;return A};Severe.prototype.addClickListeners=function(){this.mapClickListener_=GEvent.bind(this.map_,"click",this,function(B,A){if(!A){return }this.onClickImage(A)})};Severe.prototype.removeClickListeners=function(){GEvent.removeListener(this.mapClickListener_)};Severe.prototype.addSidebarListeners=function(){};Severe.prototype.removeSidebarListeners=function(){};Severe.prototype.requestData=function(){if(this.disabled_){return }if(this.loadingData_){this.requestedAnotherData_=true;return }this.loadingData_=true;this.requestedAnotherData_=false;GEvent.trigger(this,"loadstart");var B=GEvent.callback(this,this.handleData);var A="/stationmaps/gmap_severe.asp";if(this.debug_>0){GLog.write(A)}GDownloadUrl(A,B)};Severe.prototype.requestDataTimerStop=function(){if(this.requestDataTimer){$clear(this.requestDataTimer)}};Severe.prototype.requestDataTimerRestart=function(A){this.requestDataTimerStop();this.requestDataInterval=A;var B=function(){this.dataNeedsUpdate=true};this.requestDataTimer=B.periodical(this.requestDataInterval,this)};Severe.prototype.handleData=function(responseText,status){if(responseText==null||status<0){this.loadingData_=false;GEvent.trigger(this,"loaderror","Request Timed Out (status code: "+status+")");return }else{if(status<200||status>=300){this.loadingData_=false;GEvent.trigger(this,"loaderror","Request Failed (status code: "+status+")");return }}try{var data=eval("("+responseText+")")}catch(e){this.loadingData_=false;GEvent.trigger(this,"loaderror","Failed to evaluate JSON response");return }this.drawData(data);if(this.requestedAnotherData_){this.requestedAnotherData_=false;this.loadingData_=false;this.requestData()}this.loadingData_=false;GEvent.trigger(this,"loadend")};Severe.prototype.drawData=function(Q){this.removeOverlays();if(this.displayAreaTab){tableElt=new Element("table",{"class":"dataTable",cellspacing:"0",cellpadding:"0",events:{click:function(S){sortColumn(S)}}});this.displayAreaTab.empty();this.displayAreaTab.writeDom(tableElt);var L=new Element("thead");L.injectInside(tableElt);var A=this.getTableHeadContent(this.iconmode);A.injectInside(L);tbody=new Element("tbody");tbody.injectInside(tableElt)}var H=this.clickable_;for(var K in Q.ALERTS){try{var O=Q.ALERTS[K];var G=O.wui_code;var D=O.state;var P=O.zone;if(G===null||D===null||P===null){GEvent.trigger(this,"loaderror","Missing wui_code/state/zone for alert: "+K);continue}if(!this.canDisplayWuiCode(G)){continue}var E=parseFloat(O.lat);var C=parseFloat(O.lon);if(!E||!C){continue}var I=new GLatLng(E,C);var R=G;var N=this.makeIcon(G);var F=new GMarker(I,{icon:N,title:R,clickable:H});this.overlays_.push(F);this.map_.addOverlay(F);var J=null;if(H||this.displayAreaTab){J=GEvent.callbackArgs(this,this.onClickImage,I);if(H){var B=GEvent.addListener(F,"click",J);this.listeners_.push(B)}}if(this.displayAreaTab){var A=this.getTableRowContent(G,D,P,E,C);A.addClass("rowW");A.addEvents({mouseover:function(){this.addClass("rowY").removeClass("rowW")},mouseout:function(){this.addClass("rowW").removeClass("rowY")},mouseover:function(S){this.mouseOver(S)}.bind(this,[I]),mouseout:function(S){this.mouseOut(S)}.bind(this,[I]),click:J});A.injectInside(tbody)}}catch(M){GEvent.trigger(this,"loaderror",M.message+" in ALERTS["+K+"]; continuing.");continue}}};Severe.prototype.mouseOver=function(A){if(!this.selmarker){var B=new GIcon();B.iconSize=new GSize(64,64);B.iconAnchor=new GPoint(32,32);B.infoWindowAnchor=new GPoint(32,32);B.infoShadowAnchor=new GPoint(32,32);B.image="http://stationicon.wunderground.com/gmapselected.png";B.shadow="http://stationicon.wunderground.com/gmapclear.png";B.shadowSize=new GSize(1,1);this.selmarker=new GMarker(A,{icon:B});this.map_.addOverlay(this.selmarker)}this.selmarker.setLatLng(A);this.selmarker.show()};Severe.prototype.mouseOut=function(A){if(this.selmarker){this.selmarker.hide()}};Severe.prototype.onClickMarker=function(J,M,F,D,L){var E=F+"_"+D+"_"+L+"_ajaxContent";var K='<div class="balloonInfo sm"><div class="b">'+M+'</div><div class="b">'+E+"</div>";var C='<div id="'+E+'" style="height:200px; width:25em;"><p>Loading more information&hellip;</p></div>';var G="</div>";var A=this.createInfoTab(K,C,G);J.openInfoWindowTabsHtml([A],{maxWidth:400});var I=this.handleSevereText.bindAndAppendArgs(this,[E]);var H="state="+D+"&zone="+L+"&wui_code="+F;var B="/auto/wui/geo/AlertTextByStateZoneWuiCode/index.html?short=1&"+H;if(this.debug_>0){GLog.write(B)}GDownloadUrl(B,I)};Severe.prototype.onClickImage=function(I){var H=I.lat();var C=I.lng();var I=new GLatLng(H,C);var E="point_"+H+"_"+C+"_ajaxContent";var G='<div class="balloonInfo sm"><div class="b">'+I.toUrlValue()+"</div>";var D='<div id="'+E+'"><p>Checking for alerts in this location&hellip;</p></div>';var F="</div>";var A=this.createInfoTab(G,D,F);this.map_.openInfoWindowTabsHtml(I,[A],{maxWidth:400});var J=this.handleSevereLookup.bindAndAppendArgs(this,[E,I]);var B="/cgi-bin/findweather/severelookup?lat="+I.lat()+"&lon="+I.lng()+"&format=json";if(this.debug_>0){GLog.write(B)}GDownloadUrl(B,J)};Severe.prototype.handleSevereLookup=function(responseText,status,id,point){var middleText="";var responseObj=null;if(responseText==null||status<0){middleText="Error: Request for severe click lookup Timed Out (status code: "+status+")"}else{if(status<200||status>=300){middleText="Error: Request for severe click lookup Failed (status code: "+status+")"}else{try{responseObj=eval("("+responseText+")")}catch(e){responseObj=null;middleText="Error: cannot evaluate responseText";if(this.debug_==1){middleText+=":: "+responseText}}}}if(responseObj){var numresults=responseObj.numresults;var results=responseObj.results;if(numresults>0&&results){var result=results[0];var wui_code=result.type;var state=result.state;var zone=result.zone;var wui_codes=[];for(var i=0;i<results.length;i++){wui_codes.push(results[i].type)}middleText="<p>Found an alert, <br/>Loading more information&hellip;</p>";var severeTextClosure=this.handleSevereTextMultiple.bindAndAppendArgs(this,[point]);var params="state="+state+"&zone="+zone;var url="/auto/wui/geo/AlertTextByStateZoneWuiCode/index.html?short=1&"+params;if(this.debug_>0){GLog.write(url)}GDownloadUrl(url,severeTextClosure)}else{middleText="<p>No severe activity</p>"}}else{middleText="<p>Error: null severelookup response.</p>"}var ajaxContent=document.getElementById(id);if(ajaxContent){ajaxContent.innerHTML=middleText}};Severe.prototype.handleSevereText=function(C,A,E){var D="";if(C==null||A<0){D="Error: Request for more information Timed Out (status code: "+A+")"}else{if(A<200||A>=300){D="Error: Request for more information Failed (status code: "+A+")"}else{if(C.length<3){D="<p>No additional information</p>"}else{D=C}}}var B=document.getElementById(E);if(B){B.innerHTML=D}};Severe.prototype.handleSevereTextMultiple=function(H,D,K){var B=[];var I=[];var J="";var G="";if(H==null||D<0){G="Error: Request for more information Timed Out (status code: "+D+")"}else{if(D<200||D>=300){G="Error: Request for more information Failed (status code: "+D+")"}else{if(H.length<3){G="<p>No additional information</p>"}else{B=H.split("<next />")}}}if(B.length>0){for(var E=0;E<B.length;E++){var F=B[E].split("<splitpoint />");var C=F[0];var L="http://"+this.iconserve_+"."+this.icondomain_+"/graphics/";var A=L+C+".gif";var J=C;var G='<div class="balloonInfo sm">'+F[1]+"</div>";I.push(new GInfoWindowTab(J,G))}}else{I.push(new GInfoWindowTab("Error",G))}this.map_.openInfoWindowTabsHtml(K,I,{maxWidth:250})};Severe.prototype.createInfoTab=function(C,D,A){var B="";if(C){B+=C}if(D){B+=D}if(A){B+=A}return new GInfoWindowTab("Info",B)};Severe.prototype.removeOverlays=function(){while(this.overlays_.length>0){this.map_.removeOverlay(this.overlays_.pop())}while(this.listeners_.length>0){GEvent.removeListener(this.listeners_.pop())}};Severe.prototype.makeIcon=function(B){if(this.display_.iconcache[B]){return this.display_.iconcache[B]}else{var E=new GIcon();var D=18;var A=18;var F="http://"+this.iconserve_+"."+this.icondomain_+"/graphics/";var C=F+B+".gif";E.image=C;E.iconSize=new GSize(D,A);E.iconAnchor=new GPoint(D/2-2,A/2+2);E.infoWindowAnchor=new GPoint(D/2-2,A/2+2);E.printImage=C;E.mozPrintImage=C;E.imageMap=[0,0,0,D,D,A,A,0];this.display_.iconcache[B]=E;return E}};Severe.prototype.toQueryString=function(){var B=this.name_;var A=this.getOpacity();return B+".opa="+A};Severe.prototype.toPrefsObject=function(){var A={};var B=this.name_.toUpperCase();A[B+"OPA"]=this.getOpacity();return A};Severe.prototype.canDisplayWuiCode=function(A){if(["PUB","SPE","REC"].contains(A)){return false}else{return true}};Severe.prototype.getDisplayProperties=function(){return{iconcache:{}}};