var PXMLLanguage=new AMLNamespace;ample.domConfig.setNamespace("http://www.programma.tv/ns",PXMLLanguage);pElement=function(){};pElement.prototype=new AMLElement;pElement.prototype.AMLElement=new AMLElement;pElement.prototype.$isAccessible=function(){return this.getAttribute("disabled")!="true"};var pElement_week=function(){};pElement_week.prototype=new pElement;pElement_week.prototype.tabIndex=0;pElement_week.prototype.selectedItem=null;pElement_week.prototype.selectedDay=null;pElement_week.prototype.activeItem=null;pElement_week.prototype.activeDay=null;pElement_week.prototype.isScrolling=false;pElement_week.prototype.setAttribute=function(a,b){if(b==this.attributes[a]){return}if(a=="width"){this.$getContainer().style.width=b+"px"}this.AMLElement.setAttribute.call(this,a,b)};pElement_week.prototype.getDayByDate=function(a){for(var b=0;b<this.childNodes.length;b++){if(Number(this.childNodes[b].getDate())==Number(a)){return this.childNodes[b]}}return null};pElement_week.prototype.setActiveDay=function(a){if(this.activeItem==a){return}if(this.activeItem){this.activeItem.setActive(false);this.activeItem=null;this.activeDay=null}if(a){a.setActive();this.activeItem=a;this.activeDay=this.activeItem.getDate()}};pElement_week.prototype.setSelectedItem=function(c){if(this.selectedItem==c&&c._selected){return}var b=c?Number(this.selectedDay)!=Number(c.getDate())||!this.selectedItem:false;if(this.selectedItem){this.selectedItem.setSelected(false);this.selectedItem=null;this.selectedDay=null}if(c){c.setSelected();this.selectedDay=c.getDate();this.selectedItem=c}if(b){var a=ample.createEvent("CustomEvent");a.initCustomEvent("change",true,true,null,null);this.dispatchEvent(a)}};pElement_week.prototype.$getTagOpen=function(){var a=this.getAttribute("class");return'<table class="p-week'+(a?" "+a:"")+'" border="0" cellpadding="0" cellspacing="0"><tr>'};pElement_week.prototype.$getTagClose=function(){return"</tr></table>"};pElement_week.onfocus=function(a){this.setActiveDay(this.activeItem?this.activeItem:this.selectedItem)};pElement_week.onblur=function(b){this.removeEventListener("scrollend",pElement_week.onblur,false);if(this.isScrolling){this.addEventListener("scrollend",pElement_week.onblur,false);return}var a=Math.floor(this.childNodes.length/7/2)*7,c=Math.round(this.childNodes.length/7/2)*7-1;this.$setPseudoClass("focus",false);if(this.selectedDay&&Number(this.selectedDay)<Number(this.childNodes[a].getDate())){this.activeDay=this.selectedDay;this.childNodes[a-1].onactivate()}else{if(this.selectedDay&&Number(this.selectedDay)>Number(this.childNodes[c].getDate())){this.activeDay=this.selectedDay;this.childNodes[c+1].onactivate()}}};pElement_week.onkeydown=function(b){switch(b.keyIdentifier){case"Enter":case"U+0020":this.setSelectedItem(this.activeItem);break;case"Home":break;case"End":break;case"Up":case"Left":this.setActiveDay(this.activeItem.previousSibling?this.activeItem.previousSibling:this.activeItem);break;case"Down":case"Right":this.setActiveDay(this.activeItem.nextSibling?this.activeItem.nextSibling:this.activeItem);break}var a=ample.createEvent("UIEvents");a.initUIEvent("DOMActivate",true,true,null,null);this.dispatchEvent(a)};pElement_week.handlers={keydown:pElement_week.onkeydown,focus:pElement_week.onfocus,blur:pElement_week.onblur};PXMLLanguage.setElement("week",pElement_week);var pElement_wday=function(){};pElement_wday.prototype=new pElement;pElement_wday.prototype._date=null;pElement_wday.prototype._active=false;pElement_wday.prototype._selected=false;pElement_wday.prototype.setSelected=function(a){this._selected=a===false?false:true;this.$setPseudoClass("selected",this._selected)};pElement_wday.prototype.setActive=function(b){this._active=b===false?false:true;this.$setPseudoClass("active",this._active);if(this._active){var a=ample.createEvent("CustomEvent");a.initCustomEvent("activate",true,true,null,null);this.dispatchEvent(a)}};pElement_wday.prototype.getDate=function(){return this._date};pElement_wday.prototype.setDate=function(a){this._date=a;this.$getContainer("w").innerHTML=strings.DAYS[a.getDay()];this.$getContainer("d").innerHTML=a.getDate()+" "+strings.MONTHS[a.getMonth()]};pElement_wday.prototype.$getTagOpen=function(){var d=this.getAttribute("class"),a=this.getAttribute("date"),b=this.getAttribute("wday");return'<td class="p-wday'+(d?" "+d:"")+'" unselectable="on" onmousedown="return false"><div class="p-wday--r"><span class="p-wday--w">'+b+'</span><br/><span class="p-wday--d">'+a+"</span>"};pElement_wday.prototype.$getTagClose=function(){return"</div></td>"};pElement_wday.onmousedown=function(a){this.parentNode.setActiveDay(this)};pElement_wday.onclick=function(a){if(!this._active){return}this.parentNode.setSelectedItem(this);a=ample.createEvent("UIEvents");a.initUIEvent("DOMActivate",true,true,null,null);this.dispatchEvent(a)};pElement_wday.handlers={click:pElement_wday.onclick,mousedown:pElement_wday.onmousedown};var pElement_wholiday=function(){};pElement_wholiday.prototype=new pElement_wday;pElement_wholiday.prototype.$getTagOpen=function(){var d=this.getAttribute("class"),a=this.getAttribute("date"),b=this.getAttribute("wday");return'<td class="p-wholiday'+(d?" "+d:"")+'" unselectable="on" onmousedown="return false"><div class="p-wholiday--r"><span class="p-wholiday--w">'+b+'</span><br/><span class="p-wholiday--d">'+a+"</span>"};pElement_wholiday.prototype.$getTagClose=function(){return"</div></td>"};pElement_wholiday.handlers=pElement_wday.handlers;PXMLLanguage.setElement("wday",pElement_wday);PXMLLanguage.setElement("wholiday",pElement_wholiday);var pElement_channels=function(){};pElement_channels.prototype=new pElement;pElement_channels.prototype.tabIndex=0;pElement_channels.prototype.selectedItem=null;pElement_channels.prototype.activeItem=null;pElement_channels.prototype.deleteInProgress=false;pElement_channels.prototype.setActiveChannel=function(a){if(this.activeItem==a){return}if(this.activeItem){this.activeItem.setActive(false);this.activeItem=null}if(a){a.setActive();this.activeItem=a}};pElement_channels.prototype.setSelectedChannel=function(b){if(this.selectedItem==b){return}if(this.selectedItem){this.selectedItem.setSelected(false);this.selectedItem=null}if(b){b.setSelected();this.selectedItem=b;this.scrollToChannel(this.selectedItem)}var a=ample.createEvent("CustomEvent");a.initCustomEvent("change",true,true,null,null);this.dispatchEvent(a)};pElement_channels.prototype.resize=function(a){if(parseInt(this.$getContainer().style.height)+a>0){this.$getContainer().style.height=(parseInt(this.$getContainer().style.height)+a)+"px"}};pElement_channels.prototype.scrollByPages=function(b){if(this.childNodes.length){var a=this.ownerDocument.$getContainerPosition(this.$getContainer("items"));this.scrollBy(a.height*b)}};pElement_channels.prototype.scrollByLines=function(d){if(this.childNodes.length){var c=this.childNodes[0].getBoundingClientRect(),b=c.bottom-c.top,a=this;this.scrollBy(b*d);window.setTimeout(function(){(function(e){e.drawIcons()})(a)},1)}};pElement_channels.prototype.drawIcons=function(){for(var b=0;b<this.childNodes.length;b++){var a="s-"+this.childNodes[b].getAttribute("id"),d=this.childNodes[b].$getContainer("bt").className,c=false;if(d.indexOf(" "+a)==-1){if(this.isChannelVisible(this.childNodes[b])){this.childNodes[b].$getContainer("bt").className=d+" "+a;c=true}else{if(c){break}}}}};pElement_channels.prototype.scrollToChannel=function(e){var b=e.parentNode.parentNode.parentNode,f=e.getBoundingClientRect().top-b.getBoundingClientRect().top-3,c=e.getBoundingClientRect().bottom-e.getBoundingClientRect().top+7,d=b.getBoundingClientRect().bottom-b.getBoundingClientRect().top,a=this;if(f<0){e.parentNode.parentNode.$getContainer().scrollTop+=f;window.setTimeout(function(){(function(g){g.drawIcons()})(a)},1);return true}else{if(f+c>d){e.parentNode.parentNode.$getContainer().scrollTop+=(f+c)-d;window.setTimeout(function(){(function(g){g.drawIcons()})(a)},1);return true}}return false};pElement_channels.prototype.isChannelVisible=function(d){var a=d.parentNode.parentNode.parentNode,e=d.getBoundingClientRect().top-a.getBoundingClientRect().top-3,b=d.getBoundingClientRect().bottom-d.getBoundingClientRect().top+7,c=a.getBoundingClientRect().bottom-a.getBoundingClientRect().top;if(e+b<0||e>c){return false}else{return true}};pElement_channels.prototype.scrollBy=function(a){this.parentNode.$getContainer().scrollTop+=Math.floor(a)};pElement_channels.prototype.selectChannel=function(b){if(this.selectedItem!=b){if(this.selectedItem){this.selectedItem.setAttribute("selected","false")}b.setAttribute("selected","true");this.attributes.value=b.attributes.value;this.selectedItem=b;var a=this.ownerDocument.createEvent("Events");a.initEvent("change",false,false);this.dispatchEvent(a)}};pElement_channels.prototype.$getTagOpen=function(){var a=this.getAttribute("class");return'<div class="p-channels'+(a?" "+a:"")+'">'};pElement_channels.prototype.$getTagClose=function(){return"</div>"};pElement_channels.onblur=function(a){if(this.scrollToChannel(this.selectedItem)){this.setActiveChannel(this.selectedItem)}};pElement_channels.onfocus=function(a){this.setActiveChannel(this.activeItem?this.activeItem:this.selectedItem)};pElement_channels.onkeydown=function(c){switch(c.keyIdentifier){case"Enter":case"U+0020":this.setSelectedChannel(this.activeItem);break;case"Home":this.setActiveChannel(this.childNodes[0]);break;case"End":this.setActiveChannel(this.childNodes[this.childNodes.length-1]);break;case"Up":if(c.ctrlKey){if(this.activeItem.previousSibling){var f=this.activeItem==this.selectedItem,e=this.activeItem.previousSibling,b=this.insertBefore(this.activeItem,e);if(f){b.setSelected()}b.setActive()}}else{if(this.activeItem.previousSibling){this.setActiveChannel(this.activeItem.previousSibling)}}break;case"Down":if(c.ctrlKey){if(this.activeItem.nextSibling){var f=this.activeItem==this.selectedItem,d=this.activeItem.nextSibling,a=d.nextSibling,b=a?this.insertBefore(this.activeItem,a):this.appendChild(this.activeItem);if(f){b.setSelected()}b.setActive()}}else{if(this.activeItem.nextSibling){this.setActiveChannel(this.activeItem.nextSibling)}}break;case"Backspace":if(this.activeItem&&!this.deleteInProgress){this.deleteInProgress=true;this.activeItem.style.overflowY="hidden";this.activeItem.style.height=this.activeItem.$getContainer().offsetHeight+"px";this.activeItem.$play("height: 0;",200,3,pElement_channels.ondeleteEnd)}break}if(c.keyIdentifier=="Enter"||c.keyIdentifier=="U+0020"){c=ample.createEvent("UIEvents");c.initUIEvent("DOMActivate",true,true,null,null);this.dispatchEvent(c)}};pElement_channels.ondeleteEnd=function(b){this.style.overflowY="";this.style.height="auto";var a=this.nextSibling?this.nextSibling:this.previousSibling,c=this==this.parentNode.selectedItem;this.parentNode.appendChild(this);if(c){this.parentNode.setSelectedChannel(a)}this.parentNode.setActiveChannel(a);this.parentNode.deleteInProgress=false;this.parentNode.drawIcons()};pElement_channels.handlers={keydown:pElement_channels.onkeydown,blur:pElement_channels.onblur,focus:pElement_channels.onfocus};PXMLLanguage.setElement("channels",pElement_channels);var pElement_channel=function(){};pElement_channel.prototype=new pElement;pElement_channel.prototype._active=false;pElement_channel.prototype._dragged=false;pElement_channel.prototype.setActive=function(b){this._active=b===false?false:true;this.$setPseudoClass("active",this._active);if(this._active){var a=ample.createEvent("CustomEvent");a.initCustomEvent("activate",true,true,null,null);this.dispatchEvent(a)}};pElement_channel.prototype.setSelected=function(a){this.$setPseudoClass("selected",a===false?false:true)};pElement_channel.prototype.$getTagOpen=function(){var a=this.getAttribute("class");return'<div class="p-channel'+(a?" "+a:"")+'">&nbsp;<div class="p-channel--bt" title="'+this.attributes.title.replace(/\"/g,"&quot;")+'" unselectable="on" onmousedown="return false"><div class="p-channel--img"></div>'+this.attributes.name+"</div></div>"};pElement_channel.prototype.$getTagClose=function(){return""};pElement_channel.onclick=function(a){if(!this._dragged){this.parentNode.setSelectedChannel(this)}a=ample.createEvent("UIEvents");a.initUIEvent("DOMActivate",true,true,null,null);this.dispatchEvent(a);this._dragged=false};pElement_channel.onmousedown=function(a){if(!this._dragged){this.parentNode.setActiveChannel(this)}};pElement_channel.onactivate=function(a){this.parentNode.scrollToChannel(this)};pElement_channel.handlers={click:pElement_channel.onclick,mousedown:pElement_channel.onmousedown,activate:pElement_channel.onactivate};PXMLLanguage.setElement("channel",pElement_channel);var pElement_program=function(){};pElement_program.prototype=new pElement;pElement_program.prototype.$getTagOpen=function(){var a=this.getAttribute("class");return'<div class="p-program'+(a?" "+a:"")+'">'};pElement_program.prototype.$getTagClose=function(){return"</div>"};PXMLLanguage.setElement("program",pElement_program);var pElement_day=function(){};pElement_day.prototype=new pElement;pElement_day.prototype.tabIndex=0;pElement_day.prototype.activeItem=null;pElement_day.prototype.selectedItem=null;pElement_day.prototype.$getTagOpen=function(){var a=this.getAttribute("class");return'<div class="p-day'+(a?" "+a:"")+'">'};pElement_day.prototype.$getTagClose=function(){return"</div>"};pElement_day.prototype.setActiveItem=function(a){if(this.activeItem){this.activeItem.setActive(false)}if(a){this.activeItem=a;this.activeItem.setActive()}if(this.activeItem){this.scrollToItem(this.activeItem)}};pElement_day.prototype.setSelectedItem=function(a){if(this.selectedItem){this.selectedItem.setSelected(false)}if(a){this.selectedItem=a;this.selectedItem.setSelected()}};pElement_day.prototype.scrollToItem=function(b){var d=ample.getElementById("programma_container_load").$getContainer(),e=ample.getElementById("programma_container_load").getBoundingClientRect(),c=ample.getElementById("weekdays_container").getBoundingClientRect(),a=b.getBoundingClientRect().top-c.bottom-(b.$getContainer().getBoundingClientRect?10:0),f=b.getBoundingClientRect().bottom-b.getBoundingClientRect().top+4,g=e.bottom-e.top-20;if(a<0){d.scrollTop+=a;return true}else{if(a+f>g){d.scrollTop+=(a+f)-g;return true}}return false};pElement_day.onfocus=function(a){if(!this.activeItem){if(this.selectedItem){this.setActiveItem(this.selectedItem)}else{if(this.firstChild){this.setActiveItem(this.firstChild)}}}};pElement_day.onkeydown=function(a){switch(a.keyIdentifier){case"Home":if(this.childNodes.length){this.setActiveItem(this.childNodes[0])}a.preventDefault();break;case"End":if(this.childNodes.length){this.setActiveItem(this.childNodes[this.childNodes.length-1])}a.preventDefault();break;case"Up":case"Left":if(this.activeItem&&this.activeItem.previousSibling){this.setActiveItem(this.activeItem.previousSibling)}a.preventDefault();break;case"Down":case"Right":if(this.activeItem&&this.activeItem.nextSibling){this.setActiveItem(this.activeItem.nextSibling)}a.preventDefault();break}};pElement_day.handlers={focus:pElement_day.onfocus,keydown:pElement_day.onkeydown};PXMLLanguage.setElement("day",pElement_day);var pElement_item=function(){};pElement_item.prototype=new pElement;pElement_item.prototype.setActive=function(a){this.$setPseudoClass("active",a===false?false:true)};pElement_item.prototype.setSelected=function(a){this.$setPseudoClass("selected",a===false?false:true)};pElement_item.onfocus=function(a){};pElement_item.onkeydown=function(a){};pElement_item.prototype.$getTagOpen=function(){var b=this.getAttribute("class"),c=this.getAttribute("title"),a=new Date(this.getAttribute("timeStart")),d=(a.getHours()>9?a.getHours():"0"+a.getHours())+":"+(a.getMinutes()>9?a.getMinutes():"0"+a.getMinutes());return'<div class="p-item'+(b?" "+b:"")+'"><div style="height: 4px; background: #fff; font-size: 1px;"></div><div class="p-item--left"><div class="p-item--right"><div class="p-item--top"><div class="p-item--bottom"><div class="p-item--time">'+d+'</div><div class="p-item--data"><div class="p-item--title">'+c+"</div>"+(this.firstChild&&this.firstChild.length?'<div class="p-item--description">':"")};pElement_item.prototype.$getTagClose=function(){return""+(this.firstChild&&this.firstChild.length?"</div>":"")+"</div></div></div></div></div></div>"};pElement_item.onmousedown=function(a){this.parentNode.setActiveItem(this)};pElement_item.handlers={mousedown:pElement_item.onmousedown};PXMLLanguage.setElement("item",pElement_item);var pElement_hint=function(){};pElement_hint.prototype=new pElement;pElement_hint.prototype._active=false;pElement_hint.prototype.$getTagOpen=function(){var e=this.getAttribute("class"),a=this.getAttribute("width"),d=this.getAttribute("height"),b="";b='<div class="p-hint'+(e?" "+e:"")+'" style="width: '+a+"px; height: "+d+'px;"><div class="p-hint--l-corner"><div class="p-hint--i"></div></div><div class="p-hint--r-corner"><div class="p-hint--i"></div></div><div class="p-hint--l-b-corner"><div class="p-hint--i"></div></div><div class="p-hint--r-b-corner"><div class="p-hint--i"></div></div><div class="p-hint--t" style="width: '+(a-30)+"px; height: "+(d-10)+'px;"><div class="p-hint--i"></div></div><div class="p-hint--b" style="width: '+(a-30)+'px; "><div class="p-hint--i"></div></div><div class="p-hint--l" style="height: '+(d-30)+"px; width: "+(a-30)+'px;"><div class="p-hint--i"></div></div><div class="p-hint--r" style="height: '+(d-30)+'px;"><div class="p-hint--i"></div></div><div class="p-hint--pipa" style="top: '+(d-50)+'px;"><div class="p-hint--i"></div></div>';return b};pElement_hint.prototype.$getTagClose=function(){return"</div>"};PXMLLanguage.setElement("hint",pElement_hint);Date.prototype.toCalendarDate=function(){return""+this.getFullYear()+(this.getMonth()+1<10?"0":"")+(this.getMonth()+1)+(this.getDate()<10?"0":"")+this.getDate()};Date.getCurrent=function(){var a=new Date();a=a.getHours()<5?new Date(a-24*60*60*1000):a;return new Date(a.getFullYear(),a.getMonth(),a.getDate(),12,0,0,0)};Date.fromString=function(e){if(/^\d{8}$/g.test(e)){var b=e.substr(0,4),c=e.substr(4,2)-1,a=e.substr(6,2),d=Date.getCurrent();d.setFullYear(b,c,a);return(d.getFullYear()==b&&d.getMonth()==c&&d.getDate()==a)?d:Date.getCurrent()}else{return Date.getCurrent()}};var SERVER_BASE=location.href.replace(/^(https?:\/\/[^\/]+).*$/gi,"$1");ample.domConfig.setParameter("ample-module-history-fix",true);function updateClock(f){var k=new Date(),d=k.getMilliseconds(),j=ample.getElementById("clock");if(f===true){d=600}else{j._timeout=window.setTimeout(updateClock,d<500?500:1000-d)}var b=j.childNodes[0].$getContainer(),e=j.childNodes[1].$getContainer(),m=j.childNodes[2].$getContainer(),p=j.childNodes[3].$getContainer();e.style.visibility=d<500?"hidden":"visible";if(f===true||k.getSeconds()==0){b.innerHTML=(k.getHours()>9?"":"0")+k.getHours();m.innerHTML=(k.getMinutes()>9?"":"0")+k.getMinutes();p.innerHTML=", "+(k.getDate()>9?"":"0")+k.getDate()+" "+strings.MONTHS[k.getMonth()]+" "+k.getFullYear()+" года, "+strings.DAYS[k.getDay()];if(Number(ample.getElementById("weekdays").selectedDay)==Number(Date.getCurrent())){var a=Number(new Date);var l=ample.getElementsByTagNameNS(PXMLLanguage.namespaceURI,"item"),o=null,h=false,g,i,c;for(c=0;c<l.length;c++){g=Number(new Date(l[c].getAttribute("timeStart")));i=Number(new Date(l[c].getAttribute("timeEnd")));if((a>=g&&a<i)){if(!o){o=l[c].parentNode}l[c].parentNode.setSelectedItem(l[c]);if(f){l[c].parentNode.scrollToItem(l[c])}h=true;break}}if(!h&&l.length){l[0].parentNode.setSelectedItem(null)}if(o&&o.selectedItem){for(c=0;c<l.length;c++){if(l[c]==o.selectedItem){break}l[c].setAttribute("class","past")}}}}}function onClockClick(c){c.preventDefault();var b=ample.getElementById("weekdays"),a=Date.getCurrent();b.removeEventListener("scrollend",onClockClick,false);if(b.isScrolling){b.addEventListener("scrollend",onClockClick,false);return}b.setSelectedItem(b.getDayByDate(a));b.selectedDay=a;b.activeDay=a;pElement_week.onblur.call(b);if(!google_track_once_clock){google_track_once_clock=true;google_track_event("clock","clicked")}}function closeAd(){var a=ample.getElementById("programma_container_load"),c=ample.getElementById("ad_container"),b=parseInt(a.style.height)+c.$getContainer().offsetHeight;c.style.display="none";a.style.height=b+"px"}function onProgramChange(){var d=ample.getElementById("weekdays"),c=ample.getElementById("channels_container").firstChild;if(d&&c&&d.selectedItem&&c.selectedItem){var b=d.selectedDay;document.title=strings.TITLE;document.title+=" - "+c.selectedItem.getAttribute("name");document.title+=" - "+b.getDate()+" "+strings.MONTHS[b.getMonth()];var f=c.selectedItem.getAttribute("url_home"),a=ample.getElementById("href");ample.getElementById("href-container").style.display="block";a.$getContainer().innerHTML='Сайт канала:&nbsp;<a href="'+f+'" target="_blank" title="Перейти на официальный сайт: '+f+'">'+f+"</a>";if(b.getDay()>0&&b.getDay()<6){ample.getElementById("main").$getContainer().className=""}else{ample.getElementById("main").$getContainer().className="holiday"}ample.getElementById("programma_container_trobbler").style.display="block";ample.getElementById("programma_container_error").style.display="none";ample.getElementById("programma_container_nodata").style.display="none";user.date=d.selectedDay.toCalendarDate();user.channel=c.selectedItem.getAttribute("id");window.clearTimeout(ample.getElementById("programma_container_load")._timer);ample.getElementById("programma_container_load").$load(SERVER_BASE+"/"+VERSION+"/day/"+c.selectedItem.getAttribute("id")+"/"+d.selectedDay.toCalendarDate()+"/"+user.timezone+"/");ample.getElementById("programma_container_load")._timer=window.setTimeout(function(){window.clearTimeout(ample.getElementById("programma_container_load")._timer);ample.getElementById("programma_container_load").$abort();onProgramError()},TIMEOUT*1000);var e=c.selectedItem.getAttribute("id")+"/"+(Number(Date.getCurrent())==Number(d.selectedDay)?"":d.selectedDay.toCalendarDate()+"/");ample.$bookmark(e);google_track("/"+c.selectedItem.getAttribute("id")+"/"+d.selectedDay.toCalendarDate()+"/")}}function onProgramLoad(){window.clearTimeout(ample.getElementById("programma_container_load")._timer);ample.getElementById("programma_container_trobbler").style.display="none";if(!ample.getElementsByTagNameNS(PXMLLanguage.namespaceURI,"item").length){ample.getElementById("programma_container_nodata").style.display="block"}else{var a=ample.getElementsByTagNameNS(PXMLLanguage.namespaceURI,"day");if(a.length){if(ample.getElementById("weekdays").selectedDay<Date.getCurrent()){a[0].setAttribute("class","past")}}updateClock(true);if(a.length&&a[0].selectedItem){a[0].scrollToItem(a[0].selectedItem)}if(ample.getElementById("ad_container").style.display!="none"&&document.getElementById("ad-iframe")&&document.getElementById("ad-iframe").contentWindow){document.getElementById("ad-iframe").contentWindow.location.reload()}}}function onProgramError(){ample.getElementById("programma_container_trobbler").style.display="none";ample.getElementById("programma_container_error").style.display="block"}function moveWeekLeft(d){var c=ample.getElementById("weekdays"),g=ample.getElementById("weekdays_container"),e=g.$getContainer().scrollLeft,a=Math.round(g.$getContainer().scrollLeft-c._day_width*7),f=550,b=Math.round((a-e)/(f/20));if(c.isScrolling){d.preventDefault();return}c.isScrolling=true;window._interval=window.setInterval(function(){moveWeekLeftStep(e,a,b)},20);if(!google_track_once_calendar_left){google_track_once_calendar_left=true;google_track_event("calendar","moved-left")}}function moveWeekLeftStep(l,a,k){var b=ample.getElementById("weekdays_container"),j=b.$getContainer().scrollLeft,f=j+k,d;if(f<a){f=a}b.$getContainer().scrollLeft=f;if(j==b.$getContainer().scrollLeft){window.clearInterval(window._interval);var g=ample.getElementById("weekdays");g._d_start=g._d_start-7*24*60*60*1000;if(g.activeDay&&(Number(g.activeDay)>Number(g.childNodes[Math.round(g.childNodes.length/7/2)*7].getDate())-7*24*60*60*1000||Number(g.activeDay)<Number(g.childNodes[Math.floor(g.childNodes.length/7/2)*7-1].getDate())-7*24*60*60*1000)){g._d_start=g.activeDay-((g.activeDay.getDay()==0?7:g.activeDay.getDay())-1)*24*60*60*1000;g._d_start=g._d_start-Math.floor(g.childNodes.length/7/2)*7*24*60*60*1000}var e=null;for(d=0;d<g.childNodes.length;d++){g.childNodes[d].setDate(new Date(g._d_start+d*24*60*60*1000));if(Number(g.activeDay)==Number(g.childNodes[d].getDate())){e=g.childNodes[d]}}var c=g.getDayByDate(g.selectedDay);if(c){g.setSelectedItem(c)}g.setActiveDay(e);b.$getContainer().scrollLeft=l;g.isScrolling=false;g.activeItem.setActive();var h=ample.createEvent("CustomEvent");h.initEvent("scrollend",true,true,null,null);g.dispatchEvent(h)}}function moveWeekRight(d){var c=ample.getElementById("weekdays"),g=ample.getElementById("weekdays_container"),e=g.$getContainer().scrollLeft,a=Math.round(g.$getContainer().scrollLeft+c._day_width*7),f=550,b=Math.round((a-e)/(f/20));if(c.isScrolling){d.preventDefault();return}c.isScrolling=true;window._interval=window.setInterval(function(){moveWeekRightStep(e,a,b)},20);if(!google_track_once_calendar_right){google_track_once_calendar_right=true;google_track_event("calendar","moved-right")}}function moveWeekRightStep(l,a,k){var b=ample.getElementById("weekdays_container"),j=b.$getContainer().scrollLeft,f=j+k,d;if(f>a){f=a}b.$getContainer().scrollLeft=f;if(j==b.$getContainer().scrollLeft){window.clearInterval(window._interval);var g=ample.getElementById("weekdays");g._d_start=g._d_start+7*24*60*60*1000;if(g.activeDay&&(Number(g.activeDay)>Number(g.childNodes[Math.round(g.childNodes.length/7/2)*7].getDate())+7*24*60*60*1000||Number(g.activeDay)<Number(g.childNodes[Math.floor(g.childNodes.length/7/2)*7-1].getDate())+7*24*60*60*1000)){g._d_start=g.activeDay-((g.activeDay.getDay()==0?7:g.activeDay.getDay())-1)*24*60*60*1000;g._d_start=g._d_start-Math.floor(g.childNodes.length/7/2)*7*24*60*60*1000}var e=null;for(d=0;d<g.childNodes.length;d++){g.childNodes[d].setDate(new Date(g._d_start+d*24*60*60*1000));if(Number(g.activeDay)==Number(g.childNodes[d].getDate())){e=g.childNodes[d]}}var c=g.getDayByDate(g.selectedDay);if(c){g.setSelectedItem(c)}g.setActiveDay(e);b.$getContainer().scrollLeft=l;g.isScrolling=false;g.activeItem.setActive();var h=ample.createEvent("CustomEvent");h.initCustomEvent("scrollend",true,true,null,null);g.dispatchEvent(h)}}function resizeWeek(){var a=ample.getElementById("weekdays"),d=ample.getElementById("weekdays_container"),c=d.getBoundingClientRect();a._day_width=(c.right-c.left)/7.6;a.setAttribute("width",a._day_width*a.childNodes.length);for(var b=0;b<a.childNodes.length;b++){a.childNodes[b].style.width=a._day_width+"px"}d.$getContainer().scrollLeft=Math.round(a._day_width*(Math.floor(a.childNodes.length/7/2)*7-0.3))}function onAmpleLoad(a){document.body.clientHeightOld=document.body.clientHeight;document.body.stoppedVertical=null;document.body.clientWidthOld=document.body.clientWidth;document.body.stoppedHorizontal=null;var d=ample.getElementById("links").parentNode.getBoundingClientRect().bottom-ample.getElementById("links").parentNode.getBoundingClientRect().top,g=ample.getElementById("main").getBoundingClientRect().bottom-ample.getElementById("main").getBoundingClientRect().top,h=ample.getElementById("weekdays");ample.getElementById("channels_container").style.height=(g-d-4-10)+"px";ample.getElementById("channels_container")._diff=document.body.clientHeight-parseInt(ample.getElementById("channels_container").style.height);ample.getElementById("ch_outer").style.marginTop=(d+4)+"px";ample.getElementById("ch_outer").style.height=(g-d-4-3)+"px";ample.getElementById("ch_outer")._diff=document.body.clientHeight-parseInt(ample.getElementById("ch_outer").style.height);ample.getElementById("weekdays_container").style.width=(document.body.clientWidth-document.getElementById("ch_outer").offsetWidth-8)+"px";ample.getElementById("weekdays_container")._diff=document.body.clientWidth-parseInt(ample.getElementById("weekdays_container").style.width);var f=ample.getElementById("ad_container").getBoundingClientRect().bottom-ample.getElementById("ad_container").getBoundingClientRect().top;ample.getElementById("programma_container_load").style.height=(g-d-4-3-20-f-4)+"px";ample.getElementById("programma_container_load").style.width=(document.body.clientWidth-document.getElementById("ch_outer").offsetWidth-8-20)+"px";ample.getElementById("programma_container_load")._diff=document.body.clientWidth-parseInt(ample.getElementById("programma_container_load").style.width);ample.getElementById("ad_container").style.width=ample.getElementById("programma_container_load").style.width;var k=window.location.hash.substring(1).split("/")[1];k=k?Date.fromString(k):Date.getCurrent();h._d_start=k-((k.getDay()==0?7:k.getDay())-1)*24*60*60*1000;h._d_start=h._d_start-Math.floor(h.childNodes.length/7/2)*7*24*60*60*1000;for(var e=0;e<h.childNodes.length;e++){h.childNodes[e].setDate(new Date(h._d_start+e*24*60*60*1000))}h.setSelectedItem(h.getDayByDate(k));resizeWeek();updateClock(true);window.setTimeout("window.setTimeout(updateClock, 500);",1000-(new Date()).getMilliseconds());ample.getElementById("write-us").setAttribute("href","mailto:support"+"aa@programma.tv".substring(2));document.getElementById("loading").style.display="none";ample.getElementById("ample").style.visibility="visible";var c=new Date,j=Math.abs(Math.floor(c.getTimezoneOffset()/60)),b=Math.abs(c.getTimezoneOffset())-Math.abs(Math.floor(c.getTimezoneOffset()/60))*60;user.timezone=(c.getTimezoneOffset()<0?"+":"-")+(j>9?j:"0"+j)+(b>9?b:"0"+b);onChannelsLoad();window.setTimeout(createAd,1000)}function createAd(){var c=parseInt(ample.getElementById("ad_container").style.width)-39,a=ample.getElementById("ad_container").getBoundingClientRect().bottom-ample.getElementById("ad_container").getBoundingClientRect().top;if(a){var b=0;if(c>=728+728+234){b=4}else{if(c>=728+728){b=3}else{if(c>=728+468){b=2}else{if(c>=728+234){b=1}else{if(c>=728){b=0}}}}}var d=document.createElement("iframe");d.src="/?ad="+b;d.width="100%";d.height="100%";d.frameBorder="0";d.border="0";d.id="ad-iframe";ample.getElementById("ad").$getContainer().appendChild(d)}}function onAmpleResize(c){var e=900,d=500,a=document.body.clientWidth,i=document.body.clientHeight;if(document.body.clientHeightOld&&document.body.clientWidthOld){var j=i-document.body.clientHeightOld,l=a-document.body.clientWidthOld,h=ample.getElementById("channels_container"),k=ample.getElementById("weekdays_container"),f=ample.getElementById("ch_outer"),b=ample.getElementById("programma_container_load"),g=ample.getElementById("ad_container");if(j!=0){if(i>d){if(document.body.stoppedVertical!=null){j=(i-document.body.stoppedVertical);document.body.stoppedVertical=null}if(parseInt(h.style.height)+j>0){h.style.height=(parseInt(h.style.height)+j)+"px";window.setTimeout(function(){ample.getElementById("channels_container").firstChild.drawIcons()},1)}if(parseInt(f.style.height)+j>0){f.style.height=(parseInt(f.style.height)+j)+"px"}if(parseInt(b.style.height)+j>0){b.style.height=(parseInt(b.style.height)+j)+"px"}}else{if(document.body.stoppedVertical==null){document.body.stoppedVertical=document.body.clientHeightOld}}}if(l!=0){if(a>e){if(document.body.stoppedHorizontal!=null){l=(a-document.body.stoppedHorizontal);document.body.stoppedHorizontal=null}if(parseInt(k.style.width)+l>0){k.style.width=(parseInt(k.style.width)+l)+"px";resizeWeek()}if(parseInt(b.style.width)+l>0){b.style.width=(parseInt(b.style.width)+l)+"px";g.style.width=b.style.width}}else{if(document.body.stoppedHorizontal==null){document.body.stoppedHorizontal=document.body.clientWidthOld}}}document.body.clientHeightOld=i;document.body.clientWidthOld=a}}function saveSettings(){var a=ample.getElementsByTagNameNS(PXMLLanguage.namespaceURI,"channel"),d="",c="";if(!a.length){return}for(var b=0;b<a.length;b++){d+=a[b].getAttribute("id")+(b!=a.length-1?",":"")}c+="channel="+encodeURIComponent(user.channel)+"&channels="+encodeURIComponent(d)+"&channles-hint="+encodeURIComponent(user["channles-hint"]);if(user.rawSettings!=c){user.rawSettings=c;window.clearTimeout(saveSettings._timeout);saveSettings._timeout=window.setTimeout(saveSettingsRequest,2500)}}function saveSettingsRequest(){var a=new XMLHttpRequest;a.open("POST",SERVER_BASE+"/"+VERSION+"/settings/",true);a.setRequestHeader("Content-type","application/x-www-form-urlencoded");a.send(user.rawSettings)}function onAmpleUnload(a){window.clearTimeout(ample.getElementById("clock")._timeout);if(window.scrollbars){window.scrollbars.visible=true}}function onChannelsMouseWheel(a){if(a.currentTarget.firstChild.nodeName=="p:channels"){a.currentTarget.firstChild.scrollByLines(a.wheelDelta/5);a.preventDefault();if(!google_track_once_channels){google_track_once_channels=true;google_track_event("channels","scrolled")}onChannelsMouseLeave();user["channles-hint"]=0}}function onChannelsLoad(){var c=ample.getElementById("channels_container"),d=c.firstChild,a=window.location.hash.substring(1).split("/")[0];d.addEventListener("change",onProgramChange,false);if(!a){a=user.channel}if(a){var e=false;for(var b=0;b<d.childNodes.length;b++){if(d.childNodes[b].getAttribute("id")==a){e=true;d.setSelectedChannel(d.childNodes[b]);c.$getContainer().scrollTop+=2000;d.scrollToChannel(d.childNodes[b]);break}}if(!e){d.setSelectedChannel(d.firstChild)}}else{d.setSelectedChannel(d.firstChild)}window.setInterval(saveSettings,500);c.style.visibility="visible"}function onHashChange(e){var d=e.newURL.replace(/(^.+)#([^#]*)$/g,"$2"),b=d.split("/")[0],a=d.split("/")[1],f=ample.getElementById("channels_container").firstChild;a=(a?Date.fromString(a):Date.getCurrent());if(user.date!=a&&user.channel!=b){f.setSelectedChannel(null)}if(user.date!=a){ample.getElementById("weekdays").setSelectedItem(ample.getElementById("weekdays").getDayByDate(a))}if(user.channel!=b){if(b){var g=false;for(var c=0;c<f.childNodes.length;c++){if(f.childNodes[c].getAttribute("id")==b){g=true;f.setSelectedChannel(f.childNodes[c]);break}}if(!g){f.setSelectedChannel(f.firstChild)}}else{f.setSelectedChannel(f.firstChild)}}}ample.addEventListener("load",onAmpleLoad,false);ample.addEventListener("unload",onAmpleUnload,false);ample.addEventListener("hashchange",onHashChange,false);window.setInterval(onAmpleResize,50);function channelsIntervalBottom(b,f){var d=ample.getElementById("channels_container"),g=d.$getContainer().scrollTop,e=g+f;if(e>b){e=b}d.$getContainer().scrollTop=e;if(g==d.$getContainer().scrollTop){window.clearInterval(window._channels_interval);var a=200,c=500,b=ample.getElementById("channels_container").$getContainer().scrollTop-a;window._channels_interval=window.setInterval(function(){channelsIntervalTop(b,-a/(c/20))},20)}}function channelsIntervalTop(a,d){var b=ample.getElementById("channels_container"),e=b.$getContainer().scrollTop,c=e+d;if(c<a){c=a}b.$getContainer().scrollTop=c;if(e==b.$getContainer().scrollTop){window.clearInterval(window._channels_interval)}}if(window.scrollbars){window.scrollbars.visible=false}function onHelpMouseEnter(){ample.getElementById("links-current").$play("opacity: 0; color: #fff;",400,1)}function onHelpMouseLeave(){ample.getElementById("links-current").$play("opacity: 1; color: #333;",400,1)}function onChannelsMouseEnter(d){if(user["channles-hint"]==0){return}var b=ample.getElementById("channels-hint"),c=b.getBoundingClientRect();b.style.display="block";b.style.top=(d.clientY-(c.bottom-c.top)+10)+"px";ample.getElementById("ch_outer").addEventListener("mousemove",onChannelsMouseMove,false)}function onChannelsMouseLeave(a){if(user["channles-hint"]==0){return}ample.getElementById("channels-hint").style.display="none";ample.getElementById("ch_outer").removeEventListener("mousemove",onChannelsMouseMove,false)}function onChannelsMouseMove(d){var b=ample.getElementById("channels-hint");if(user["channles-hint"]==0){b.style.display="none";return}var c=b.getBoundingClientRect();b.style.top=(d.clientY-(c.bottom-c.top)+10)+"px"};
