if(timeOffset==void 0)var timeOffset=0;$.get("http://svenska.yle.fi/global/global_col/servertime.php",function(a){timeOffset=new Date(parseInt(a,10))-new Date});NowPlaying.prototype.rmApiUrl="http://svenska.yle.fi/global/scripts/rm_json_api.php";NowPlaying.prototype.prApiUrl="http://svenska.yle.fi/data/feeds/ohjusapi.json?r=serverTime";NowPlaying.prototype.updateTime=5E4;NowPlaying.prototype.name="";NowPlaying.prototype.linkURL="";NowPlaying.prototype.currI=0;
NowPlaying.prototype.channelAlt=[4,54,55,57,58,59];NowPlaying.prototype.recentSongs=[];function NowPlaying(a,c,b,e,h){var d=this;this.name=a;this.linkURL=c;var f=this.prApiUrl,g=this.rmApiUrl;if(b)this.updateTime=b;setTimeout(function(){d.fetchAndUpdate(f,g)},h);this.startUpdate(f,g)}NowPlaying.prototype.stop=function(){clearInterval(this.interval)};NowPlaying.prototype.startUpdate=function(a,c){var b=this;this.interval=setInterval(function(){b.fetchAndUpdate(a,c)},this.updateTime)};
NowPlaying.prototype.fetchAndUpdate=function(a,c){var b=this,e=$("#now-playing-channel a:first"),h=$("#now-playing-info a"),d=new Date;d.setMilliseconds(d.getMilliseconds()+parseInt(timeOffset,10));d=d.getFullYear()+"-"+(d.getMonth()+1<10?"0"+(d.getMonth()+1):""+(d.getMonth()+1))+"-"+(d.getDate()<10?"0"+d.getDate():""+d.getDate())+"T"+(d.getHours()<10?"0"+d.getHours():""+d.getHours())+":"+(d.getMinutes()<10?"0"+d.getMinutes():""+d.getMinutes());e.attr("href",b.linkURL);h.attr("href",b.linkURL);e.html(b.name);
$.ajax({type:"GET",url:a+"&start="+d,dataType:"json",success:function(a){a=a.broadcasts[0].title;b.currI=a.indexOf("Regional")!=-1||a.indexOf("God morgon")!=-1?4:0;updateField("now-playing-programme",a)}});$.ajax({type:"GET",url:c+"?channel_id="+b.channelAlt[b.currI]+"&type=item&num=0",dataType:"jsonp",json:"callback",success:function(a){if(a.status=="fail")return null;var a=a.RMPADEXPORT,c=a.ITEM["PUBLISH-DATA"].attributes.ARTIST.toLowerCase(),b=new Date;b.setMilliseconds(b.getMilliseconds()+parseInt(timeOffset,
10));isRMTimeActive(a.ITEM.attributes.STARTING_TIME,a.ITEM["PUBLISH-DATA"].attributes.DURATION,b)?(updateField("now-playing-song",""+c+": "+a.ITEM["PUBLISH-DATA"].attributes.TITLE),$("#now-playing-song").slideDown("slow")):$("#now-playing-song").slideUp("slow",function(){updateField("now-playing-song","")});$("#now-playing-info").slideDown("slow")}})};
NowPlaying.prototype.hasNotBeenPlayed=function(a){for(var c=0;c<3;c++)if(this.recentSongs[c]==a)return!1;this.recentSongs.unshift(a);this.recentSongs.length>3&&this.recentSongs.pop();return!0};function isRMTimeActive(a,c,b){if(!a)return!1;a=new Date(b.getFullYear(),b.getMonth(),b.getDate(),parseInt(a.substr(11,2),10),parseInt(a.substr(14,2),10),parseInt(a.substr(17,2),10));if(b<a)return!1;a.setSeconds(a.getSeconds()+parseInt(c,10));return a<b?!1:!0}
function updateField(a,c){var b=$("#"+a);b.html()!=c&&b.html(c)}$(document).ready(function(){new NowPlaying("Radio Vega","http://arenan.yle.fi/player/index.php?channel=4&language=sv",1E4,"",1E3)});
var wdb="http://www.yle.fi/saakuvat/ruotsi",weatherData=[{region:"Helsingfors",url:wdb+"/Helsingfors.gif"},{region:"Vasa",url:wdb+"/Vasa.gif"},{region:"Jakobstad",url:wdb+"/Jakobstad.gif"},{region:"Karleby",url:wdb+"/Karleby.gif"},{region:"Kristinestad",url:wdb+"/Kristinestad.gif"},{region:"&Aring;bo",url:wdb+"/obo.gif"},{region:"V&auml;st&aring;boland",url:wdb+"/Nagu.gif"},{region:"Kimito&ouml;n",url:wdb+"/Kimito.gif"},{region:"Hang&ouml;",url:wdb+"/Hanko.gif"},{region:"Raseborg",url:wdb+"/Ekenas.gif"},
{region:"Ing&aring;",url:wdb+"/Inkoo.gif"},{region:"Sjunde&aring;",url:wdb+"/Sjundeo.gif"},{region:"Lojo",url:wdb+"/Lohja.gif"},{region:"Borg&aring;",url:wdb+"/Borgo.gif"},{region:"Lovisa",url:wdb+"/Loviisa.gif"}],currIndex=0,autoScrolling;
$(document).ready(function(){function a(a){currIndex+=a;currIndex=currIndex<0?weatherData.length-1:currIndex;currIndex=currIndex>weatherData.length-1?0:currIndex;var d=new Image;g.animate({opacity:0},"fast");$(d).attr("src",weatherData[currIndex].url);d.readyState=="complete"||d.complete?c(g):$(d).load(function(){c(g)});autoScrolling!==0&&b(a)}function c(a){$("span.city",a).slideUp("fast",function(){$(this).html(weatherData[currIndex].region);a.css("background-image","url("+weatherData[currIndex].url+
")");a.animate({opacity:1},"fast");$(this).slideDown("fast")})}function b(b){f.attr("title","Vidare manuellt");d.attr("title","Vidare manuellt");i=setTimeout(function(){autoScrolling=b;a(b);saveCurrIndex(autoScrolling)},h)}function e(b){f.attr("title","Dubbelklick ger uppspelning");d.attr("title","Dubbelklick ger uppspelning");clearTimeout(i);autoScrolling=0;a(b);saveCurrIndex(autoScrolling)}var h=5E3;autoScrolling=setCurrIndex();var d=$('#scroll [rel="left"]'),f=$('#scroll [rel="right"]'),g=$("#weather .weather-bg"),
i;d.unbind("click");d.click(function(){e(-1);return!1});d.bind("dblclick",function(){b(-1)});f.unbind("click");f.click(function(){e(1);return!1});f.bind("dblclick",function(){b(1)});autoScrolling!=0&&b(autoScrolling);c(g)});function toggleBlock(a,c){var b=$(a),e=$(c);e.is(":visible")?(b.removeClass("open"),e.slideUp("fast")):(b.addClass("open"),e.slideDown("fast"))}var c_name="svylefi_weather",w_exp=365;
function saveCurrIndex(a){var c=new Date;c.setDate(c.getDate()+w_exp);document.cookie=c_name+"="+escape(currIndex)+"|"+a+(c==null?"":"; expires="+c.toUTCString())+"; path=/; domain=yle.fi"}
function setCurrIndex(){if(document.cookie.length>0){var a=document.cookie.indexOf(c_name+"=");if(a!=-1){var a=a+c_name.length+1,c=document.cookie.indexOf(";",a);if(c==-1)c=document.cookie.length;a=document.cookie.substring(a,c).split("|");currIndex=parseInt(unescape(a[0]),10);return parseInt(unescape(a[1]),10)}}currIndex=0;return 1};
