if(typeof(namespace)!="function"){function namespace(ns,separator){var nsParts,tmp=null;var parent=window;if(typeof(separator)=="undefined"){separator="."}nsParts=ns.split(separator);for(var idx=0,max=nsParts.length;idx<max;idx+=1){parent[nsParts[idx]]=parent[nsParts[idx]]||{};parent=parent[nsParts[idx]]}}}namespace("UPC.util");namespace("UPC.widget");namespace("UPC.apps");if(!this.JSON){this.JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());UPC.util.Cookie=function(){function isSupported(){return navigator.cookieEnabled?true:false}function remove(name){write(name,"",-1);document.cookie=name+"=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/"}function read(name){var nameEQ=name+"=";var ca=document.cookie.split(";");for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==" "){c=c.substring(1,c.length)}if(c.indexOf(nameEQ)==0){return c.substring(nameEQ.length,c.length)}}return null}function readJSON(name){var value=read(name);if(value!==null){value=unescape(value);if(value.isJSON()){return value.evalJSON()}return null}return null}function readURLEncoded(name){var value=read(name);if(value!=null){value=unescape(value);return value.toQueryParams()}return null}function write(name,value,days,path,domain){var date=new Date();var expires=null;if(days){date.setTime(date.getTime()+(days*24*60*60*1000));expires="; expires="+date.toGMTString()}else{expires=""}if(typeof(path)==="undefined"){path="/"}if(typeof(domain)==="undefined"){domain=window.location.hostname}document.cookie=name+"="+value+expires+"; path="+path+(domain!=""?"; domain="+domain:"")}function writeJSON(name,value,days,path,domain){value=escape(Object.toJSON(value));write(name,value,days,path,domain)}function writeURLEncoded(name,value,days,path,domain){value=escape(Object.toQueryString(value));write(name,value,days,path,domain)}return{isSupported:isSupported,read:read,readJ:readJSON,readJSON:readJSON,readURL:readURLEncoded,write:write,writeJ:writeJSON,writeJSON:writeJSON,writeURL:writeURLEncoded,remove:remove}}();(function(){function _hash(data,n){var norm=Math.pow(2,-32);var a=2095533;var s=0,c=1;var t,t0=0;data=data.toString();for(var i=0,max=data.length;i<max;i+=1){s-=data.charCodeAt(i)*65537*norm;if(s<0){s+=1}t=a*s+c*norm;t0=s=t-(c=t|0);t=a*s+c*norm;s=t-(c=t|0)}if(n){return Math.floor(n*(s+t0*norm))}else{return s+t0*norm}}function _toQueryString(arg){var arr=[];if(typeof(arg)==="object"){for(key in arg){if(arg.hasOwnProperty(key)){arr.push(encodeURIComponent(key)+"="+encodeURIComponent(arg[key]))}}}if(arr.length!==0){return arr.join("&")}return null}if(typeof(UPC)==="undefined"){UPC={util:{}}}else{if(typeof(UPC.util)==="undefined"){UPC.util={}}}UPC.util.Fetch=(function(){var _objName="UPC.util.Fetch";var _objErrMsg="Error in "+_objName;var counter=-1,head,timeOut=10000;var requests={},window=this;var XhrObject=window.ActiveXObject||XMLHttpRequest;function getJsonp(url,args){var requestId,params="",urlHash;if(typeof(url)==="string"&&args&&typeof(args.onSuccess)==="function"){if(args.params){params=_toQueryString(args.params);url+=(url.indexOf("?")?"?":"&")+params}if(args.cache&&args.cache===false){requestId="jsonp_"+_hash(url,10000000)+(++counter);window[requestId]=function(data){args.onSuccess.call(this,data);window[requestId]=null;try{delete window[requestId]}catch(err){}}}else{requestId="jsonp_"+_hash(url,10000000);if(requests[requestId]){requests[requestId]=[args.onSuccess].concat(requests[requestId])}else{requests[requestId]=[args.onSuccess]}window[requestId]=function(data){if(requests[requestId]){requests[requestId].pop().call(this,data);window.setTimeout(function(){if(requests[requestId]&&requests[requestId].length===0&&window[requestId]){requests[requestId]=null;window[requestId]=null;try{delete requests[requestId];delete window[requestId]}catch(err){}}},0)}}}url+=(url.indexOf("?")?"&":"?")+"callback="+requestId;if(typeof(args.onFailure)==="function"){getScript(url,{onFailure:args.onFailure})}else{getScript(url)}}else{throw new Error(_objErrMsg+".getJsonp() -> invalid params given")}}function getScript(url,args){var done=false,script=document.createElement("script"),head;var timeOut=5000,timer;if(!url){throw Error(_objErrMsg+".getScript() -> url is undefined")}if(!args){args={}}if(args.timeOut){timeOut=args.timeOut}timer=window.setTimeout(function(){if(typeof(args.onFailure)==="function"){args.onFailure.call(this)}},timeOut);script.src=url;script.async=true;script.onload=script.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){done=true;clearTimeout(timer);if(typeof(args.onSuccess)==="function"){args.onSuccess()}script.onload=script.onreadystatechange=null;if(script&&script.parentNode){script.parentNode.removeChild(script)}}};if(!head){head=document.getElementsByTagName("head")[0]}head.appendChild(script)}function getXhr(url,args){var method="GET",params={},xhr=new (XhrObject)("Microsoft.XMLHTTP");if(typeof(url)==="string"&&args&&typeof(args.onSuccess||args.on200)==="function"){if(typeof(args.method)==="string"){method=args.method.toUpperCase()}if(method==="POST"||method==="PUT"||method==="DELETE"){xhr.open("POST",url,1);xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");if(typeof(args.params)==="object"){params=args.params||{}}if(method==="PUT"){params._method="put"}else{if(method==="DELETE"){params._method="delete"}}params=_toQueryString(args.params)}else{if(args.params){params=_toQueryString(args.params);url+=(url.indexOf("?")?"?":"&")+params}else{params=null}xhr.open("GET",url,1)}xhr.setRequestHeader("X-Requested-With","XMLHttpRequest");xhr.onreadystatechange=function(){var data;if(xhr.readyState===4){try{if(xhr.status>199&&xhr.status<300){if(JSON&&typeof(JSON.parse)!=="function"){data=JSON.parse(xhr.responseText)}else{data=(new Function("return "+xhr.responseText))()}if(typeof(args["on"+xhr.status])==="function"){args["on"+xhr.status](data,xhr)}else{if(typeof(args.onSuccess)==="function"){args.onSuccess(data,xhr)}}}else{if(typeof(args["on"+xhr.status])==="function"){args["on"+xhr.status](xhr)}else{if(typeof(args.onFailure)==="function"){args.onFailure(xhr)}}}}catch(err){try{if(typeof(args.onFailure)==="function"){args.onFailure(xhr)}}catch(err){throw new Error(_objErrMsg+".getXhr() -> Error occurred in onFailure()")}}}};if(params){xhr.send(params)}else{xhr.send()}}else{throw new Error(_objErrMsg+".getXhr() -> invalid params given")}}return{getJsonp:getJsonp,getScript:getScript,getXhr:getXhr}})()})();var Overlay=Class.create({current_options:null,holder:null,background:null,holder_shown:false,bckg_shown:false,hiding_in_progress:false,hide_timer:null,click_event_handler:null,window_events_handler:null,content_parent_element:null,content_element:null,init:function(){if(this.holder){return}this.holder=this.init_holder();this.background=this.init_background();Element.extend(document);Element.extend(document.documentElement)},init_holder:function(){var holder=document.createElement("div");Element.extend(holder);holder.identify();holder.style.position="absolute";var opacity=this.option("opacity");if(opacity){holder.setOpacity(opacity)}holder.hide();document.body.appendChild(holder);return holder},position_holder:function(force_reposition){var holder=this.holder;var holder_dims=holder.getDimensions();if(Prototype.Browser.Opera){var viewport_dims={width:window.innerWidth,height:window.innerHeight}}else{var viewport_dims=document.viewport.getDimensions()}var viewport_scroll_offsets=document.viewport.getScrollOffsets();var position=this.option("position");holder.style.left=(viewport_dims.width-holder_dims.width)/2+viewport_scroll_offsets.left+"px";if(this.option("auto_reposition")||force_reposition){if(position=="center"){if(viewport_dims.height<=holder_dims.height){holder.style.top=0}else{holder.style.top=(viewport_dims.height-holder_dims.height)/2+viewport_scroll_offsets.top+"px"}}else{if(position=="top"){holder.style.top=viewport_scroll_offsets.top+"px"}else{if(position=="bottom"){holder.style.top=viewport_dims.height-holder_dims.height+viewport_scroll_offsets.top+"px"}else{throw"Unsupported position: "+position}}}}else{if(position=="center"){holder.style.top=(viewport_dims.height-holder_dims.height)/2+"px"}else{if(position=="top"){holder.style.top="0px"}else{if(position=="bottom"){holder.style.top=viewport_dims.height-holder_dims.height+"px"}else{throw"Unsupported position: "+position}}}}},init_background:function(){var background=document.createElement("div");Element.extend(background);background.style.position="fixed";background.style.left=0;background.style.top=0;background.style.width="100%";background.style.height="100%";background.style.backgroundColor="#000";var bckg_opacity=this.option("bckg_opacity");if(bckg_opacity){background.setOpacity(bckg_opacity)}background.hide();document.body.appendChild(background);return background},position_and_size_background:function(){},update:function(content){this.holder.className=this.option("cls");this.holder.style.zIndex=this.option("z-index");this.background.style.zIndex=this.option("z-index")-1;this.restore_content_element();if(typeof content==typeof""){this.holder.update(content)}else{this.content_element=content;this.content_parent_element=content.parentNode;this.holder.update(null);this.holder.appendChild(content)}this.position_holder(true);if(this.option("modal")){this.background.className=this.option("bckg_cls");this.position_and_size_background()}},show:function(content,options){Overlay.instances.push(this);this.current_options=options;this.clear_hide_timer();$$("select").each(function(e){e.setStyle({visibility:"hidden"})});this.init();this.update(content);this.start_handling_window_events();$$("#"+this.holder.id+" select").each(function(e){e.setStyle({visibility:"visible"})});var beforeshow=this.option("beforeshow");if(beforeshow){beforeshow(this)}if(this.option("animate")){var animation_duration=this.option("animation_duration");var holder_animation_options=this.show_animation_options(false);if(this.holder_shown){new Effect.Opacity(this.holder,holder_animation_options)}else{this.holder.appear(holder_animation_options)}if(this.option("modal")){var bckg_animation_options=this.show_animation_options(true);if(this.bckg_shown){new Effect.Opacity(this.background,bckg_animation_options)}else{this.background.appear(bckg_animation_options)}}else{this.background.fade(this.hide_animation_options(true))}var that=this;setTimeout(function(){that.complete_show()},animation_duration)}else{this.holder.show();this.option("modal")?this.background.show():this.background.hide();this.complete_show()}this.holder_shown=true;this.bckg_shown=Boolean(this.option("modal"));return this},complete_show:function(){var aftershow=this.option("aftershow");if(aftershow){aftershow(this)}this.set_hide_timer();this.start_handling_click_events()},hide:function(){if(this.hiding_in_progress){return}this.hiding_in_progress=true;this.clear_hide_timer();this.stop_handling_click_events();if(this.option("animate")){var animation_duration=this.option("animation_duration");this.holder.fade(this.hide_animation_options(false));if(this.option("modal")){this.background.fade(this.hide_animation_options(true))}var that=this;setTimeout(function(){that.complete_hide()},animation_duration)}else{this.holder.hide();this.background.hide();this.complete_hide()}this.holder_shown=false;this.bckg_shown=false},complete_hide:function(){Overlay.instances=Overlay.instances.without(this);this.stop_handling_window_events();if(Overlay.instances.length==0){$$("select").each(function(e){e.setStyle({visibility:"visible"})})}else{$$("#"+Overlay.instances.last().holder.id+" select").each(function(e){e.setStyle({visibility:"visible"})})}this.clear_hide_timer();this.restore_content_element();var afterhide=this.option("afterhide");if(afterhide){afterhide(this)}this.hiding_in_progress=false},start_handling_click_events:function(){if(!this.option("click_hide")){this.stop_handling_click_events();return}if(!this.click_event_handler){var that=this;this.click_event_handler=function(){that.hide()}}Event.observe(this.holder,"click",this.click_event_handler);Event.observe(this.background,"click",this.click_event_handler)},stop_handling_click_events:function(){Event.stopObserving(this.holder,"click",this.click_event_handler);Event.stopObserving(this.background,"click",this.click_event_handler)},start_handling_window_events:function(){var that=this;if(this.option("modal")){this.window_events_handler=function(){that.position_holder();that.position_and_size_background()}}else{this.window_events_handler=function(){that.position_holder()}}Event.observe(window,"resize",this.window_events_handler);Event.observe(window,"scroll",this.window_events_handler)},stop_handling_window_events:function(){Event.stopObserving(window,"resize",this.window_events_handler);Event.stopObserving(window,"scroll",this.window_events_handler)},set_hide_timer:function(){var auto_hide=this.option("auto_hide");var duration=this.option("duration");if(auto_hide&&duration){var that=this;this.hide_timer=setTimeout(function(){that.hide()},duration)}},clear_hide_timer:function(){if(this.hide_timer){clearTimeout(this.hide_timer);this.hide_timer=null}},option:function(name){if(this.current_options&&this.current_options[name]!==undefined){return this.current_options[name]}if(Overlay.default_options[name]!==undefined){return Overlay.default_options[name]}return null},show_animation_options:function(for_background){return{duration:this.option("animation_duration")/1000,to:this.option(for_background?"bckg_opacity":"opacity")}},hide_animation_options:function(for_background){return{duration:this.option("animation_duration")/1000,from:this.option(for_background?"bckg_opacity":"opacity")}},restore_content_element:function(){if(this.content_element&&this.content_parent_element){this.content_parent_element.appendChild(this.content_element)}this.content_element=null;this.content_parent_element=null}});Object.extend(Overlay,{instances:[],valid_options:["cls","bckg_cls","opacity","bckg_opacity","position","z-index","click_hide","auto_hide","auto_reposition","duration","modal","animate","animation_duration","beforeshow","aftershow","afterhide"],default_options:{"z-index":9999,position:"center",click_hide:true,auto_hide:true,auto_reposition:true,duration:5000,animate:true,animation_duration:500,opacity:0.9,bckg_opacity:0.6},defaults:function(new_default_options){for(name in new_default_options){Overlay.default_options[name]=new_default_options[name]}},hide:function(child){for(var i=0,max=Overlay.instances.length;i<max;i+=1){if(Element.descendantOf(child,Overlay.instances[i].holder)){Overlay.instances[i].hide();break}}}});(function(){var Cursor={x:0,y:0,init:function(){this.setEvent("mouse");this.setEvent("touch")},setEvent:function(type){var moveHandler=document["on"+type+"move"]||function(){};document["on"+type+"move"]=function(e){moveHandler(e);Cursor.refresh(e)}},refresh:function(e){if(!e){e=window.event}if(e.type=="mousemove"){this.set(e)}else{if(e.touches){this.set(e.touches[0])}}},set:function(e){if(e.pageX||e.pageY){this.x=e.pageX;this.y=e.pageY}else{if(e.clientX||e.clientY){this.x=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;this.y=e.clientY+document.body.scrollTop+document.documentElement.scrollTop}}}};Cursor.init();var Position={get:function(obj){var curleft=0,curtop=0;if(obj.offsetParent){do{curleft+=obj.offsetLeft;curtop+=obj.offsetTop}while((obj=obj.offsetParent))}return[curleft,curtop]}};Dragdealer=function(wrapper,options){if(typeof(wrapper)==="string"){wrapper=document.getElementById(wrapper)}if(!wrapper){return}var handle=wrapper.getElementsByTagName("div")[0];if(!handle||handle.className.search(/(^|\s)handle(\s|$)/)==-1){return}this.init(wrapper,handle,options||{});this.setup()};Dragdealer.prototype={init:function(wrapper,handle,options){this.wrapper=wrapper;this.handle=handle;this.options=options;this.disabled=this.getOption("disabled",false);this.horizontal=this.getOption("horizontal",true);this.vertical=this.getOption("vertical",false);this.slide=this.getOption("slide",true);this.steps=this.getOption("steps",0);this.snap=this.getOption("snap",false);this.loose=this.getOption("loose",false);this.speed=this.getOption("speed",10)/100;this.xPrecision=this.getOption("xPrecision",0);this.yPrecision=this.getOption("yPrecision",0);this.callback=options.callback||null;this.animationCallback=options.animationCallback||null;this.bounds={left:options.left||0,right:-(options.right||0),top:options.top||0,bottom:-(options.bottom||0),x0:0,x1:0,xRange:0,y0:0,y1:0,yRange:0};this.value={prev:[-1,-1],current:[options.x||0,options.y||0],target:[options.x||0,options.y||0]};this.offset={wrapper:[0,0],mouse:[0,0],prev:[-999999,-999999],current:[0,0],target:[0,0]};this.change=[0,0];this.activity=false;this.dragging=false;this.tapping=false},getOption:function(name,defaultValue){return this.options[name]!==undefined?this.options[name]:defaultValue},setup:function(){this.setWrapperOffset();this.setBoundsPadding();this.setBounds();this.setSteps();this.addListeners()},setWrapperOffset:function(){this.offset.wrapper=Position.get(this.wrapper)},setBoundsPadding:function(){if(!this.bounds.left&&!this.bounds.right){this.bounds.left=Position.get(this.handle)[0]-this.offset.wrapper[0];this.bounds.right=-this.bounds.left}if(!this.bounds.top&&!this.bounds.bottom){this.bounds.top=Position.get(this.handle)[1]-this.offset.wrapper[1];this.bounds.bottom=-this.bounds.top}},setBounds:function(){this.bounds.x0=this.bounds.left;this.bounds.x1=this.wrapper.offsetWidth+this.bounds.right;this.bounds.xRange=(this.bounds.x1-this.bounds.x0)-this.handle.offsetWidth;this.bounds.y0=this.bounds.top;this.bounds.y1=this.wrapper.offsetHeight+this.bounds.bottom;this.bounds.yRange=(this.bounds.y1-this.bounds.y0)-this.handle.offsetHeight;this.bounds.xStep=1/(this.xPrecision||Math.max(this.wrapper.offsetWidth,this.handle.offsetWidth));this.bounds.yStep=1/(this.yPrecision||Math.max(this.wrapper.offsetHeight,this.handle.offsetHeight))},setSteps:function(){if(this.steps>1){this.stepRatios=[];for(var i=this.steps;i--;){this.stepRatios[i]=i/(this.steps-1)}}},addListeners:function(){var self=this;this.wrapper.onselectstart=function(){return false};this.handle.onmousedown=this.handle.ontouchstart=function(e){self.handleDownHandler(e)};this.wrapper.onmousedown=this.wrapper.ontouchstart=function(e){self.wrapperDownHandler(e)};var mouseUpHandler=document.onmouseup||function(){};document.onmouseup=function(e){mouseUpHandler(e);self.documentUpHandler(e)};var touchEndHandler=document.ontouchend||function(){};document.ontouchend=function(e){touchEndHandler(e);self.documentUpHandler(e)};var resizeHandler=window.onresize||function(){};window.onresize=function(e){resizeHandler(e);self.documentResizeHandler(e)};this.wrapper.onmousemove=function(e){self.activity=true};this.wrapper.onclick=function(e){return !self.activity};this.interval=setInterval(function(){self.animate()},25);self.animate(false,true)},handleDownHandler:function(e){this.activity=false;Cursor.refresh(e);this.preventDefaults(e,true);this.startDrag();this.cancelEvent(e)},wrapperDownHandler:function(e){Cursor.refresh(e);this.preventDefaults(e,true);this.startTap()},documentUpHandler:function(e){this.stopDrag();this.stopTap()},documentResizeHandler:function(e){this.setWrapperOffset();this.setBounds();this.update()},enable:function(){this.disabled=false;this.handle.className=this.handle.className.replace(/\s?disabled/g,"")},disable:function(){this.disabled=true;this.handle.className+=" disabled"},setStep:function(x,y,snap){this.setValue(this.steps&&x>1?(x-1)/(this.steps-1):0,this.steps&&y>1?(y-1)/(this.steps-1):0,snap)},setValue:function(x,y,snap){this.setTargetValue([x,y||0]);if(snap){this.groupCopy(this.value.current,this.value.target)}},startTap:function(target){if(this.disabled){return}this.tapping=true;if(target===undefined){target=[Cursor.x-this.offset.wrapper[0]-(this.handle.offsetWidth/2),Cursor.y-this.offset.wrapper[1]-(this.handle.offsetHeight/2)]}this.setTargetOffset(target)},stopTap:function(){if(this.disabled||!this.tapping){return}this.tapping=false;this.setTargetValue(this.value.current);this.result()},startDrag:function(){if(this.disabled){return}this.offset.mouse=[Cursor.x-Position.get(this.handle)[0],Cursor.y-Position.get(this.handle)[1]];this.dragging=true},stopDrag:function(){if(this.disabled||!this.dragging){return}this.dragging=false;var target=this.groupClone(this.value.current);if(this.slide){var ratioChange=this.change;target[0]+=ratioChange[0]*4;target[1]+=ratioChange[1]*4}this.setTargetValue(target);this.result()},feedback:function(){var value=this.value.current;if(this.snap&&this.steps>1){value=this.getClosestSteps(value)}if(!this.groupCompare(value,this.value.prev)){if(typeof(this.animationCallback)=="function"){this.animationCallback(value[0],value[1])}this.groupCopy(this.value.prev,value)}},result:function(){if(typeof(this.callback)=="function"){this.callback(this.value.target[0],this.value.target[1])}},animate:function(direct,first){if(direct&&!this.dragging){return}if(this.dragging){var prevTarget=this.groupClone(this.value.target);var offset=[Cursor.x-this.offset.wrapper[0]-this.offset.mouse[0],Cursor.y-this.offset.wrapper[1]-this.offset.mouse[1]];this.setTargetOffset(offset,this.loose);this.change=[this.value.target[0]-prevTarget[0],this.value.target[1]-prevTarget[1]]}if(this.dragging||first){this.groupCopy(this.value.current,this.value.target)}if(this.dragging||this.glide()||first){this.update();this.feedback()}},glide:function(){var diff=[this.value.target[0]-this.value.current[0],this.value.target[1]-this.value.current[1]];if(!diff[0]&&!diff[1]){return false}if(Math.abs(diff[0])>this.bounds.xStep||Math.abs(diff[1])>this.bounds.yStep){this.value.current[0]+=diff[0]*this.speed;this.value.current[1]+=diff[1]*this.speed}else{this.groupCopy(this.value.current,this.value.target)}return true},update:function(){if(!this.snap){this.offset.current=this.getOffsetsByRatios(this.value.current)}else{this.offset.current=this.getOffsetsByRatios(this.getClosestSteps(this.value.current))}this.show()},show:function(){if(!this.groupCompare(this.offset.current,this.offset.prev)){if(this.horizontal){if(this.offset.current[0]>=0&&this.offset.current[0]<=parseInt(this.wrapper.style.width)){this.handle.style.left=String(this.offset.current[0])+"px"}}if(this.vertical){if(this.offset.current[1]>=0&&this.offset.current[1]<=parseInt(this.wrapper.style.height)){this.handle.style.top=String(this.offset.current[1])+"px"}}this.groupCopy(this.offset.prev,this.offset.current)}},setTargetValue:function(value,loose){var target=loose?this.getLooseValue(value):this.getProperValue(value);this.groupCopy(this.value.target,target);this.offset.target=this.getOffsetsByRatios(target)},setTargetOffset:function(offset,loose){var value=this.getRatiosByOffsets(offset);var target=loose?this.getLooseValue(value):this.getProperValue(value);this.groupCopy(this.value.target,target);this.offset.target=this.getOffsetsByRatios(target)},getLooseValue:function(value){var proper=this.getProperValue(value);return[proper[0]+((value[0]-proper[0])/4),proper[1]+((value[1]-proper[1])/4)]},getProperValue:function(value){var proper=this.groupClone(value);proper[0]=Math.max(proper[0],0);proper[1]=Math.max(proper[1],0);proper[0]=Math.min(proper[0],1);proper[1]=Math.min(proper[1],1);if((!this.dragging&&!this.tapping)||this.snap){if(this.steps>1){proper=this.getClosestSteps(proper)}}return proper},getRatiosByOffsets:function(group){return[this.getRatioByOffset(group[0],this.bounds.xRange,this.bounds.x0),this.getRatioByOffset(group[1],this.bounds.yRange,this.bounds.y0)]},getRatioByOffset:function(offset,range,padding){return range?(offset-padding)/range:0},getOffsetsByRatios:function(group){return[this.getOffsetByRatio(group[0],this.bounds.xRange,this.bounds.x0),this.getOffsetByRatio(group[1],this.bounds.yRange,this.bounds.y0)]},getOffsetByRatio:function(ratio,range,padding){return Math.round(ratio*range)+padding},getClosestSteps:function(group){return[this.getClosestStep(group[0]),this.getClosestStep(group[1])]},getClosestStep:function(value){var k=0;var min=1;for(var i=this.steps;i--;){if(Math.abs(this.stepRatios[i]-value)<min){min=Math.abs(this.stepRatios[i]-value);k=i}}return this.stepRatios[k]},groupCompare:function(a,b){return a[0]==b[0]&&a[1]==b[1]},groupCopy:function(a,b){a[0]=b[0];a[1]=b[1]},groupClone:function(a){return[a[0],a[1]]},preventDefaults:function(e,selection){if(!e){e=window.event}if(e.preventDefault){e.preventDefault()}e.returnValue=false;if(selection&&document.selection){document.selection.empty()}},cancelEvent:function(e){if(!e){e=window.event}if(e.stopPropagation){e.stopPropagation()}e.cancelBubble=true}}})();UPC.util.Exception=function(){var _objName="UPC.util.Exception";var _objErrMsg="Error in "+_objName+": ";var buttonTemplate=new Template('<button id="err_button_close" class="#{class}"/ value=""><span>#{label}</span></button>');var config={contentTemplate:new Template('<button class="generic_button overlay_close" id="err_close" value=""><span></span></button><h2 class="title">#{title}</h2><p class="generic_content">#{content}</p>'),defaults:{cls:"err_container active",position:"center",modal:true,animate:false,auto_hide:false,click_hide:false,opacity:1},onRaiseReload:true};var contentTemplate=config.contentTenplate;var mainElement=document.createElement("div");var raised=false;var reloadPage=config.onRaiseReload;var OverlayWindow=new Overlay();mainElement.setAttribute("id","err_content_container");document.body.appendChild(mainElement);Element.addClassName(mainElement,"overlay");Element.hide(mainElement);if(!OverlayWindow){throw _objErrMsg+"initialize() -> dependancy library overlay.js is missing"}Event.observe(mainElement,"click",function(e){var element=Event.element(e);if(element.nodeName==="SPAN"&&element.parentNode.nodeName==="BUTTON"){element=element.parentNode}if(element.id&&(element.id==="err_close"||element.id==="err_ok")){raised=false;Element.hide(mainElement);if(reloadPage){window.location.href=window.location.href.replace("https:","http:")}else{OverlayWindow.hide()}}});function raise(msg,title,options){var html="";var okButtonText=null;var params=config.defaults;if(options&&raised===false){if(options.beforeShow&&typeof(options.beforeShow==="function")){params.beforesShow=function(){options.beforeShow}}if(options.hasOwnProperty("onRaiseReload")){reloadPage=options.onRaiseReload?true:false}if(options.afterShow&&typeof(options.afterShow==="function")){params.aftershow=options.afterShow}params.afterhide=function(){if(options.afterHide&&typeof(options.afterHide==="function")){options.afterHide()}reloadPage=config.onRaiseReload;Element.hide(mainElement)}}if(UPC.util.Localization){okButtonText=UPC.util.Localization.getString("buttons.Ok")}if(okButtonText){html=contentTemplate.evaluate({title:title,content:msg,okButtonText:okButtonText||""})}else{html=config.contentTemplate.evaluate({title:title,content:msg})}if(mainElement&&msg&&title&&raised===false){raised=true;mainElement.innerHTML=html;Element.show(mainElement);OverlayWindow.show($("err_content_container"),params)}}function setParams(args){if(args.elementId){mainElement.setAttribute("id",args.elementId)}if(args.contentTemplate){contentTemplate=args.contentTemplate}if(args.onRaiseReload){config.onRaiseReload=args.onRaiseReload?true:false}}return{raise:raise,setParams:setParams}}();UPC.util.Configuration=function(){var config={};function initialize(configObj){if(typeof(configObj)!="undefined"){config=configObj}}function addConfig(key,obj){if(typeof(obj)=="object"){configObj={};configObj[key]=obj;Object.extend(config,configObj);return true}else{return false}}function getConfigValue(key){var result=config;var tmp=null;key=key.split(".");tmp=key.length;for(var part=0;part<tmp;part++){if(result[key[part]]){result=result[key[part]]}else{return null}}if(result){return result}return null}return{init:initialize,setConfig:addConfig,getConfigValue:getConfigValue}}();UPC.util.Localization=function(){var defaultOptions={localeBasePath:new Template("/script/locales/#{locale}/#{application}.js"),application:"default"};var options={};var strings={};var locale="";function initialize(localeStr,userOptions){Object.extend(options,defaultOptions);if(typeof(userOptions)!="undefined"){Object.extend(options,userOptions)}setLocale(localeStr);return this}function setStrings(transport){if(typeof(transport.responseJSON)!="undefined"){strings=Object.extend(strings,transport.responseJSON)}}function getLocale(){var key=null;var result=null;var tmp=null;if(arguments.length==1){key=arguments[0];key=key.split(".");result=strings[locale];if(isLoaded(locale)){tmp=key.length;for(var part=0;part<tmp;part++){if(result[key[part]]){result=result[key[part]]}else{return null}}}return result}else{return locale}}function getLocaleString(key){var result=strings[locale];var tmp=null;key=key.split(".");if(isLoaded(locale)){tmp=key.length;for(var part=0;part<tmp;part++){result=result[key[part]]||""}}if(result&&result.constructor==Array){result=result.join(" ")}if(typeof(result)!=="undefined"){return result}return""}function setLocale(localeStr){if(!isLoaded(localeStr)){var path=options.localeBasePath.evaluate({application:options.application,locale:localeStr});new Ajax.Request(path,{method:"get",onSuccess:function(response){setStrings(response)},onComplete:function(response){if(options.onComplete){options.onComplete()}},onFailure:raiseException,evalJSON:"force"})}locale=localeStr;return localeStr}function isLoaded(localeStr){if(typeof strings[localeStr]!=="undefined"){return true}else{return false}}function raiseException(err){UPC.util.Exception.raise("Locale could not be loaded. ","Error")}return{init:initialize,getString:getLocaleString,isLoaded:isLoaded,getLocale:getLocale,setLocale:setLocale}}();(function(){if(typeof namespace!=="function"){function namespace(ns,separator){var nsParts,tmp=null;var parent=window;if(typeof separator==="undefined"){separator="."}nsParts=ns.split(separator);for(var idx=0,max=nsParts.length;idx<max;idx+=1){parent[nsParts[idx]]=parent[nsParts[idx]]||{};parent=parent[nsParts[idx]]}}}namespace("UPC.util");UPC.util.Validate={isAlphaNumeric:function(arg){var re=/^[a-zA-Z0-9]/i;if(typeof arg!="undefined"){return re.test(arg)}return false},isArray:function(arg){if(arg&&arg.constructor===Array){return true}return false},isBetween:function(arg,min,max){if(this.isInt(arg)&&this.isInt(min)&&this.isInt(max)){return(parseInt(arg,10)>=parseInt(min,10)&&parseInt(arg,10)<=parseInt(max,10))}return false},isBetweenStr:function(arg,min,max){if(this.isString(arg)&&this.isInt(min)&&this.isInt(max)){return(arg.length>=min&&arg.length<=max)}return false},isBoolean:function(arg){if(typeof arg!=="undefined"&&(arg===true||arg===false||arg===1||arg===0)){return true}return false},isDate:function(arg){if(arg){return arg.constructor==Date}return false},isDigit:function(arg){var re=new RegExp("^[0-9]+$","g");return re.test(arg)},isEmail:function(arg){var re=new RegExp("^[a-z0-9_.-]+@([a-z0-9]+([-]+[a-z0-9]+)*.)+[a-z]{2,7}","ig");return re.test(arg)},isEmpty:function(arg){if(arg){if(typeof arg==="object"){for(var obj in arg){if(arg.hasOwnProperty(obj)){return false}}}if(arg.constructor===Array&&arg.length!==0){return false}else{if(typeof arg==="string"&&arg.length!==0){return false}else{if(typeof arg==="number"||typeof arg==="boolean"){return false}}}}return true},isFloat:function(arg){var re=new RegExp("^([+-]?((([0-9]+(.)?)|([0-9]*.[0-9]+))([eE][+-]?[0-9]+)?))$");if(typeof arg!=="undefined"){return re.test(arg)}return false},isFunction:function(arg){return(typeof arg==="function")},isInt:function(arg){return(typeof arg==="number")},isJSON:function(arg){var re=new RegExp("^[,:{}[]0-9.-+Eaeflnr-u \n\r\t]*$","g");if(typeof arg==="string"&&arg.length!==0){arg=arg.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,"");return re.test(arg)}return false},isObject:function(arg){if(typeof arg==="object"){return true}return false},isMember:function(arg,arr){if(this.isArray(arr)){for(var i=arr.length;i--;){if(arr[i]===arg){return true}}}return false},isString:function(arg){if(typeof arg==="string"){return true}return false},isIso8601TimeStamp:function(arg){if(typeof arg==="string"&&arg.length!==0){return/^20\d{2}-\d{2}-\d{2}T\d{2}:\d{2}Z$/.test(arg)}return false},isSession:function(arg){if(arg&&arg.hasOwnProperty("type")&&arg.type==="Session"&&arg.hasOwnProperty("bookings")&&arg.hasOwnProperty("customer")&&arg.hasOwnProperty("favorites")&&this.isArray(arg.bookings)&&this.isArray(arg.favorites)){return true}return false},isUser:function(arg){if(arg&&arg.hasOwnProperty("_type")&&arg.hasOwnProperty("customerId")&&arg.hasOwnProperty("isAccountEnabled")&&arg.hasOwnProperty("givenName")&&arg.hasOwnProperty("familyName")&&arg.hasOwnProperty("boxes")&&arg._type==="User"){return true}return false},isURL:function(arg){var re=new RegExp("^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&?/.=]+$");if(typeof arg==="string"&&arg.length!==0){return re.test(arg)}return false}};UPC.util.Parse={epochToIso8601:function(arg){var date,tmp=null;if(arg<1000000000000){arg*=1000}date=new Date(arg);tmp=[date.getFullYear(),date.getMonth()+1,date.getUTCDate(),date.getUTCHours(),date.getMinutes()];if(arg&&date){return[tmp[0],"-",tmp[1]<10?"0"+tmp[1]:tmp[1],"-",tmp[2]<10?"0"+tmp[2]:tmp[2],"T",tmp[3]<10?"0"+tmp[3]:tmp[3],":",tmp[4]<10?"0"+tmp[4]:tmp[4],"Z"].join("")}else{return null}},hash:function(data,n){var norm=Math.pow(2,-32);var a=2095533;var s=0,c=1;var t,t0=0;data=data.toString();for(var i=0,max=data.length;i<max;i+=1){s-=data.charCodeAt(i)*65537*norm;if(s<0){s+=1}t=a*s+c*norm;t0=s=t-(c=t|0);t=a*s+c*norm;s=t-(c=t|0)}if(n){return Math.floor(n*(s+t0*norm))}else{return s+t0*norm}},iso8601ToEpoch:function(arg){var date=null;var tmp=(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})Z$/).exec(arg);if(tmp&&tmp.length==6){date=new Date(Date.UTC(tmp[1],parseInt(tmp[2],10)-1,tmp[3],tmp[4],tmp[5],0));return date.getTime()}else{return null}},ltrim:function(arg){if(!UPC.util.Validate.isString(arg)||arg.length===0){return null}return arg.replace(/\s*((\S+\s*)*)/,"$1")},rtrim:function(arg){if(!UPC.util.Validate.isString(arg)||arg.length===0){return null}return arg.replace(/((\s*\S+)*)\s*/,"$1")},toQueryString:function(arg){var arr=[],key;if(typeof arg==="object"){for(key in arg){if(arg.hasOwnProperty(key)){arr.push(encodeURIComponent(key)+"="+encodeURIComponent(arg[key]))}}}if(arr.length!==0){return arr.join("&")}return null},trim:function(arg){if(!UPC.util.Validate.isString(arg)||arg.length===0){return null}return this.ltrim(this.rtrim(arg))}}})();(function(){var _objName="EpgObjects",_objErrMsg="Error in "+_objName+"-> ";var P=null,V=null;try{P=UPC.util.Parse;V=UPC.util.Validate}catch(err){throw new Error(_objErrMsg+" dependancy libraries Parse of Validate are not defined")}function _errMsgInvalidArgs(){return"setting of "+(this._type?this._type:"EpgObject")+" failed one or more of the required arguments is invalid"}function _errMsgInvalidOptionalArgs(args){if(V.isArray(args)){return"setting of optional attribute(s) "+args.join(",")+" of "+(this._type?this._type:"EpgObject")+" failed: invalid arguments given"}return"setting of optional attributes of"+(this._type?this._type:"EpgObject")+" failed: one or more of given arguments is invalid"}function _errMsgMissingArgs(){return"setting of "+(this._type?this._type:"EpgObject")+" failed one or more of the required arguments missing"}function _inheritsFrom(parent,child){if(parent.constructor==Function){child.prototype=new parent();child.prototype.constructor=child;child.prototype.parent=parent.prototype}else{child.prototype=parent;child.prototype.constructor=this;child.prototype.parent=parent}}function _makeClass(){return function(args){if(this instanceof arguments.callee){if(args&&typeof this.init==="function"){this.init.apply(this,args.callee?args:arguments)}}else{return new arguments.callee(arguments)}return null}}function _setBooleanProperty(property,bool){if(property&&V.isBoolean(bool)){this._attr[property]=bool;return true}return false}function _setDateProperty(property,date){var epoch=null;if(V.isDate(date)){this._attr[property]=date;return true}else{if(V.isIso8601TimeStamp(date)){epoch=P.iso8601ToEpoch(date);if(epoch){this._attr[property]=new Date(epoch);return true}}}return false}function _setDigitProperty(property,digit){if(property&&V.isDigit(digit)){this._attr[property]=digit*1;return true}return false}function _setIntegerProperty(property,integer){if(property&&V.isDigit(integer)){this._attr[property]=parseInt(integer,10);return true}return false}function _setStringProperty(property,str){if(property&&V.isString(str)){this._attr[property]=str;return true}return false}var EmptyFunction=function(){};var EpgCore=EmptyFunction;EpgCore.prototype=new (function(){this.constructor=EpgCore;this._attr={};this._type="Core";this.getId=function(){return this._attr.id||null};this.getObjectType=function(){return this._type||null};this.isset=function(arg){if(!(typeof this._attr[arg]==="undefined"||typeof this._attr[arg]===null)){return true}return false}});var EpgObjectsContainer=_makeClass();EpgObjectsContainer.prototype._type="ObjectsContainer";function _delObjectsContainer(arg){if((V.isString(arg)||V.isDigit(arg))&&this._attr.objects[arg]&&this.length>0){if(this.callbacks&&V.isFunction(this.callbacks.onDelete)){this.callbacks.onDelete.call(this,arg)}delete this._attr.objects[arg];this.length--;return true}return false}function _eachObjectsContainerItem(arg){var index=0,object=null,objects=this._attr.objects;if(V.isFunction(arg)&&objects){for(object in objects){if(objects.hasOwnProperty(object)){arg(objects[object],object,index);index+=1}}}}function _getObjectsContainer(arg){if(this._attr.objects){if(!arg){return this._attr.objects||null}else{if((V.isString(arg)||V.isDigit(arg))&&this._attr.objects[arg]){return this._attr.objects[arg]}}}return null}function _getObjectsContainerArray(arg){var arr=[],keys=null,object,objects;if(this._attr.objects){objects=this._attr.objects;if(V.isArray(arg)){for(var i=0,max=arg.length;i<max;i+=1){if(this.hasMember(arg[i])){arr[arr.length]=objects[arg[i]]}}}else{for(object in objects){if(objects.hasOwnProperty(object)){arr[arr.length]=objects[object]}}}}return arr}function _hasMember(id){if(id&&typeof this._attr.objects[id]!=="undefined"){return true}return false}function _setObjectsContainer(arg,strict,objectType){var isWithoutErrors=true,object=null,tmp={};if(V.isArray(arg)&&arg.length!==0){for(var i=0,max=arg.length;i<max;i++){if(!_setObjectsContainer.call(this,arg[i],strict,objectType)&&strict){throw new Error(_errMsgInvalidArgs.call(this))}else{isWithoutErrors=false}}if(isWithoutErrors){return true}}else{try{if(arg instanceof (objectType)){object=arg}else{if(!V.isEmpty(arg)){object=new objectType(arg,true)}}if(object&&!V.isObject(this._attr.objects[object.getId()])){this.length++;this._attr.objects[object.getId()]=object;if(this.callbacks&&V.isFunction(this.callbacks.onInsert)){this.callbacks.onInsert.call(this,object)}if(!this.objectType&&V.isFunction(object.getObjectType)){this.objectType=object.getObjectType()}}}catch(err){if(strict){throw new Error(_errMsgInvalidArgs.call(this))}return false}return true}return false}EpgObjectsContainer.prototype.del=function(arg){return _delObjectsContainer.call(this,arg)};EpgObjectsContainer.prototype.each=function(arg){return _eachObjectsContainerItem.call(this,arg)};EpgObjectsContainer.prototype.get=function(arg){return _getObjectsContainer.call(this,arg)};EpgObjectsContainer.prototype.getArray=function(arg){return _getObjectsContainerArray.call(this,arg)};EpgObjectsContainer.prototype.getLength=function(){return this.length||null};EpgObjectsContainer.prototype.getObjectType=function(){return this.objectType||null};EpgObjectsContainer.prototype.hasMember=function(id){return _hasMember.call(this,id)};EpgObjectsContainer.prototype.init=function(objectType,arg,strict,callbacks){this._attr={objects:{}};this.length=0;if(callbacks){this.callbacks=callbacks}this.set=function(arg,strict){return _setObjectsContainer.call(this,arg,strict,objectType)};if(arg){this.set(arg,strict)}this.init=EmptyFunction};EpgChannel=_makeClass();_inheritsFrom(EpgCore,EpgChannel);EpgChannel.prototype._type="Channel";function _setBroadcastFormat(broadcastFormat){if(V.isString(broadcastFormat)){broadcastFormat=broadcastFormat.toUpperCase();if(broadcastFormat==="SD"){this._attr.broadcastFormat="SD";return true}else{if(broadcastFormat==="HD"){this._attr.broadcastFormat="HD";return true}}}return false}function _setChannel(args,strict){var notSet=[];if(args){if(args.hasOwnProperty("broadcastFormat")&&!this.setBroadcastFormat(args.broadcastFormat)){notSet[notSet.length]="broadcastFormat"}if(args.hasOwnProperty("description")&&!this.setDescription(args.description)){notSet[notSet.length]="description"}if(args.hasOwnProperty("liveTvUrl")&&!this.setLiveTvUrl(args.liveTvUrl)){notSet[notSet.length]="liveTvUrl"}if(args.hasOwnProperty("logoIMG")){args.logoImg=args.logoIMG}if(args.hasOwnProperty("logoImg")&&!this.setLogoImg(args.logoImg)){notSet[notSet.length]="logoImg"}if(args.hasOwnProperty("position")&&!this.setPosition(args.position)){notSet[notSet.length]="position"}if(args.hasOwnProperty("url")&&!this.setUrl(args.url)){notSet[notSet.length]="url"}if(notSet.length===0){return true}else{if(strict){throw new Error(_errMsgInvalidOptionalArgs.call(this,notSet))}}}return false}EpgChannel.prototype.getName=function(){return this._attr.name};EpgChannel.prototype.getBroadcastFormat=function(){return this._attr.broadcastFormat||null};EpgChannel.prototype.getDescription=function(){return this._attr.description||null};EpgChannel.prototype.getLiveTvUrl=function(){return this._attr.getLiveTvUrl||null};EpgChannel.prototype.getLogoImg=function(){return this._attr.getLogoImg||null};EpgChannel.prototype.getPosition=function(){return this._attr.position||null};EpgChannel.prototype.getUrl=function(){return this._attr.url||null};EpgChannel.prototype.isHd=function(){var type=this.getBroadcastFormat();if(type==="HD"){return true}return false};EpgChannel.prototype.set=function(args,strict){return _setChannel.call(this,args,strict)};EpgChannel.prototype.setBroadcastFormat=function(broadcastFormat){return _setBroadcastFormat.call(this,broadcastFormat)};EpgChannel.prototype.setDescription=function(description){return _setStringProperty.call(this,"description",description)};EpgChannel.prototype.setLiveTvUrl=function(liveTvUrl){return _setStringProperty.call(this,"liveTvUrl",liveTvUrl)};EpgChannel.prototype.setLogoImg=function(logoImg){return _setStringProperty.call(this,"logoImg",logoImg)};EpgChannel.prototype.setPosition=function(position){return _setDigitProperty.call(this,"position",position)};EpgChannel.prototype.setUrl=function(url){return _setStringProperty.call(this,"url",url)};EpgChannel.prototype.init=function(args,strict){this._attr={};if(!(args.hasOwnProperty("id")&&args.hasOwnProperty("name"))){throw new Error(_errMsgMissingArgs.call(this))}if(!(_setStringProperty.call(this,"id",args.id)&&_setStringProperty.call(this,"name",args.name))){throw new Error(_errMsgInvalidArgs.call(this))}_setChannel.call(this,args,strict);this.init=EmptyFunction};EpgChannels=_makeClass();_inheritsFrom(EpgObjectsContainer,EpgChannels);EpgChannels.prototype._type="Channels";function _getHdChannels(){var channelId,channels;if(!V.isArray(this.filter.hd)){channels=this.get();if(channels){this.filter.hd=[];for(channelId in channels){if(channels.hasOwnProperty(channelId)){if(channels[channelId].isHd()){this.filter.hd.push(channels[channelId].getId())}}}}}if(!V.isEmpty(this.filter.hd)){return this.filter.hd}return null}EpgChannels.prototype.getHdChannels=function(){return _getHdChannels.call(this)};EpgChannels.prototype.init=function(args,strict){this._attr={};this.filter={};this.parent.init.call(this,EpgChannel,args,strict,{onDel:function(object){try{delete objects[object.getName()];return true}catch(err){return false}},onInsert:function(object){if(V.isFunction(object.getName)){this._attr.objects[object.getName()]=object}}});this.init=EmptyFunction};EpgProgramme=_makeClass();_inheritsFrom(EpgCore,EpgProgramme);EpgProgramme.prototype._type="Programme";function _setProgramme(args,strict){var notSet=[];if(args){if(args.hasOwnProperty("ageRating")&&!this.setAgeRating(args.ageRating)){notSet[notSet.length]="ageRating"}if(args.hasOwnProperty("countryOfOrigin")&&!this.setCountryOfOrigin(args.countryOfOrigin)){notSet[notSet.length]="countryOfOrigin"}if(args.hasOwnProperty("displayRating")&&!this.setDisplayRating(args.displayRating)){notSet[notSet.length]="displayRating"}if(args.hasOwnProperty("episodeTitle")&&!this.setEpisodeTitle(args.episodeTitle)){notSet[notSet.length]="episodeTitle"}if(args.hasOwnProperty("seriesId")&&!this.setSeriesId(args.seriesId)){notSet[notSet.length]="seriesId"}if(args.hasOwnProperty("shortDescription")&&!this.setShortDescription(args.shortDescription)){notSet[notSet.length]="shortDescription"}if(args.hasOwnProperty("subcategory")&&!this.setSubcategory(args.subcategory)){notSet[notSet.length]="subcategory"}if(args.hasOwnProperty("yearOfRelease")&&!this.setYearOfRelease(args.yearOfRelease)){notSet[notSet.length]="yearOfRelease"}if(notSet.length===0){return true}else{if(strict){throw new Error(_errMsgInvalidOptionalArgs.call(this,notSet))}}}return false}function _setProgrammeSubcategory(subcategory,strict){if(subcategory instanceof EpgSubcategory){this._attr.subcategory=subcategory;return true}else{if(subcategory&&V.isString(subcategory.id)&&V.isString(subcategory.name)){this._attr.subcategory=new EpgSubcategory(subcategory,strict);return true}}return false}EpgProgramme.prototype.getAgeRating=function(){return this._attr.ageRating||null};EpgProgramme.prototype.getCountryOfOrigin=function(){return this._attr.countryOfOrigin||null};EpgProgramme.prototype.getDisplayRating=function(){return this._attr.displayRating||null};EpgProgramme.prototype.getEpisodeTitle=function(){return this._attr.episodeTitle||null};EpgProgramme.prototype.getSeriesId=function(){return this._attr.seriesId||null};EpgProgramme.prototype.getShortDescription=function(){return this._attr.shortDescription||null};EpgProgramme.prototype.getSubcategory=function(){return this._attr.subcategory||null};EpgProgramme.prototype.getTitle=function(){return this._attr.title||null};EpgProgramme.prototype.getYearOfRelease=function(){return this._attr.yearOfRelease||null};EpgProgramme.prototype.set=function(args,strict){return _setProgramme.call(this,args,strict)};EpgProgramme.prototype.setAgeRating=function(ageRating){return _setIntegerProperty.call(this,"ageRating",ageRating)};EpgProgramme.prototype.setCountryOfOrigin=function(countryOfOrigin){return _setStringProperty.call(this,"countryOfOrigin",countryOfOrigin)};EpgProgramme.prototype.setDisplayRating=function(displayRating){return _setStringProperty.call(this,"displayRating",displayRating)};EpgProgramme.prototype.setEpisodeTitle=function(episodeTitle){return _setStringProperty.call(this,"episodeTitle",episodeTitle)};EpgProgramme.prototype.setSeriesId=function(seriesId){return _setDigitProperty.call(this,"seriesId",seriesId)};EpgProgramme.prototype.setShortDescription=function(shortDescription){return _setStringProperty.call(this,"shortDescription",shortDescription)};EpgProgramme.prototype.setSubcategory=function(subcategory,strict){return _setProgrammeSubcategory.call(this,subcategory,strict)};EpgProgramme.prototype.setYearOfRelease=function(yearOfRelease){return _setIntegerProperty.call(this,"yearOfRelease",yearOfRelease)};EpgProgramme.prototype.init=function(args,strict){this._attr={};if(!(args.hasOwnProperty("id")&&args.hasOwnProperty("title"))){throw new Error(_errMsgMissingArgs.call(this))}if(!(_setDigitProperty.call(this,"id",args.id)&&_setStringProperty.call(this,"title",args.title))){throw new Error(_errMsgInvalidArgs.call(this))}_setProgramme.call(this,args,strict);this.init=EmptyFunction};EpgProgrammes=_makeClass();_inheritsFrom(EpgObjectsContainer,EpgProgrammes);EpgProgrammes.prototype._type="Programmes";EpgProgrammes.prototype.init=function(args,strict){this._attr={};this.filter={};this.parent.init.call(this,EpgProgramme,args,strict);this.init=EmptyFunction};EpgEvent=_makeClass();_inheritsFrom(EpgCore,EpgEvent);EpgEvent.prototype._type="Event";function _getIso8601EndDateTime(){return P.epochToIso8601(this._attr.endDateTime.getTime())||null}function _getIso8601StartDateTime(){return P.epochToIso8601(this._attr.startDateTime.getTime())||null}function _setEvent(args,strict){var notSet=[];if(args){if(args.hasOwnProperty("channel")&&!this.setChannel(args.channel)){notSet[notSet.length]="channel"}if(args.hasOwnProperty("endDateTime")&&!this.setEndDateTime(args.endDateTime)){notSet[notSet.length]="endDateTime"}if(args.hasOwnProperty("programme")&&!this.setProgramme(args.programme)){notSet[notSet.length]="programme"}if(args.hasOwnProperty("url")&&!this.setUrl(args.url)){notSet[notSet.length]="url"}if(notSet.length===0){return true}else{if(strict){throw new Error(_errMsgInvalidOptionalArgs.call(this,notSet))}}}return false}function _setEventChannel(channel,strict){if(channel instanceof EpgChannel){this._attr.channel=channel;return true}else{if(channel&&V.isString(channel.id)&&V.isString(channel.name)){this._attr.channel=new EpgChannel(channel,strict);return true}}return false}function _setEventProgramme(programme){if(programme instanceof EpgProgramme){this._attr.programme=programme;return true}else{if(programme&&V.isDigit(programme.id)&&V.isString(programme.title)){this._attr.programme=new EpgProgramme(programme);return true}}return false}EpgEvent.prototype.getChannel=function(){return this._attr.channel||null};EpgEvent.prototype.getEndDateTime=function(){return this._attr.endDateTime||null};EpgEvent.prototype.getIso8601EndDateTime=function(){return _getIso8601EndDateTime.call(this)};EpgEvent.prototype.getIso8601StartDateTime=function(){return _getIso8601StartDateTime.call(this)};EpgEvent.prototype.getProgramme=function(){return this._attr.programme||null};EpgEvent.prototype.getStartDateTime=function(){return this._attr.startDateTime||null};EpgEvent.prototype.getUrl=function(){return this._attr.url||null};EpgEvent.prototype.getGridUrl=function(){return"/TV/?eId="+["eid",this.getId(),this.getChannel().getId(),this.getIso8601StartDateTime()].join("_")};EpgEvent.prototype.set=function(args,strict){return _setEvent.call(this,args,strict)};EpgEvent.prototype.setChannel=function(channel,strict){return _setEventChannel.call(this,channel,strict)};EpgEvent.prototype.setEndDateTime=function(endDateTime){return _setDateProperty.call(this,"endDateTime",endDateTime)};EpgEvent.prototype.setProgramme=function(programme,strict){return _setEventProgramme.call(this,programme,strict)};EpgEvent.prototype.setUrl=function(url){return _setStringProperty.call(this,"url",url)};EpgEvent.prototype.init=function(args,strict){this._attr={};if(!(args.hasOwnProperty("id")&&args.hasOwnProperty("startDateTime"))){throw new Error(_errMsgMissingArgs.call(this))}if(!(_setDigitProperty.call(this,"id",args.id)&&_setDateProperty.call(this,"startDateTime",args.startDateTime))){throw new Error(_errMsgInvalidArgs.call(this))}_setEvent.call(this,args,strict);this.init=EmptyFunction};EpgEvents=_makeClass();_inheritsFrom(EpgObjectsContainer,EpgEvents);EpgEvents.prototype._type="Events";EpgEvents.prototype.init=function(args,strict){this._attr={};this.filter={};this.parent.init.call(this,EpgEvent,args,strict);this.init=EmptyFunction};EpgBooking=_makeClass();_inheritsFrom(EpgEvent,EpgBooking);EpgBooking.prototype._type="Booking";function _hasSeriesId(){if(this._attr.hasOwnProperty("seriesId")){return true}return false}function _setBooking(args,strict){var notSet=[];if(args){if(args.hasOwnProperty("channelId")&&!this.setChannelId(args.channelId)){notSet[notSet.length]="channelId"}if(args.hasOwnProperty("programmeId")&&!this.setProgrammeId(args.programmeId)){notSet[notSet.length]="programmeId"}if(args.hasOwnProperty("status")&&!this.setStatus(args.status)){notSet[notSet.length]="status"}if(args.hasOwnProperty("statusCode")&&!this.setStatusCode(args.statusCode)){notSet[notSet.length]="statusCode"}if(args.hasOwnProperty("seriesId")&&!this.setSeriesId(args.seriesId)){notSet[notSet.length]="seriesId"}if(args.hasOwnProperty("tx_id")){args.txId=args.tx_id}if(args.hasOwnProperty("txId")&&!this.setTxId(args.txId)){notSet[notSet.length]="txId"}if(notSet.length===0){return true}else{if(strict){throw new Error(_errMsgInvalidOptionalArgs.call(this,notSet))}}}return false}function _setStatus(status){var statuses=["success","failure","pending","waiting"];if(V.isMember(status,statuses)){this._attr.status=status;return true}return false}EpgBooking.prototype.getTxId=function(){return this._attr.txId||null};EpgBooking.prototype.getChannelId=function(){return this._attr.channelId||null};EpgBooking.prototype.getEventId=function(){return this._attr.id||null};EpgBooking.prototype.getProgrammeId=function(){return this._attr.programmeId||null};EpgBooking.prototype.getStatus=function(){return this._attr.status||null};EpgBooking.prototype.getStatusCode=function(){return this._attr.statusCode||null};EpgBooking.prototype.getSeriesId=function(){return this._attr.seriesId||null};EpgBooking.prototype.hasSeriesId=function(){return _hasSeriesId.call(this)};EpgBooking.prototype.set=function(args,strict){return _setBooking.call(this,args,strict)};EpgBooking.prototype.setChannelId=function(channelId){return _setStringProperty.call(this,"channelId",channelId)};EpgBooking.prototype.setEventId=function(id){return _setId.call(this,id)};EpgBooking.prototype.setProgrammeId=function(programmeId){return _setDigitProperty.call(this,"programmeId",programmeId)};EpgBooking.prototype.setStatus=function(status){return _setStatus.call(this,status)};EpgBooking.prototype.setStatusCode=function(statusCode){return _setDigitProperty.call(this,"statusCode",statusCode)};EpgBooking.prototype.setSeriesId=function(seriesId){return _setDigitProperty.call(this,"seriesId",seriesId)};EpgBooking.prototype.setTxId=function(txId){return _setStringProperty.call(this,"txId",txId)};EpgBooking.prototype.init=function(args,strict){this._attr={status:"pending"};if(args.eventId){args.id=args.eventId}if(!(_setDigitProperty.call(this,"id",args.id)&&_setDateProperty.call(this,"startDateTime",args.startDateTime))){throw new Error(_errMsgInvalidArgs.call(this))}_setBooking.call(this,args,strict);this.init=EmptyFunction};EpgBookings=_makeClass();_inheritsFrom(EpgObjectsContainer,EpgBookings);EpgBookings.prototype._type="Bookings";EpgBookings.prototype.init=function(args,strict){this._attr={};this.filter={};this.parent.init.call(this,EpgBooking,args,strict);this.init=EmptyFunction};EpgReminder=_makeClass();_inheritsFrom(EpgBooking,EpgReminder);EpgReminder.prototype._type="Reminder";EpgReminders=_makeClass();_inheritsFrom(EpgObjectsContainer,EpgReminders);EpgReminders.prototype._type="Reminders";EpgReminders.prototype.init=function(args,strict){this._attr={};this.filter={};this.parent.init.call(this,EpgReminder,args,strict);this.init=EmptyFunction};EpgDomain=_makeClass();_inheritsFrom(EpgCore,EpgDomain);EpgDomain.prototype._type="Domain";function _setDomain(args){var notSet=[];if(args){if(args.hasOwnProperty("channelId")&&!this.setChannelId(args.channelId)){notSet[notSet.length]="channelId"}if(notSet.length===0){return true}else{if(strict){throw new Error(_errMsgInvalidOptionalArgs.call(this,notSet))}}}return false}EpgDomain.prototype.getName=function(){return this._attr.name||null};EpgDomain.prototype.set=function(args,strict){return _set.call(this,args,strict)};EpgDomain.prototype.init=function(args,strict){this._attr={};if(!(args.hasOwnProperty("id")&&args.hasOwnProperty("name"))){throw new Error(_errMsgMissingArgs.call(this))}if(!(_setDigitProperty.call(this,"id",args.id)&&_setStringProperty.call(this,"name",args.name))){throw new Error(_errMsgInvalidArgs.call(this))}_setDomain.call(this,args,strict);this.init=EmptyFunction};EpgDomains=_makeClass();_inheritsFrom(EpgObjectsContainer,EpgDomains);EpgDomains.prototype._type="Domains";EpgDomains.prototype.init=function(args,strict){this._attr={};this.filter={};this.parent.init.call(this,EpgDomain,args,strict);this.init=EmptyFunction};EpgGroup=_makeClass();_inheritsFrom(EpgCore,EpgGroup);EpgGroup.prototype._type="Group";function _setGroup(args){var notSet=[];if(args){if(args.hasOwnProperty("channelId")&&!this.setChannelId(args.channelId)){notSet[notSet.length]="channelId"}if(notSet.length===0){return true}else{if(strict){throw new Error(_errMsgInvalidOptionalArgs.call(this,notSet))}}}return false}EpgGroup.prototype.getName=function(){return this._attr.name||null};EpgGroup.prototype.set=function(args,strict){return _set.call(this,args,strict)};EpgGroup.prototype.setName=function(name){return _setStringProperty.call(this,"name",name)};EpgGroup.prototype.init=function(args,strict){this._attr={};if(!args.hasOwnProperty("id")){throw new Error(_errMsgMissingArgs.call(this))}if(!_setDigitProperty.call(this,"id",args.id)){throw new Error(_errMsgInvalidArgs.call(this))}_setGroup.call(this,args,strict);this.init=EmptyFunction};EpgGroups=_makeClass();_inheritsFrom(EpgObjectsContainer,EpgGroups);EpgGroups.prototype._type="Groups";EpgGroups.prototype.init=function(args,strict){this._attr={};this.filter={};this.parent.init.call(this,EpgGroup,args,strict);this.init=EmptyFunction};EpgCategory=_makeClass();_inheritsFrom(EpgCore,EpgCategory);EpgCategory.prototype._type="Category";EpgCategory.prototype.getName=function(){return this._attr.name||null};EpgCategory.prototype.set=function(args,strict){return _set.call(this,args,strict)};EpgCategory.prototype.init=function(args,strict){this._attr={};if(!(args.hasOwnProperty("id")&&args.hasOwnProperty("name"))){throw new Error(_errMsgMissingArgs.call(this))}if(!(_setStringProperty.call(this,"id",args.id)&&_setStringProperty.call(this,"name",args.name))){throw new Error(_errMsgInvalidArgs.call(this))}this.init=EmptyFunction};EpgCategories=_makeClass();_inheritsFrom(EpgObjectsContainer,EpgCategories);EpgCategories.prototype._type="Categories";EpgCategories.prototype.init=function(args,strict){this._attr={};this.filter={};this.parent.init.call(this,EpgCategory,args,strict);this.init=EmptyFunction};EpgSubcategory=_makeClass();_inheritsFrom(EpgCore,EpgSubcategory);EpgSubcategory.prototype._type="Subcategory";function _setSubcategory(args,strict){var notSet=[];if(args){if(args.hasOwnProperty("category")&&!this.setCategory(args.category)){notSet[notSet.length]="category"}if(notSet.length===0){return true}else{if(strict){throw new Error(_errMsgInvalidOptionalArgs.call(this,notSet))}}}return false}function _setSubcategoryCategory(category,strict){if(category instanceof EpgCategory){this._attr.category=category;return true}else{if(category&&V.isString(category.id)&&V.isString(category.name)){this._attr.category=new EpgCategory(category,strict);return true}}return false}EpgSubcategory.prototype.getCategory=function(){return this._attr.category||null};EpgSubcategory.prototype.getName=function(){return this._attr.name||null};EpgSubcategory.prototype.set=function(args,strict){return _set.call(this,args,strict)};EpgSubcategory.prototype.setCategory=function(category,strict){return _setSubcategoryCategory.call(this,category,strict)};EpgSubcategory.prototype.init=function(args,strict){this._attr={};if(!(args.hasOwnProperty("id")&&args.hasOwnProperty("name"))){throw new Error(_errMsgMissingArgs.call(this))}if(!(_setStringProperty.call(this,"id",args.id)&&_setStringProperty.call(this,"name",args.name))){throw new Error(_errMsgInvalidArgs.call(this))}_setSubcategory.call(this,args,strict);this.init=EmptyFunction};EpgSubcategories=_makeClass();_inheritsFrom(EpgObjectsContainer,EpgSubcategories);EpgSubcategories.prototype._type="Subcategories";EpgSubcategories.prototype.init=function(args,strict){this._attr={};this.filter={};this.parent.init.call(this,EpgSubcategory,args,strict);this.init=EmptyFunction};EpgSetTopBox=_makeClass();_inheritsFrom(EpgCore,EpgSetTopBox);EpgSetTopBox.prototype._type="SetTopBox";function _setType(type){var types=["STB","DVR"];if(V.isMember(type,types)){this._attr.type=type;return true}return false}function _setBoxStatus(status){var statuses=["offline","standby","online","unknown"];if(V.isMember(status,statuses)){this._attr.status=status;return true}return false}function _setReadyForServiceValue(value){if(V.isBoolean(value)){this._attr.isReadyForService=value;return true}return false}function _setSetTopBox(args,strict){var notSet=[];if(args){if(args.hasOwnProperty("description")&&!this.setDescription(args.description)){notSet[notSet.length]="description"}if(args.hasOwnProperty("hasIncompatibleSubscription")&&!this.setHasIncompatibleSubscription(args.hasIncompatibleSubscription)){notSet[notSet.length]="hasIncompatibleSubscription"}if(args.hasOwnProperty("isBookingsCapable")&&!this.setIsBookingsCapable(args.isBookingsCapable)){notSet[notSet.length]="isBookingsCapable"}if(args.hasOwnProperty("isHdCapable")&&!this.setIsHdCapable(args.isHdCapable)){notSet[notSet.length]="isHdCapable"}if(args.hasOwnProperty("status")&&!this.setStatus(args.status)){notSet[notSet.length]="status"}if(args.hasOwnProperty("isReadyForService")){this.setReadyForServiceValue(args.isReadyForService)}if(notSet.length===0){return true}else{if(strict){throw new Error(_errMsgInvalidOptionalArgs.call(this,notSet))}}}return false}EpgSetTopBox.prototype.getDescription=function(){return this._attr.description||null};EpgSetTopBox.prototype.getHasIncompatibleSubscription=function(){return this._attr.hasIncompatibleSubscription||false};EpgSetTopBox.prototype.isBookingsCapable=function(){return this._attr.isBookingsCapable||false};EpgSetTopBox.prototype.getIsHdCapable=function(){return this._attr.isHdCapable||false};EpgSetTopBox.prototype.getSmartCardId=function(){return this._attr.id||null};EpgSetTopBox.prototype.getStatus=function(){return this._attr.status||null};EpgSetTopBox.prototype.getType=function(){return this._attr.type||null};EpgSetTopBox.prototype.isReadyForService=function(){return this._attr.isReadyForService||false};EpgSetTopBox.prototype.set=function(args,strict){return _setSetTopBox.call(this,args,strict)};EpgSetTopBox.prototype.setDescription=function(description){return _setStringProperty.call(this,"description",description)};EpgSetTopBox.prototype.setHasIncompatibleSubscription=function(hasIncompatibleSubscription){return _setBooleanProperty.call(this,"hasIncompatibleSubscription",hasIncompatibleSubscription)};EpgSetTopBox.prototype.setIsHdCapable=function(isHdCapable){return _setBooleanProperty.call(this,"isHdCapable",isHdCapable)};EpgSetTopBox.prototype.setIsBookingsCapable=function(isBookingsCapable){return _setBooleanProperty.call(this,"isBookingsCapable",isBookingsCapable)};EpgSetTopBox.prototype.setStatus=function(status){return _setBoxStatus.call(this,status)};EpgSetTopBox.prototype.setReadyForServiceValue=function(value){return _setBooleanProperty.call(this,"isReadyForService",value)};EpgSetTopBox.prototype.init=function(args,strict){this._attr={};if(args.smartCardId){args.id=args.smartCardId}if(!(_setStringProperty.call(this,"id",args.id)&&_setType.call(this,args.type))){throw new Error(_errMsgInvalidArgs.call(this))}_setSetTopBox.call(this,args,strict);this.init=EmptyFunction};EpgSetTopBoxes=_makeClass();_inheritsFrom(EpgObjectsContainer,EpgSetTopBoxes);EpgSetTopBoxes.prototype._type="SetTopBoxes";EpgSetTopBoxes.prototype.init=function(args,strict){this._attr={};this.filter={};this.parent.init.call(this,EpgSetTopBox,args,strict);this.init=EmptyFunction};EpgUser=_makeClass();_inheritsFrom(EpgCore,EpgUser);function _addFavouriteChannelId(channelId){if(V.isString(channelId)){if(!V.isMember(channelId,this._attr.favouriteChannels)){this._attr.favouriteChannels[this._attr.favouriteChannels.length]=channelId}return true}return false}function _deleteFavouriteChannelId(channelId){var i=0;if(V.isString(channelId)&&V.isMember(channelId,this._attr.favouriteChannels)){while(i<this._attr.favouriteChannels.length){if(this._attr.favouriteChannels[i]==channelId){this._attr.favouriteChannels.splice(i,1)}else{i++}}return true}return false}function _getBox(){if(V.isDigit(this._attr.defaultSmartCardId)&&this._attr.boxes.get(this._attr.defaultSmartCardId)){return this._attr.boxes.get(this._attr.defaultSmartCardId)}return null}function _getBoxById(id){if(V.isDigit(id)&&this._attr.boxes.hasMember(id)){return this._attr.boxes.get(id)}return null}function _hasDvr(){var box=_getBox.call(this);if(box&&box.getType()==="DVR"){return true}return false}function _hasAtLeastOneDvrBox(){var boxes=this._attr.boxes.getArray();return boxes.some(function(box){return box.getType()==="DVR"})}function _hasHdCapableBox(){var box=_getBox.call(this),boxType;if(box){boxType=box.getType();if(box.getIsHdCapable()){return true}}return false}function _hasCompatibleBox(){var box=_getBox.call(this),boxType;if(box){boxType=box.getType();if((boxType==="DVR"||boxType==="STB")&&box.isBookingsCapable()){return true}}return false}function _hasIncompatibleSubscription(){var box=_getBox.call(this);if(box&&box.getHasIncompatibleSubscription()){return true}return false}function _hasStb(){var box=_getBox.call(this),boxType;if(box){boxType=box.getType();if(boxType==="DVR"||boxType==="STB"){return true}}return false}function _setBoxes(args,strict){if(this.isset(this._attr.boxes)){delete this._attr.boxes}this._attr.boxes=new EpgSetTopBoxes(args,strict);if(!V.isEmpty(this._attr.boxes)){return true}return false}function _setFavourites(arg){var j=0;if(V.isArray(arg)){this._attr.favouriteChannels=[];for(var i=arg.length;i--;){if(_addFavouriteChannelId.call(this,arg[i])){j++}}if(j===arg.length){return true}}return false}function _setFavouriteChannels(arg){if(V.isArray(arg)){return _setFavourites.call(this,arg)}return false}function _setEmailConfig(args){var emailConfig=this._attr.emailConfig;if(V.isString(args.recipient)){emailConfig.recipient=args.recipient}else{emailConfig.recipient=""}if(V.isBoolean(args.isVerified)){emailConfig.isVerified=args.isVerified}else{emailConfig.isVerified=false}if(V.isBoolean(args.isEnabled)){emailConfig.isEnabled=args.isEnabled}else{emailConfig.isEnabled=false}if(args.hasOwnProperty("recipient")||args.hasOwnProperty("isEnabled")||args.hasOwnProperty("isVerified")){return true}return false}function _setIsAccountEnabled(arg){if(V.isBoolean(arg)){this._attr.isAccountEnabled=arg;return true}else{this._attr.isAccountEnabled=false;return false}}function _setPushConfig(args){var pushConfig=this._attr.pushConfig;if(V.isString(args.recipient)){pushConfig.recipient=args.recipient}else{pushConfig.recipient=""}if(V.isBoolean(args.isVerified)){pushConfig.isVerified=args.isVerified}else{pushConfig.isVerified=false}if(V.isBoolean(args.isEnabled)){pushConfig.isEnabled=args.isEnabled}else{pushConfig.isEnabled=false}if(args.hasOwnProperty("recipient")||args.hasOwnProperty("isEnabled")||args.hasOwnProperty("isVerified")){return true}return false}function _setSmsConfig(args){var smsConfig=this._attr.smsConfig;if(V.isString(args.recipient)){smsConfig.recipient=args.recipient}else{smsConfig.recipient=""}if(V.isBoolean(args.isVerified)){smsConfig.isVerified=args.isVerified}else{smsConfig.isVerified=false}if(V.isBoolean(args.isEnabled)){smsConfig.isEnabled=args.isEnabled}else{smsConfig.isEnabled=false}if(V.isString(args.token)){smsConfig.token=args.token}if(args.hasOwnProperty("recipient")||args.hasOwnProperty("isEnabled")||args.hasOwnProperty("isVerified")||args.hasOwnProperty("token")){return true}return false}function _setCityCode(arg){var value=parseInt(arg,10);if(typeof value=="number"&&value===value){this._attr.cityCode=value;return true}return false}function _setUser(args,strict){var notSet=[];if(args){if(args.hasOwnProperty("boxes")&&!this.setBoxes(args.boxes,strict)){notSet[notSet.length]="boxes"}if(args.hasOwnProperty("defaultSmartCardId")&&!this.setDefaultSmartCardId(args.defaultSmartCardId)){notSet[notSet.length]="defaultSmartCardId"}if(args.hasOwnProperty("emailConfig")&&!this.setEmailConfig(args.emailConfig)){notSet[notSet.length]="emailConfig"}if(args.hasOwnProperty("favouriteChannels")&&!this.setFavouriteChannels(args.favouriteChannels)){notSet[notSet.length]="favouriteChannels"}if(args.hasOwnProperty("familyName")&&!this.setFamilyName(args.familyName)){notSet[notSet.length]="familyName"}if(args.hasOwnProperty("givenName")&&!this.setGivenName(args.givenName)){notSet[notSet.length]="givenName"}if(args.hasOwnProperty("isAccountEnabled")&&!this.setIsAccountEnabled(args.isAccountEnabled)){notSet[notSet.length]="isAccountEnabled"}if(args.hasOwnProperty("pushConfig")&&!this.setPushConfig(args.pushConfig)){notSet[notSet.length]="pushConfig"}if(args.hasOwnProperty("smsConfig")&&!this.setSmsConfig(args.smsConfig)){notSet[notSet.length]="smsConfig"}if(args.hasOwnProperty("cityCode")){this.setCityCode(args.cityCode)}if(notSet.length===0){return true}else{if(strict){throw new Error(_errMsgInvalidOptionalArgs.call(this,notSet))}}}return false}EpgUser.prototype.addFavouriteChannelId=function(channelId){return _addFavouriteChannelId.call(this,channelId)};EpgUser.prototype.deleteFavouriteChannelId=function(channelId){return _deleteFavouriteChannelId.call(this,channelId)};EpgUser.prototype.getBox=function(){return _getBox.call(this)||null};EpgUser.prototype.getBoxById=function(boxId){return _getBoxById.call(this,boxId)||null};EpgUser.prototype.getBoxes=function(){return this._attr.boxes||null};EpgUser.prototype.getCustomerId=function(){return this._attr.id||null};EpgUser.prototype.getDefaultSmartCardId=function(){return this._attr.defaultSmartCardId||null};EpgUser.prototype.getEmailConfig=function(){return this._attr.emailConfig||null};EpgUser.prototype.getEmailConfigRecipient=function(){return this._attr.emailConfig.recipient||null};EpgUser.prototype.getEmailConfigIsVerified=function(){return this._attr.emailConfig.isVerified||false};EpgUser.prototype.getEmailConfigIsEnabled=function(){return this._attr.emailConfig.isEnabled||false};EpgUser.prototype.getFamilyName=function(){return this._attr.familyName||null};EpgUser.prototype.getFavouriteChannels=function(){return this._attr.favouriteChannels||null};EpgUser.prototype.getGivenName=function(){return this._attr.givenName||null};EpgUser.prototype.getIsAccountEnabled=function(){return this._attr.isAccountEnabled||false};EpgUser.prototype.getPushConfig=function(){return this._attr.pushConfig||null};EpgUser.prototype.getPushConfigRecipient=function(){return this._attr.pushConfig.recipient||null};EpgUser.prototype.getPushConfigIsVerified=function(){return this._attr.pushConfig.isVerified||false};EpgUser.prototype.getPushConfigIsEnabled=function(){return this._attr.pushConfig.isEnabled||false};EpgUser.prototype.getSmsConfig=function(){return this._attr.smsConfig||null};EpgUser.prototype.getSmsConfigRecipient=function(){return this._attr.smsConfig.recipient||null};EpgUser.prototype.getSmsConfigIsVerified=function(){return this._attr.smsConfig.isVerified||false};EpgUser.prototype.getSmsConfigIsEnabled=function(){return this._attr.smsConfig.isEnabled||false};EpgUser.prototype.getCityCode=function(){return this._attr.cityCode||null};EpgUser.prototype.hasDvr=function(){return _hasDvr.call(this)};EpgUser.prototype.hasAtLeastOneDvrBox=function(){return _hasAtLeastOneDvrBox.call(this)};EpgUser.prototype.hasCompatibleBox=function(){return _hasCompatibleBox.call(this)};EpgUser.prototype.hasHdCapableBox=function(){return _hasHdCapableBox.call(this)};EpgUser.prototype.hasIncompatibleSubscription=function(){return _hasIncompatibleSubscription.call(this)};EpgUser.prototype.hasStb=function(){return _hasStb.call(this)};EpgUser.prototype.set=function(args,strict){return _setUser.call(this,args,strict)};EpgUser.prototype.setBoxes=function(arg,strict){return _setBoxes.call(this,arg,strict)};EpgUser.prototype.setDefaultSmartCardId=function(smartCard){return _setStringProperty.call(this,"defaultSmartCardId",smartCard)};EpgUser.prototype.setEmailConfig=function(emailConfig){return _setEmailConfig.call(this,emailConfig)};EpgUser.prototype.setEmailConfigRecipient=function(emailConfigRecipient){return _setEmailConfig.call(this,{recipient:emailConfigRecipient})};EpgUser.prototype.setEmailConfigIsVerified=function(emailConfigIsVerified){return _setEmailConfig.call(this,{isVerified:emailConfigIsVerified})};EpgUser.prototype.setEmailConfigIsEnabled=function(emailConfigIsEnabled){return _setEmailConfig.call(this,{isEnabled:emailConfigIsEnabled})};EpgUser.prototype.setFamilyName=function(familyName){return _setStringProperty.call(this,"familyName",familyName)};EpgUser.prototype.setFavouriteChannels=function(arg){return _setFavouriteChannels.call(this,arg)};EpgUser.prototype.setGivenName=function(givenName){return _setStringProperty.call(this,"givenName",givenName)};EpgUser.prototype.setIsAccountEnabled=function(isAccountEnabled){return _setIsAccountEnabled.call(this,isAccountEnabled)};EpgUser.prototype.setPushConfig=function(pushConfig){return _setPushConfig.call(this,pushConfig)};EpgUser.prototype.setPushConfigRecipient=function(pushConfigRecipient){return _setPushConfig.call(this,{recipient:pushConfigRecipient})};EpgUser.prototype.setPushConfigIsVerified=function(pushConfigIsVerified){return _setPushConfig.call(this,{isVerified:pushConfigIsVerified})};EpgUser.prototype.setPushConfigIsEnabled=function(pushConfigIsEnabled){return _setPushConfig.call(this,{isEnabled:pushConfigIsEnabled})};EpgUser.prototype.setSmsConfig=function(smsConfig){return _setSmsConfig.call(this,smsConfig)};EpgUser.prototype.setSmsConfigRecipient=function(smsConfigRecipient){return _setSmsConfig.call(this,{recipient:smsConfigRecipient})};EpgUser.prototype.setSmsConfigIsVerified=function(smsConfigIsVerified){return _setSmsConfig.call(this,{isVerified:smsConfigIsVerified})};EpgUser.prototype.setSmsConfigIsEnabled=function(smsConfigIsEnabled){return _setSmsConfig.call(this,{isEnabled:smsConfigIsEnabled})};EpgUser.prototype.setCityCode=function(cityCode){return _setCityCode.call(this,cityCode)};EpgUser.prototype.init=function(args,strict){this._type="User";this._attr={boxes:{},favouriteChannels:[],emailConfig:{},smsConfig:{},pushConfig:{}};if(args.customerId){args.id=args.customerId}if(!_setDigitProperty.call(this,"id",args.id)){throw new Error(_errMsgInvalidArgs.call(this))}_setUser.call(this,args,strict);this.init=EmptyFunction}})();(function(){var basePath="";var baseUrl="https://"+document.location.hostname;var favouritesTime=new Date().getTime();var favouritesRefreshTime=60000;var fullUrl=null;var lang="English";var errMsg="Error in ";var userRefreshTime=30000;var userTime=new Date().getTime();try{var Cookie=UPC.util.Cookie;var F=UPC.util.Fetch;var V=UPC.util.Validate}catch(err){throw"epg-customer.js -> dependancy library is missing or did not initiate properly"}EpgSession=(function(){var _objName="EpgSession";var _objErrMsg="Error in "+_objName;var bookings=null;var bookingsTime=new Date().getTime();var bookingsRefreshTime=30000;var cookieName="epg_state";var user=null;var persistentCookieName="epg_rm";var statusMessages={bookings:null,reminders:null,session:null};var remindersRefreshTime=30000;var remindersTime=new Date().getTime();var reminders=null;if(!EpgUser||!EpgBooking||!EpgEvent||!EpgReminder){throw _objErrMsg+"-> dependancy Epg objects library is missing or did not initiate properly"}function _hasRequiredParams(){if(V.isString(serverUrl)&&V.isString(serverPath)&&V.isString(lang)){return true}return false}function _setBookings(arg){var tmp=[];if(!bookings&&arg){bookings=new EpgBookings(arg,true)}else{bookings.set(arg,true)}if(V.isArray(arg)&&arg.length!==0){for(var i=arg.length;i--;){if(arg[i].id&&bookings.hasMember(arg[i].id)){tmp[tmp.length]=bookings.get(arg[i].id)}}}else{if(arg instanceof Object){if(arg.id&&bookings.hasMember(arg.id)){tmp=bookings.get(arg.id)}}}return tmp}function _setStatusBookings(status){var tmp=bookings.get();if(V.isString(status)&&!V.isEmpty(tmp)){for(var booking in tmp){if(tmp.hasOwnProperty(booking)){tmp[booking].setStatus(status)}}}}function _setStatusMessagesBookings(arg){statusMessages.bookings=arg}function _setStatusMessagesReminders(arg){statusMessages.reminders=arg}function _setStatusMessagesSession(arg){statusMessages.session=arg}function _setStatusReminders(status){if(V.isString(status)){for(var reminder in reminders){if(reminders.hasOwnProperty(reminder)&&reminder instanceof EpgReminder){reminders[reminders].setStatus(status)}}}}function _setReminders(arg){var tmp=[];if(!reminders&&arg){reminders=new EpgReminders(arg,true)}else{reminders.set(arg,true)}if(V.isArray(arg)&&arg.length!==0){for(var i=arg.length;i--;){if(arg[i].id&&reminders.hasMember(arg[i].id)){tmp[tmp.length]=reminders.get(arg[i].id)}}}else{if(arg instanceof Object){if(arg.id&&reminders.hasMember(arg.id)){tmp=reminders.get(arg.id)}}}return tmp}function create(args){var data=null;var params={};if(!hasSsl()){throw _objErrMsg+".create() -> invalid HTTP protocol use SSL"}if(!_hasRequiredParams){throw _objErrMsg+".create() -> please use "+_objName+".setParams() to set URL to server"}if(V.isBoolean(args.rememberMe)){params.rememberMe=args.rememberMe}if(V.isFunction(args.onSuccess)&&V.isFunction(args.onFailure)&&V.isString(args.username)&&V.isString(args.password)){params.username=args.username;params.password=args.password;F.getXhr(fullUrl+"User/session",{method:"post",params:params,onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{if(!V.isSession(data)&&!V.isUser(data.customer)){throw _ObjErrMsg+".create() -> onSuccess response contains invalid user object"}user=new EpgUser(data.customer);_setBookings(data.bookings);_setReminders(data.reminders);args.onSuccess(user,bookings,reminders,response)}catch(err){args.onFailure(response,err)}}})}else{throw _objErrMsg+".create() -> invalid params given"}}function destroy(args){var params={};if(!isValid()){return}if((V.isFunction(args.onSuccess)&&V.isFunction(args.onFailure))||Object.values(params).length===0){user=null;F.getXhr(fullUrl+"User/session",{method:"delete",onFailure:function(response){Cookie.remove(cookieName);Cookie.remove(persistentCookieName);args.onFailure(response)},onSuccess:function(){Cookie.remove(cookieName);Cookie.remove(persistentCookieName);args.onSuccess(true)}})}else{throw _objErrMsg+".destroy() -> invalid parameters given"}}function getBooking(eventId){if(!isValid()){throw _objErrMsg+".getBooking() -> no session found please login"}if(bookings&&bookings.hasMember(eventId)){return bookings.get(eventId)}return null}function getStatusMessageBookings(code){if(statusMessages.bookings.hasOwnProperty(code)){return statusMessages.bookings[code]}return null}function getStatusMessageReminders(code){if(statusMessages.reminders.hasOwnProperty(code)){return statusMessages.reminders[code]}return null}function getStatusMessageSession(code){if(statusMessages.session.hasOwnProperty(code)){return statusMessages.session[code]}return null}function getReminder(eventId){if(!isValid()){throw _objErrMsg+" getReminder() -> no session found please login"}if(reminders&&reminders.hasMember(eventId)){return reminders.get(eventId)}return null}function getUser(){return user||null}function hasBooking(eventId){if(eventId){if(!isValid()){return false}else{if(user){if(!user.hasDvr()){return false}}}if(bookings&&bookings.hasMember(eventId)){return true}}return false}function hasCookie(){var cookie=Cookie.read(cookieName);var persistentCookie=Cookie.read(persistentCookieName);if(V.isString(cookie)||V.isString(persistentCookie)){return true}return false}function hasSsl(){if(document.location.protocol==="https:"){return true}return false}function hasReminder(eventId){if(eventId){if(!isValid()){return false}else{if(user){if(!user.hasStb()){return false}}}if(reminders&&reminders.hasMember(eventId)){return true}}return false}function isValid(){if(hasCookie()&&hasSsl()&&user!==null&&bookings!==null&&reminders!==null){return true}return false}function setParams(args){if(!hasSsl()){throw _objErrMsg+".setParams() -> invalid HTTP protocol use SSL"}if(args){if(args.hasOwnProperty("lang")){lang=args.lang}if(V.isString(args.baseUrl)){baseUrl=args.baseUrl}if(V.isString(args.basePath)){basePath=args.basePath}else{throw _objErrMsg+".setParams() -> serverPath is not defined"}fullUrl=baseUrl+basePath;if(args.hasOwnProperty("statusMessagesBookings")){setStatusMessagesBookings(args.statusMessagesBookings)}else{retrieveStatusMessagesBookings({onSuccess:function(){},onFailure:function(){}})}if(args.hasOwnProperty("statusMessagesReminders")){setStatusMessagesReminders(args.statusMessagesReminders)}else{retrieveStatusMessagesReminders({onSuccess:function(){},onFailure:function(){}})}if(args.hasOwnProperty("statusMessagesSession")){setStatusMessagesReminders(args.statusMessagesSession)}else{retrieveStatusMessagesSession({onSuccess:function(){},onFailure:function(){}})}if(args.hasOwnProperty("bookingsRefreshTime")&&V.isInt(args.bookingsRefreshTime)){bookingsRefreshTime=args.bookingsRefreshTime}if(args.hasOwnProperty("favouritesRefreshTime")&&V.isInt(args.favouritesRefreshTime)){favouritesRefreshTime=args.favouritesRefreshTime}if(args.hasOwnProperty("reminderRefreshTime")&&V.isInt(args.reminderRefreshTime)){reminderRefreshTime=args.reminderRefreshTime}}else{throw _objErrMsg+".setParams() -> Invalid arguments passed"}}function retrieve(args){var data=null;var params={};if(!hasSsl()||!hasCookie()){throw _objErrMsg+".retrieve() -> invalid HTTP protocol use SSL"}if(V.isFunction(args.onSuccess)&&V.isFunction(args.onFailure)){F.getXhr(fullUrl+"User/session",{onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{user=new EpgUser(data.customer,true);_setBookings(data.bookings);_setReminders(data.reminders);args.onSuccess(data)}catch(err){args.onFailure(response,err)}}})}else{throw _objErrMsg+".retrieve() -> invalid params given"}}function retrieveBookings(args){var currentTime=new Date().getTime();var data=null;if(!isValid()){throw _objErrMsg+".retrieveBookings() -> no session found please login"}if(!user.hasDvr()){throw _objErrMsg+".retrieveBookings() -> box identified by defaultSmartCardId does not support DVR"}if(!args||(!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure))){throw _objErrMsg+".retrieveBookings() -> onSuccess and onFailure arguments are invalid"}if((bookingsTime<currentTime-bookingsRefreshTime)||((args.hasOwnProperty("cache")&&args.cache===false))){F.getXhr(fullUrl+"User/bookings",{onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{if(!V.isArray(data)){throw _ObjErrMsg+".retrieveBookings() -> onSuccess response contains invalid data object"}_setStatusBookings("deleted");args.onSuccess(_setBookings(data));bookingsTime=new Date().getTime()}catch(err){args.onFailure(response,err)}}})}else{args.onSuccess(bookings.getArray())}}function retrieveStatusMessagesBookings(args){if(!args||(!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure))){throw _objErrMsg+".retrieveStatusMessagesBookings() -> onSuccess and onFailure arguments are invalid"}F.getXhr(fullUrl+"bookings/statusMessages?lang="+lang,{onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{args.onSuccess(_setStatusMessagesBookings(data))}catch(err){args.onFailure(response,err)}}})}function retrieveStatusMessagesReminders(args){if(!args||(!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure))){throw _objErrMsg+"retrieveStatusMessagesReminders() -> onSuccess and onFailure arguments are invalid"}F.getXhr(fullUrl+"reminders/statusMessages?lang="+lang,{onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{args.onSuccess(_setStatusMessagesReminders(data))}catch(err){args.onFailure(response,err)}}})}function retrieveStatusMessagesSession(args){if(!args||(!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure))){throw _objErrMsg+".retrieveStatusMessagesSession() -> onSuccess and onFailure arguments are invalid"}F.getXhr(fullUrl+"User/session/statusMessages?lang="+lang,{onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{args.onSuccess(_setStatusMessagesSession(data))}catch(err){args.onFailure(response,err)}}})}function retrieveReminders(args){var currentTime=new Date().getTime();var data=null;if(!isValid()){throw _objErrMsg+".retrieveReminders() -> no session found please login"}if(!user.hasStb()){throw _objErrMsg+".retrieveReminders() -> box identified by defaultSmartCardId does not support DVR"}if(!args||(!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure))){throw _objErrMsg+".retrieveBookings() -> onSuccess and onFailure arguments are invalid"}if((remindersTime<currentTime-remindersRefreshTime)||((args.hasOwnProperty("cache")&&args.cache===false))){F.getXhr(fullUrl+"User/reminders",{onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{if(!V.isArray(data)){throw _ObjErrMsg+".retrieveReminders() -> onSuccess response contains invalid data object"}_setStatusReminders("deleted");args.onSuccess(_setReminders(data));remindersTime=new Date().getTime()}catch(err){args.onFailure(response,err)}}})}else{args.onSuccess(reminders.getArray())}}function updateBookings(args){var params={};if(!isValid()){throw _objErrMsg+"updateBookings() -> no session found please login"}if(!user.hasDvr()){throw _objErrMsg+".updateBookings() -> box identified by defaultSmartCardId does not support DVR"}params.shouldOverride=args.shouldOverride||false;if(V.isInt(args.eventId)){params.eventId=parseInt(args.eventId,10)}else{params.seriesId=parseInt(args.seriesId,10)}if((V.isInt(args.eventId)||V.isInt(args.seriesId))&&V.isFunction(args.onSuccess)&&V.isFunction(args.onFailure)){F.getXhr(fullUrl+"User/bookings",{method:"post",params:params,onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{if(params.shouldOverride){retrieveBookings({cache:false,onFailure:function(response){args.onFailure(response)},onSuccess:function(data){try{args.onSuccess(data)}catch(err){args.onFailure(response,err)}}})}else{args.onSuccess(_setBookings(data),response)}}catch(err){args.onFailure(response,err)}}})}else{throw _objErrMsg+".updateBookings() -> invalid parameters given"}}function updateReminders(args){var params={};if(!isValid()){throw _objErrMsg+"updateReminders() -> no session found please login"}if(!user.hasStb()){throw _objErrMsg+".updateReminders() -> customer does not have DTV subscription"}if((V.isInt(args.eventId))&&V.isFunction(args.onSuccess)&&V.isFunction(args.onFailure)){F.getXhr(fullUrl+"User/reminders",{method:"post",params:{eventId:parseInt(args.eventId,10)},onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{args.onSuccess(_setReminders(data),response)}catch(err){args.onFailure(response,err)}}})}else{throw _objErrMsg+".updateReminder() -> invalid parameters given"}}function retrieveStbStatus(args){if(!isValid()){throw _objErrMsg+"retrieveStbStatus() -> no session found please login"}if(!user.hasStb()){throw _objErrMsg+".retrieveStbStatus() -> customer does not have DTV subscription"}var url=fullUrl+"User/boxes";if(V.isFunction(args.onSuccess)&&V.isFunction(args.onFailure)){if(args.smartCardId){url+="/"+args.smartCardId}}else{throw _objErrMsg+".retrieveStbStatus() -> invalid parameters given"}F.getXhr(url,{method:"get",onSuccess:function(data,response){try{if(Object.isArray(data)){data.each(function(item){user.getBoxById(item.smartCardId).setReadyForServiceValue(item.isReadyForService)})}else{user.getBoxById(data.smartCardId).setReadyForServiceValue(data.isReadyForService)}args.onSuccess(user.getBoxes())}catch(err){args.onFailure(response,err)}},onFailure:function(response){args.onFailure(response)}})}return{create:create,destroy:destroy,getBooking:getBooking,getStatusMessageBookings:getStatusMessageBookings,getStatusMessageReminders:getStatusMessageReminders,getStatusMessageSession:getStatusMessageSession,getReminder:getReminder,getUser:getUser,hasBooking:hasBooking,hasCookie:hasCookie,hasSsl:hasSsl,hasReminder:hasReminder,isValid:isValid,retrieve:retrieve,retrieveBookings:retrieveBookings,retrieveStatusMessagesBookings:retrieveStatusMessagesBookings,retrieveStatusMessagesReminders:retrieveStatusMessagesReminders,retrieveStatusMessagesSession:retrieveStatusMessagesSession,retrieveReminders:retrieveReminders,retrieveStbStatus:retrieveStbStatus,setParams:setParams,updateBookings:updateBookings,updateReminders:updateReminders}})();function _deleteFavourite(args){var _objName=this._type;var _objErrMsg=errMsg+this._type;var params={};var self=this;if(!EpgSession.isValid()){throw _objErrMsg+".deleteFavourite() -> no session found please login"}if(V.isString(args.channelId)&&V.isFunction(args.onSuccess)&&V.isFunction(args.onFailure)){F.getXhr(fullUrl+"User/favouriteChannels",{method:"delete",params:{channelId:args.channelId},onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{self.set({favouriteChannels:data},true);args.onSuccess(self);favouritesTime=new Date().getTime()}catch(err){args.onFailure(response,err)}}})}else{throw _objErrMsg+".deleteFavourite() -> invalid parameters given"}}function _sendEmailToken(args){var _objName=this._type;var _objErrMsg=errMsg+this._type;var self=this;if(!EpgSession.isValid()){throw _objErrMsg+".sendEmailToken() -> no session found please login"}if(V.isFunction(args.onSuccess)&&V.isFunction(args.onFailure)){F.getXhr(fullUrl+"User/token",{method:"post",onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{if(!V.isUser(data)){throw _ObjErrMsg+".sendEmailToken() -> onSuccess response contains invalid user object"}self.set(data,true);args.onSuccess(self,response)}catch(err){args.onFailure(response,err)}}})}else{throw _objErrMsg+".sendEmailToken() -> invalid parameters given"}}function _sendSmsToken(args){var _objName=this._type;var _objErrMsg=errMsg+this._type;var self=this;if(!EpgSession.isValid()){throw _objErrMsg+".sendSmsToken() -> no session found please login"}if(V.isFunction(args.onSuccess)&&V.isFunction(args.onFailure)){F.getXhr(fullUrl+"User/token/sms",{method:"post",onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{if(!V.isUser(data)){throw _ObjErrMsg+"sendSmsToken() -> onSuccess response contains invalid user object"}self.set(data,true);args.onSuccess(self,response);userTime=new Date().getTime()}catch(err){args.onFailure(response,err)}}})}else{throw _objErrMsg+" sendSmsToken() -> invalid parameters given"}}function _retrieveFavourites(args){var _objName=this._type;var _objErrMsg=errMsg+this._type;var data=null;var currentTime=new Date().getTime();var self=this;var url=fullUrl+"User/favouriteChannels";if(!EpgSession.isValid()){throw _objErrMsg+".retrieveFavourites() -> no session found please login"}if(!args||(!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure))){throw _objErrMsg+".retrieveFavourites() -> onSuccess and onFailure arguments are invalid"}if((favouritesTime<currentTime-favouritesRefreshTime)||((args&&args.hasOwnProperty("cache")&&args.cache===false))){F.getXhr(url,{onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{self.set({favouriteChannels:data},true);args.onSuccess(self.getFavouriteChannels());favouritesTime=new Date().getTime()}catch(err){args.onFailure(response,err)}}})}else{args.onSuccess(this.getFavouriteChannels())}}function _retrieveUser(args){var _objName=this._type;var _objErrMsg=errMsg+this._type;var currentTime=new Date().getTime();var data=null;var self=this;var url=fullUrl+"User";if(!EpgSession.isValid()){throw errMsg+_objName+".retrieve() -> no session found please login"}if(!args||(!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure))){throw _objErrMsg+".retrieve() -> onSuccess and onFailure arguments are invalid"}if((userTime<currentTime-userRefreshTime)||((args.hasOwnProperty("cache")&&args.cache===false))){F.getXhr(url,{onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{self.set(data,true);args.onSuccess(self);userTime=new Date().getTime()}catch(err){args.onFailure(response,err)}}})}else{args.onSuccess(this)}}function _updateFavourites(args){var _objName=this._type;var _objErrMsg=errMsg+this._type;var self=this;if(!EpgSession.isValid()){throw _objErrMsg+".updateFavourites() -> no session found please login"}if(V.isString(args.channelId)&&V.isFunction(args.onSuccess)&&V.isFunction(args.onFailure)){F.getXhr(fullUrl+"User/favouriteChannels",{method:"put",params:{channelId:args.channelId},onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{self.set({favouriteChannels:data},true);args.onSuccess(self.getFavouriteChannels());favouritesTime=new Date().getTime()}catch(err){args.onFailure(response,err)}}})}else{throw _objErrMsg+".updateFavourites() -> invalid parameters given"}}function _updateUser(args){var _objName=this._type;var _objErrMsg=errMsg+this._type;var params={};var self=this;if(!EpgSession.isValid()){throw _objErrMsg+".update() -> no session found please login"}if(V.isDigit(args.defaultSmartCardId)){params.defaultSmartCardId=args.defaultSmartCardId}if(V.isBoolean(args.isAccountEnabled)){params.isAccountEnabled=args.isAccountEnabled}if(V.isBoolean(args.emailConfigIsEnabled)){params.emailConfigIsEnabled=args.emailConfigIsEnabled}if(typeof(args.emailConfigRecipient)==="string"){params.emailConfigRecipient=args.emailConfigRecipient}if(V.isBoolean(args.smsConfigIsEnabled)){params.smsConfigIsEnabled=args.smsConfigIsEnabled}if(typeof(args.smsConfigRecipient)==="string"){params.smsConfigRecipient=args.smsConfigRecipient}if(V.isFunction(args.onSuccess)&&V.isFunction(args.onFailure)&&!V.isEmpty(params)){F.getXhr(fullUrl+"User",{method:"put",params:params,onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{self.set(data,true);userTime=new Date().getTime();args.onSuccess(self,response)}catch(err){args.onFailure(response,err)}}})}else{throw _ObjErrMsg+".update() -> invalid parameters given"}}function _verifySmsToken(args){var _objName=this._type;var _objErrMsg=errMsg+this._type;var token=null;if(!EpgSession.isValid()){throw _objErrMsg+".verifySmsToken() -> no session found please login"}if(V.isBetweenStr(args.token,5,5)&&V.isAlphaNumeric(args.token,5,5)&&V.isFunction(args.onSuccess)&&V.isFunction(args.onFailure)){F.getXhr(fullUrl+"Token/verify/sms/"+args.token,{method:"delete",onFailure:function(response){args.onFailure(response)},onSuccess:function(data,response){try{args.onSuccess(data,response)}catch(err){args.onFailure(response,err)}}})}else{throw _objErrMsg+" verifySmsToken() -> invalid parameters given"}}EpgUser.prototype.deleteFavourite=function(args){return _deleteFavourite.call(this,args)};EpgUser.prototype.sendEmailToken=function(args){return _sendEmailToken.call(this,args)};EpgUser.prototype.sendSmsToken=function(args){return _sendSmsToken.call(this,args)};EpgUser.prototype.retrieve=function(args){return _retrieveUser.call(this,args)};EpgUser.prototype.retrieveFavourites=function(args){return _retrieveFavourites.call(this,args)};EpgUser.prototype.update=function(args){return _updateUser.call(this,args)};EpgUser.prototype.updateFavourites=function(args){return _updateFavourites.call(this,args)};EpgUser.prototype.verifySmsToken=function(args){return _verifySmsToken.call(this,args)}})();(function(){var errMsg="Error in ";basePath="",baseUrl=null,fullUrl=null,timeOut=15000;try{var F=UPC.util.Fetch,V=UPC.util.Validate}catch(err){throw"epg-schedule.js -> dependancy library is missing or did not initiate properly"}function _errMsgInvalidOptionalArgs(){return"init of "+(this._type?this._type:"EpgObject")+" failed one or more of the optional attributes is invalid"}function _parseUrlArgs(basepath,args){var optionalParams,tmp=[],url=fullUrl;if(V.isDigit(args.eventId)){url+="Event/"+args.eventId}else{if(V.isString(args.channelId)){url+="Channel/"+args.channelId}else{if(V.isDigit(args.programmeId)){url+="Programme/"+args.programmeId}else{if(V.isArray(args.channelIds)){if(args.channelIds.length>5){args.channelIds=args.channelIds.slice(0,5)}url+="Channel/"+(args.channelIds.join("|"))}else{if(V.isArray(args.eventIds)){if(args.eventIds.length>5){args.eventIds=args.eventIds.slice(0,5)}url+="Event/"+(args.eventIds.join("|"))}else{if(V.isArray(args.programmeIds)){if(args.programmeIds.length>5){args.programmeIds=args.programmeIds.slice(0,5)}url+="Programme/"+(args.programmeIds.join("|"))}else{if(V.isString(args.seriesId)){url+="Series/"+args.seriesId}else{if(V.isString(args.domainId)||V.isArray(args.domainIds)){if(args.domainId){url+="Domain/"+args.domainId}else{if(args.domainIds.length>5){args.domainIds=args.domainIds.slice(0,5)}url+="Domain/"+(args.domainIds.join("|"))}if(V.isDigit(args.groupId)){url+="/groups/"+args.groupId}else{if(V.isArray(args.groupIds)){if(args.groupIds.length>5){args.grouplIds=args.groupIds.slice(0,5)}url+="/groups/"+args.groupIds.join("|")}}}}}}}}}}url+=basepath;if(V.isObject(args.params)&&V.isArray(args.params.optional)){optionalParams=args.params.optional;for(var i=optionalParams.length;i--;){if(optionalParams[i]==="eventUrl"){tmp.push("Event.url")}else{if(optionalParams[i]==="channelUrl"){tmp.push("Channel.url")}else{if(optionalParams[i]==="channelLogo"){tmp.push("Channel.logoIMG")}else{if(optionalParams[i]==="shortDescription"){tmp.push("Programme.shortDescription")}}}}}tmp=tmp.join(",");args.params.optionalProperties=tmp;delete args.params.optional}return url}function _processBatch(objectType,data){var i=0,j=0,maxI,maxJ,result=null;if(V.isArray(data[0])&&V.isArray(data[0][0])){result=[];for(i=0,maxI=data.length;i<maxI;i+=1){for(j=0,maxJ=data[i].length;j<maxJ;j+=1){if(i===0){if(!V.isEmpty(data[i][j])){result.push(new objectType(data[i][j],true))}}else{if(!V.isEmpty(data[i][j])){result[j].set(data[i][j],true)}}}}}else{if(data.length>1){for(i=0,max=data.length;i<max;i++){if(i===0){if(!V.isEmpty(data[i])){result=new objectType(data[i],true)}}else{if(!V.isEmpty(data[i])){result.set(data[i],true)}}}}else{if(V.isArray(data[0])){result=[];for(i=0,max=data[0].length;i<max;i++){if(!V.isEmpty(data[0][i])){result.push(new objectType(data[0][i],true))}}}}}return result}function BatchRequest(args){var isRequestCancelled=false,isResponseEmpty=false,batchSize=1,responseNr=-1,responses=[],requestNr=-1,requestMax=40;function _request(){for(var i=batchSize;i--;){requestNr++;try{args.request.call(this,requestNr)}catch(err){isResponseError=true}}}this.add=function(data){if(V.isEmpty(data)){isResponseEmpty=true}else{responses.push(data)}responseNr++;if(isRequestCancelled){args.onFailure();return}try{if(requestNr===responseNr){if(isResponseEmpty||requestNr>=requestMax-1){args.onSuccess(responses)}else{_request.call(this)}}}catch(err){args.onFailure()}};this.cancel=function(){this.isRequestCancelled=true;args.onFailure()};if(args){if(V.isInt(args.batchSize)){batchSize=args.batchSize}if(V.isInt(args.batchMax)){requestMax=args.batchMax}if(V.isFunction(args.request)&&V.isFunction(args.onSuccess)){_request.call(this)}}}EpgSchedule=(function(){var _objName="EpgSchedule",_objErrMsg="Error in "+_objName;function _batchJsonpRequest(url,args,callbacks){var params={};if(V.isObject(args.params)){params=args.params}new BatchRequest({batchMax:V.isInt(args.batchMax)?args.batchMax:10,batchSize:V.isInt(args.batchSize)?args.batchSize:2,request:function(batchNr){var self=this;params.batch=batchNr;F.getJsonp.call(this,url,{params:params,timeOut:args.timeOut||timeOut,onFailure:function(){self.cancel()},onSuccess:function(data){self.add(data)}})},onFailure:function(){if(V.isObject(callbacks)&&V.isFunction(callbacks.onFailure)){callbacks.onFailure()}else{args.onFailure()}},onSuccess:function(data){if(V.isObject(callbacks)&&V.isFunction(callbacks.onSuccess)){callbacks.onSuccess(data)}else{args.onSuccess(data)}}})}function setParams(args){if(args){if(V.isString(args.baseUrl)){baseUrl=args.baseUrl}else{throw _objErrMsg+".setParams() -> serverPath is not defined"}if(V.isString(args.basePath)){basePath=args.basePath}else{throw _objErrMsg+".setParams() -> serverPath is not defined"}if(V.isString(args.timeOut)){timeOut=args.timeOut}if(baseUrl&&basePath){fullUrl=baseUrl+basePath;return true}}else{throw _objErrMsg+".setParams() -> Invalid arguments passed"}return false}function retrieveChannels(args){var url;if(!(args.channelId||args.channelIds)){url=_parseUrlArgs("Channel.json",args)}else{url=_parseUrlArgs(".json",args)}if(!args||!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure)){throw _objErrMsg+".retrieveChannels(): onSuccess or onFailure parameters are undefined"}else{if(args.channelId||args.channelIds){args.batchMax=args.batchSize=1}_batchJsonpRequest.call(this,url,args,{onSuccess:function(data){var tmp;try{if(args.channelId){tmp=new EpgChannel(data[0])}else{if(args.channelIds){tmp=_processBatch(EpgChannel,data)}else{tmp=_processBatch(EpgChannels,data)}}}catch(err){}args.onSuccess(tmp)}})}}function retrieveDomains(args){var url;if(!args||!(args.domainId||args.domainIds)){throw _objErrMsg+".retrieveDomains(): domainId(s) undefined"}url=_parseUrlArgs(".json",args);args.batchMax=args.batchSize=1;if(!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure)){throw _objErrMsg+".retrieveDomains(): onSuccess or onFailure parameters are undefined"}else{_batchJsonpRequest.call(this,url,args,{onSuccess:function(data){var tmp;try{if(args.domainId){tmp=new EpgDomain(data[0])}else{tmp=_processBatch(EpgDomains,data)}}catch(err){}args.onSuccess(tmp)}})}}function retrieveEvents(args){var url;if(!args||!(args.eventId||args.eventIds||args.channelId||args.channelIds||args.seriesId)){throw _objErrMsg+".retrieveEvents(): channelId(s) or seriesId undefined"}if(args.eventId||args.eventIds){args.batchMax=args.batchSize=1;url=_parseUrlArgs(".json",args)}else{url=_parseUrlArgs("/events.json",args)}if(!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure)){throw _objErrMsg+".retrieveEvents(): onSuccess or onFailure parameters are undefined"}else{_batchJsonpRequest.call(this,url,args,{onSuccess:function(data){var tmp;try{if(args.eventId){tmp=new EpgEvent(data[0])}else{if(args.eventIds){tmp=_processBatch(EpgEvent,data)}else{tmp=_processBatch(EpgEvents,data)}}}catch(err){}args.onSuccess(tmp)}})}}function retrieveEventsNowAndNext(args){var params={},url;if(!args||!(args.channelId||args.channelIds||args.seriesId)){throw _objErrMsg+".retrieveEventsNowAndNext(): channelId(s) or seriesId undefined"}if(args.eventId||args.eventIds){args.batchMax=args.batchSize=1}url=_parseUrlArgs("/events/NowAndNext.json",args);if(!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure)){throw _objErrMsg+".retrieveEventsNowAndNext(): onSuccess or onFailure parameters are undefined"}else{if(V.isObject(args.params)){params=args.params}params.order="startDateTime";params.batchSize=2;new BatchRequest({batchMax:1,batchSize:1,request:function(batchNr){var self=this;params.batch=batchNr;F.getJsonp.call(this,url,{params:params,timeOut:args.timeOut||timeOut,onFailure:function(){self.cancel()},onSuccess:function(data){self.add(data)}})},onFailure:function(){args.onFailure()},onSuccess:function(data){var tmp;try{if(args.channelId){tmp=_processBatch(EpgEvent,data)}else{tmp=_processBatch(EpgEvents,data)}}catch(err){}args.onSuccess(tmp)}})}}function retrieveGroups(args){var url;if(!args||!(args.domainId||args.domainIds)){throw _objErrMsg+".retrieveGroups(): domainId(s) undefined"}if(args.domainIds&&(args.groupId||args.groupIds)){throw _objErrMsg+".retrieveGroups(): you can not retrieve group(s) from multiple domains"}if(!(args.groupId||args.groupIds)){url=_parseUrlArgs("/groups.json",args)}else{url=_parseUrlArgs(".json",args)}args.batchMax=args.batchSize=1;if(!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure)){throw _objErrMsg+".retrieveGroups(): onSuccess or onFailure parameters are undefined"}else{_batchJsonpRequest.call(this,url,args,{onSuccess:function(data){var tmp;try{if(args.groupId){tmp=new EpgGroup(data[0])}else{tmp=_processBatch(EpgGroups,data)}}catch(err){}args.onSuccess(tmp)}})}}function retrieveProgrammes(args){var url;if(!(args.programmeId||args.programmeIds)){url=_parseUrlArgs("Programme.json",args)}else{url=_parseUrlArgs(".json",args)}if(!args||!V.isFunction(args.onSuccess)||!V.isFunction(args.onFailure)){throw _objErrMsg+".retrieveProgrammes(): onSuccess or onFailure parameters are undefined"}else{if(args.programmeId||args.programmeIds){args.batchMax=args.batchSize=1}_batchJsonpRequest.call(this,url,args,{onSuccess:function(data){var tmp;try{if(args.programmeId){tmp=new EpgProgramme(data[0])}else{if(args.programmeIds){tmp=_processBatch(EpgProgramme,data)}else{tmp=_processBatch(EpgProgrammes,data)}}}catch(err){}args.onSuccess(tmp)}})}}return{retrieveChannels:retrieveChannels,retrieveDomains:retrieveDomains,retrieveEvents:retrieveEvents,retrieveEventsNowAndNext:retrieveEventsNowAndNext,retrieveGroups:retrieveGroups,retrieveProgrammes:retrieveProgrammes,setParams:setParams}})()})();namespace("UPC.widget");UPC.widget.Tooltip=function(){var _objName="UPC.widget.Tooltip";var _objErrMsg="Error in "+_objName+": ";var mainId="tooltip";var mainElement=null;var currentTrigger=null;var timer=null;var mouttimer=null;var contentTemplate=new Template('<div id="tooltip-content">#{content}</div>');var options=null;var effectDuration=0.15;var Config=null;function initialize(userOptions){try{Config=UPC.util.Configuration}catch(err){throw _objErrMsg+"initialize() -> dependancy library is missing or did not initiate properly  "}if(typeof(userOptions)!=="undefined"){Object.extend(options,userOptions)}mainId=_getConfigValue("elementId")||"tooltip";mainElement=$(mainId);if(mainElement===null){throw _objErrMsg+"main element could not be found."}Element.hide(mainId);this.contentTemplate=_getConfigValue("contentTemplate")||contentTemplate;return this}function _autoHide(){clearTimeout(timer);if(!mainElement.visible()){return}try{Effect.toggle(mainElement.id,"appear",{duration:effectDuration})}catch(ReferenceError){Element.hide(mainId)}if(currentTrigger!==null){currentTrigger.stopObserving("mouseout");currentTrigger.stopObserving("mousemove");currentTrigger=null}}function _bindMouseoutEvent(){currentTrigger.observe("mouseout",function(){clearTimeout(timer);if(mainElement.visible()){clearTimeout(mouttimer);mouttimer=setTimeout(function(){hide()},500)}else{clearTimeout(timer);clearTimeout(mouttimer)}if(currentTrigger!==null){currentTrigger.stopObserving("mouseout")}})}function _getConfigValue(key){if(options!==null){return options[key]||Config.getConfigValue("Tooltip."+key)}else{return Config.getConfigValue("Tooltip."+key)}}function _makeTooltipVisible(ev,atPos){if(!mainElement.visible()){currentTrigger.stopObserving("mousemove");if(atPos){_updateTipPosition(ev,atPos)}try{if(!Prototype.Browser.IE){Effect.toggle(mainElement.id,"appear",{duration:effectDuration})}else{Element.show(mainId)}}catch(err){Element.show(mainId)}}}function _offset(atPos){var o=_getConfigValue("offset");if(atPos===null&&o[0]===0&&o[0]===0){o=[0,16]}return o}function _update(e){_updateTipPosition(e,null)}function _updateTipPosition(ev,atPos){var offset=_offset(atPos);var widthPx=_getConfigValue("width");var width=(widthPx)?widthPx+"px":"auto";var left=null;var top=null;if(atPos===null){var position=[ev.pointerX(),ev.pointerY()];left=position[0]+offset[0];top=position[1]+offset[1]}else{left=((widthPx)?(atPos.left-(widthPx/2)):atPos.left)+offset[0];top=(atPos.top-mainElement.getHeight())+offset[1]}mainElement.setStyle({position:"absolute",left:left+"px",top:top+"px",width:width})}function hide(e){clearTimeout(timer);clearTimeout(mouttimer);if(currentTrigger!==null){currentTrigger.stopObserving("mousemove");currentTrigger.stopObserving("mouseout");currentTrigger=null}if(!mainElement.visible()){return}try{if(!Prototype.Browser.IE){Effect.toggle(mainElement.id,"appear",{duration:effectDuration})}else{Element.hide(mainId)}}catch(err){Element.hide(mainId)}}function show(e,content,atPos,el){clearTimeout(mouttimer);if(mainElement.visible()){clearTimeout(mouttimer);Element.hide(mainId)}currentTrigger=(e!==null)?e.element():el;if(typeof(content)==="string"){mainElement.innerHTML=contentTemplate.evaluate({content:content})}else{return false}clearTimeout(mouttimer);var showDelay=_getConfigValue("showDelay");if(showDelay>0){if(atPos===null&&currentTrigger!==null){currentTrigger.observe("mousemove",_update)}timer=setTimeout(function(){_makeTooltipVisible(e,atPos);var autoDismiss=_getConfigValue("autoDismissDelay");if(autoDismiss){timer=setTimeout(_autoHide,autoDismiss)}},showDelay)}else{_makeTooltipVisible(e,atPos);timer=setTimeout(_autoHide,_getConfigValue("autoDismissDelay"))}_bindMouseoutEvent();return true}return{init:initialize,show:show,hide:hide}}();namespace("UPC.widgets");UPC.widgets.WordPopup=Class.create(Autocompleter.Base,{initialize:function(select,update,options,callback){options.onShow=function(element,update){update.style.cssText="visibility: hidden;";_adjustOffsetAndShow.curry(element,update).defer()};options.onHide=function(element,update){if(Prototype.Browser.IE){document.getElementById(update.id).style.display="none"}else{Effect.Fade(update,{duration:0.15})}};function _adjustOffsetAndShow(referenceElement,targetElement){var posOffset=referenceElement.positionedOffset();targetElement.style.cssText="left: "+posOffset.left+"px;"}this.selectEl=$(select);this.element=this.selectEl.previous();this.element.id=this.selectEl.id+"_combo";var inputClasses=Element.classNames(select);this.baseInitialize(this.selectEl.id+"_combo",update,options);this.selectOptionReplacements=[];var optionList=this.selectEl.getElementsByTagName("option");var node;var tmp=optionList.length;for(var i=0;i<tmp;i++){node=optionList[i];this.selectOptionReplacements.push('<li id="'+node.value+'" value="'+node.value+'">'+node.innerHTML+"</li>")}this.values="<ul>"+this.selectOptionReplacements.join("")+"</ul>";this.setSelectedIndex(options.selectedIndex,optionList);Event.observe(this.element,"click",this.activate.bindAsEventListener(this));Event.observe(this.element,"mouseout",this.mouseOut.bindAsEventListener(this));this.callback=callback||Prototype.emptyFunction},getUpdatedChoices:function(){this.updateChoices(this.values);Event.observe(this.update,"mouseout",this.mouseOut.bindAsEventListener(this))},render:function(){if(Element.getStyle(this.update,"display")==="none"){this.options.onShow(this.element,this.update)}this.active=true},inside:function(element,x,y){var offset=Element.cumulativeOffset(element);if(element&&x&&y){return(y>=offset[1]&&y<offset[1]+element.offsetHeight&&x>=offset[0]&&x<offset[0]+element.offsetWidth)}return false},onClick:function(e){var element=Event.element(e);this.index=element.autocompleteIndex;this.selectEntry();this.hide()},mouseOut:function(e){var dropDownElement;if(this.hasFocus){dropDownElement=this.update.childElements()[0];if(!this.inside(dropDownElement,e.pointerX(),e.pointerY())){this.onBlur();Event.stopObserving(this.update,"mouseout")}}},addObservers:function(element){Event.observe(element,"click",this.onClick.bindAsEventListener(this))},updateElement:function(updatedElement){this.element.innerHTML=updatedElement.innerHTML;this.afterUpdateElement(this.element,updatedElement)},afterUpdateElement:function(text,li){this.updateSelect(li.id)},setSelectedIndex:function(index,nodes){this.selectEl.selectedIndex=(index!=null)?index:this.selectEl.selectedIndex;nodes=nodes||$A(this.selectEl.getElementsByTagName("option"));this.element.innerHTML=nodes[this.selectEl.selectedIndex].text},setValues:function(){return this.values},updateSelect:function(value){if(value!==this.selectEl.value){var options=$A(this.selectEl.getElementsByTagName("option"));for(var i=options.length;i--;){var thisOption=options[i].value;if(thisOption==value){this.selectEl.selectedIndex=i;this.callback.defer(this.selectEl);break}}}}});namespace("UPC.apps.epg");UPC.apps.epg.SearchController=function(){var _objName="UPC.apps.epg.SearchController";var _objErrMsg="Error in "+_objName+": ";var defaultQueryText="";var form,mainElement=null,cityCode=null;try{var Locale=UPC.util.Localization}catch(err){throw _objErrMsg+"-> dependancy library is missing or did not initiate properly "}function initialize(element){mainElement=$(element);if(!mainElement){throw _objErrMsg+"main element missing."}cityCode=$("city");defaultQueryText=Locale.getString("search.default")||"";Event.observe(mainElement,"focus",focus);form=mainElement.up("form");Event.observe(form,"submit",submit)}function blur(){mainElement.removeClassName("active");if(mainElement.value===""){mainElement.value=defaultQueryText}}function focus(){mainElement.addClassName("active");if(mainElement.value===defaultQueryText){mainElement.value=""}}function submit(e){if(mainElement.value===""||mainElement.value===defaultQueryText){Event.stop(e)}else{if(cityCode){cityCode.value=_getCityCode()}}}function _getCityCode(){var value;var user=EpgSession.getUser();if(user){value=user.getCityCode()}return value||""}return{init:initialize,blur:blur,focus:focus,submit:submit}}();namespace("UPC.apps.epg");UPC.apps.epg.OverlayController=function(){var _objName="UPC.apps.epg.OverlayController";var _objErrMsg="Error in "+_objName+": ";var activeId=null;var config={activeClassName:"active",className:"overlay",elementId:"overlays_container",overlayParams:{cls:"overlay_container active",position:"center",modal:true,animate:false,auto_hide:false,click_hide:false,opacity:1},timeOut:60000,waitTime:5000};var expired=0,html="",overlays=null,mainElement=null;try{var Config=UPC.util.Configuration;var Locale=UPC.util.Localization;var OverlayWindow=new Overlay();var Validate=UPC.util.Validate;var Cookie=UPC.util.Cookie}catch(err){throw _objErrMsg+"-> dependancy library is missing or did not initiate properly"}function initialize(element,options){var tmp=null;mainElement=element;overlays=options;if(mainElement===null){throw _objErrMsg+"initialize() failed no overlay container found in DOM."}tmp=[Locale.getLocale("overlays"),_getConfigValue("overlays")];if(tmp[0]&&tmp[1]){_secureCopyObject(overlays,tmp[0]);_secureCopyObject(overlays,tmp[1]);for(var overlay in overlays){if(overlays.hasOwnProperty(overlay)&&overlays[overlay].hasOwnProperty("html")){if(overlays[overlay].html.constructor===Array){overlays[overlay].html=overlays[overlay].html.join("")}html+=overlays[overlay].html}}mainElement.innerHTML=html}if(location.hostname.indexOf("upc.pl")>-1&&Cookie.isSupported()){if(Cookie.read("epg_visited")!=="1"){show("splash");Cookie.write("epg_visited","1",1825)}}return this}function _getConfigValue(key){return Config.getConfigValue("OverlayController."+key)}function _getLocaleValue(key){var locale=null;if(key){locale=Locale.getString(key);if(locale.constructor===Array){locale=locale.join("")}return locale||null}return null}function _onClick(e){var element=e.element();if(element.nodeName==="SPAN"&&element.parentNode.nodeName==="BUTTON"){element=element.parentNode}if(Element.hasAttribute(element,"id")&&element.id==overlays.elementId){return null}else{return element}return null}function _onKeyUp(e){var key=e.which||e.keyCode;if(key&&isOverlayDisplayed()){if(key===Event.KEY_ESC){OverlayWindow.hide()}else{if(overlays&&activeId&&overlays[activeId].hasOwnProperty("onKeyUp")){overlays[activeId].onKeyUp(key)}}Event.stop(e)}}function _secureCopyObject(dest,src){if(dest&&src){for(var value in dest){if(src.hasOwnProperty(value)&&dest.hasOwnProperty(value)){if(src[value].constructor===Array){dest[value]=src[value]}else{if(typeof src[value]==="object"){_secureCopyObject(dest[value],src[value])}else{if(typeof src[value]==="string"){dest[value]=src[value]}else{if(typeof src[value]==="number"){dest[value]=src[value]}else{if(typeof src[value]==="boolean"){if(dest[value]===true){src[value]=true}else{src[value]=false}}}}}}}}}}function _setOverlayOnClick(elementId,overlayId){Event.observe(elementId,"click",function(e){if(overlayId==="faq"||EpgSession.isValid()||((overlayId==="login"||overlayId==="splash")&&overlays[overlayId].hasOwnProperty("onClick"))){overlays[overlayId].onClick(_onClick(e))}else{show("login")}})}function _showOverlay(){var overlay=null,overlayId=null,params;var timeOut=20000;var waitTime=config.waitTime||5000;if(activeId===null){window.clearTimeout(_showOverlay)}else{overlayId=overlays[activeId].elementId;overlay=$(overlayId)}if(!isOverlayDisplayed()&&overlayId&&overlay){params=config.overlayParams;params.afterhide=function(){if(overlays[activeId].hasOwnProperty("afterHide")&&Validate.isFunction(overlays[activeId].afterHide)){try{overlays[activeId].afterHide()}catch(err){hide()}}activeId=null};params.aftershow=function(){if(overlays[activeId].hasOwnProperty("afterShow")&&Validate.isFunction(overlays[activeId].afterShow)){try{overlays[activeId].afterShow()}catch(err){hide()}}};params.beforeshow=function(){if(overlays[activeId].hasOwnProperty("beforeShow")&&Validate.isFunction(overlays[activeId].beforeShow)){try{overlays[activeId].beforeShow()}catch(err){hide()}}delete overlays[activeId].beforeShowParams};OverlayWindow.show(overlay,params);expired=0;window.clearTimeout(_showOverlay)}else{if(expired>timeOut){expired=0;activeId=null;window.clearTimeout(_showOverlay)}else{expired+=waitTime;window.setTimeout(_showOverlay,waitTime)}}}function hide(){if(activeId){OverlayWindow.hide();activeId=null}}function isOverlayDisplayed(){var overlays=document.getElementsByClassName(config.className);for(var i=overlays.length;i--;){if(Element.hasClassName(overlays[i].parentNode,config.activeClassName)){return true}}return false}function show(overlayId,options){var isOtherOverlayDisplayed=false;var tmp=overlays[overlayId];if(!overlayId||!OverlayWindow){throw _objErrMsg+".show() -> invalid arguments given"}if(activeId){return}if(overlayId&&tmp&&tmp.hasOwnProperty("elementId")&&$(tmp.elementId)){if(!tmp.hasOwnProperty("rendered")){tmp.rendered=true;_setOverlayOnClick(tmp.elementId,overlayId)}if(options){if(options.beforeShowParams){tmp.beforeShowParams=options.beforeShowParams}}activeId=overlayId;_showOverlay()}else{throw _objErrMsg+".show() -> invalid parameter given: "+overlayId}}Event.observe(document,"keyup",_onKeyUp);return{init:initialize,hide:hide,isOverlayDisplayed:isOverlayDisplayed,show:show}}();namespace("UPC.apps.epg");UPC.apps.epg.ToolBoxController=function(){var _objName="UPC.apps.epg.ToolboxController";var _objErrMsg="Error in "+_objName+": ";var channelsPopup,programmesPopup,mainElement,toolboxSettings=null;var config={channelClassName:"channel_info",currentClassName:"current",filteredClassName:"filtered",filteredOutClassName:"filtered_out",noSelection:"WONoSelectionString",favouriteClassName:"favourite",selectorTemplate:new Template("li:not([class~=#{filter}]):not([class~=channel_info])"),selectProgrammeId:"programme_type",selectChannelId:"channels_type",updateContainerId:"word_popup_update_container",cookieName:"epg_filter",cookieExpiresDays:0,cookieDefaultValues:["WONoSelectionString","WONoSelectionString"],gridMenuId:"grid_menu_container"};var menus=$A([config.selectProgrammeId,config.selectChannelId]);var suppressFilterErrorMsgs=false;try{var Cookie=UPC.util.Cookie;var Exception=UPC.util.Exception;var FavouritesController=null;var GridController=null;var Locale=UPC.util.Localization;var Validate=UPC.util.Validate;var WordPopup=UPC.widgets.WordPopup}catch(err){throw _objErrMsg+"-> dependancy library is missing or did not initiate properly "}function initialize(element){mainElement=element;if(mainElement===null){throw _objErrMsg+"target element could not be found."}try{FavouritesController=UPC.apps.epg.FavouritesController;GridController=UPC.apps.epg.GridController}catch(err){throw _objErrMsg+"-> dependancy library is missing or did not initiate properly "}_loadToolboxSettings();var menuAOptIndex=_getIndexOfValue(config.selectProgrammeId,toolboxSettings[menus.indexOf(config.selectProgrammeId)]);programmesPopup=new WordPopup(config.selectProgrammeId,config.updateContainerId,{selectedIndex:menuAOptIndex},applyProgrammeFilter);var menuBOptIndex=_getIndexOfValue(config.selectChannelId,toolboxSettings[menus.indexOf(config.selectChannelId)]);channelsPopup=new WordPopup(config.selectChannelId,config.updateContainerId,{selectedIndex:menuBOptIndex},applyChannelFilter);mainElement.observe("epg:contentUpdated",applyFilters);return this}function _getIndexOfValue(selectId,optionVal){var opt=$(selectId).select('option[value="'+optionVal+'"]')[0];return(opt)?opt.index:0}function _loadToolboxSettings(){toolboxSettings=Cookie.readJ(config.cookieName);if(null===toolboxSettings){toolboxSettings=config.cookieDefaultValues;Cookie.writeJ(config.cookieName,toolboxSettings,config.cookieExpiresDays)}}function _updateToolboxSettings(pos,value){if(Validate.isDigit(pos)&&Validate.isString(value)){toolboxSettings[pos]=value;Cookie.writeJ(config.cookieName,toolboxSettings,config.cookieExpiresDays)}}function applyChannelFilter(filter){if(filter){_updateToolboxSettings(menus.indexOf(config.selectChannelId),filter.value);applyFilters()}}function applyChannelGroupFilter(groupId){var channel=null;var channelFound=false;var channels=mainElement.getElementsByTagName("ol");var filteredOutClassName=config.filteredOutClassName;var logTime=new Date().getTime();var visibleChannelsCount=0;FavouritesController.display();if(groupId!==config.noSelection){for(var i=0,max=channels.length;i<max;i+=1){channel=channels[i];if(Element.hasClassName(channel,groupId)){visibleChannelsCount++}else{Element.addClassName(channel,filteredOutClassName)}}}else{visibleChannelsCount=mainElement.getElementsByTagName("ol").length}if(visibleChannelsCount===0){if(groupId===config.favouriteClassName&&!suppressFilterErrorMsgs){Exception.raise(Locale.getString("error.favourites.no_results.msg"),Locale.getString("error.favourites.no_results.title"),{onRaiseReload:false})}else{if(!suppressFilterErrorMsgs){Exception.raise(Locale.getString("error.filter.no_results.msg"),Locale.getString("error.filter.no_results.title"),{onRaiseReload:false})}}groupId=config.noSelection;channelsPopup.setSelectedIndex(0);applyChannelFilter(groupId)}else{UPC.apps.epg.visibleChannelsCount=visibleChannelsCount}_updateToolboxSettings(menus.indexOf(config.selectChannelId),groupId);GridController.needsDisplay()}function applyFilters(){applyChannelGroupFilter(channelsPopup.selectEl.value);applyProgrammeFilter(programmesPopup.selectEl)}function applyProgrammeFilter(filter){var channel,channels,programs,events=null;var filteredOutClassName=config.filteredOutClassName;var visibleChannelsCount=mainElement.getElementsByTagName("ol").length;resetFilter();if(filter&&filter.value!==config.noSelection){channels=mainElement.getElementsByTagName("ol");for(var i=channels.length;i--;){channel=channels[i];if(!Element.hasClassName(channel,filteredOutClassName)){programs=getElementsByPrgGenre(filter.value,channel);if(programs.length===0){Element.addClassName(channel,filteredOutClassName);visibleChannelsCount--}else{events=channel.getElementsByTagName("li");for(var j=events.length;j--;){if(events[j].id&&events[j].id===config.gridMenuId){continue}if(Element.hasClassName(events[j],config.channelClassName)){continue}if(Element.hasClassName(events[j],filter.value)){Element.addClassName(events[j],config.filteredClassName)}else{Element.addClassName(events[j],config.filteredOutClassName)}}}}else{visibleChannelsCount--}}UPC.apps.epg.visibleChannelsCount=visibleChannelsCount;if(visibleChannelsCount===0){filter.value=config.noSelection;resetFilter();programmesPopup.setSelectedIndex(0);applyChannelGroupFilter(channelsPopup.selectEl.value);if(!suppressFilterErrorMsgs){Exception.raise(Locale.getString("error.filter.no_results.msg"),Locale.getString("error.filter.no_results.title"),{onRaiseReload:false})}}}_updateToolboxSettings(menus.indexOf(config.selectProgrammeId),filter.value);GridController.needsDisplay()}function getChannelsPopUp(){return channelsPopup}function getElementsByPrgGenre(searchClass,node){var classElements=[];if(node===null){node=document}var els=node.getElementsByTagName("li");for(var i=0,j=0,max=els.length;i<max;i+=1){if(Element.hasClassName(els[i],searchClass)){classElements[j]=els[i];j++}}return classElements}function suppressErrors(arg){if(Validate.isBoolean(arg)){suppressFilterErrorMsgs=arg}}function resetFilter(){var channels,programmes,event=null;var filteredClassName=config.filteredClassName;var filteredOutClassName=config.filteredOutClassName;if(channelsPopup.selectEl.value!==config.noSelection){channels=document.getElementsByClassName(channelsPopup.selectEl.value)}else{channels=document.getElementsByTagName("ol")}UPC.apps.epg.visibleChannelsCount=channels.length;if(GridController){GridController.resetGridView()}for(var i=channels.length;i--;){if(Element.hasClassName(channels[i],filteredOutClassName)){Element.removeClassName(channels[i],filteredOutClassName)}programmes=channels[i].getElementsByTagName("li");for(j=programmes.length;j--;){if(Element.hasClassName(programmes[j],filteredOutClassName)){Element.removeClassName(programmes[j],filteredOutClassName)}else{if(Element.hasClassName(programmes[j],filteredClassName)){Element.removeClassName(programmes[j],filteredClassName)}}}}}return{init:initialize,applyChannelFilter:applyChannelFilter,applyChannelGroupFilter:applyChannelGroupFilter,applyPopups:applyFilters,applyProgrammeFilter:applyProgrammeFilter,channelsPopup:getChannelsPopUp,getElementsByPrgGenre:getElementsByPrgGenre,suppressErrors:suppressErrors,resetPopups:resetFilter}}();namespace("UPC.apps.epg");UPC.apps.epg.TimeController=function(){var _objName="UPC.apps.epg.TimeController";var _objErrMsg="Error in "+_objName+": ";var dayLocalizerKeys=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];var monthLocalizerKeys=["january","february","march","april","may","june","july","august","september","october","november","december"];var currentTimeSlot=null;var timeControl=null;var ctiElement=null;var hideCtiElement=false;var mainElement=null;var currentEvents=[];var ctiStarted=false;var _ctiOffset=null;var ctiCurrentStyle=null;var config={currentClassName:"current",filteredClassName:"filtered",filteredOutClassName:"filtered_out",hours:3,primetimeStartHour:20,timeRibbonId:"timeline",timeControllerId:"timeController",dateClassName:"date",dayClassName:"day",hoursId:"hours",ctiElementId:"current_time_indicator",selectedClassName:"selected",selectedDayClassName:"selected_day",selectedHoursSelector:"#timeController ul#hours li.selected",selectedDaySelector:"#timeController > li.selected_day",hourUnitsSelector:"#timeController ul#hours li",dayLinksSelector:"#timeController a.date",dateTimeDisplayId:"current_date",timeSlotTemplate:null,hourMarkerSelector:".timeline",isTodayClassName:"today",ctiInterval:60,ctiFirstMarketInset:30};var Config=null,Locale=null,DataController=null;function initialize(element){mainElement=$(element);if(mainElement===null){return false}try{Config=UPC.util.Configuration;Locale=UPC.util.Localization;DataController=UPC.apps.epg.DataController}catch(err){throw _objErrMsg+"-> dependancy library is missing or did not initiate properly"}timeControl=$(config.timeControllerId);if(timeControl===null){throw _objErrMsg+"Time Controller element could not be found. Was expecting to find ul#timeController"}currentTimeSlot=new Date();currentTimeSlot.setDate(currentTimeSlot.getDate());currentTimeSlot.setMinutes(0);currentTimeSlot.setSeconds(0);currentTimeSlot.setMilliseconds(0);Element.observe(config.timeControllerId,"click",function(e){var element=e.element();if(element.nodeName==="A"&&Element.hasClassName(element,config.dateClassName)){_dateOnClick(element);e.stop()}else{if(element.nodeName==="LI"&&!Element.hasClassName(element,config.selectedDayClassName)){if(Element.hasClassName(element,config.dayClassName)){element=element.down("a");_dateOnClick(element)}else{if(element.parentNode.id===config.hoursId){_timeOnClick(element)}}e.stop()}}});ctiElement=$(config.ctiElementId);mainElement.observe("epg:contentUpdated",updateDisplay);return this}function _dateOnClick(element){var parentElement=element.up();var selectedDay=$$(config.selectedDaySelector).first();displayTimeIndicator(false);document.fire("epg:dateChange");Element.removeClassName(selectedDay,config.selectedDayClassName);parentElement.addClassName(config.selectedDayClassName);parentElement.insert($(config.hoursId));if(parentElement.hasClassName(config.isTodayClassName)){_selectNow()}_updateGridDate(element)}function _selectPrimetime(){currentTimeSlot.setHours(config.primetimeStartHour);_selectCurrentHours()}function _selectNow(){currentTimeSlot=new Date();currentTimeSlot.setMinutes(0);currentTimeSlot.setSeconds(0);currentTimeSlot.setMilliseconds(0);_selectCurrentHours()}function _selectCurrentHours(){$$(config.selectedHoursSelector).invoke("toggleClassName",config.selectedClassName);var startHour=currentTimeSlot.getHours();var defaultHours=$$(config.hourUnitsSelector);var defaultHoursA=$A(defaultHours).slice(startHour,startHour+config.hours);defaultHoursA.invoke("toggleClassName",config.selectedClassName)}function _timeOnClick(element){var times=$$(config.hourUnitsSelector);var timesA=$A(times);var hour=timesA.indexOf(element);var currentSelectedTimes,selectedTimes=null;if(currentTimeSlot.getHours()!=hour){displayTimeIndicator(false);document.fire("epg:timeChange");hour=Math.min(25-config.hours,hour);currentSelectedTimes=$$(config.selectedHoursSelector);currentSelectedTimes.invoke("toggleClassName",config.selectedClassName);selectedTimes=timesA.slice(hour,hour+config.hours);selectedTimes.invoke("toggleClassName",config.selectedClassName);_updateGridTime(hour)}}function _updateGridDate(element){var date;var tmp=Element.hasAttribute(element,"href");if(Element.hasAttribute(element,"href")){date=currentTimeSlot;tmp=Element.readAttribute(element,"href");tmp=/^#(\d{4})-(\d{2})-(\d{2})T$/.exec(tmp);if(tmp&&tmp.length==4){date=new Date(Date.UTC(tmp[1],parseInt(tmp[2],10)-1,tmp[3],date.getUTCHours(),date.getUTCMinutes(),0))}currentTimeSlot=date;DataController.load(currentTimeSlot,function(){hideCtiElement=false})}}function _updateDate(){var locale=Config.getConfigValue("TimeController.locale");if(Locale.isLoaded(locale)){var endHour=currentTimeSlot.getHours()+3;endHour=(endHour>24)?endHour-24:endHour;endHour=(endHour<10)?"0"+endHour:endHour;config.timeSlotTemplate=new Template(Locale.getString("timeSlotDateFormat"));var timeSlotStringValues={day_abbr:Locale.getString("days.full."+dayLocalizerKeys[currentTimeSlot.getDay()]),date:currentTimeSlot.getDate(),month_abbr:Locale.getString("months.full."+monthLocalizerKeys[currentTimeSlot.getMonth()]),hour_start:currentTimeSlot.getHours(),hour_end:endHour};var time=config.timeSlotTemplate.evaluate(timeSlotStringValues);today=new Date().getDay();if(currentTimeSlot.getDay()===today){time=Locale.getString("days.today")}else{if(currentTimeSlot.getDay()===(today+1)){time=Locale.getString("days.tomorrow")}}$(config.dateTimeDisplayId).innerHTML=time}}function _updateDateMarkers(){var date=currentTimeSlot;var dateHref=[date.getFullYear(),"-",date.getMonth()<10?"0"+(date.getMonth()+1):(date.getMonth()+1),"-",date.getDate()<10?"0"+date.getDate():date.getDate(),"T"].join("");var selectedDay=$$(config.selectedDaySelector).first();var timeline=$(config.timeControllerId);if(timeline===null){return}timeline.select(".date").each(function(element,idx){if(element.href&&Element.readAttribute(element,"href").substring(1)===dateHref){Element.removeClassName(selectedDay,config.selectedDayClassName);element.up().addClassName(config.selectedDayClassName);element.up().insert($(config.hoursId))}})}function _updateHourMarkers(){var ribbon=$(config.timeRibbonId);if(ribbon===null){return}var hourValue=currentTimeSlot.getHours();ribbon.select(".timeline_position").each(function(hr,idx){hr.innerHTML=(hourValue<10?"0"+hourValue:hourValue)+":00";hourValue++;if(hourValue===24){hourValue=0}}.bind(this))}function _updateGridTime(hour){currentTimeSlot.setHours(hour);DataController.load(currentTimeSlot,function(){hideCtiElement=false})}function ctiCalculatedOffset(){if(_ctiOffset===null){var ctiWidth=ctiElement.getWidth()/2;var timeline=$(config.timeRibbonId);var timelineOrigin=timeline.cumulativeOffset();var leftOffset=timelineOrigin.left-ctiWidth;var topOffset=timelineOrigin.top+timeline.getHeight();_ctiOffset={top:topOffset,left:leftOffset}}return _ctiOffset}function displayTimeIndicator(show){var now=new Date();var ts=new Date();if(show&&currentTimeSlot){ts.setTime(currentTimeSlot.getTime()+(3*3600000));if(now<currentTimeSlot||now>ts){hideCtiElement=true;Element.hide(ctiElement)}else{if(show===true){hideCtiElement=false;Element.show(ctiElement)}}return}hideCtiElement=true;Element.hide(ctiElement)}function getCurrentTimeSlot(){return currentTimeSlot}function setCurrentTimeSlot(date,callback){if(date){currentTimeSlot=new Date(date);displayTimeIndicator(true);_updateDateMarkers();_updateHourMarkers();_selectCurrentHours();_updateDate();DataController.load(currentTimeSlot,function(){if(typeof(callback)==="function"){callback()}}.bind(this))}}function updateDisplay(){var timeslot=currentTimeSlot.getTime();var nowTimeSlot=new Date().getTime();_updateHourMarkers();_selectCurrentHours();if(timeslot<=nowTimeSlot&&nowTimeSlot<=(timeslot+3*3600*1000)){setTimeout(updateTimeIndicator,1)}_updateDate()}function updateTimeIndicator(newHeight){var now=new Date();var channels=mainElement.getElementsByTagName("ol");var channelEvents,event,time;var ctiPos=0;var currentClassName=config.currentClassName;var ctiTimeElapsed=((now-currentTimeSlot)/60000);var ctiMinutesResolution=5;var ctiShift=Math.floor(ctiTimeElapsed/ctiMinutesResolution*20);var ctiOffset=ctiCalculatedOffset();var currentEventFound=false;var hours=(now.getHours()<10)?"0"+now.getHours():now.getHours();var mins=(now.getMinutes()<10)?"0"+now.getMinutes():now.getMinutes();var timestamp=(hours+"."+mins)/1;if(hideCtiElement===true){displayTimeIndicator(false)}else{displayTimeIndicator(true)}ctiCurrentStyle={left:ctiOffset.left+ctiShift,top:ctiOffset.top};ctiElement.setStyle({left:ctiCurrentStyle.left+"px",top:ctiCurrentStyle.top+"px"});for(var i=0,max=currentEvents.length;i<max;i+=1){if(Element.hasClassName(currentEvents[i],currentClassName)){Element.removeClassName(currentEvents[i],currentClassName)}if(i===currentEvents.length-1){currentEvents=[]}}for(i=channels.length;i--;){currentEventFound=false;channelEvents=channels[i].getElementsByTagName("li");for(var x=channelEvents.length;x--;){event=channelEvents[x];time=event.getElementsByTagName("span")[1];if(time){time=time.innerHTML.split("-").inject([],function(array,el){array.push(el.replace(":",".")/1);return array});if((time&&time[0]<=timestamp&&(time[1]>timestamp||time[1]<time[0]))||(time[0]==time[1])){Element.addClassName(event,currentClassName);currentEventFound=true;currentEvents.push(event);break}}if(currentEventFound){break}}}document.fire("epg:timeUpdated");if(!ctiStarted){new PeriodicalExecuter(function(){var timeslot=currentTimeSlot.getTime();var nowTimeSlot=new Date().getTime();if(timeslot<=nowTimeSlot&&nowTimeSlot<=(timeslot+3*3600*1000)){updateTimeIndicator()}},config.ctiInterval);ctiStarted=true}}function resetHorizontalPositionAndHeight(height){var ctiOffset=ctiCalculatedOffset();_ctiOffset=null;var newCtiOffset=ctiCalculatedOffset();var leftMovePixels=ctiOffset.left-newCtiOffset.left;var ctiStyle={};if(height!==null){ctiStyle.height=height+"px"}if(ctiCurrentStyle!==null){ctiCurrentStyle.left=Math.round(ctiCurrentStyle.left-leftMovePixels);ctiStyle.left=ctiCurrentStyle.left+"px"}ctiElement.setStyle(ctiStyle)}return{init:initialize,displayTimeIndicator:displayTimeIndicator,getCurrentTimeSlot:getCurrentTimeSlot,setCurrentTimeSlot:setCurrentTimeSlot,updateDisplay:updateDisplay,updateTimeIndicator:updateTimeIndicator,resetPosition:resetHorizontalPositionAndHeight}}();namespace("UPC.apps.epg");UPC.apps.epg.DataController=function(){var _objName="UPC.apps.epg.DataController";var _objErrMsg="Error in "+_objName+": ";var cache={keys:[],data:[]};var loading=[];var busyElement,mainElement,scId,scElement=null;var busy=false;var Config=null,Exception=null;var GridController=null,Locale=null,TimeController=null;function initialize(element){mainElement=$(element);if(!mainElement){throw _objErrMsg+"main element could not be found."}mainElement.observe("epg:contentUpdated",preloadData);try{Config=UPC.util.Configuration;Exception=UPC.util.Exception;GridController=UPC.apps.epg.GridController;Locale=UPC.util.Localization;TimeController=UPC.apps.epg.TimeController}catch(err){throw _objErrMsg+"initialize() -> dependancy library is missing or did not initiate properly"}scId=Config.getConfigValue("GridController.slotContainerId");scElement=$(scId);if(scElement){busyElement=scElement.innerHTML}return this}function cacheData(datetime,cityCode,transport){var data={};data.timeslot=datetime.getTime();data.content=transport.responseText;data.cityCode=cityCode;if(cache.length>=Config.getConfigValue("DataController.maxCacheSize")){cache.shift()}var cacheKey=data.timeslot+"|"+data.cityCode;cache.keys.push(cacheKey);cache.data[cacheKey]=data;if(datetime.getTime()==TimeController.getCurrentTimeSlot().getTime()){displayData(datetime)}if(cache.keys.length===1){GridController.resizeGrid()}}function displayData(datetime){var data=null;if(typeof datetime==="undefined"){datetime=TimeController.getCurrentTimeSlot()}var cacheKey=datetime.getTime()+"|"+_getCityCode();data=getDataFromCache(cacheKey);mainElement.update(data.content);mainElement.fire("epg:contentUpdated",{datetime:datetime})}function preloadData(e){var datetime=e.memo.datetime;for(var idx=1;idx<=Config.getConfigValue("DataController.preloadCount");idx++){var ts=new Date(datetime.getFullYear(),datetime.getMonth(),datetime.getDate(),datetime.getHours(),0,0);ts.setHours(ts.getHours()+(3*idx));var cityCode=_getCityCode();var ajaxOptions={method:"get",onSuccess:cacheData.bind(this,ts,cityCode),onFailure:function(){}};var cacheKey=ts.getTime()+"|"+cityCode;if(getDataFromCache(cacheKey)===null&&!loading.include(ts.getTime())){loading.push(ts.getTime());var url=Config.getConfigValue("DataController.dataUrlTpl").evaluate({datetime:ts.toJSON().gsub(/"/,""),cityCode:cityCode?("&city="+cityCode):""});new Ajax.Request(url,ajaxOptions)}}}function _getCityCode(){var value="";var user=EpgSession.getUser();if(user){if(value=user.getCityCode()){return value}}return""}function loadData(datetime,callback){var url=null;toggleLoader(true);if(typeof datetime==="undefined"){datetime=TimeController.getCurrentTimeSlot()}var cityCode=_getCityCode();url=Config.getConfigValue("DataController.dataUrlTpl").evaluate({datetime:datetime.toJSON().gsub(/"/,""),cityCode:cityCode?("&city="+cityCode):""});var cacheKey=datetime.getTime()+"|"+cityCode;if(getDataFromCache(cacheKey)!==null){displayData();if(typeof callback==="function"){callback()}}else{if(url){new Ajax.Request(url,{method:"get",onSuccess:function(response){cacheData(datetime,cityCode,response);if(typeof callback==="function"){callback()}},onFailure:raiseException})}}}function getDataFromCache(cacheKey){if(cache.keys.include(cacheKey)){return cache.data[cacheKey]}return null}function raiseException(msg){toggleLoading(false);Exception.raise(Locale.getString("error.data.not_loaded.msg"),Locale.getString("error.data.not_loaded.title"));return false}function toggleLoader(show){if(cache.keys.length>0&&show!==busy&&scElement&&busyElement){if(show){busy=true;document.body.style.cursor="wait";scElement.update(busyElement)}else{window.setTimeout(function(){busy=false;document.body.style.cursor="default"},0)}}}return{init:initialize,load:loadData,display:displayData,toggleLoader:toggleLoader}}();UPC.apps.epg.FavouritesController=function(){var _objName="UPC.apps.epg.FavouritesController";var _objErrMsg="Error in "+_objName+": ";var config={channelIdPrefix:"cid_",cookieName:"epg_favs",cookieNameDepreacted:"UPC.apps.epg.userFavourites",cookieExpires:365,favouriteClassName:"favourite",filteredOutClassName:"filtered_out"};var custApiFavourites=[];var favourites=[];var mainElement=null;try{var Config=UPC.util.Configuration;var Cookie=UPC.util.Cookie;var Locale=UPC.util.Localization;var LogicController=UPC.apps.epg.LogicController;var Validate=UPC.util.Validate}catch(err){throw _objErrMsg+"-> dependancy library is missing or did not initiate properly  "}function initialize(element){mainElement=element;if(!mainElement){throw _objErrMsg+"main element missing."}_loadFavourites();return this}function _addFavourite(id){if(id){favourites.push(id)}}function _loadFavourites(callback){var user,tmp=null;if(EpgSession.isValid()){user=EpgSession.getUser();user.retrieveFavourites({onSuccess:function(data,response){custApiFavourites=data;if(callback){callback()}},onFailure:function(response){}})}else{tmp=Cookie.readJSON(config.cookieName);if(tmp){favourites=tmp;if(callback){callback()}}}}function _parseChannelElement(element){var tmp=null;if(element&&element.hasAttribute("id")){tmp=element.id.split("_");if(Validate.isArray(tmp)&&tmp.length>=2){return tmp[1]}}return null}function _removeFavourite(id){favourites=favourites.without(id)}function displayFavourites(){var channelIdPrefix=config.channelIdPrefix;var favouriteClassName=config.favouriteClassName;var element=null;if(EpgSession.isValid()){for(var i=favourites.length;i--;){element=$(channelIdPrefix+favourites[i]);if(element){Element.removeClassName(element,favouriteClassName)}}for(var i=custApiFavourites.length;i--;){element=$(channelIdPrefix+custApiFavourites[i]);if(element){Element.addClassName(element,favouriteClassName)}}_loadFavourites(function(){for(var i=custApiFavourites.length;i--;){element=$(channelIdPrefix+custApiFavourites[i]);if(element){Element.addClassName(element,favouriteClassName)}}})}else{for(var i=favourites.length;i--;){element=$(channelIdPrefix+favourites[i]);if(element){Element.addClassName(element,favouriteClassName)}}}}function getFavourites(){if(EpgSession.isValid()){return custApiFavourites}return favourites}function hasFavourites(){if(EpgSession.isValid()){return custApiFavourites.length>0}return favourites.length>0}function isFavourite(channelId){if(EpgSession.isValid()){return custApiFavourites.member(channelId)}return(favourites.member(channelId))}function saveToCookie(){Cookie.writeJSON(config.cookieName,favourites,config.cookieExpires)}function update(element,callback){var action=null,re=null;var channelId=_parseChannelElement(element);var favouriteClassName=config.favouriteClassName;var user=null;if(element){if(EpgSession.isValid()){user=EpgSession.getUser();if(custApiFavourites.member(channelId)){if(Element.hasClassName(element,favouriteClassName)){Element.removeClassName(element,favouriteClassName)}action="delete";custApiFavourites.pop(channelId);user.deleteFavourite({channelId:channelId,onSuccess:function(data,response){custApiFavourites=data;if(callback){callback(action)}},onFailure:function(reponse){custApiFavourites.push(channelId);Element.addClassName(element,favouriteClassName)}})}else{Element.addClassName(element,favouriteClassName);action="add";if(!custApiFavourites.member(channelId)){custApiFavourites.push(channelId)}user.updateFavourites({channelId:channelId,onSuccess:function(data,reponse){custApiFavourites=data;if(callback){callback(action)}},onFailure:function(reponse){custApiFavourites.pop(channelId);Element.removeClassName(element,favouriteClassName)}})}}else{if(favourites.member(channelId)){Element.removeClassName(element,favouriteClassName);action="delete";_removeFavourite(channelId)}else{Element.addClassName(element,favouriteClassName);action="add";_addFavourite(channelId)}if(callback){callback(action)}saveToCookie()}return true}return false}return{init:initialize,display:displayFavourites,get:getFavourites,hasFavourites:hasFavourites,isFavourite:isFavourite,update:update}}();namespace("UPC.apps.epg");UPC.apps.epg.GridMenuController=function(){var _objName="UPC.apps.epg.GridMenuController";var _objErrMsg="Error in "+_objName+": ";var active={};var activeClass="active";var options={};var mainElement=null;var mainElementId="grid_menu";var tmp=null;var Config=null;function initialize(userOptions){try{Config=UPC.util.Configuration}catch(err){throw _objErrMsg+"initialize() -> dependancy library is missing or did not initiate properly  "}if(typeof userOptions!="undefined"){Object.extend(options,userOptions)}mainElementId=_getConfigValue("elementId")||mainElementId;mainElement=document.createElement("LI");mainElement.setAttribute("id",mainElementId);Element.hide(mainElement);return this}function _getConfigValue(key){if(options!==null){return options[key]||Config.getConfigValue("GridMenuController."+key)}else{return Config.getConfigValue("GridMenuController."+key)}}function _slideIn(){if(active&&active.channelElement){tmp=Element.childElements(active.channelElement);if(tmp){tmp.each(function(child,index){if(index===1&&child.id===active.elementId&&tmp.length===3){Element.removeClassName(child,activeClass)}else{if(child.id===active.elementId){Element.removeClassName(child,activeClass)}}})}Element.hide(mainElement)}}function _slideOut(){var tmp=null;if(active&&active.channelElement){tmp=Element.childElements(active.channelElement);if(tmp){tmp.each(function(child,index){if(index===1&&child.id===active.elementId&&tmp.length===3){child.addClassName(activeClass)}else{if(index!==0&&child.id===active.elementId){child.addClassName(activeClass)}}})}Element.show(mainElement)}}function getHeight(){if(active!==null&&mainElement){return Element.getHeight(mainElement)}return 0}function hide(){if(active!==null&&active.element&&mainElement){active.channelElement=active.element.parentNode;if(typeof _getConfigValue("beforeHide")==="function"){_getConfigValue("beforeHide")(active)}_slideIn();active=null;if(typeof _getConfigValue("afterHide")==="function"){_getConfigValue("afterHide")()}}}function setContent(html){mainElement.innerHTML=html}function setParams(args){if(args.slideOutHeight){options.slideOutHeight=args.slideOutHeight}}function show(elementId){try{var tmp=null;if(active&&active.element){hide()}active={elementId:elementId};active.element=$(elementId);if(!active.element){return false}active.channelElement=active.element.parentNode;if(active.channelElement&&mainElement){if(typeof _getConfigValue("beforeShow")==="function"){_getConfigValue("beforeShow")(active)}active.channelElement.appendChild(mainElement);_slideOut();if(typeof _getConfigValue("afterShow")==="function"){_getConfigValue("afterShow")(active)}}}catch(err){}}function reload(){if(active){_slideIn();if(typeof _getConfigValue("beforeShow")==="function"){_getConfigValue("beforeShow")(active)}_slideOut();if(typeof _getConfigValue("afterShow")==="function"){_getConfigValue("afterShow")(active)}}}return{init:initialize,getHeight:getHeight,hide:hide,setContent:setContent,setParams:setParams,show:show,reload:reload}}();namespace("UPC.apps.epg");UPC.apps.epg.LogicController=(function(){var _objName="UPC.apps.epg.LogicController";var _objErrMsg="Error in "+_objName+": ";var active={};var allowBookings=false;var allowReminders=false;var allowSms=false;var analyticsUrl=null;var minBookingTimeBeforeEndEvent=360;var buttons={cancel:"Cancel",close:"",info:"More information",settings:"MySettings",setBooking:"Record",setSerieBooking:"Record this episode only",setSeriesBooking:"Record all episodes",setReminder:"Set reminder"};var buttonTemplate=new Template('<button id="#{id}" #{optional} class="#{cls}"/ value=""><span>#{lbl}</span></button>');var channelIdPrefix="cid_";var channelHdClassName="hd";var confirmTemplate=new Template('<h2 class="event_title">#{title}</h2><div class="event_details" id="event_details"><span class="event_channel">#{channel}</span>, <span class="event_time">#{time}</span></div>');var sesCookieName="epg_state";var uiCookieName="epg_ui_state";var uiCookieParams=null;var analyticsPath="/javascript/deployments/EPG-JS/current/analytics-min.js";var custApiPath="/cgi-bin/WebObjects/EPGBooking.woa/api/";var eventIdPrefix="eid_";var grid={element:null,bookingClasses:{deleted:"booking_deleted",failure:"booking_failure",overridden:"booking_overridden",pending:"booking_pending",success:"booking_success",waiting:"booking_waiting"},callbacks:{},liveTVClass:"livetv",reminderClasses:{failure:"reminder_failure",pending:"reminder_pending",success:"reminder_success",waiting:"reminder_waiting"}};var gridMenu={element:null,elementId:"grid_menu_container",buttonClass:"grid_menu_button",buttonsContainerId:"grid_menu_buttons_container",buttonsHTML:null,contentTemplate:new Template('<div class="grid_menu_content_container"><div class="grid_menu_event_detail_container"><button class="grid_menu_close_button" id="grid_menu_close"><span>#{closeButtonText}</span></button> <span id="grid_menu_event_url">#{title}</span><br/><span id="grid_menu_event_channel">#{channel}</span>, <span id="grid_menu_time">#{time}</span><br/><p id="grid_menu_desc">#{desc}</p></div><div id="grid_menu_dvr_container">#{DVRContent} </div></div>'),locale:null,setBookingButtonId:"grid_menu_set_booking",setSeriesBookingButtonId:"grid_menu_set_series_booking",setReminderButtonId:"grid_menu_set_reminder",statusTemplate:new Template('<p class=" grid_menu_content #{cls} ">#{msg}</p>')};var gridPage=true;var hasSesCookieName="epg_hs";var overlays={splash:{elementId:"splash_content_container",html:"",onClick:function(element){if(element){switch(element.id){case"splash_close":OverlayController.hide();break;case"btn_login":location.href="https://"+location.hostname+"/TV/";break;case"btn_learn_more":location.href="http://www.upc.pl/telewizja/poznaj-telewizje-cyfrowa/zdalne-nagrywanie/";break}}}},faq:{elementId:"faq_content_container",html:"",activeClassName:"active"},login:{elementId:"login_content_container",checkboxId:"login_checkbox",formId:"login_details",formContainerId:"login_form_container",html:"",msgContainerId:"login_msg_container",passwordId:"login_user_passwd",rememberMeId:"login_remember_me",usernameId:"login_user_name",waitingContainerId:"login_waiting_container",beforeShowParams:null},settings:{elementId:"settings_content_container",html:"",activeClassName:"active",formContainerId:"settings_form_container",givenNameId:"settings_user_given_name",familyNameId:"settings_user_family_name",emailCheckboxId:"settings_user_email_checkbox",emailInputId:"settings_user_email_input",emailInputContainerId:"settings_user_email_input_container",emailTextId:"settings_user_email_text",emailTextContainerId:"settings_user_email_text_container",emailConfirmId:"settings_user_email_confirm",emailFailureId:"settings_user_email_failure",emailInvalidId:"settings_user_email_invalid",emailSentId:"settings_email_sent",notifyContainerId:"settings_user_notify_container",smsContainerId:"settings_user_sms_content_container",smsCheckboxId:"settings_user_sms_checkbox",smsFailureId:"settings_user_sms_failure",smsInvalidId:"settings_user_sms_invalid",smsInputId:"settings_user_sms_input",smsInputContainerId:"settings_user_sms_input_container",smsTextId:"settings_user_sms_text",smsTextContainerId:"settings_user_sms_text_container",stbContainerId:"settings_stb_container",stbOptionsContainerId:"settings_stb_options_container",submitButtonId:"settings_done",termsContainerId:"settings_terms_container",termsBackButtonId:"settings_show",waitingContainerId:"settings_waiting_container",upsellContainerId:"settings_upsell_container",multiBoxMessageId:"settings_multi_box_message",warningClassName:"warning_content"},setBooking:{elementId:"set_booking_content_container",contentTemplate:confirmTemplate,detailsId:"set_booking_event_details",overrideNoId:"set_booking_override_no",overrideYesId:"set_booking_override_yes",html:""},setSeriesBooking:{elementId:"set_series_booking_content_container",contentTemplate:confirmTemplate,detailsId:"set_series_booking_details",html:""},setReminder:{elementId:"set_reminder_content_container",contentTemplate:confirmTemplate,detailsId:"set_reminder_details",html:""},setupComplete:{elementId:"setup_complete_content_container",html:""},setupNotify:{elementId:"setup_notify_content_container",html:"",activeClassName:"active",formContainerId:"setup_notify_form_container",givenNameId:"setup_notify_given_name",familyNameId:"setup_notify_family_name",emailCheckboxId:"setup_notify_email_checkbox",emailInputId:"setup_notify_email_input",emailInputContainerId:"setup_notify_email_input_container",emailTextId:"setup_notify_email_text",emailTextContainerId:"setup_notify_email_text_container",emailConfirmId:"setup_notify_email_confirm",emailFailureId:"setup_notify_email_failure",emailInvalidId:"setup_notify_email_invalid",notifyContainerId:"setup_notify_notify_container",smsContainerId:"setup_notify_sms_content_container",smsCheckboxId:"setup_notify_sms_checkbox",smsFailureId:"setup_notify_sms_failure",smsInvalidId:"setup_notify_sms_invalid",smsInputId:"setup_notify_sms_input",smsInputContainerId:"setup_notify_sms_input_container",smsTextId:"setup_notify_sms_text",smsTextContainerId:"setup_notify_sms_text_container",waitingContainerId:"setup_notify_waiting_container",warningClassName:"warning_content"},setupLegal:{checkboxId:"setup_legal_checkbox",elementId:"setup_legal_content_container",formContainerId:"setup_legal_form_container",msgContainerId:"setup_legal_msg_container",waitingContainerId:"setup_legal_waiting_container",html:""},smsToken:{elementId:"sms_token_content_container",html:"",activeClassName:"active",completeContainerId:"sms_token_complete_container",doneButtonId:"sms_token_done",formContainerId:"sms_token_form_container",smsTokenExpiredId:"sms_token_expired",smsTokenFailureId:"sms_token_failure",smsTokenInputId:"sms_token_input",smsTokenInputContainerId:"sms_token_input_container",smsTokenInvalidId:"sms_token_invalid",smsTokenSentId:"sms_token_sent",smsTokenResentId:"sms_token_resent",submitButtonId:"sms_token_submit",waitingContainerId:"sms_token_waiting_container",warningClassName:"warning_content"},upsellNoStb:{elementId:"upsell_no_stb_content_container",html:"",onClick:function(element){if(element&&element.id==="upsell_no_stb_close"){OverlayController.hide()}}},stbIncapable:{elementId:"stb_incapable_content_container",html:"",onClick:function(element){if(element&&element.id==="stb_incapable_close"){OverlayController.hide()}}},subscriptionIncompatible:{elementId:"subscription_incompatible_content_container",html:"",onClick:function(element){if(element&&element.id==="subscription_incompatible_close"){OverlayController.hide()}}},upsellNoDVR:{elementId:"upsell_no_dvr_content_container",html:"",beforeShow:function(){window.setTimeout(function(){var params,user=EpgSession.getUser();if(user&&typeof s!=="undefined"&&s_account){params={pageName:" upclive/tv_en_film/tvgids/TV/grid/upsell/no_dvr",eVar41:user.getId(),events:"event9, event44"};if(active&&active.channelId){params.eVar43=active.channelId}if(s.hasOwnProperty("record")){s.record(params)}}},0)},onClick:function(element){if(element&&element.id==="upsell_no_dvr_close"){OverlayController.hide()}}},upsellNoHD:{elementId:"upsell_no_hd_content_container",html:"",beforeShow:function(){window.setTimeout(function(){var params,user=EpgSession.getUser();if(user&&typeof s!=="undefined"&&s_account){params={pageName:"upclive/tv_en_film/tvgids/TV/grid/upsell/no_hd",eVar41:user.getId(),events:"event9,event45"};if(active&&active.channelId){params.eVar43=active.channelId}if(s.hasOwnProperty("record")){s.record(params)}}},0)},onClick:function(element){if(element&&element.id==="upsell_no_hd_close"){OverlayController.hide()}}}};var overlaysContainerId="overlays_container";var scId=null;var topNavMenu={elementId:"topnav_controls",html:"",faqId:"topnav_faq",loginId:"topnav_login",loggingInId:"topnav_logging_in",logoutId:"topnav_logout",loggingOutId:"topnav_logging_out",settingsId:"topnav_settings",settingsButtonClass:"generic_button",userDetailsId:"topnav_user_container",userFullNameId:"topnav_user_full_name"};var tmp=null;var Faq=null,Login=null,Settings=null,Setup=null,User=null;try{var Cookie=UPC.util.Cookie;var Config=UPC.util.Configuration;var Exception=UPC.util.Exception;var Locale=UPC.util.Localization;var DataController=UPC.apps.epg.DataController;var FavouritesController=UPC.apps.epg.FavouritesController;var OverlayController=UPC.apps.epg.OverlayController;var Parse=UPC.util.Parse;var TimeController=UPC.apps.epg.TimeController;var ToolBoxController=UPC.apps.epg.ToolBoxController;var Validate=UPC.util.Validate}catch(err){throw _objErrMsg+"-> dependancy library is missing or did not initiate properly"}function initialize(){if(Cookie&&document.location.protocol==="http:"&&Cookie.read(hasSesCookieName)){ToolBoxController.suppressErrors(true);_switchToProtocol("https")}tmp=_getLocaleValue("config.allowBookings");if(tmp){allowBookings=true}tmp=_getLocaleValue("config.allowReminders");if(tmp){allowReminders=true}tmp=_getLocaleValue("config.allowSms");if(tmp){allowSms=true}scId=Config.getConfigValue("GridController.slotContainerId");if($(scId)){Event.observe(scId,"click",_gridOnClick);Event.observe(scId,"change",_gridOnChange);gridMenu.locale=Locale.getLocale("gridMenu")||{};grid.callbacks={grid_menu_set_booking:{onClick:function(){if(_isActionAllowed()){OverlayController.show("setBooking")}},secure:true},grid_menu_set_serie_booking:{onClick:function(){if(_isActionAllowed()){OverlayController.show("setSeriesBooking")}},secure:true},grid_menu_set_series_booking:{onClick:function(){if(_isActionAllowed()){OverlayController.show("setSeriesBooking")}},secure:true},grid_menu_set_reminder:{onClick:function(){if(_isActionAllowed(true)){OverlayController.show("setReminder")}},secure:true},grid_menu_close:{onClick:function(){deleteUiState();document.fire("epg:gridMenuHide")}}};document.observe("epg:timeUpdated",function(){document.fire("epg:gridMenuReload")})}else{gridPage=false}if(allowBookings){_secureCopyObject(topNavMenu,_getConfigValue("topNavMenu"));tmp=$(topNavMenu.elementId);if(tmp){tmp.innerHTML=_getLocaleValue("topNavMenu.html")||topNavMenu.html}tmp=_getLocaleValue("config.minBookingTimeBeforeEndEvent");if(Validate.isDigit(tmp)){minBookingTimeBeforeEndEvent=parseInt(tmp,10)}minBookingTimeBeforeEndEvent*=1000;OverlayController.init($(overlaysContainerId),overlays);Login=_loginOverlay();TopNavigation=_topNavigation();window.setTimeout(function(){var sCode=null;if(allowBookings&&Cookie&&document.location.protocol==="https:"){custApiPath=_getConfigValue("custApiPath")||custApiPath;EpgSession.setParams({lang:Locale.getString("lang"),basePath:custApiPath});if(EpgSession.hasCookie()){ToolBoxController.suppressErrors(true);TopNavigation.toggle("loggingIn");Login.submit()}else{TopNavigation.toggle("loggedOut");OverlayController.show("login")}}else{restoreUiState()}Faq=_faqOverlay();Settings=_settingsOverlay();SetBooking=_setBookingOverlay();SetReminder=_setReminderOverlay();Setup=_setupOverlay();SmsToken=_smsTokenOverlay()},0)}else{_setupTopNavigationWhenBookingsDisallowed();OverlayController.init($(overlaysContainerId),overlays);Faq=_faqOverlay()}analyticsPath=_getConfigValue("analyticsPath")||analyticsPath;if(analyticsPath){window.setTimeout(function(){var script=document.createElement("SCRIPT");var heads=document.getElementsByTagName("HEAD");script.setAttribute("type","text/javascript");script.setAttribute("src",analyticsPath);for(i=heads.length;i--;){heads[i].appendChild(script)}},0)}return this}function _eventToElementId(event){if(event instanceof EpgBooking||event instanceof EpgReminder){if(event.hasSeriesId()){return eventIdPrefix+event.getEventId()+"_"+event.getChannelId()+"_"+event.getIso8601StartDateTime()+"_"+event.getSeriesId()}else{return eventIdPrefix+event.getEventId()+"_"+event.getChannelId()+"_"+event.getIso8601StartDateTime()}}else{return null}}function _faqOverlay(){var config=overlays.faq;var activeClassName=config.activeClassName||"active";var faq=$(config.elementId);var selected=null;function _beforeShow(){if(selected){_reset()}selected=null}function _onClick(element){if(element){if(Element.hasAttribute(element,"id")&&element.id==="faq_close"){_reset();OverlayController.hide()}else{if(element.nodeName==="DT"){if(selected&&selected===element){_reset();selected=null}else{if(selected){_reset()}Element.toggleClassName(element,activeClassName);selected=element;element=Element.next(element);if(element){Element.addClassName(element,activeClassName)}}}}}}function _reset(){var active=null;if(faq){active=faq.getElementsByClassName(activeClassName);for(var i=active.length;i--;){Element.removeClassName(active[i],activeClassName)}}}config.beforeShow=_beforeShow;config.onClick=_onClick;return this}function _getButtonText(key){if(key&&typeof key==="string"){return _getLocaleValue("buttons."+key)||buttons[key]}return null}function _getConfigValue(key){return Config.getConfigValue("LogicController."+key)}function _getLocaleValue(key){var locale=null;if(key){locale=Locale.getString(key);if(locale.constructor===Array){locale=locale.join("")}return locale||null}return null}function _getStatusGridElement(element,eventType){var tmp=null;if(element){if(eventType==="booking"){tmp=grid.bookingClasses}else{if(eventType==="reminder"){tmp=grid.reminderClasses}}for(var cls in tmp){if(tmp.hasOwnProperty(cls)&&Element.hasClassName(element,tmp[cls])){return cls}}}return null}function _gridOnChange(e){var element=e.element();if(Element.hasAttribute("id")&&element.id!=scId){if(element.id&&gridCallbacks.hasOwnProperty(element.id)){if(gridCallbacks[element.id].hasOwnProperty("onChange")){gridCallbacks[element.id].onChange(e);e.stop()}}}}function _gridOnClick(e){var element=e.element();var user=EpgSession.getUser();if(element.nodeName==="SPAN"&&element.parentNode.nodeName==="BUTTON"){element=element.parentNode}if(element.hasAttribute("id")&&element.id!=scId){if(element.id&&grid.callbacks.hasOwnProperty(element.id)){if(grid.callbacks[element.id].hasOwnProperty("onClick")){if(grid.callbacks[element.id].hasOwnProperty("secure")&&grid.callbacks[element.id].secure===true){saveUiState({eId:active.elementId,buttonId:element.id});if(document.location.protocol!=="https:"){_switchToProtocol("https")}else{if(!EpgSession.isValid()){document.fire("epg:gridMenuReload");OverlayController.show("login")}else{if(!user.getIsAccountEnabled()){document.fire("epg:gridMenuReload");OverlayController.show("setupLegal")}else{grid.callbacks[element.id].onClick(e);e.stop()}}}}else{grid.callbacks[element.id].onClick(e);e.stop()}}}}}function _isActionAllowed(isReminder){var user=EpgSession.getUser();if(user&&active&&active.hasOwnProperty("eventId")){if(user.hasIncompatibleSubscription()){OverlayController.show("subscriptionIncompatible");return false}else{if(user.getBoxes()==="undefined"||user.getBoxes().length===0){OverlayController.show("upsellNoStb");return false}else{if(!user.hasDvr()&&!isReminder){OverlayController.show("upsellNoDVR")}else{if(!user.hasCompatibleBox()){OverlayController.show("stbIncapable");return false}else{if(user.hasHdCapableBox()===false&&active.isChannelHD===true){OverlayController.show("upsellNoHD");return false}}}}}return true}return false}function _isBookable(active){var currentTime=new Date().getTime();var tmp=null;if(active){if(active.startDateTime){tmp=Parse.iso8601ToEpoch(active.startDateTime);if(tmp&&tmp>=currentTime){return true}}if(active.endDateTime&&minBookingTimeBeforeEndEvent){tmp=Parse.iso8601ToEpoch(active.endDateTime);tmp-=minBookingTimeBeforeEndEvent;if(tmp>=currentTime){return true}}}return false}function _isWithinCurrentTimeSlot(date){var endTime,startTime=TimeController.getCurrentTimeSlot().getTime();if(Validate.isDate(date)&&startTime){date=date.getTime();endTime=startTime+10800000;if(date<endTime&&startTime<date){return true}}return false}function _loginOverlay(){var config=overlays.login;var checkbox=$(config.checkboxId);var formContainer=$(config.formContainerId);var msgContainer=$(config.msgContainerId);var msgDefaultText="Incorrect login";var password=$(config.passwordId);var username=$(config.usernameId);var waitingContainer=$(config.waitingContainerId);if(!(msgContainer&&formContainer&&username&&password&&waitingContainer&&checkbox)){throw _objErrMsg+" _loginOverlay() -> some DOM elements needed for initialization of the overlay are missing"}else{msgDefaultText=msgContainer.innerHTML}function _afterShow(){if(formContainer.style.display!=="none"&&formContainer.style.visibility!=="hidden"){try{if(username&&username.value===""){username.focus()}else{if(password&&password.value===""){password.focus()}}}catch(err){}}}function _authenticated(){if(gridPage){document.fire("epg:restoreGrid");restoreUiState();ToolBoxController.suppressErrors(false)}else{if(document.location.search.indexOf("&city=")!==-1){var user=EpgSession.getUser();if(user){var cityCode=user.getCityCode();if(cityCode){var matches=document.location.search.match(/&city=(\d+)?/i);if(matches){if(!matches[1]||parseInt(matches[1],10)!==cityCode){window.location.href=window.location.href.replace(matches[0],"&city="+cityCode)}}}}}}FavouritesController.display()}function _beforeShow(){var params=config.beforeShowParams;if(params&&params.hasOwnProperty("mode")&&params.mode==="waiting"){Element.show(waitingContainer);Element.hide(formContainer)}else{TopNavigation.toggle("loggedOut");Element.hide(waitingContainer);Element.show(formContainer)}params=null}function _onClick(element){var elementId=null;var name,passwd;if(element&&Element.hasAttribute(element,"id")){elementId=element.id;if(elementId=="login_submit"){Element.hide(msgContainer);name=Parse.trim(username.value);passwd=Parse.trim(password.value);if(Validate.isString(name)&&Validate.isString(passwd)&&formContainer&&waitingContainer&&msgContainer){Element.hide(formContainer);Element.show(waitingContainer);submit({username:Parse.trim(username.value),password:Parse.trim(password.value),rememberMe:checkbox.checked});password.value=""}else{Element.show(msgContainer)}}else{if(elementId==="login_close"){Cookie.remove(hasSesCookieName);_switchToProtocol("http");OverlayController.hide()}else{if(elementId==="login_remember_me"){if(checkbox.checked){checkbox.checked=false}else{checkbox.checked=true}}}}}}function _onKeyUp(key){var name,passwd;if(key){if(key===Event.KEY_RETURN){Element.hide(msgContainer);name=Parse.trim(username.value);passwd=Parse.trim(password.value);if(Validate.isString(name)&&Validate.isString(passwd)&&formContainer&&waitingContainer&&msgContainer){Element.hide(formContainer);Element.show(waitingContainer);submit({username:Parse.trim(username.value),password:Parse.trim(password.value),rememberMe:checkbox.checked});password.value=""}else{Element.show(msgContainer)}}}}function submit(args){var params={onSuccess:function(){var user=EpgSession.getUser();TopNavigation.toggle("loggedIn");Cookie.write(hasSesCookieName,1);if(gridPage){if(user&&!user.hasIncompatibleSubscription()){if(allowReminders&&user.hasStb()){document.observe("epg:remindersUpdated",_showReminders);document.observe("epg:timeUpdated",_showReminders);document.observe("epg:contentUpdated",_showReminders)}if(allowBookings&&user.hasDvr()){document.observe("epg:bookingsUpdated",_showBookings);document.observe("epg:timeUpdated",_showBookings);document.observe("epg:contentUpdated",_showBookings)}if(!user.getIsAccountEnabled()){OverlayController.show("setupLegal");ToolBoxController.suppressErrors(false)}else{if(allowReminders&&user.hasStb()){document.fire("epg:remindersUpdated")}if(allowBookings&&user.hasDvr()){document.fire("epg:bookingsUpdated")}}}}if(args&&args.hasOwnProperty("username")){window.setTimeout(function(){var user=EpgSession.getUser();if(user&&typeof s!=="undefined"&&s_account&&s.hasOwnProperty("record")){s.record({pageName:"upclive/tv_en_film/tvgids/TV/grid/login",eVar41:user.getId(),eVar42:user.getSmsConfigIsEnabled(),events:"event9,event43"})}},1000)}},onFailure:function(response){var statusCode=null,statusMsg=null,responseJSON;OverlayController.hide();if(response.status){if(response.status===500||response.status===404){Cookie.remove(hasSesCookieName);Exception.raise(Locale.getString("error.noService.msg"),Locale.getString("error.noService.title"))}else{if(msgContainer&&args&&args.hasOwnProperty("username")&&args.hasOwnProperty("password")){if(response.responseText.isJSON()){responseJSON=JSON.parse(response.responseText);if(responseJSON.hasOwnProperty("statusCode")){statusCode=responseJSON.statusCode;statusMsg=EpgSession.getStatusMessageSession(statusCode);if(statusMsg){Element.update(msgContainer,"<p> "+statusMsg+"</p>")}}}Element.show(msgContainer)}TopNavigation.toggle("loggedOut");OverlayController.show("login");window.scrollTo(0,1);window.scrollTo(0,0)}}}};msgContainer.innerHTML=msgDefaultText;if(args&&args.hasOwnProperty("username")&&args.hasOwnProperty("password")){params.username=args.username;params.password=args.password;if(args.hasOwnProperty("rememberMe")){params.rememberMe=args.rememberMe}EpgSession.create(params)}else{EpgSession.retrieve(params)}if(msgContainer){Element.hide(msgContainer)}}config.afterShow=_afterShow;config.beforeShow=_beforeShow;config.onClick=_onClick;config.onKeyUp=_onKeyUp;document.observe("epg:authenticated",_authenticated);return{submit:submit}}function _secureCopyObject(dest,src){if(dest&&src){for(var value in dest){if(src.hasOwnProperty(value)&&dest.hasOwnProperty(value)){if(src[value].constructor===Array){dest[value]=src[value]}else{if(typeof src[value]==="object"){_secureCopyObject(dest[value],src[value])}else{if(typeof src[value]==="string"){dest[value]=src[value]}else{if(typeof src[value]==="number"){dest[value]=src[value]}else{if(typeof src[value]==="boolean"){if(dest[value]===true){src[value]=true}else{src[value]=false}}}}}}}}}}function _setBookingOverlay(){var bookingConfig=overlays.setBooking;var bookingDetailsId=bookingConfig.detailsId;var bookingDetails=$(bookingDetailsId);var bookingContentTemplate=bookingConfig.contentTemplate;var overrideNoId=bookingConfig.overrideNoId;var overrideNoElement=$(overrideNoId);var overrideYesId=bookingConfig.overrideYesId;var overrideYesElement=$(overrideYesId);var seriesBookingConfig=overlays.setSeriesBooking;var seriesBookingDetailsId=seriesBookingConfig.detailsId;var seriesBookingDetails=$(seriesBookingDetailsId);if(!(bookingConfig&&seriesBookingConfig&&bookingDetails&&overrideNoElement&&overrideYesElement&&seriesBookingDetails)){throw _objErrMsg+" _setBookingOverlay() -> some DOM elements needed for initialization of the overlay are missing"}function _beforeShow(){var html="";var tmp=[bookingDetails,seriesBookingDetails];for(var i=tmp.length;i--;){if(active&&tmp[i]){html=bookingContentTemplate.evaluate({title:active.title,channel:active.channel,time:active.time});tmp[i].innerHTML=html}else{if(tmp[i]){tmp[i].innerHTML=""}}}if(overrideNoElement){overrideNoElement.checked="checked"}}function _onClick(element){var booking,elementId=null,params=null;if(element&&Element.hasAttribute(element,"id")){elementId=element.id;if(elementId==="set_booking_close"||elementId==="set_series_booking_close"){OverlayController.hide()}else{if(active&&(elementId==="set_booking_ok"||elementId==="set_series_booking_ok")){if(elementId=="set_booking_ok"&&overrideYesElement&&overrideYesElement.checked){active.shouldOverride=true}else{active.shouldOverride=false}params={shouldOverride:active.shouldOverride,onSuccess:function(data,response){var elementId,eventId=null;if(!data){return}else{if(data instanceof EpgBooking){data=[data]}}for(var i=data.length;i--;){if(EpgSession.hasBooking(data[i].getEventId())){elementId=_eventToElementId(data[i]);eventId=data[i].getEventId();_setStatusGridElement(elementId,"booking",data[i].getStatus());if(active&&eventId===active.eventId){document.fire("epg:gridMenuReload")}if(active.shouldOverride){_showBookings(true)}booking=data[i];window.setTimeout(function(){var user=EpgSession.getUser();if(user&&typeof s!=="undefined"&&s_account&&s.hasOwnProperty("record")){s.record({pageName:"upclive/tv_en_film/tvgids/TV/grid/channel/"+booking.getChannelId(),transactionID:booking.getTxId(),prop41:booking.getStatus(),prop42:booking.getChannelId(),prop43:booking.getProgrammeId(),prop44:booking.getTxId(),eVar41:user.getId(),events:"event9,event41"})}},0)}}},onFailure:function(response){_setStatusGridElement(elementId,"booking","failure");document.fire("epg:gridMenuReload");throw _objErrMsg+" _setBookingClickHandler() -> setBooking failed"}};if(active.seriesId&&elementId==="set_series_booking_ok"){params.seriesId=parseInt(active.seriesId,10)}else{params.eventId=parseInt(active.eventId,10)}try{active.bookingStatus="waiting";_setStatusGridElement(active.elementId,"booking","waiting");document.fire("epg:gridMenuReload");EpgSession.updateBookings(params)}catch(err){}OverlayController.hide()}else{if(elementId==="set_booking_cancel"||elementId==="set_series_booking_cancel"){OverlayController.hide()}}}}}bookingConfig.beforeShow=_beforeShow;bookingConfig.onClick=_onClick;seriesBookingConfig.beforeShow=_beforeShow;seriesBookingConfig.onClick=_onClick;return this}function _setStatusGridElement(elementId,eventType,status){var classes,element=$(elementId);if(element){if(eventType==="booking"){tmp=grid.bookingClasses}else{if(eventType==="reminder"){tmp=grid.reminderClasses}}if(Element.hasClassName(element,tmp[status])){return}for(var cls in tmp){if(tmp.hasOwnProperty(cls)&&Element.hasClassName(element,tmp[cls])){Element.removeClassName(element,tmp[cls])}}if(status==="pending"||status==="success"||status==="waiting"||status==="failure"||status==="overridden"||status==="deleted"){if(eventType==="booking"){tmp=tmp[status]}else{if(eventType==="reminder"){tmp=tmp[status]}}if(tmp){Element.addClassName(element,tmp)}}}}function _settingsOverlay(){var config=overlays.settings;var activeClassName=config.activeClassName;var emailCheckbox=$(config.emailCheckboxId);var emailConfirm=$(config.emailConfirmId);var emailFailure=$(config.emailFailureId);var emailInvalid=$(config.emailInvalidId);var emailSent=$(config.emailSentId);var emailText=$(config.emailTextId);var emailDefaultText=emailText?emailText.innerHTML:" Unknown ";var emailTextContainer=$(config.emailTextContainerId);var emailInput=$(config.emailInputId);var emailInputContainer=$(config.emailInputContainerId);var formContainer=$(config.formContainerId);var notifyContainer=$(config.notifyContainerId);var selectedSmartCard=null;var smsContainer=$(config.smsContainerId);var smsCheckbox=$(config.smsCheckboxId);var smsFailure=$(config.smsFailureId);var smsInvalid=$(config.smsInvalidId);var smsText=$(config.smsTextId);var smsDefaultText=smsText?smsText.innerHTML:" Unknown ";var smsTextContainer=$(config.smsTextContainerId);var smsInput=$(config.smsInputId);var smsInputContainer=$(config.smsInputContainerId);var stbContainer=$(config.stbContainerId);var stbOptionsContainer=$(config.stbOptionsContainerId);var submitButton=$(config.submitButtonId);var setTopBoxEntryRadioButtonTemplate=new Template(Locale.getString("settingsOverlay.setTopBoxEntryRadioButtonTemplate"));var setTopBoxEntryTemplate=new Template(Locale.getString("settingsOverlay.setTopBoxEntryTemplate"));var statusOnlineTemplate=new Template(Locale.getString("settingsOverlay.statusOnlineTemplate"));var statusOfflineTemplate=new Template(Locale.getString("settingsOverlay.statusOfflineTemplate"));var statusBusyTemplate=new Template(Locale.getString("settingsOverlay.statusBusyTemplate"));var termsContainer=$(config.termsContainerId);var termsBackButton=$(config.termsBackButtonId);var waitingContainer=$(config.waitingContainerId);var upsellContainer=$(config.upsellContainerId);var warningClassName=config.warningClassName;var warningElements=formContainer.getElementsByClassName(warningClassName);var tmp=null;if(!(smsContainer&&waitingContainer&&formContainer&&notifyContainer&&emailFailure&&emailConfirm&&emailSent&&emailCheckbox&&smsFailure&&smsCheckbox&&submitButton&&termsBackButton&&upsellContainer)){throw _objErrMsg+" _settingsOverlay() -> some DOM elements needed for initialization of the settings overlay are missing"}function _beforeShow(){var activeElements=formContainer.getElementsByClassName(activeClassName);var html="";var user=EpgSession.getUser();Element.hide(formContainer);Element.hide(notifyContainer);Element.hide(termsContainer);_removeClassFromCollection(activeElements,activeClassName);Element.addClassName(emailTextContainer,activeClassName);Element.addClassName(smsTextContainer,activeClassName);Element.show(waitingContainer);if(!allowSms){Element.hide(smsContainer)}user.retrieve({onSuccess:function(user){var boxes=user.getBoxes();if(boxes.length){var boxList=boxes.getArray();boxList.sort(function(a,b){if(a.getType()==b.getType()){return a.getId()>b.getId()}return a.getType()=="DVR"?-1:1});if(user.hasAtLeastOneDvrBox()){Element.show(notifyContainer);tmp=user.getEmailConfigRecipient();if(Parse.trim(tmp)!==null){emailText.innerHTML=tmp;emailInput.value=tmp}else{emailText.innerHTML=emailDefaultText;emailInput.value=""}if(user.getEmailConfigIsEnabled()){emailCheckbox.checked=true}if(!user.getEmailConfigIsVerified()&&emailCheckbox.checked){Element.addClassName(emailConfirm,activeClassName)}tmp=user.getSmsConfigRecipient();if(Parse.trim(tmp)!==null){smsText.innerHTML=tmp;smsInput.value=tmp}else{smsText.innerHTML=smsDefaultText;smsInput.value=""}if(user.getSmsConfigIsEnabled()){smsCheckbox.checked=true}}tmp=user.getBoxes();if(stbContainer&&stbOptionsContainer){if(user.getDefaultSmartCardId()){var labelSmartCardNumber=Locale.getString("labels.smartCardNumber"),labelFeatures=Locale.getString("labels.features"),labelsetBookings=Locale.getString("labels.setBookings"),labelsetRemiders=Locale.getString("labels.setReminders"),labelStatus=Locale.getString("labels.status");boxList.each(function(box){if(box instanceof EpgSetTopBox){var id=box.getId();var entry={labelSmartCardNumber:labelSmartCardNumber,labelFeatures:labelFeatures,labelStatus:labelStatus,smartCardId:id,stbDescription:box.getDescription(),features:"",status:statusBusyTemplate.evaluate()};if(boxes.length>1){entry.radioButton=setTopBoxEntryRadioButtonTemplate.evaluate({smartCardId:id,optional:(id===user.getDefaultSmartCardId())?'checked="checked"':""})}else{entry.radioButton=""}var features=[labelsetRemiders];if(box.getType()==="DVR"){features.push(labelsetBookings)}entry.features=features.reverse().join(", ");html+=setTopBoxEntryTemplate.evaluate(entry)}});if(boxes.length>1){Element.show(config.multiBoxMessageId)}stbOptionsContainer.innerHTML=html;var selectedElement=Element.down(stbOptionsContainer,"input[checked='checked']");if(selectedElement){var parent=Element.up(selectedElement,".box_details");if(parent){Element.addClassName(parent,"active")}}Element.show(stbContainer);EpgSession.retrieveStbStatus({onSuccess:function(boxes){boxes.each(function(box){_updateStbStatus(box.getId(),box.isReadyForService())});_checkStatusOfAllBoxes(boxes);window.scrollTo(0,1);window.scrollTo(0,0)},onFailure:function(){if(typeof console!=="undefined"){console.error([].slice.call(arguments))}}})}else{Element.hide(stbContainer)}}Element.hide(waitingContainer);Element.show(formContainer);Element.show(submitButton)}else{OverlayController.hide();OverlayController.show("upsellNoStb")}},onFailure:function(){}})}function _onClick(element){var user=EpgSession.getUser();if(Element.hasAttribute(element,"id")&&formContainer&&waitingContainer){switch(element.id){case"settings_close":Element.hide(submitButton);Element.hide(termsBackButton);OverlayController.hide();break;case"settings_done":_submit();break;case"settings_show":Element.show(formContainer);Element.hide(termsContainer);break;case"settings_terms":Element.hide(formContainer);Element.show(termsBackButton);Element.show(termsContainer);break;case"settings_user_email_edit":emailTextContainer.value=user.getEmailConfigRecipient()||"";Element.removeClassName(emailTextContainer,activeClassName);Element.addClassName(emailInputContainer,activeClassName);break;case"settings_user_send_email":Element.removeClassName(emailConfirm,activeClassName);Element.addClassName(emailSent,activeClassName);user.sendEmailToken({onSuccess:function(){},onFailure:function(){Element.removeClassName(emailSent,activeClassName);Element.addClassName(emailFailure,activeClassName)}});break;case"settings_user_sms_edit":smsTextContainer.value=user.getSmsConfigRecipient()||"";Element.removeClassName(smsTextContainer,activeClassName);Element.addClassName(smsInputContainer,activeClassName);break;default:if(element.id.startsWith("box_radio_")){var parent=element.up(".box_details");if(!Element.hasClassName(parent,"active")){var allBoxes=Element.siblings(parent,".active");if(allBoxes.length){allBoxes.each(function(box){Element.removeClassName(box,"active")})}Element.addClassName(parent,"active")}}else{if(element.id.startsWith("refresh_button_")){var boxId=element.id.split("refresh_button_")[1];var parent=element.parentNode;Element.update(parent,statusBusyTemplate.evaluate());setTimeout(function(){EpgSession.retrieveStbStatus({smartCardId:boxId,onSuccess:function(boxes){boxes.each(function(box){_updateStbStatus(box.getId(),box.isReadyForService())});_checkStatusOfAllBoxes(boxes);window.scrollTo(0,1);window.scrollTo(0,0)},onFailure:function(){}})},1000)}}}}}function _updateStbStatus(smartCardId,status){var template=null;if(status){template=statusOnlineTemplate}else{template=statusOfflineTemplate}$("status_"+smartCardId).update(template.evaluate({id:smartCardId}))}function _checkStatusOfAllBoxes(boxes){var boxArray=boxes.getArray();var allOnline=boxArray.every(function(box){return box.isReadyForService()});if(allOnline){$("set_top_box_error").hide()}else{$("set_top_box_error").show()}}function _onKeyUp(key){if(key===Event.KEY_RETURN){_submit()}}function _submit(){var user=EpgSession.getUser();var emailAddress=Parse.trim(emailInput.value);var params={emailConfigIsEnabled:false,emailConfigRecipient:user.getEmailConfigRecipient(),smsConfigRecipient:user.getSmsConfigRecipient(),smsConfigIsEnabled:false,onSuccess:function(user){if(!user.getSmsConfigIsVerified()&&Parse.trim(user.getSmsConfigRecipient())!==null&&user.getSmsConfigIsEnabled()){Element.hide(submitButton);Element.hide(termsBackButton);OverlayController.hide();OverlayController.show("smsToken")}else{location.href=location.href.replace(/([\?&])eId=eid_[^&]+&?/,"$1")}},onFailure:function(){Element.hide(waitingContainer);Element.show(formContainer);OverlayController.hide()}};var smsNr=Parse.trim(smsInput.value);var smsNrLength=parseInt(_getLocaleValue("config.smsNrLength"),10)||10;var submit=true;_removeClassFromCollection(warningElements,activeClassName);if(stbOptionsContainer.innerHTML!==""){var input=Form.getInputs(config.stbOptionsContainerId,"radio","stb_option").find(function(radio){return radio.checked});if(input){selectedSmartCard=input.value}}if(selectedSmartCard){params.defaultSmartCardId=selectedSmartCard}if(user.hasAtLeastOneDvrBox()){if(emailAddress!==null&&!Validate.isEmail(emailAddress)){emailCheckbox.checked=false;Element.addClassName(emailInvalid,activeClassName);submit=false}else{if(user.getEmailConfigRecipient()!==emailAddress){tmp=emailAddress||"";user.setEmailConfigRecipient(tmp);if(emailAddress){emailText.innerHTML=user.getEmailConfigRecipient()}params.emailConfigRecipient=user.getEmailConfigRecipient()}}if(smsNr!==null&&(!Validate.isDigit(smsNr)||smsNr.length!==smsNrLength)){smsCheckbox.checked=false;Element.addClassName(smsInvalid,activeClassName);submit=false}else{if(user.getSmsConfigRecipient()!==smsNr){tmp=smsNr||"";user.setSmsConfigRecipient(tmp);if(smsNr){smsText.innerHTML=tmp}params.smsConfigRecipient=user.getSmsConfigRecipient()}}if(emailAddress===null){emailCheckbox.checked=false}if(smsNr===null){smsCheckbox.checked=false}if(!submit){return}Element.hide(formContainer);Element.show(waitingContainer);if(emailCheckbox.checked){params.emailConfigIsEnabled=true}if(smsCheckbox.checked){params.smsConfigIsEnabled=true}}if(user.hasDvr()||stbOptionsContainer.innerHTML!==""){user.update(params)}else{OverlayController.hide()}}config.beforeShow=_beforeShow;config.onClick=_onClick;config.onKeyUp=_onKeyUp;return this}function _setupOverlay(){var completeConfig=overlays.setupComplete;var legalConfig=overlays.setupLegal;var notifyConfig=overlays.setupNotify;var activeClassName=notifyConfig.activeClassName;var emailCheckbox=$(notifyConfig.emailCheckboxId);var emailInvalid=$(notifyConfig.emailInvalidId);var emailText=$(notifyConfig.emailTextId);var emailDefaultText=emailText?emailText.innerHTML:" Unknown ";var emailTextContainer=$(notifyConfig.emailTextContainerId);var emailInput=$(notifyConfig.emailInputId);var emailInputContainer=$(notifyConfig.emailInputContainerId);var notifyFormContainer=$(notifyConfig.formContainerId);var notifyWaitingContainer=$(notifyConfig.waitingContainerId);var legalCheckbox=$(legalConfig.checkboxId);var legalFormContainer=$(legalConfig.formContainerId);var legalMsgContainer=$(legalConfig.msgContainerId);var legalWaitingContainer=$(legalConfig.waitingContainerId);var smsContainer=$(notifyConfig.smsContainerId);var smsCheckbox=$(notifyConfig.smsCheckboxId);var smsInvalid=$(notifyConfig.smsInvalidId);var smsText=$(notifyConfig.smsTextId);var smsDefaultText=smsText?smsText.innerHTML:" Unknown ";var smsTextContainer=$(notifyConfig.smsTextContainerId);var smsInput=$(notifyConfig.smsInputId);var smsInputContainer=$(notifyConfig.smsInputContainerId);var warningClassName=notifyConfig.warningClassName;var warningElements=notifyFormContainer.getElementsByClassName(warningClassName);var tmp=null;if(!(notifyFormContainer&&notifyWaitingContainer&&smsContainer&&notifyFormContainer&&emailCheckbox&&emailInvalid&&emailText&&emailInput&&smsCheckbox&&smsInvalid&&smsText&&smsInput&&legalFormContainer&&legalMsgContainer&&legalWaitingContainer)){throw _objErrMsg+" _setupOverlay() -> some DOM elements needed for initialization of the overlay are missing"}function _completeOnClick(element){if(element&&Element.hasAttribute(element,"id")&&element.id==="setup_complete_close"||element.id==="setup_complete_done"){OverlayController.hide();restoreUiState()}}function _completeOnKeyUp(key){if(key&&key===Event.KEY_RETURN){OverlayController.hide()}}function _notifyBeforeShow(){var activeElements=notifyFormContainer.getElementsByClassName(activeClassName);var html="";var user=EpgSession.getUser();Element.hide(notifyFormContainer);_removeClassFromCollection(activeElements,activeClassName);Element.addClassName(emailTextContainer,activeClassName);Element.addClassName(smsTextContainer,activeClassName);Element.show(notifyWaitingContainer);if(!allowSms){Element.hide(smsContainer)}user.retrieve({onSuccess:function(user){tmp=user.getEmailConfigRecipient();if(Parse.trim(tmp)!==null){emailText.innerHTML=tmp;emailInput.value=tmp}else{emailText.innerHTML=emailDefaultText;emailInput.value=""}if(user.getEmailConfigIsEnabled()){emailCheckbox.checked=true}tmp=user.getSmsConfigRecipient();if(Parse.trim(tmp)!==null){smsText.innerHTML=tmp;smsInput.value=tmp}else{smsText.innerHTML=smsDefaultText;smsInput.value=""}if(user.getSmsConfigIsEnabled()){smsCheckbox.checked=true}Element.hide(notifyWaitingContainer);Element.show(notifyFormContainer)},onFailure:function(response){OverlayController.hide();if(response&&response.status==="401"){OverlayController.show("login")}}})}function _notifyOnClick(element){var elementId=null;var user=EpgSession.getUser();if(!element){return}if(Element.hasAttribute(element,"id")&&notifyFormContainer&&notifyWaitingContainer){elementId=element.id;switch(elementId){case"setup_notify_close":OverlayController.hide();break;case"setup_notify_continue":_notifySubmit();break;case"setup_notify_email_edit":emailTextContainer.value=user.getEmailConfigRecipient()||"";Element.removeClassName(emailTextContainer,activeClassName);Element.addClassName(emailInputContainer,activeClassName);break;case"setup_notify_sms_edit":smsTextContainer.value=user.getSmsConfigRecipient()||"";Element.removeClassName(smsTextContainer,activeClassName);Element.addClassName(smsInputContainer,activeClassName);break}}}function _notifySubmit(){var user=EpgSession.getUser();var emailAddress=Parse.trim(emailInput.value);var params={emailConfigIsEnabled:false,emailConfigRecipient:user.getEmailConfigRecipient(),smsConfigRecipient:user.getSmsConfigRecipient(),smsConfigIsEnabled:false,onSuccess:function(user){Element.hide(notifyWaitingContainer);OverlayController.hide();if(!user.getSmsConfigIsVerified()&&allowSms&&Parse.trim(user.getSmsConfigRecipient())!==null){overlays.smsToken.afterHide=function(){OverlayController.show("setupComplete");delete overlays.smsToken.afterHide};OverlayController.show("smsToken")}else{OverlayController.show("setupComplete")}},onFailure:function(){Element.show(notifyFormContainer);Element.hide(notifyWaitingContainer);OverlayController.hide()}};var smsNr=Parse.trim(smsInput.value);var smsNrLength=parseInt(_getLocaleValue("config.smsNrLength"),10)||10;var submit=true;_removeClassFromCollection(warningElements,activeClassName);if(Element.visible(notifyFormContainer)){if(emailAddress!==null&&!Validate.isEmail(emailAddress)){emailCheckbox.checked=false;Element.addClassName(emailInvalid,activeClassName);submit=false}else{if(user.getEmailConfigRecipient()!==emailAddress){tmp=emailAddress||"";user.setEmailConfigRecipient(tmp);if(emailAddress){emailText.innerHTML=user.getEmailConfigRecipient()}params.emailConfigRecipient=user.getEmailConfigRecipient()}}if(smsNr!==null&&(!Validate.isDigit(smsNr)||smsNr.length!==smsNrLength)){smsCheckbox.checked=false;Element.addClassName(smsInvalid,activeClassName);submit=false}else{if(user.getSmsConfigRecipient()!==smsNr){tmp=smsNr||"";user.setSmsConfigRecipient(tmp);if(smsNr){smsText.innerHTML=user.getSmsConfigRecipient()}params.smsConfigRecipient=user.getSmsConfigRecipient()}}if(emailAddress===null){emailCheckbox.checked=false}if(smsNr===null){smsCheckbox.checked=false}if(!submit){return}Element.hide(notifyFormContainer);Element.show(notifyWaitingContainer);if(emailCheckbox.checked){params.emailConfigIsEnabled=true}if(smsCheckbox.checked){params.smsConfigIsEnabled=true}user.update(params)}}function _legalBeforeShow(){Element.hide(legalWaitingContainer);Element.show(legalFormContainer)}function _legalOnClick(element){var elementId=null;if(legalCheckbox&&element){if(Element.hasAttribute(element,"id")){Element.hide(legalMsgContainer);elementId=element.id;if(elementId==="setup_legal_close"){OverlayController.hide()}else{if(elementId==="setup_legal_continue"){_legalSubmit()}else{if(elementId==="setup_legal_accept"){if(legalCheckbox.checked){legalCheckbox.checked=false}else{legalCheckbox.checked=true}}}}}}}function _legalOnKeyUp(key){if(key&&key===Event.KEY_RETURN){_legalSubmit()}}function _legalSubmit(){var user=EpgSession.getUser();if(legalCheckbox&&legalCheckbox.checked){Element.hide(legalFormContainer);Element.show(legalWaitingContainer);user.update({isAccountEnabled:true,onSuccess:function(){OverlayController.hide();try{if(!user.hasCompatibleBox()){OverlayController.show("stbIncapable")}else{OverlayController.show("settings")}}catch(err){}},onFailure:function(){}})}else{Element.show(legalMsgContainer)}}legalConfig.beforeShow=_legalBeforeShow;legalConfig.onClick=_legalOnClick;legalConfig.onKeyUp=_legalOnKeyUp;notifyConfig.beforeShow=_notifyBeforeShow;notifyConfig.onClick=_notifyOnClick;completeConfig.onClick=_completeOnClick;completeConfig.onKeyUp=_completeOnKeyUp;return this}function _setReminderOverlay(){var config=overlays.setReminder;var detailsId=config.detailsId;var details=$(detailsId);var contentTemplate=config.contentTemplate;if(!(config&&details)){throw _objErrMsg+" _setBookingOverlay() -> some DOM elements needed for initialization of the overlay are missing"}function _beforeShow(){var html="";if(active){html=contentTemplate.evaluate({title:active.title,channel:active.channel,time:active.time});details.innerHTML=html}else{if(details){details.innerHTML=""}}}function _onClick(element){var elementId=null;if(Element.hasAttribute(element,"id")){elementId=element.id;if(elementId=="set_reminder_close"){OverlayController.hide()}else{if(elementId=="set_reminder_ok"&&active&&active.elementId){_setStatusGridElement(active.elementId,"reminder","waiting");document.fire("epg:gridMenuReload");EpgSession.updateReminders({eventId:parseInt(active.eventId,10),onSuccess:function(reminder,response){var elementId,eventId=null;if(!reminder){return}if(reminder&&EpgSession.hasReminder(reminder.getEventId())){elementId=_eventToElementId(reminder);eventId=parseInt(reminder.getId(),10);_setStatusGridElement(elementId,"reminder",reminder.getStatus());window.setTimeout(function(){var user=EpgSession.getUser();if(user&&typeof s!=="undefined"&&s_account&&s.hasOwnProperty("record")){s.record({pageName:" upclive/tv_en_film/tvgids/TV/grid/channel/"+reminder.getChannelId(),transactionID:reminder.getTxId(),prop41:reminder.getStatus(),prop42:reminder.getChannelId(),prop43:reminder.getProgrammeId(),prop44:reminder.getTxId(),eVar41:user.getId(),events:"event9,event42"})}},0);if(active&&eventId===parseInt(active.eventId,10)){document.fire("epg:gridMenuReload")}}},onFailure:function(response){_setStatusGridElement(active.elementId,"reminder","failure");document.fire("epg:gridMenuReload");throw _objErrMsg+" _setReminderClickHandler() -> setReminder failed"}});OverlayController.hide()}else{if(elementId=="set_reminder_cancel"){OverlayController.hide()}}}}}config.beforeShow=_beforeShow;config.onClick=_onClick;return this}function _showBookings(cache){EpgSession.retrieveBookings({cache:cache?cache:false,onSuccess:function(data){for(var i=data.length;i--;){if(_isWithinCurrentTimeSlot(data[i].getStartDateTime())||_isWithinCurrentTimeSlot(data[i].getEndDateTime())){elementId=_eventToElementId(data[i]);_setStatusGridElement(elementId,"booking",data[i].getStatus());if(active&&active.hasOwnProperty("elementId")&&active.elementId===elementId){document.fire("epg:gridMenuReload")}}}},onFailure:function(response){}})}function _showReminders(cache){EpgSession.retrieveReminders({cache:cache?cache:false,onSuccess:function(data){for(var i=data.length;i--;){if(_isWithinCurrentTimeSlot(data[i].getStartDateTime())){elementId=_eventToElementId(data[i]);_setStatusGridElement(elementId,"reminder",data[i].getStatus());if(active&&active.hasOwnProperty("elementId")&&active.elementId===elementId){document.fire("epg:gridMenuReload")}}}},onFailure:function(response){}})}function _smsTokenOverlay(){var config=overlays.smsToken;var activeClassName=config.activeClassName;var completeContainer=$(config.completeContainerId);var doneButton=$(config.doneButtonId);var formContainer=$(config.formContainerId);var smsTokenExpired=$(config.smsTokenExpiredId);var smsTokenFailure=$(config.smsTokenFailureId);var smsTokenInvalid=$(config.smsTokenInvalidId);var smsTokenInput=$(config.smsTokenInputId);var smsTokenInputContainer=$(config.smsTokenInputContainerId);var smsTokenSent=$(config.smsTokenSentId);var smsTokenResent=$(config.smsTokenResentId);var submitButton=$(config.submitButtonId);var waitingContainer=$(config.waitingContainerId);var waitTime=8000;var warningClassName=config.warningClassName;var warningElements=formContainer.getElementsByClassName(warningClassName);if(!(waitingContainer&&formContainer&&smsTokenFailure&&smsTokenInvalid&&smsTokenResent&&smsTokenSent&&submitButton&&smsTokenExpired&&smsTokenSent&&completeContainer&&doneButton)){throw _objErrMsg+" _smsTokenOverlay() -> some DOM elements needed for initialization of the overlay are missing"}function _afterShow(){window.setTimeout(function(){var activeElements=formContainer.getElementsByClassName(activeClassName);if(activeElements.length===0){Element.addClassName(smsTokenResent,activeClassName)}},waitTime);Element.hide(doneButton);Element.hide(submitButton);Element.show(submitButton)}function _beforeShow(){_removeClassFromCollection(warningElements,activeClassName);Element.hide(completeContainer);Element.hide(waitingContainer);Element.show(formContainer);smsTokenInput.value=""}function _onClick(element){var elementId=null;if(Element.hasAttribute(element,"id")){elementId=element.id;if(elementId=="sms_token_close"||elementId==config.doneButtonId){Element.hide(doneButton);Element.hide(submitButton);OverlayController.hide()}else{if(elementId==config.submitButtonId){_submit()}}}else{if(Element.hasClassName(element,"sms_token_send_sms")){_removeClassFromCollection(warningElements,activeClassName);_sendSms()}}}function _onKeyUp(key){if(key&&key===Event.KEY_RETURN){_submit()}}function _sendSms(){var user=EpgSession.getUser();window.setTimeout(function(){var activeElements=formContainer.getElementsByClassName(activeClassName);if(activeElements.length===0){Element.addClassName(smsTokenSent,activeClassName)}},waitTime);user.sendSmsToken({onSuccess:function(){},onFailure:function(){Element.removeClassName(smsTokenSent,activeClassName);Element.addClassName(smsTokenFailure,activeClassName)}})}function _submit(){var smsToken=Parse.trim(smsTokenInput.value);var user=EpgSession.getUser();_removeClassFromCollection(warningElements,activeClassName);if(smsToken===null||smsToken.length<5){Element.addClassName(smsTokenInvalid,activeClassName)}else{if(Validate.isBetweenStr(smsToken,5,5)&&Validate.isAlphaNumeric(smsToken)){Element.hide(completeContainer);Element.hide(formContainer);Element.show(waitingContainer);user.verifySmsToken({token:smsToken,onSuccess:function(){Element.hide(waitingContainer);Element.show(completeContainer);Element.show(doneButton)},onFailure:function(response){Element.hide(waitingContainer);_removeClassFromCollection(warningElements,activeClassName);Element.show(formContainer);if(response.status){if(response.status===500){Element.addClassName(smsTokenFailure,activeClassName)}else{if(response.status===410){Element.addClassName(smsTokenExpired,activeClassName);_sendSms()}else{if(response.status===404){Element.addClassName(smsTokenInvalid,activeClassName)}}}}}})}}}config.afterShow=_afterShow;config.beforeShow=_beforeShow;config.onClick=_onClick;config.onKeyUp=_onKeyUp;return this}function _switchToProtocol(protocol){var tmp=window.location;if(protocol==="https"){tmp.href=tmp.href.replace("http","https")}else{if(protocol==="http"){tmp.href=tmp.href.replace("https","http").replace(/&city=\d+/i,"&city=")}}}function _setupTopNavigationWhenBookingsDisallowed(){var mainElement=$(topNavMenu.elementId);var faq=$(topNavMenu.faqId);var _onClick=function(e){var element=e.element();if(element.id===topNavMenu.faqId){_showFAQOverlay()}e.stop()};Event.observe(mainElement,"click",_onClick)}function _topNavigation(){var mainElement=$(topNavMenu.elementId);var faq=$(topNavMenu.faqId);var login=$(topNavMenu.loginId);var loggingIn=$(topNavMenu.loggingInId);var logout=$(topNavMenu.logoutId);var loggingOut=$(topNavMenu.loggingOutId);var settings=$(topNavMenu.settingsId);var userDetails=$(topNavMenu.userDetailsId);var userFullName=$(topNavMenu.userFullNameId);var logInTimer=null;if(!(mainElement&&login&&logout&&settings&&faq&&userDetails&&userFullName&&loggingIn&&loggingOut)){throw _objErrMsg+" _topNavigation() -> some DOM elements needed for initialization of the menu are missing"}function _detectStatus(){var user;if(EpgSession.isValid()){user=EpgSession.getUser();_showLoggingInState();user.retrieve({onSuccess:function(user){if(user&&user.isset("familyName")&&user.isset("givenName")){userFullName.innerHTML=user.getGivenName()+" "+user.getFamilyName()}_showLoggedInState();OverlayController.hide();document.fire("epg:authenticated")},onFailure:function(response,err){_showLoggedOutState()}})}else{_showLoggedOutState()}}function _onClick(e){var element=e.element();if(element.id){window.setTimeout(function(){var id=element.id;if(typeof s!=="undefined"&&s_account&s.clickMap){s.clickMap(id)}},0);if(element.id!==topNavMenu.faqId&&!EpgSession.isValid()){if(document.location.protocol==="http:"){_showLoggingInState();_switchToProtocol("https")}else{_showLoggingInState();OverlayController.show("login")}}else{if(element.id===topNavMenu.logoutId){_showLoggingOutState();try{EpgSession.destroy({onSuccess:function(){_showLoggedOutState();Cookie.remove(hasSesCookieName);_switchToProtocol("http")},onFailure:function(){_showLoggedOutState();Cookie.remove(hasSesCookieName);_switchToProtocol("http")}})}catch(err){}}else{if(element.id===topNavMenu.settingsId){OverlayController.show("settings")}else{if(element.id===topNavMenu.faqId){_showFAQOverlay()}}}}}e.stop()}function _showLoggedInState(){if(logInTimer){window.clearTimeout(logInTimer)}logInTimer=window.setTimeout(function(){Element.show(userDetails);Element.show(logout);Element.show(settings);Element.show(faq);Element.hide(login);Element.hide(loggingIn);Element.hide(loggingOut);logInTimer=null},10)}function _showLoggedOutState(){window.setTimeout(function(){Element.hide(userDetails);Element.hide(loggingIn);Element.hide(logout);Element.hide(loggingOut);Element.hide(settings);Element.show(faq);Element.show(login)},0)}function _showLoggingInState(){if(logInTimer){window.clearTimeout(logInTimer)}logInTimer=window.setTimeout(function(){Element.hide(userDetails);Element.hide(logout);Element.hide(settings);Element.show(faq);Element.hide(login);Element.show(loggingIn);Element.hide(loggingOut);logInTimer=null},10)}function _showLoggingOutState(){window.setTimeout(function(){Element.hide(userDetails);Element.hide(logout);Element.hide(settings);Element.show(faq);Element.hide(login);Element.hide(loggingIn);Element.show(loggingOut)},0)}function toggle(state){if(!state){_detectStatus()}else{switch(state){case"loggedIn":_detectStatus();break;case"loggingIn":_showLoggingInState();break;case"loggedOut":_showLoggedOutState();break;case"loggingOut":_showLoggingOutState();break;default:_showLoggedOutState()}}}Event.observe(mainElement,"click",_onClick);toggle();return{toggle:toggle}}function _showFAQOverlay(){var externalHelpLink=Locale.getString("help.externalLink")||"";if(externalHelpLink){window.location=externalHelpLink}else{OverlayController.show("faq")}}function _removeClassFromCollection(collection,className){if(collection&&className){for(var i=collection.length;i--;){Element.removeClassName(collection[i],className)}}}function deleteUiState(){Cookie.remove(uiCookieName)}function elementIdToEvent(elementId){var params,tmp=null;if(elementId){tmp=elementId.split("_");if(tmp&&tmp.length>2){params={eventId:parseInt(tmp[1],10),channelId:tmp[2],startDateTime:tmp[3]};if(tmp[4]){params.seriesId=parseInt(tmp[4],10)}var targetId=channelIdPrefix+tmp[2];tmp[5]=window[targetId]||$(targetId);if(tmp[5]&&Element.hasClassName(tmp[5],channelHdClassName)){params.isChannelHD=true}else{params.isChannelHD=false}}}return params}function getGridMenuDVRHTMLContent(arg){var buttons="",html="";var currentTime=new Date().getTime();var locale=_getConfigValue("locale");var booking=null,reminder=null,tmp=null;var statusTemplate=gridMenu.statusTemplate;active=arg;if(active&&active.element&&active.eventId&&Locale.isLoaded(locale)){active.hasBooking=EpgSession.hasBooking(active.eventId);active.hasReminder=EpgSession.hasReminder(active.eventId);active.bookingStatus=_getStatusGridElement(active.element,"booking");active.reminderStatus=_getStatusGridElement(active.element,"reminder");if(allowBookings===false){active.bookingStatus="n/a"}else{if(active.hasBooking){booking=EpgSession.getBooking(active.eventId);active.bookingStatus=booking.getStatus()}else{if(active.bookingStatus===null){active.bookingStatus="none"}}}if(active.hasReminder){reminder=EpgSession.getReminder(active.eventId);active.reminderStatus=reminder.getStatus()}else{if(active.reminderStatus===null){active.reminderStatus="none"}}if((active.bookingStatus==="none"||active.bookingStatus==="failure"||active.bookingStatus==="deleted")&&active.hasOwnProperty("startDateTime")&&_isBookable(active)){if(active.hasOwnProperty("seriesId")){buttons+=buttonTemplate.evaluate({id:gridMenu.setBookingButtonId,cls:gridMenu.buttonClass,lbl:_getButtonText("setSerieBooking")});buttons+=buttonTemplate.evaluate({id:gridMenu.setSeriesBookingButtonId,cls:gridMenu.buttonClass,lbl:_getButtonText("setSeriesBooking")})}else{buttons+=buttonTemplate.evaluate({id:gridMenu.setBookingButtonId,cls:gridMenu.buttonClass,lbl:_getButtonText("setBooking")})}}if(active.bookingStatus==="failure"){if(booking&&statusTemplate){tmp=EpgSession.getStatusMessageBookings(booking.getStatusCode());if(tmp){html=statusTemplate.evaluate({cls:grid.bookingClasses[active.bookingStatus],msg:tmp})}}else{html=gridMenu.locale.bookingStatusFailure||""}}else{if(active.bookingStatus==="success"){html=gridMenu.locale.bookingStatusSuccess||""}else{if(active.bookingStatus==="waiting"){html=gridMenu.locale.bookingStatusWaiting||""}else{if(active.bookingStatus==="pending"){html=gridMenu.locale.bookingStatusPending||""}else{if(active.bookingStatus==="overridden"){html=gridMenu.locale.bookingStatusOverridden||""}}}}}if(allowReminders){if(active.reminderStatus==="none"&&active.hasOwnProperty("startDateTime")&&Parse.iso8601ToEpoch(active.startDateTime)>currentTime){buttons+=buttonTemplate.evaluate({id:gridMenu.setReminderButtonId,cls:gridMenu.buttonClass,lbl:_getButtonText("setReminder")})}else{if(active.bookingStatus==="none"||active.bookingStatus==="n/a"){if(active.reminderStatus==="failure"){if(reminder&&statusTemplate){tmp=EpgSession.getStatusMessageReminders(reminder.getStatusCode());if(tmp){html=statusTemplate.evaluate({cls:grid.bookingClasses[active.reminderStatus],msg:tmp})}}else{html=gridMenu.locale.reminderStatusFailure||""}buttons+=buttonTemplate.evaluate({id:gridMenu.setReminderButtonId,cls:gridMenu.buttonClass,lbl:_getButtonText("setReminder")})}else{if(active.reminderStatus==="success"){html=gridMenu.locale.reminderStatusSuccess||""}else{if(active.reminderStatus==="waiting"){html=gridMenu.locale.reminderStatusWaiting||""}else{if(active.reminderStatus==="pending"){html=gridMenu.locale.reminderStatusPending||""}}}}}}}}if(buttons!==""){html+="<div id="+gridMenu.buttonsContainerId+">"+buttons+"</div>"}return html}function saveUiState(args){var uiCookieParams=Cookie.readJSON(uiCookieName);if(args&&args.hasOwnProperty("eId")&&(!uiCookieParams||args.hasOwnProperty("buttonId"))){Cookie.writeJSON(uiCookieName,args,0)}}function restoreUiState(){var uiCookieParams=Cookie.readJSON(uiCookieName);var currentTime=new Date().getTime();var tmp=null,user;window.setTimeout(function(){if(uiCookieParams){document.fire("epg:gridMenuReload");if(uiCookieParams.hasOwnProperty("eId")&&$(uiCookieParams.eId)){if(uiCookieParams.hasOwnProperty("buttonId")&&grid.callbacks[uiCookieParams.buttonId]&&grid.callbacks[uiCookieParams.buttonId].hasOwnProperty("onClick")){tmp=elementIdToEvent(uiCookieParams.eId);if(EpgSession.isValid()){user=EpgSession.getUser();if(!EpgSession.hasReminder(active.eventId)&&Parse.iso8601ToEpoch(active.startDateTime)>currentTime&&uiCookieParams.buttonId==="grid_menu_set_reminder"){grid.callbacks[uiCookieParams.buttonId].onClick()}else{if(user.hasDvr()&&active&&(uiCookieParams.buttonId==="grid_menu_set_booking"||uiCookieParams.buttonId==="grid_menu_set_series_booking")&&_isBookable(active)&&!EpgSession.hasBooking(active.eventId)){grid.callbacks[uiCookieParams.buttonId].onClick()}else{if(active&&(uiCookieParams.buttonId==="grid_menu_set_booking"||uiCookieParams.buttonId==="grid_menu_set_series_booking")){grid.callbacks[uiCookieParams.buttonId].onClick()}}}}}}}},1000)}return{init:initialize,deleteUiState:deleteUiState,elementIdToEvent:elementIdToEvent,getGridMenuDVRHTMLContent:getGridMenuDVRHTMLContent,saveUiState:saveUiState,restoreUiState:restoreUiState}})();namespace("UPC.apps.epg");UPC.apps.epg.GridController=function(){var _objName="UPC.apps.epg.GridController";var _objErrMsg="Error in "+_objName+": ";var buttons={close:"",info:"More information"};var config={allDayEventClassName:"width_36",channelIdPrefix:"cid_",channelHeight:56,channelClassName:"channel_info",cookieName:"epg_grid_state",uiCookieName:"epg_ui_state",favouriteClassName:"favourite",favouriteIconClassName:"favicon",disabledScrollbarClassName:"disabled",hideScrollbarClassName:"hide",loadingClassName:"loading",jsScrollbarClassName:"js_scrollbar"};var active=null,filter=null,localeBasePath=null,mainElement=null,scId=null;var displayJsScrollbar=false,sc=null,tmp=null,viewHeight=null,viewPortHeight=null;var cookieParams=null,urlParams=null;var scContent=null,scScrollbar=null,scScrollOffset=0,scScrollbarId=null;var Scrollbar=null;Prototype.Browser.IE7=Prototype.Browser.IE&&parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5),10)==7;try{var Config=UPC.util.Configuration;var Cookie=UPC.util.Cookie;var DataController=UPC.apps.epg.DataController;var FavouritesController=UPC.apps.epg.FavouritesController;var GridMenuController=UPC.apps.epg.GridMenuController;var Locale=UPC.util.Localization;var LogicController=UPC.apps.epg.LogicController;var Parse=UPC.util.Parse;var SearchController=UPC.apps.epg.SearchController;var ToolBoxController=UPC.apps.epg.ToolBoxController;var Tooltip=UPC.widget.Tooltip;var TimeController=UPC.apps.epg.TimeController;var Validate=UPC.util.Validate}catch(err){throw _objErrMsg+"-> dependancy library is missing or did not initiate properly  "}function initialize(element){mainElement=$(element);scId=Config.getConfigValue("GridController.slotContainerId");sc=$(scId);scScrollbarId=Config.getConfigValue("GridController.scrollbarId");scScrollbar=$(scScrollbarId);scContent=sc.firstDescendant();if(!mainElement){throw _objErrMsg+"main element missing."}if(navigator.userAgent.indexOf("iPad")!=-1){displayJsScrollbar=true}if(!(scId&&scScrollbarId&&scScrollbar)){throw _objErrMsg+"unable to find slotcontainer or scrollbar in DOM."}localeBasePath=Config.getConfigValue("GridController.localeBasePath");DataController=UPC.apps.epg.DataController.init($(scId));FavouritesController=UPC.apps.epg.FavouritesController.init(mainElement);ToolBoxController=UPC.apps.epg.ToolBoxController.init(mainElement);TimeController=UPC.apps.epg.TimeController.init(mainElement);Tooltip=UPC.widget.Tooltip.init();Event.observe(scId,"mouseover",_showTooltip);Event.observe(scId,"click",_gridOnClick);Event.observe(scId,"mousewheel",Tooltip.hide);Event.observe(window,"unload",function(){saveGridState()});if(document.documentElement.className.indexOf("chrome")===-1){viewHeight=$("header").getHeight()+$("userpanel").getHeight()+$("tvguide_toolbox").getHeight()+$("epg_footer").getHeight()}else{viewHeight=$("userpanel").getHeight()+$("tvguide_toolbox").getHeight()+$("epg_footer").getHeight()}Event.observe(window,"resize",resizeGrid);document.observe("epg:dateChange",_gridDateChange);document.observe("epg:timeChange",_gridTimeChange);document.observe("epg:contentUpdated",_gridContentUpdate);document.observe("epg:restoreGrid",restoreGridState);if(document.location.protocol==="http:"){if(!Cookie||!Cookie.read("epg_hs")){restoreGridState()}}GridMenuController.init({elementId:_getConfigValue("gridMenu.elementId"),afterHide:function(){var margin;if(displayJsScrollbar&&scContent&&Scrollbar){margin=scScrollOffset*(scContent.offsetHeight-sc.offsetHeight);scContent.style.marginTop=-margin+"px"}_resizeChannels()},afterShow:function(){var margin;if(displayJsScrollbar&&scContent&&Scrollbar){margin=scScrollOffset*(scContent.offsetHeight-sc.offsetHeight);scContent.style.marginTop=-margin+"px"}_resizeChannels()},beforeHide:function(args){var cookieParams=Cookie.read(config.cookieName);if(cookieParams){Cookie.remove(config.cookieName);Cookie.remove(config.uiCookieName)}TimeController.displayTimeIndicator(true);active=null},beforeShow:function(args){var allDayEventClassName=config.allDayEventClassName;var scOffset,time=null,tmp=null;var date=new Date();if(args&&args.element&&!Element.hasClassName(args.element,config.channelClassName)&&args.element.nodeName=="LI"){active=args;tmp=[Element.down(active.element,"a"),Element.down(active.element,"div.event_detail"),Element.down(active.element,"p.desc")];if(active.elementId){Object.extend(active,LogicController.elementIdToEvent(active.elementId))}if(tmp[0]&&tmp[1]&&tmp[2]){active.title=tmp[0].innerHTML;active.desc=tmp[2].innerHTML;active.url=tmp[0].href;tmp[4]=Element.down(tmp[1],"span.event_channel");tmp[5]=Element.down(tmp[1],"span.time");if(tmp[4]&&tmp[5]){active.channel=tmp[4].innerHTML;active.time=tmp[5].innerHTML}if(Validate.isIso8601TimeStamp(active.startDateTime)&&active.time){time=[active.time.match(/^(\d{2}):(\d{2})\s-\s(\d{2}):(\d{2})$/),Parse.iso8601ToEpoch(active.startDateTime)];if(time.length===2&&time[0].length===5){for(var i=time[0].length;i--;){time[0][i]=parseInt(time[0][i],10)}if(time[0][1]===time[0][3]&&time[0][2]===time[0][4]&&Element.hasClassName(active.element,allDayEventClassName)){time[2]=3600*24}else{if(time[0][3]<time[0][1]){time[2]=3600*24;time[2]+=(24-(time[0][1]+1))*3600;time[2]+=(60-time[0][2])*60;time[2]+=time[0][4]*60}else{if(time[0][3]===time[0][1]){time[2]=(time[0][4]-time[0][2])*60}else{time[2]=((time[0][3]-1)-time[0][1])*3600;time[2]+=(60-time[0][2])*60;time[2]+=time[0][4]*60}}}time[2]=time[2]*1000+time[1];active.endDateTime=Parse.epochToIso8601(time[2])}}tmp=_getConfigValue("gridMenu.contentTemplate");if(tmp){if(Locale.isLoaded(_getConfigValue("locale"))){active.DVRContent=LogicController.getGridMenuDVRHTMLContent(active)}else{active.DVRContent=""}html=tmp.evaluate({title:active.title||"",desc:active.desc||"",url:active.url||"",channel:active.channel||"",time:active.time||"",closeButtonText:_getButtonText("close"),DVRContent:active.DVRContent});GridMenuController.setContent(html)}}TimeController.displayTimeIndicator(false);saveGridState(active.elementId)}}});document.observe("epg:gridMenuHide",GridMenuController.hide);document.observe("epg:gridMenuReload",GridMenuController.reload);Locale.init(Config.getConfigValue("GridController.locale"),{localeBasePath:new Template(localeBasePath+"#{locale}.js"),onComplete:function(){if(!LogicController){throw _objErrMsg+"initialize() -> dependancy library UPC.apps.epg.LogicController is missing"}else{if(!Cookie.isSupported()){Exception.raise(Locale.getString("error.cookie.msg"),Locale.getString("error.cookie.title"),{onRaiseReload:false})}SearchController.init("query");window.setTimeout(function(){LogicController.init()},0);if(active!==null){GridMenuController.reload()}}}});return this}function _createScrollBar(){var hideScrollbarClassName=config.hideScrollbarClassName;if(Element.hasClassName(scScrollbar,hideScrollbarClassName)){Element.removeClassName(scScrollbar,hideScrollbarClassName)}if(!scContent){scContent=sc.getElementsByClassName("timeslot")[0]}if(Dragdealer){Scrollbar=new Dragdealer(scScrollbar,{horizontal:false,vertical:true,speed:35,yPrecision:scContent.offsetHeight,animationCallback:function(x,y){var margin;if(!scContent){scContent=sc.getElementsByClassName("timeslot")[0]}if(scContent){margin=y*(scContent.offsetHeight-sc.offsetHeight);scContent.style.marginTop=-margin+"px";scScrollOffset=y}}})}else{throw _objErrMsg+"-> scrollbar library is missing or did not initiate properly"}}function _getButtonText(key){if(key&&typeof(key)=="string"){return _getLocaleValue("buttons."+key)||buttons[key]}return null}function _getConfigValue(key){return Config.getConfigValue("GridController."+key)}function _getLocaleValue(key){var locale=null;if(key){locale=Locale.getString(key);if(locale.constructor===Array){locale=locale.join("")}return locale||null}return null}function _gridContentUpdate(){hideScrollbarClassName=config.hideScrollbarClassName;loadingClassName=config.loadingClassName;if(Element.hasClassName(sc,loadingClassName)){Element.removeClassName(sc,loadingClassName)}if(displayJsScrollbar){scContent=sc.getElementsByClassName("timeslot")[0];if(scContent&&scScrollbar&&Element.hasClassName(scScrollbar,hideScrollbarClassName)){Element.removeClassName(scScrollbar,hideScrollbarClassName)}}else{Element.removeClassName(sc,config.disabledScrollbarClassName)}}function _gridDateChange(){saveGridState({scrollOffset:0});if(displayJsScrollbar){if(Scrollbar){Scrollbar.setValue(0,0)}Element.addClassName(scScrollbar,config.hideScrollbarClassName)}else{Element.addClassName(sc,config.loadingClassName)}LogicController.deleteUiState()}function _gridOnClick(e){var disabledScrollbarClassName=config.disabledScrollbarClassName;var element=Event.element(e);var liElement=null;if(element){if(Element.hasClassName(element,config.favouriteIconClassName)){liElement=element.up("ol");FavouritesController.update(liElement,function(action){if(action==="delete"){if(!displayJsScrollbar){ToolBoxController.applyPopups()}else{if(Element.hasClassName(scScrollbar,disabledScrollbarClassName)){ToolBoxController.applyPopups()}}}});Event.stop(e)}else{if(element.nodeName==="A"&&element.parentNode.nodeName==="LI"){element=element.parentNode}if(!Element.hasClassName(element,config.channelClassName)&&element.nodeName==="LI"&&element.id&&_isValidGridEventElementId(element.id)){GridMenuController.show(element.id);Event.stop(e)}}}}function _gridTimeChange(){saveGridState({scrollOffset:0});if(displayJsScrollbar){if(Scrollbar){Scrollbar.setValue(0,0)}Element.addClassName(scScrollbar,config.hideScrollbarClassName)}else{Element.addClassName(sc,config.loadingClassName)}LogicController.deleteUiState()}function _isValidEpgDate(arg){var start=new Date(),end;start.setHours(0);start.setMinutes(0);start.setSeconds(0);start=start.getTime();end=start+(7*24*3600*1000);if(arg&&arg>=start&&arg<=end){return true}return false}function _isValidGridEventElementId(arg){if(typeof(arg)==="string"&&arg.length!==0){return/^eid_\d{8,20}_[a-zA-Z0-9]+_20\d{2}-\d{2}-\d{2}T\d{2}:\d{2}Z/.test(arg)}return false}function _loadGrid(date,offset,callback){if(Validate.isDate(date)&&Validate.isInt(offset)){deleteGridState();TimeController.setCurrentTimeSlot(date,function(){if($(urlParams.eId)){GridMenuController.show(urlParams.eId)}if(displayJsScrollbar){Element.addClassName(sc,config.jsScrollbarClassName);if(Scrollbar===null){_createScrollBar();Scrollbar.setValue(0,offset)}else{Scrollbar.setValue(0,offset)}}Element.removeClassName(sc,config.loadingClassName);if(callback){callback()}})}}function _resizeChannels(){var channelHeight,gridHeight,margin,maxGridHeight=null;var gridMenuHeight=GridMenuController.getHeight();var hideScrollbarClassName=config.hideScrollbarClassName;channelHeight=config.channelHeight||56;maxGridHeight=((UPC.apps.epg.visibleChannelsCount*channelHeight))||channelHeight;gridHeight=Math.min(maxGridHeight,viewPortHeight);gridHeight=Math.max(gridHeight,channelHeight);if(displayJsScrollbar&&!scContent){scContent=sc.getElementsByClassName("timeslot")[0]}if(gridHeight<viewPortHeight){gridHeight+=gridMenuHeight;if(displayJsScrollbar){if(!Element.hasClassName(scScrollbar,config.disabledScrollbarClassName)){Element.addClassName(scScrollbar,config.disabledScrollbarClassName);if(Scrollbar&&typeof(Scrollbar.disable)==="function"){Scrollbar.setValue(0,0);Scrollbar.disable()}scContent.style.marginTop="0px";Element.setStyle(scScrollbar,{height:gridHeight+"px"})}else{Element.setStyle(sc,{height:gridHeight+"px"});if(Scrollbar){Scrollbar.setValue(0,0)}margin=scScrollOffset*(scContent.offsetHeight-sc.offsetHeight);scContent.style.marginTop=-margin+"px";Element.setStyle(scScrollbar,{height:gridHeight+"px"})}}else{if(!Element.hasClassName(sc,config.disabledScrollbarClassName)){Element.addClassName(sc,config.disabledScrollbarClassName)}Element.setStyle(sc,{height:gridHeight+"px"})}}else{if(gridHeight===channelHeight){if(displayJsScrollbar){if(!Element.hasClassName(scScrollbar,config.disabledScrollbarClassName)){Element.addClassName(scScrollbar,config.disabledScrollbarClassName)}Element.setStyle(scScrollbar,{height:gridHeight+"px"})}else{if(!Element.hasClassName(sc,config.disabledScrollbarClassName)){Element.addClassName(sc,config.disabledScrollbarClassName)}}}else{if(displayJsScrollbar){if(Element.hasClassName(scScrollbar,config.disabledScrollbarClassName)){Element.removeClassName(scScrollbar,config.disabledScrollbarClassName)}if(gridHeight>=channelHeight){Element.setStyle(sc,{height:gridHeight+"px"});if(Scrollbar&&typeof(Scrollbar.enable)==="function"){Scrollbar.enable()}margin=scScrollOffset*(scContent.offsetHeight-sc.offsetHeight);scContent.style.marginTop=-margin+"px"}Element.setStyle(scScrollbar,{height:gridHeight+"px"})}else{if(Element.hasClassName(sc,config.disabledScrollbarClassName)){Element.removeClassName(sc,config.disabledScrollbarClassName)}Element.setStyle(sc,{height:gridHeight+"px"})}}}TimeController.resetPosition(gridHeight);return gridHeight}function _secureCopyObject(dest,src){if(dest&&src){for(var value in dest){if(src.hasOwnProperty(value)&&dest.hasOwnProperty(value)){if(src[value].constructor===Array){dest[value]=src[value]}else{if(typeof(src[value])==="object"){_secureCopyObject(dest[value],src[value])}else{if(typeof(src[value])==="string"){dest[value]=src[value]}else{if(typeof(src[value])==="number"){dest[value]=src[value]}else{if(typeof(src[value])==="boolean"){if(dest[value]===true){src[value]=true}else{src[value]=false}}}}}}}}}}function _showTooltip(e){var element=Event.element(e)||null;var desc=null,elPos=null,elWid=null,top=null;var ignoreClassNames=["channel","channel_info","channel_logo","filtered_out","hd","channel_meta","channel_name","nodata","active","grid_menu"];if(element===null||!element.href){return}if(element.nodeName==="A"&&element.parentNode.nodeName==="LI"){element=element.parentNode}elPos=element.cumulativeOffset();elWid=element.getWidth();blockMiddle=elPos.left+(elWid/2);top=elPos.top-element.cumulativeScrollOffset().top;for(var j=ignoreClassNames.length;j--;){if(Element.hasClassName(element,ignoreClassNames[j])){return}}if(Element.hasClassName(element,"favicon")||Element.hasClassName(element,"live")){if(Element.hasAttribute(element,"title")&&!Element.hasAttribute(element,"desc")){desc=element.title;element.title="";element.setAttribute("desc",desc);Tooltip.show(null,desc,{top:top,left:blockMiddle},element)}else{if(Element.hasAttribute(element,"desc")){Tooltip.show(null,"<p>"+Element.readAttribute(element,"desc")+"</p>",{top:top,left:blockMiddle},element)}}}else{Tooltip.show(null,element.innerHTML,{top:top,left:blockMiddle},element)}Event.stop(e)}function deleteGridState(){Cookie.remove(config.cookieName)}function needsDisplay(){resizeGrid();DataController.toggleLoader(false)}function resetGridView(){GridMenuController.hide();deleteGridState();if(displayJsScrollbar){Scrollbar.setValue(0,0)}}function resizeGrid(){var newViewPortHeight=document.viewport.getDimensions().height-viewHeight;if(viewPortHeight!=newViewPortHeight){viewPortHeight=newViewPortHeight}_resizeChannels()}function restoreGridState(){var callback=null,date=null,offset=0,params,startDateTime;cookieParams=Cookie.readJSON(config.cookieName);urlParams=window.location.href.toQueryParams();if(urlParams&&urlParams.hasOwnProperty("startDateTime")||urlParams.hasOwnProperty("eId")){Cookie.remove(config.cookieName);if(Validate.isIso8601TimeStamp(urlParams.startDateTime)){date=new Date(Parse.iso8601ToEpoch(urlParams.startDateTime))}else{if(_isValidGridEventElementId(urlParams.eId)){params=LogicController.elementIdToEvent(urlParams.eId);if(params.startDateTime){date=new Date(Parse.iso8601ToEpoch(params.startDateTime))}offset=0;callback=function(){var element;element=$(urlParams.eId);GridMenuController.show(urlParams.eId);if(element&&!displayJsScrollbar){window.setTimeout(function(){element.scrollIntoView(true)},0)}TimeController.displayTimeIndicator(false)}}}}else{if(cookieParams&&Validate.isInt(cookieParams.date)&&Validate.isFloat(cookieParams.scrollOffset)){callback=function(){var element;if(_isValidGridEventElementId(cookieParams.eId)){element=$(cookieParams.eId)}else{if(cookieParams.startDateTime&&cookieParams.channelId){var channel=$("cid_"+cookieParams.channelId);if(channel){var targetEventElement=channel.childElements().detect(function(element){if(element.id){var segments=element.id.split("_");return segments.pop()===cookieParams.startDateTime}return false});if(targetEventElement){GridMenuController.show(targetEventElement.id);if(targetEventElement&&!displayJsScrollbar){window.setTimeout(function(){targetEventElement.scrollIntoView(true)},0)}TimeController.displayTimeIndicator(false);Cookie.remove(config.cookieName)}}}}};date=new Date(cookieParams.date);date.setUTCMinutes(0);offset=cookieParams.scrollOffset}else{_loadGrid(TimeController.getCurrentTimeSlot(),offset,callback);return}}if(!_isValidEpgDate(date)){date=new Date()}date.setUTCMinutes(0);_loadGrid(date,offset,callback)}function saveGridState(args){var params={date:(TimeController.getCurrentTimeSlot()).getTime(),scrollOffset:scScrollOffset};if(args){if(_isValidGridEventElementId(args.elementId)){var segments=args.elementId.split("_");params.channelId=segments[2];params.startDateTime=segments[3]}if(args.hasOwnProperty("startDateTime")){params.startDateTime=args.startDateTime}if(args.hasOwnProperty("channelId")){params.channelId=args.channelId}if(args.scrollOffset){params.scrollOffset=scrollOffset}if(Validate.isDate(args.date)){params.date=args.date.getTime()}}if(active&&active.elementId){if(active.startDateTime&&Validate.isIso8601TimeStamp(active.startDateTime)){params.startDateTime=active.startDateTime}var element=$(active.elementId);var channelElement;if(element&&(channelElement=element.up("ol"))){params.channelId=channelElement.id.replace("cid_","")}else{if(active.channelId){params.channelId=active.channelId}}}if(Validate.isInt(params.date)&&Validate.isFloat(params.scrollOffset)&&Validate.isString(config.cookieName)){Cookie.writeJSON(config.cookieName,params,0)}}return{init:initialize,deleteGridState:deleteGridState,needsDisplay:needsDisplay,resetGridView:resetGridView,resizeGrid:resizeGrid,restoreGridState:restoreGridState,saveGridState:saveGridState}}();namespace("UPC.apps.epg");UPC.apps.epg.ListController=function(){var _objName="UPC.apps.epg.ListController";var _objErrMsg="Error in "+_objName+": ";var localeBasePath=null,mainElement=null;var topNavMenu={elementId:"topnav_controls",html:"",faqId:"topnav_faq",loginId:"topnav_login",logoutId:"topnav_logout",settingsId:"topnav_settings",settingsButtonClass:"generic_button",userDetailsId:"topnav_user_container",userFullNameId:"topnav_user_full_name"};try{var Config=UPC.util.Configuration;var Cookie=UPC.util.Cookie;var Locale=UPC.util.Localization;var FavouritesController=UPC.apps.epg.FavouritesController;var LogicController=null;var SearchController=UPC.apps.epg.SearchController}catch(err){throw _objErrMsg+"-> dependancy library is missing or did not initiate properly  "}function initialize(element){mainElement=$(element);if(mainElement==null){throw _objErrMsg+" main element could not be found."}LogicController=UPC.apps.epg.LogicController;localeBasePath=Config.getConfigValue("ListController.localeBasePath");FavouritesController=FavouritesController.init(mainElement);mainElement.observe("click",_listOnClick);Locale.init(Config.getConfigValue("GridController.locale"),{localeBasePath:new Template(localeBasePath+"#{locale}.js"),onComplete:function(){if(!LogicController){throw _objErrMsg+"initialize() -> dependancy library UPC.apps.epg.LogicController is missing"}else{try{SearchController.init("query");window.setTimeout(function(){LogicController.init()},0);FavouritesController.display()}catch(err){throw err}}}});LogicController.deleteUiState()}function _listOnClick(e){var element=e.findElement("a")||null;if(element){if(element.match("a.favicon")){FavouritesController.update(element.up());e.stop();return}}}return{init:initialize}}();window.setTimeout(function(){var custApiPath,gridPath,analyticsPath,localeBasePath,locale;var locales=["nl_NL","en_IE","pl_PL"];var tmp=window.epgConfig;var urlParams=window.location.href.toQueryParams();if(!tmp){tmp={}}if(urlParams.hasOwnProperty("locale")&&locales.member(urlParams.locale)){locale=urlParams.locale}else{locale=tmp.locale||"en_GB"}analyticsPath=tmp.analyticsPath||"/javascript/deployments/EPG-JS/current/analytics-min.js";localeBasePath=tmp.localeBasePath||"/javascript/pc/src/apps/epg/locales/";custApiPath=tmp.custApiPath||"/customerApi/api/";gridPath=tmp.gridPath||"/TV/wa/grid/";var Config,Locale,GridController,ListController;var GlobalConfig={Exception:{elementId:"err_content_container",contentTemplate:new Template('<button class="generic_button overlay_close" id="err_close" value=""><span></span></button><h2 class="title">#{title}</h2><p class="generic_content">#{content} </p><div class="buttons_container generic_content"><button class="generic_button" id="err_ok" value=""><span>#{okButtonText}</span></button></div>')},GridController:{locale:locale,localeBasePath:localeBasePath,gridMenu:{elementId:"grid_menu_container",contentTemplate:new Template('<div class="grid_menu_content_container"><div class="grid_menu_event_detail_container"><button class="grid_menu_close_button" id="grid_menu_close">#{closeButtonText}</button> <span id="grid_menu_event_url">#{title}</span><br/><span id="grid_menu_event_channel">#{channel}</span>, <span id="grid_menu_time">#{time}</span><br/><p id="grid_menu_desc">#{desc}</p></div><div id="grid_menu_dvr_container">#{DVRContent} </div></div>')},slotContainerId:"slot_container",scrollbarId:"scrollbar"},OverlayController:{locale:locale,elementId:"overlays_container",overlays:{splash:{elementId:"splash_content_container"},faq:{elementId:"faq_content_container"},login:{elementId:"login_content_container",errMsgContainerId:"login_err_msg_container",formId:"login_details",formContainerId:"login_form_container",passwordId:"login_user_passwd",usernameId:"login_user_name",waitingId:"login_waiting_container"},settings:{elementId:"settings_content_container"},setBooking:{elementId:"set_booking_content_container",detailsId:"set_booking_details",overrideNoId:"set_booking_override_no",overrideYesId:"set_booking_override_yes",contentTemplate:new Template('<h2 class="title">#{title}</h2><div class="event_detail" id="event_detail"><span class="event_channel">#{channel}</span>, <span class="event_time">#{time}</span></div>')},setSeriesBooking:{elementId:"set_series_booking_content_container",detailsId:"set_series_booking_details",contentTemplate:new Template('<h2 class="title">#{title}</h2><div class="event_detail" id="event_detail"><span class="event_channel">#{channel}</span>, <span class="event_time">#{time}</span></div>')},setReminder:{elementId:"set_reminder_content_container",detailsId:"set_reminder_details",contentTemplate:new Template('<h2 class="title">#{title}</h2><div class="event_detail" id="event_detail"><span class="event_channel">#{channel}</span>, <span class="event_time">#{time}</span></div>')},setupComplete:{elementId:"setup_complete_content_container"},setupNotify:{elementId:"setup_notify_content_container"},setupLegal:{elementId:"setup_legal_content_container"},smsToken:{elementId:"sms_token_content_container"},upsellNoDVR:{elementId:"upsell_no_dvr_content_container"},upsellNoHD:{elementId:"upsell_no_hd_content_container"}}},ListController:{locale:locale,localeBasePath:localeBasePath},LogicController:{locale:locale,genericButtonClass:"grid_button",linkButtonClass:"grid_button",analyticsPath:analyticsPath,custApiPath:custApiPath,grid:{bookingClasses:{deleted:"booking_deleted",failure:"booking_failure",overridden:"booking_overridden",pending:"booking_pending",success:"booking_success",waiting:"booking_waiting"},reminderClasses:{failure:"reminder_failure",pending:"reminder_pending",success:"reminder_success",waiting:"reminder_waiting"}},gridMenu:{elementId:"grid_menu_container",buttonClass:"grid_menu_button",buttonContainerId:"grid_menu_buttons_container",statusTemplate:new Template('<p class=" grid_menu_content #{cls} ">#{msg}</p>')},topNavMenu:{elementId:"topnav_controls",faqId:"topnav_faq",loginId:"topnav_login",logoutId:"topnav_logout",settingsId:"topnav_settings",settingsButtonClass:"generic_button",userDetailsId:"topnav_user_container",userFullNameId:"topnav_user_full_name"}},DataController:{maxCacheSize:6,preloadCount:0,dataUrlTpl:new Template(gridPath+"?startDateTime=#{datetime}#{cityCode}"),eventInfoUrl:"/TV/Guide/Event/",busyId:"current_time_container",busyClassName:"busy"},SearchController:{locale:locale},TimeController:{timelineSelector:".timeline",ctiId:"",currentTimeSlotId:"",ctiInterval:60,locale:locale},Tooltip:{elementId:"tooltip",contentTemplate:new Template('<div id="tooltip_content">#{content}</div>'),showDelay:800,hideDelay:5000,width:300,autoDismissDelay:12500,offset:[0,0]}};try{Locale=UPC.util.Localization;UPC.util.Exception.setParams({elementId:GlobalConfig.Exception.elementId,contentTemplate:GlobalConfig.Exception.contentTemplate});Config=UPC.util.Configuration;GridController=UPC.apps.epg.GridController;ListController=UPC.apps.epg.ListController;LogicController=UPC.apps.epg.LogicController;Config.init(GlobalConfig);if($("grid")!==null){GridController.init($("upc_tvguide"))}else{if($("channel_description")!==null||$("search_results")!==null||$("detail_page")!==null){ListController.init($("upc_tvguide"))}}}catch(err){if(Locale.isLoaded(locale)){UPC.util.Exception.raise(Locale.getString("error.critical.msg"),Locale.getString("error.defaultTitle"))}else{UPC.util.Exception.raise(err.message,"Error")}}},0);
