function updateProgram(a){for(var b=a.length-1;b>=0;b--){var c=a[b];if(c.timestamp<globalTime){if(b!=currentProgram){currentProgram=b;showCurrentProgram(a,b);generateCoverflow(a,b)}break}}}function showCurrentProgram(a,b){var d=a[b];var e=a[b+1];var c="";if(typeof d!="undefined"){c+="<div style='padding: 3px 5px;'>Zurzeit läuft: <strong>";c+=getItemTitle(b);c+="</strong></div>"}if(typeof e!="undefined"){c+="<div style='padding: 3px 5px;'>ab "+e.strTime+" Uhr: ";c+=getItemTitle(b+1);c+="</div>"}$("#currentProgram").html(c)}function toggleProgramView(){$("#currentProgram").toggle();if($("#fullProgram").is(":hidden")){var c="<table style='border-collapse: collapse; width: 100%;'>";var a="";var f=false;for(var b=0;b<dayProgram.length;b++){var e=dayProgram[b];var d=dayProgram[b+1];if(typeof d!="undefined"&&d.timestamp<globalTime){continue}if(a!=e.strDate){c+="<tr><td colspan='2' style='padding: 5px; border-bottom: 1px solid #aaa; background: #ddd;'>Programm vom "+e.strDate+"</td></tr>"}a=e.strDate;c+="<tr><td style='padding: 5px; border-bottom: 1px solid #aaa; vertical-align: top; white-space: nowrap;'>"+e.strTime+"</td><td style='padding: 5px; vertical-align: top; border-bottom: 1px solid #aaa;'>";if(e.image!=""){c+="<img src='image.php?fotoID="+e.image+"&amp;height=60' style='height: 60px;' class='posRight' />"}if(typeof e.reihe!="undefined"){c+="<strong>"+_makeHtml(e.reihe);if(e.reihe!=""&&e.title!=""){c+=" - "}}c+=_makeHtml(e.title)+"</strong>";if(e.intro!=""){c+="<br/><small>"+_makeHtml(e.intro)+"</small>"}c+="</td></tr>\n";f=true}c+="</table>";$("#fullProgram").html(f?c:"");$("#fullProgram").append("<p style='padding-bottom: 0.8em;'>Das vollständige Programm von &quot;ERF 1&quot; finden Sie im <a href='2435-ERF_eins_Programm.html?reset=1'>Programm-Teil</a>.</p>");$("#fullProgram").show();$("#fullProgram").scrollTop(0);$("#program a.link").text("Vorschau ausblenden")}else{$("#fullProgram").hide();$("#program a.link").text("Vorschau einblenden")}}function generateCoverflow(a,c){try{var d=a[c].module;var f=a[c].item}catch(g){}if(typeof d=="undefined"){d=0}if(typeof f=="undefined"){f=0}var b=ajaxDomain+"ajax.php?mode=tvLiveCoverflow&module="+d+"&item="+f;if(debug){console.log(b)}$.getScript(b,function(){initCoverflow();if(debug){console.log("update coverflow")}})}function loadItemLiveContent(){if(typeof dayProgram=="undefined"||typeof dayProgram[currentProgram]=="undefined"){return""}var b=dayProgram[currentProgram];var a="";a+="<h1 style='margin-top: 10px;'>"+getItemTitle(currentProgram)+"</h1>";a+="<div class='article'></div>";$("#flashContent").html(a);$("#flashLeserbrief").empty();if(typeof b.programID!="undefined"&&b.programID!=""){$("#flashContent .article").load(ajaxDomain+"ajax.php",{mode:"dayProgramContent",type:"tv",item:b.programID})}else{if(typeof b.intro!="undefined"&&b.intro!=""){$("#flashContent .article").html("<p>"+b.intro+"</p>")}else{$("#flashContent .article").html("<p>Zu dieser Sendung gibt es keine weiteren Informationen.</p>")}}}function getItemTitle(a){if(typeof dayProgram=="undefined"){return""}var b=dayProgram[a];var c="";if(typeof b!="undefined"){if(typeof b.reihe!="undefined"){c+=_makeHtml(b.reihe)}if(typeof b.reihe!="undefined"&&typeof b.title!="undefined"&&b.reihe!=""&&b.title!=""){c+=" - "}if(typeof b.title!="undefined"){c+=_makeHtml(b.title)}}return c}function _makeHtml(a){return(typeof a!="undefined"?a.replace(/</g,"&lt;").replace(/>/g,"&gt;"):"")}function timer(){window.setTimeout("timer()",interval);livestream=true;if(globalTime==null||intervalAjaxCount>=intervalAjax){$.getJSON(ajaxDomain+"ajax.php",{mode:"tvJsonTime"},function(a){globalTime=a.time;intervalAjaxCount=0;updateProgram(dayProgram)})}else{globalTime=globalTime+interval/1000;intervalAjaxCount++;updateProgram(dayProgram)}}var playerHeight=240;var currentProgram=-1;var interval=30000;var intervalAjax=30;var intervalAjaxCount=0;var globalTime=null;
