$.extend($.fn,{webcamsarchive:function(a){settings=jQuery.extend({date:false},a);return this.each(function(){var e=settings.date;var b=$(this).attr("rel");var c;var d=b.split(":");if(d.length==2){c=d[0]}else{c=b}if(!e&&d.length==2){e=d[1]}var f=new WebcamsArchive(this,c,e,1)})}});function WebcamsArchive(b,a,d,e){this.currentIndex=null;this.previousIndex=null;this.animation=null;this.times=null;this.id=a;this.size=e;this.container=b;var f=this;var c=new Date();this.today=c.isoDate();if(d){this.date=d}else{this.date=this.today}if($(this.container).width()>900){this.size=2}this.loadTimes(this.date);$(this.container).find("div.time-stop-play").bind("click",function(g){f.play()});$(this.container).find("div.time-left").bind("click",function(g){f.showPrevious()});$(this.container).find("div.time-right").bind("click",function(g){f.showNext()});$(this.container).find("div.time-current").bind("click",function(g){f.setCurrentTimePosition(null)});$(this.container).find("div.time-scale").bind("mouseout",function(g){$(f.container).find("div.time-selector").hide()});$(this.container).find("div.timeline-day").bind("click",function(h){var g=$(this).attr("rel");if(g!=f.date){f.loadTimes(g)}})}WebcamsArchive.prototype.loadTimes=function(a){this.date=a;var b=this;$(this.container).find("div.timeline-day-selected").removeClass("timeline-day-selected").addClass("timeline-day-default");$(this.container).find("div.timeline-day[rel='"+a+"']").addClass("timeline-day-selected").removeClass("timeline-day-default");$(this.container).attr("rel",this.id+":"+this.date);if(a!=this.today){$(this.container).find("img.webcamimage-latest").hide()}else{$(this.container).find("img.webcamimage-latest").show()}$(this.container).find("div.archive-loading-indicator").fadeIn(200);$.getJSON("/ajax/webcamsarchive/",{id:this.id,date:a,size:this.size},function(d){$(b.container).find("div.time-available").remove();$(b.container).find("div.time-hover").remove();$(b.container).find("div.time-marker").hide();var c=(b.currentIndex==null)?"webcamimage-latest":"webcamimage"+b.currentIndex;$(b.container).find("img.webcamimage").remove();if(d==null){$(b.container).find("div.webcamsarchive-unavailable").show()}else{$(b.container).find("div.webcamsarchive-unavailable").hide();b.times=d;b.registerTimes(a)}$(b.container).find("div.archive-loading-indicator").fadeOut(200)})};WebcamsArchive.prototype.registerTimes=function(c){var j=this;for(var f=0;f<this.times.length;f++){var b=this.times[f];var h=Math.floor(b.min/15);var e=33+(b.hour-5)*16+h*4;var g=(f==0)?33:e;heightMouseOver=348-g;var d=$("<div class='time-available'></div>").css("top",e);var a=$("<div class='time-hover'></div>").css({"z-index":5,width:"100%",top:g+"px",height:heightMouseOver+"px",position:"absolute"}).bind("mouseover",{index:f},function(i){j.setSelectTimePosition(i.data.index)}).bind("click",{index:f},function(i){j.setCurrentTimePosition(i.data.index)});$(this.container).find("div.time-scale").append(d);$(this.container).find("div.time-scale").append(a)}this.currentIndex=null;if(c==this.today){this.setCurrentTimePosition(null)}else{if(this.times.length>0){this.setCurrentTimePosition(Math.floor(this.times.length/2))}}$(this.container).find("div.webcam-filetime").fadeTo(1000,0.6)};WebcamsArchive.prototype.setCurrentTimePosition=function(a){if(a==null){$(this.container).find("div.time-marker").hide();$(this.container).find("div.time-current").addClass("time-current-selected")}else{var b=this.times[a];$(this.container).find("div.time-marker").show();var c=Math.floor(b.min/15);$(this.container).find("div.time-marker").css("top",27+(b.hour-5)*16+c*4);$(this.container).find("div.time-marker > .time-container > .time-min15").css("background-position","-15px -"+c*10+"px");$(this.container).find("div.time-marker > .time-container > .time-hours").css("background-position","left -"+b.hour*10+"px");$(this.container).find("div.time-current").removeClass("time-current-selected")}this.showTimeLayer(a)};WebcamsArchive.prototype.setSelectTimePosition=function(a){var b=this.times[a];$(this.container).find("div.time-selector").show();var c=Math.floor(b.min/15);$(this.container).find("div.time-selector").css("top",27+(b.hour-5)*16+c*4);$(this.container).find("div.time-selector > .time-container > .time-min15").css("background-position","-15px -"+c*10+"px");$(this.container).find("div.time-selector > .time-container > .time-hours").css("background-position","left -"+b.hour*10+"px")};WebcamsArchive.prototype.loadTimeLayer=function(a){if(a!=null&&a<this.times.length){var b=this.times[a];if(!$(this.container).find("img.webcamimage"+a).length){$(this.container).find("div.webcam-images").append("<img src='"+b.src+"' class='webcamimage webcamimage"+a+"'>")}}};WebcamsArchive.prototype.showNext=function(){var a=(this.currentIndex==null)?0:this.currentIndex+1;if(a<this.times.length){this.setCurrentTimePosition(a);if(a<this.times.length){this.loadTimeLayer(a+1)}}};WebcamsArchive.prototype.showPrevious=function(){var a=(this.currentIndex==null)?this.times.length-1:this.currentIndex-1;if(a>=0){this.setCurrentTimePosition(a);if(a>0){this.loadTimeLayer(a-1)}}};WebcamsArchive.prototype.showCurrent=function(){this.setCurrentTimePosition(null)};WebcamsArchive.prototype.play=function(){if(this.times.length==0){return false}else{if(this.animation!=null){$(this.container).find("div.time-stop-play").removeClass("time-stop").addClass("time-play");window.clearTimeout(this.animation);this.animation=null}else{$(this.container).find("div.time-stop-play").removeClass("time-play").addClass("time-stop");var c=(this.currentIndex==null)?0:this.currentIndex;for(var a=c;a<this.times.length;a++){this.loadTimeLayer(a)}this.setCurrentTimePosition(c);var b=this;this.animation=window.setTimeout(function(){b.playNext()},1200)}}};WebcamsArchive.prototype.playNext=function(){if(this.currentIndex<this.times.length-1){this.setCurrentTimePosition(this.currentIndex+1);var a=this;this.animation=window.setTimeout(function(){a.playNext()},500)}else{this.animation=null;$(this.container).find("div.time-stop-play").removeClass("time-stop").addClass("time-play")}};WebcamsArchive.prototype.showTimeLayer=function(c){if(c==this.currentIndex){return}var e=this;var a=(this.currentIndex==null)?"webcamimage-latest":"webcamimage"+this.currentIndex;var d=(c==null)?"webcamimage-latest":"webcamimage"+c;this.loadTimeLayer(c);$(this.container).find("img."+d).css("z-index",3).fadeIn(350,function(f){$(e.container).find("img."+d).css("z-index",2);$(e.container).find("img."+a).css("z-index",1).hide()});var b=(c!=null)?this.times[c].sfiletime:"aktuelles Kamerabild";$(this.container).find("div.webcam-filetime").text(b);this.previousIndex=this.currentIndex;this.currentIndex=c};Date.prototype.isoDate=function(){var b=(this.getMonth()+1).toString();var a=this.getDate().toString();if(b.length==1){b="0"+b}if(a.length==1){a="0"+a}return this.getFullYear().toString()+"-"+b+"-"+a};