function Photos(){}Photos.prototype.initialize=function(C,B,D,A){this.map_=C;this.name_=B;this.sidebarPrefix_=D;this.options_=A||{};this.disabled_=false;this.loading_=false;this.requestedAnother_=false;this.active_=false;this.markers_=[];this.listeners_=[];this.modeListeners=[];this.iconserve_=this.options_.iconserve||"icons-pe";this.icondomain_=this.options_.icondomain||"wxug.com";this.debug_=this.options_.debug||0;this.displayAreaTab=this.options_.displayAreaTab||null;this.cluster=null;this.handle_go=null;this.start=0;this.startSave=false;this.setupHandleGo();this.adjustDateSelect()};Photos.prototype.setupHandleGo=function(){var B=$(this.sidebarPrefix_+"_handle");var A=$(this.sidebarPrefix_+"_handle_go");if(A){A.addClass("none")}var C=function(){A.addClass("none");GEvent.trigger(this,"settingschanged");this.requestData()}.bind(this);if(B){B.addEvents({focus:function(){A.removeClass("none")},blur:C});A.addEvent("click",C)}};Photos.prototype.toggle=function(A){if(A){this.mapInfowindowopenListener_=GEvent.bind(this.map_,"infowindowopen",this,function(){this.disabled_=true});this.mapInfowindowcloseListener_=GEvent.bind(this.map_,"infowindowclose",this,function(){this.disabled_=false});this.mapMovedListener_=GEvent.bind(this.map_,"moveend",this,function(){if(this.disabled_==true){this.disabled_=false}else{this.requestData()}});this.setupCluster();this.addSidebarListeners();this.disabled_=false;this.requestData()}else{this.removeSidebarListeners();GEvent.removeListener(this.mapMovedListener_);GEvent.removeListener(this.mapInfowindowcloseListener_);GEvent.removeListener(this.mapInfowindowopenListener_);this.removeOverlays()}this.active_=A};Photos.prototype.requestData=function(){if(this.disabled_){return }if(this.loading_){this.requestedAnother_=true;return }this.loading_=true;this.requestedAnother_=false;GEvent.trigger(this,"loadstart");var A=this.map_.getBounds();var E=A.getNorthEast();var D=A.getSouthWest();var G=E.lat();var F=D.lat();var M=E.lng();var J=D.lng();var B=this.getDateSelection();var L=this.getMaxPhotos();var K=this.getCategory();var H=this.getHandle();this.start=(this.startSave)?this.start:0;this.startSave=false;var I=GEvent.callback(this,this.handleData);var C="/wximage/responder.html?maxlat="+G+"&minlat="+F+"&maxlon="+M+"&minlon="+J+"&yyyymmdd="+B+"&start="+this.start+"&max="+L+"&cat="+K+"&spread=1&format=json";if(H&&H.length){C+="&handle="+H}if(this.debug_>0){GLog.write(C)}GDownloadUrl(C,I)};Photos.prototype.handleData=function(responseText,status){if(responseText==null||status<0){this.loading_=false;GEvent.trigger(this,"loaderror","Request Timed Out (status code: "+status+")");this.removeOverlays();return }else{if(status<200||status>=300){this.loading_=false;GEvent.trigger(this,"loaderror","Request Failed (status code: "+status+")");this.removeOverlays();return }}try{var data=eval("("+responseText+")")}catch(e){this.loading_=false;GEvent.trigger(this,"loaderror","Failed to evaluate JSON response");this.removeOverlays();return }if(data.PHOTOS){this.drawData(data.PHOTOS)}else{this.removeOverlays()}if(data.MISC&&(this.debug_==1)){for(var key in data.MISC){GLog.write(key+": "+data.MISC[key])}}if(this.requestedAnother_){this.requestedAnother_=false;this.loading_=false;this.requestData()}this.loading_=false;GEvent.trigger(this,"loadend")};Photos.prototype.drawData=function(h){this.removeOverlays();var H=null;if(this.displayAreaTab){GEvent.clearNode(this.displayAreaTab);this.displayAreaTab.empty();H=new Element("div");this.displayAreaTab.writeDom(H)}for(var a=0;a<h.length;a++){var F=h[a];try{var M=parseFloat(F.lat);var I=parseFloat(F.lon);if(!$chk(M)||!$chk(I)){throw"error"}}catch(d){continue}var Y=new GLatLng(M,I);var f=F.handle;var B=F.number;var j=F.title;var c=F.caption;var C=F.cameratype;var L=F.url;var g=F.thumb_url;var P=F.thumb_width;var T=F.thumb_height;var K=(F.epoch_taken)?(F.epoch_taken*1000):0;var O=(F.epoch_uploaded)?(F.epoch_uploaded*1000):0;var Z=F.city;var J=F.state;var X=F.country;var W=F.category;var E=F.iseditorspick;var Q=F.isvippick;var b=this.makeIcon(g);var N=new GMarker(Y,{icon:b,title:j});this.markers_.push(N);var R=this.getBalloonContent(f,B,j,c,M,I,C,L,g,P,T,K,O,Z,J,X,W,E,Q);var V=GEvent.callbackArgs(this,this.onClick,N,R);var D=GEvent.addListener(N,"click",V);if(this.displayAreaTab){var S=new Element("div",{"class":this.sidebarPrefix_+"_box"});var U=new Element("a",{href:"",events:{click:function(k,i){k=new Event(k).stop();this.cluster.triggerClick(i)}.bindAsEventListener(this,[this.markers_.length-1])}});var G=this.getDisplayAreaBox(f,B,j,c,M,I,C,L,g,P,T,K,O,Z,J,X,W,E,Q,b);U.setHTML(G);S.adopt(U);this.displayAreaTab.writeDom(S)}}if(this.markers_.length>0){this.cluster.addMarkers(this.markers_)}this.cluster.refresh(true);if(this.displayAreaTab&&H){var A=this.getNextPrevLinks(this.markers_.length);H.adopt(A)}};Photos.prototype.getNextPrevLinks=function(D){var H=new Element("div",{"class":"taC subG p10"});var G=this.start;var A=parseInt(this.getMaxPhotos(),10);if(this.start>0){var B=new Element("a",{href:"#",title:"Newer Photos","class":"b",events:{click:function(I){I=new Event(I).stop();this.start-=A;if(this.start<0){this.start=0}this.startSave=true;this.requestData()}.bindAsEventListener(this)}}).setHTML("&laquo; Newer");H.adopt(B)}var C="";if(G==0&&D==0){C="No Photos found"}else{if(G>0&&D==0){C="No more photos"}else{if(D>=A){C="&nbsp;&nbsp;Showing Photos "+(G+1)+" &ndash; "+(G+A)+"&nbsp;&nbsp;"}else{if(D<A){C="&nbsp;&nbsp;Showing Photos "+(G+1)+" &ndash; "+(G+D)+"&nbsp;&nbsp;"}}}}var F=new Element("span").setHTML(C);H.adopt(F);if(D>=A){var E=new Element("a",{href:"#",title:"Older Photos","class":"b",events:{click:function(I){I=new Event(I).stop();this.start+=A;this.startSave=true;this.requestData()}.bindAsEventListener(this)}}).setHTML("Older &raquo;");H.adopt(E)}return H};Photos.prototype.setupCluster=function(){var A="There are %count photos here";var B=this.clusterMarkerClick.bind(this);this.cluster=new ClusterMarker(this.map_,{clusterMarkerTitle:A,clusterMarkerClick:B,clusteringEnabled:true,customClusterMarkerFn:this.customClusterMarker,intersectPadding:-2,autoregroupEnabled:false,triggerClick:this.clusterTriggerClick})};Photos.prototype.onClick=function(A,B){var C=new GInfoWindowTab("Info",B);A.openInfoWindowTabsHtml([C],{maxWidth:300})};Photos.prototype.makeIcon=function(B){var D=40;var A=30;var C=new GIcon();C.image=B;C.shadow="http://"+this.iconserve_+"."+this.icondomain_+"/graphics/wu2/webcam_bg.png";C.iconSize=new GSize(D,A);C.shadowSize=new GSize(D+5,A+5);C.iconAnchor=new GPoint(D/2,A/2);C.infoWindowAnchor=new GPoint(D/2-2,A/2+2);C.printImage=B;C.mozPrintImage=B;C.transparent="http://"+this.iconserve_+"."+this.icondomain_+"/graphics/wu2/transparentRect40x30.png";C.imageMap=[0,0,0,D,D,A,A,0];return C};Photos.prototype.removeOverlays=function(){while(this.markers_.length>0){var A=this.markers_.pop();GEvent.clearInstanceListeners(A);this.map_.removeOverlay(A)}while(this.listeners_.length>0){GEvent.removeListener(this.listeners_.pop())}this.cluster.removeMarkers()};Photos.prototype.addSidebarListeners=function(){try{if(!this.maxListener){var D=$(this.sidebarPrefix_+"_max_slider");var C=$(this.sidebarPrefix_+"_max_knob");if(!D||!C){throw ("max slider is unsupported on this layer")}var B=this.getMaxPhotosLimit()-1;var A=parseInt(this.getMaxPhotos(),10)-1;this.maxListener=new Slider(D,C,{steps:B,onChange:function(F){$(this.sidebarPrefix_+"_max_value").setText(F+1)}.bind(this),onComplete:function(F){var F=parseInt(F,10);$(this.sidebarPrefix_+"_max").value=F+1;if(this.active_==true){this.startSave=true;GEvent.trigger(this,"settingschanged");this.requestData()}}.bind(this)}).set(A)}}catch(E){}try{this.dateYearListener=GEvent.bindDom($(this.sidebarPrefix_+"_year"),"change",this,function(){GEvent.trigger(this,"settingschanged");this.requestData()})}catch(E){}try{this.dateMonthListener=GEvent.bindDom($(this.sidebarPrefix_+"_month"),"change",this,function(){GEvent.trigger(this,"settingschanged");this.requestData()})}catch(E){}try{this.dateDayListener=GEvent.bindDom($(this.sidebarPrefix_+"_day"),"change",this,function(){GEvent.trigger(this,"settingschanged");this.requestData()})}catch(E){}try{this.catListener=GEvent.bindDom($(this.sidebarPrefix_+"_cat"),"change",this,function(){GEvent.trigger(this,"settingschanged");this.requestData()})}catch(E){}try{this.anyDayListener=GEvent.bindDom($(this.sidebarPrefix_+"_anyDay"),"click",this,function(){this.adjustDateSelect();GEvent.trigger(this,"settingschanged");this.requestData()})}catch(E){}try{this.anyDateListener=GEvent.bindDom($(this.sidebarPrefix_+"_anyDate"),"click",this,function(){this.adjustDateSelect();GEvent.trigger(this,"settingschanged");this.requestData()})}catch(E){}try{this.anyMonthListener=GEvent.bindDom($(this.sidebarPrefix_+"_anyMonth"),"click",this,function(){var F=this.getAnyMonth();if(F){$(this.sidebarPrefix_+"_day").addClass("none");$(this.sidebarPrefix_+"_month").addClass("none");$(this.sidebarPrefix_+"_anyDay").setProperty("checked",true)}else{$(this.sidebarPrefix_+"_day").removeClass("none");$(this.sidebarPrefix_+"_month").removeClass("none")}GEvent.trigger(this,"settingschanged");this.requestData()})}catch(E){}};Photos.prototype.removeSidebarListeners=function(){try{GEvent.removeListener(this.dateYearListener)}catch(A){}try{GEvent.removeListener(this.dateMonthListener)}catch(A){}try{GEvent.removeListener(this.dateDayListener)}catch(A){}try{GEvent.removeListener(this.catListener)}catch(A){}try{GEvent.removeListener(this.anyDayListener)}catch(A){}try{GEvent.removeListener(this.anyMonthListener)}catch(A){}};Photos.prototype.toQueryString=function(){var B=this.name_;var A=B+".date="+this.getDateSelection();A+="&"+B+".anyd="+(this.getAnyDay()?"1":"0");A+="&"+B+".anyt="+(this.getAnyDate()?"1":"0");A+="&"+B+".max="+this.getMaxPhotos();A+="&"+B+".cat="+this.getCategory();var C=this.getHandle();if(C&&C.length){A+="&"+B+".usr="+C}return A};Photos.prototype.toPrefsObject=function(){var A={};var B=this.name_.toUpperCase();A[B+"DATE"]=this.getDateSelection();A[B+"ANYD"]=this.getAnyDay();A[B+"ANYT"]=this.getAnyDate();A[B+"MAX"]=this.getMaxPhotos();A[B+"CAT"]=this.getCategory();A[B+"USR"]=this.getHandle();return A};Photos.prototype.getDateSelection=function(){try{var F=$(this.sidebarPrefix_+"_year").getValue();var C=$(this.sidebarPrefix_+"_month").getValue();var H=$(this.sidebarPrefix_+"_day").getValue();var B=this.getAnyDate();var A=this.getAnyDay();var G=this.getAnyMonth();if(B||A){H="00"}if(B||G){C="00"}if(B){F="0000"}var I=F+""+zeroPad(C,2)+""+zeroPad(H,2);return I}catch(D){var E=new Date();var I=E.getUTCFullYear()+""+zeroPad(E.getUTCMonth()+1,2)+""+zeroPad(E.getUTCDate(),2);return I}};Photos.prototype.adjustDateSelect=function(){var C=this.getAnyDay();var A=this.getAnyDate();var B=$(this.sidebarPrefix_+"_day");var E=$(this.sidebarPrefix_+"_month");var D=$(this.sidebarPrefix_+"_year");if(C){if(B){B.addClass("none")}}else{if(B){B.removeClass("none")}}if(A){if(B){B.setProperty("disabled",true)}if(E){E.setProperty("disabled",true)}if(D){D.setProperty("disabled",true)}}else{if(B){B.setProperty("disabled",false)}if(E){E.setProperty("disabled",false)}if(D){D.setProperty("disabled",false)}}};Photos.prototype.getMode=function(){var A=getRadioValue(this.sidebarPrefix_+"_mode");if(A){return A}else{return"0"}};Photos.prototype.getMaxPhotos=function(){try{var A=$(this.sidebarPrefix_+"_max").getValue();return A}catch(B){return"20"}};Photos.prototype.getMaxPhotosLimit=function(){return 50};Photos.prototype.getCategory=function(){try{var A=$(this.sidebarPrefix_+"_cat").getValue();return A}catch(B){return"0"}};Photos.prototype.getAnyDay=function(){try{return $(this.sidebarPrefix_+"_anyDay").checked?true:false}catch(A){return false}};Photos.prototype.getAnyMonth=function(){try{return $(this.sidebarPrefix_+"_anyMonth").checked?true:false}catch(A){return false}};Photos.prototype.getAnyDate=function(){try{return $(this.sidebarPrefix_+"_anyDate").checked?true:false}catch(A){return false}};Photos.prototype.getHandle=function(){try{return $(this.sidebarPrefix_+"_handle").getValue()}catch(A){return""}};Photos.prototype.clusterMarkerClick=function(A){var P=A.clusteredMarkers;var C=A.clusterMarker;var T=P.length;if(T==0){return }if(typeof (C.isExpanded)=="undefined"){C.isExpanded=false}C.isExpanded=!C.isExpanded;if(C.isExpanded){var B=P[0];var R=B.getIcon().iconSize;var G=R.width/2;var Q=R.height/2;var S=this.map_.fromLatLngToDivPixel(C.getLatLng());var J=S.x;var I=S.y;var E=R.width/2+5;var M=E;var H=0;var K=60;if(T<15){for(var O=T-1;O>=0;O--){var D=new GPoint(J,I);var N=this.map_.fromDivPixelToLatLng(D);var F=P[O];F.setLatLng(N);this.map_.addOverlay(F);F._isVisible=true;J+=G;I+=Q}}else{for(var O=T-1;O>=0;O--){var D=new GPoint(J,I);var N=this.map_.fromDivPixelToLatLng(D);var F=P[O];F.setLatLng(N);this.map_.addOverlay(F);F._isVisible=true;var L=(2*Math.PI*M)/E;M+=(K/L);H+=(2*Math.PI/L);J=S.x+(M*Math.cos(H));I=S.y+(M*Math.sin(H))}}P[T-1].hide();GEvent.trigger(P[T-1],"click")}else{for(var O=0;O<T;O++){var F=P[O];this.map_.removeOverlay(F);F._isVisible=false}}};Photos.prototype.customClusterMarker=function(D,H){var F=D.length;var J=this.clusterMarkerTitle.replace(/%count/gi,F);var I=this._mapMarkers[D[0]];var A=I.getIcon().image;var O=I.getIcon().iconSize;var C=O.width;var M=O.height;var N=C;var L=M;var K=I.getIcon().shadow;var B=I.getIcon().shadowSize;if(K&&B){if(B.width>N){N=B.width}if(B.height>L){L=B.height}}var G='<div style="width:'+N+"px; height:"+L+"px;";if(K){G+="background: url("+K+") no-repeat;"}G+='"><img src="'+A+'" alt="" style="width:'+C+"px; height:"+M+'px;" /><div style="width: 21px; height: 16px; position: relative; left: '+(C-18)+'px; top: -12px;"><div style="width: 21px; height: 16px; background-image: url(http://icons.wxug.com/graphics/smash/stackIcon.gif);"><div style="font-family: Arial; font-size: 7pt; padding-top: 3px; text-align: center">'+F+"</div></div></div></div>";var E=new HTMLOverlay(H,G,{mouseable:true,title:J});return E};Photos.prototype.clusterTriggerClick=function(B){var A=this._mapMarkers[B];if(A._isVisible){GEvent.trigger(A,"click")}else{var C=A._parentCluster;GEvent.trigger(C,"click");GEvent.trigger(A,"click")}};