var weatherObj=Class.create();weatherObj.prototype={initialize:function(e,c,b,a,f){this.id=e;this.weatherbox=$(this.id);this.conditions=new Array;this.day=new Array;this.curday=-1;this.url=c;this.options={idprefix:"w_",imageDir:(b)?b:"ub/images/weather/"};var d=navigator.appVersion.match(/MSIE (\d+\.\d+)/,"");this.isIE=d!=null;this.pngAllowed=this.isIE&&Number(d[1])>=5.5;this.setHashTables();this.injectBehaviors(a||new defaultWeatherDesignObj());this.initAjax(f)},setHashTables:function(){var a="";this.wList={0:a+"(bkn[^.]*\\.jpg|ovc[^.]*\\.jpg)$",1:a+"(dust[^.]*\\.jpg)$",2:a+"(fg[^.]*\\.jpg|nfg[^.]*\\.jpg)$",3:a+"(fzra[^.]*\\.jpg|fzrara[^.]*\\.jpg)$",4:a+"(mix[^.]*\\.jpg)$",5:a+"(nsvrtsra[^.]*\\.jpg)$",6:a+"(mist[^.]*\\.jpg)$",8:a+"(sct[^.]*\\.jpg|few[^.]*\\.jpg)$",9:a+"(raip[^.]*\\.jpg)$",10:a+"(rasn[^.]*\\.jpg)$",12:a+"(smoke[^.]*\\.jpg)$",14:a+"(hot[^.]*\\.jpg|skc[^.]*\\.jpg)$",15:a+"(tsra[^.]*\\.jpg|hi_tsra[^.]*\\.jpg)$",16:a+"(wind[^.]*\\.jpg)$",7:a+"(ip[^.]*\\.jpg)$",13:a+"(sn[^.]*\\.jpg|cold[^.]*\\.jpg)$",11:a+"(shra[^.]*\\.jpg|hi_shwrs[^.]*\\.jpg|ra1[^.]*\\.jpg|ra[^.]*\\.jpg)$"};this.wListLength=17},injectBehaviors:function(a){a.execute(this);this.setMainPic();this.setTemps()},setMainTemp:function(a){var b=a||0;this.maintemp.innerHTML=b+"&ordm;"},setMainPic:function(a){this.setPic(this.options.idprefix+"MainPic",a)},setPic:function(f,c){var b=$(f);if(c&&this.wList[c]){c=parseInt(c);var d=(f==this.options.idprefix+"MainPic")?"large_":"small_";var e=this.options.imageDir+d+"all.png";var a=d=="large_"?64:24;b.style.background='transparent url("'+e+'") '+(c&&c>0?"-"+(c*a):0)+"px top no-repeat";b.style.overflow="hidden";b.style.width=a+"px";b.style.height=a+"px";if(this.pngAllowed){b.style.background="none";b.style.width=(a*this.wListLength)+"px";b.style.position="absolute";b.style.left="-"+(c*a-1)+"px";b.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+e+"', sizingMethod='scale')";b.style.clip="rect(0px, "+((c+1)*a-1)+"px, "+(a-1)+"px, "+(c*a)+"px)"}}else{b.style.background='transparent url("'+this.options.imageDir+'wait.gif") center center no-repeat'}return true},processWeather:function(d,a){if(a){for(var b in this.wList){var c=new RegExp(this.wList[b]);if(a.match(c)){return this.setPic(d,b)}}}},setDays:function(){var b=new Date();if(this.curday!=b.getDay()){this.curday=b.getDay();var a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];for(i=0;i<5;i++){this.day["name"+i].innerHTML=a[(i+this.curday)%7]}}},setTemps:function(b){var a=b||[0,0,0,0,0,0,0,0,0,0];for(i=0;i<5;i++){this.day["high"+i].innerHTML=a[i*2]+"&ordm;";this.day["low"+i].innerHTML=a[i*2+1]+"&ordm;"}this.setMainTemp(a[0])},initAjax:function(d){if(d){var a=new Object;if(this.isIE){a.responseXML=new ActiveXObject("Microsoft.XMLDOM");a.responseXML.async="false";a.responseXML.loadXML(d)}else{try{var c=new DOMParser();a.responseXML=c.parseFromString(d,"text/xml")}catch(b){a.responseXML=null}}this.ajaxResponse(a)}else{this.callAjax()}new PeriodicalExecuter(this.callAjax.bindAsEventListener(this),2700)},callAjax:function(){var a=new Ajax.Request(this.url,{method:"get",onSuccess:this.ajaxResponse.bindAsEventListener(this),onFailure:this.error,asynchronous:true})},ajaxResponse:function(e){var d=e.responseXML;var b=[];this.setDays();if(d&&d.getElementsByTagName("dwml").length>0){d=d.getElementsByTagName("dwml")[0].getElementsByTagName("data")[0].getElementsByTagName("parameters")[0];var h=d.getElementsByTagName("temperature");var a=h[0].getElementsByTagName("value");var c=h[1].getElementsByTagName("value");for(i=0;i<a.length;i++){if(a[i].firstChild.nodeValue){b[i*2]=a[i].firstChild.nodeValue}}for(i=0;i<c.length;i++){if(c[i].firstChild.nodeValue){b[i*2+1]=c[i].firstChild.nodeValue}}this.setTemps(b);var g=d.getElementsByTagName("weather")[0].getElementsByTagName("weather-conditions");for(i=0;i<g.length;i++){if(g[i].getAttribute("weather-summary")){this.conditions[i]=g[i].getAttribute("weather-summary")}}this.maincond.innerHTML=this.conditions[0];var f=d.getElementsByTagName("conditions-icon")[0].getElementsByTagName("icon-link");for(i=0;i<f.length;i++){if(i==0){this.processWeather(this.options.idprefix+"MainPic",f[i].firstChild.nodeValue)}this.processWeather(this.options.idprefix+"dayico"+i,f[i].firstChild.nodeValue)}}},error:function(a){}};var defaultWeatherDesignObj=Class.create();defaultWeatherDesignObj.prototype={initialize:function(){},execute:function(b){var g=b.weatherbox.style;g.marginLeft="0px";g.width="195px";g.height="150px";g.background='url("'+b.options.imageDir+'weathermain.png")';g.position="relative";if(b.isIE){if(b.pngAllowed){g.background="none";g.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+b.options.imageDir+"weathermain.png', sizingMethod='scale')"}else{g.background='url("'+b.options.imageDir+'weathermain.gif")'}}var d=document.createElement("a");d.style.position="absolute";d.style.marginTop="133px";d.style.height="10px";d.style.width="195px";d.style.textAlign="center";d.style.fontFamily="Arial";d.style.fontSize="0.5em";d.style.color="#EEE";d.innerHTML="Data from NWS";d.href="http://www.weather.gov/";d.target="_blank";b.weatherbox.appendChild(d);var e=5;for(i=0;i<5;i++){var l=document.createElement("div");l.style.position="absolute";l.style.marginTop="60px";l.style.marginLeft=e-3+"px";l.style.fontVariant="small-caps";l.style.fontFamily="Arial";l.style.fontSize="1em";l.style.fontWeight="bold";l.style.color="#FFF";l.id=b.options.idprefix+"day"+i;b.day["name"+i]=l;b.weatherbox.appendChild(l);var f=document.createElement("div");f.style.position="absolute";f.style.marginTop="82px";f.style.marginLeft=e+4+"px";f.style.width="24px";f.style.height="24px";f.id=b.options.idprefix+"dayico"+i;b.day["ico"+i]=f;b.weatherbox.appendChild(f);var j=document.createElement("div");j.style.position="absolute";j.style.marginTop="104px";j.style.marginLeft=e+"px";j.style.fontFamily="Arial";j.style.fontSize="1em";j.style.color="#FFF";j.style.width="40px";j.id=b.options.idprefix+"dayhigh"+i;b.day["high"+i]=j;b.weatherbox.appendChild(j);var h=document.createElement("div");h.style.position="absolute";h.style.marginTop="120px";h.style.marginLeft=e+3+"px";h.style.fontFamily="Arial";h.style.fontSize="0.5em";h.style.fontWeight="bold";h.style.color="#DDD";h.style.width="40px";h.id=b.options.idprefix+"daylow"+i;b.day["low"+i]=h;b.weatherbox.appendChild(h);e+=40}var a=document.createElement("div");a.style.position="absolute";a.style.marginTop="20px";a.style.marginLeft="130px";a.style.textAlign="right";a.style.width="60px";a.style.height="30px";a.style.fontFamily="Arial";a.style.fontSize="1.8em";a.style.color="#FFF";a.id=b.options.idprefix+"MainTemp";b.maintemp=a;b.weatherbox.appendChild(b.maintemp);var k=document.createElement("div");k.style.position="absolute";k.style.marginTop="41px";k.style.marginLeft="5px";k.style.textAlign="left";k.style.width="132px";k.style.height="1.2em";k.style.fontFamily="Arial";k.style.fontSize="0.6em";k.style.color="#FFF";k.style.overflow="hidden";k.id=b.options.idprefix+"MainCond";b.maincond=k;b.weatherbox.appendChild(b.maincond);var c=document.createElement("div");c.style.position="absolute";c.style.marginTop="2px";c.style.marginLeft="65px";c.style.width="64px";c.style.height="64px";c.style.zIndex=1;c.id=b.options.idprefix+"MainPic";b.weatherbox.appendChild(c)}};var boxWeatherDesignObj=Class.create();boxWeatherDesignObj.prototype={initialize:function(){},execute:function(b){var g=b.weatherbox.style;g.marginLeft="0px";g.width="242px";g.height="250px";g.background='url("'+b.options.imageDir+'weathermain_box.jpg")';g.position="relative";var e=document.createElement("a");e.style.position="absolute";e.style.marginTop="227px";e.style.height="10px";e.style.width="232px";e.style.textAlign="right";e.style.fontFamily="Arial";e.style.fontSize="6pt";e.style.color="#DDD";e.innerHTML="Data from NWS";e.href="http://www.weather.gov/";e.target="_blank";b.weatherbox.appendChild(e);var k=75;for(i=0;i<5;i++){var m=document.createElement("div");m.style.position="absolute";m.style.marginTop=k+"px";m.style.marginLeft="20px";m.style.fontVariant="small-caps";m.style.fontFamily="Arial";m.style.fontSize="12pt";m.style.fontWeight="bold";m.style.color="#FFF";m.id=b.options.idprefix+"day"+i;b.day["name"+i]=m;b.weatherbox.appendChild(m);var f=document.createElement("div");f.style.position="absolute";f.style.marginTop=k+"px";f.style.marginLeft="82px";f.style.width="24px";f.style.height="24px";f.id=b.options.idprefix+"dayico"+i;b.day["ico"+i]=f;b.weatherbox.appendChild(f);var j=document.createElement("div");j.style.position="absolute";j.style.marginTop=k+"px";j.style.marginLeft="135px";j.style.fontFamily="Arial";j.style.fontSize="12pt";j.style.color="#FFF";j.style.width="40px";j.id=b.options.idprefix+"dayhigh"+i;b.day["high"+i]=j;b.weatherbox.appendChild(j);var d=document.createElement("div");d.style.position="absolute";d.style.marginTop=k+"px";d.style.marginLeft="175px";d.style.fontFamily="Arial";d.style.fontSize="12pt";d.style.color="#DDD";d.style.width="40px";d.id=b.options.idprefix+"dayslash"+i;d.innerHTML="/";b.weatherbox.appendChild(d);var h=document.createElement("div");h.style.position="absolute";h.style.marginTop=k+"px";h.style.marginLeft="200px";h.style.fontFamily="Arial";h.style.fontSize="12pt";h.style.color="#DDD";h.style.width="40px";h.id=b.options.idprefix+"daylow"+i;b.day["low"+i]=h;b.weatherbox.appendChild(h);k+=30}var a=document.createElement("div");a.style.position="absolute";a.style.marginTop="15px";a.style.marginLeft="150px";a.style.textAlign="right";a.style.width="80px";a.style.height="55px";a.style.fontFamily="Arial";a.style.fontSize="23pt";a.style.color="#FFF";a.id=b.options.idprefix+"MainTemp";b.maintemp=a;b.weatherbox.appendChild(b.maintemp);var l=document.createElement("div");l.style.position="absolute";l.style.marginTop="15px";l.style.marginLeft="12px";l.style.paddingTop="2px";l.style.textAlign="center";l.style.width="50px";l.style.height="55px";l.style.fontFamily="Arial";l.style.fontSize="7pt";l.style.color="#FFF";l.id=b.options.idprefix+"MainCond";b.maincond=l;b.weatherbox.appendChild(b.maincond);var c=document.createElement("div");c.style.position="absolute";c.style.marginTop="2px";c.style.marginLeft="90px";c.style.width="64px";c.style.height="64px";c.id=b.options.idprefix+"MainPic";b.weatherbox.appendChild(c)}};
