var TVMDS={};TVMDS.util={typeOf:function(B){var A=typeof B;if(A==="object"){if(B){if(typeof B.length==="number"&&!(B.propertyIsEnumerable("length"))&&typeof B.splice==="function"){A="array"}}else{A="null"}}return A},isEmpty:function(C){var B,A;if(this.typeOf(C)==="object"){for(B in C){A=C[B];if(A!==undefined&&this.typeOf(A)!=="function"){return false}}}return true},entityify:function(A){return A.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},trim:function(A){return A.replace(/^\s+|\s+$/g,"")},dump:function(A,G){var F="dump: \n";var E="";if(!G){G=0}for(var B=0;B<G+1;B++){E+="    "}if(typeof (A)==="object"){for(var C in A){var D=A[C];if(typeof (D)=="object"){F+=E+"'"+C+"' ...\n";F+=this.dump(D,G+1)}else{F+=E+"'"+C+"' => \""+D+'"\n'}}}else{F="===>"+A+"<===("+typeof (A)+")"}return F}};if(typeof TVMDS==="undefined"){alert("TVMDS_cookie: Dependency 'TVMDS_core' not loaded.")}TVMDS.cookie={set:function(C,D,E){if(E){var B=new Date();B.setTime(B.getTime()+(E*24*60*60*1000));var A="; expires="+B.toGMTString()}else{var A=""}document.cookie=C+"="+D+A+"; path=/"},get:function(B){var D=B+"=";var A=document.cookie.split(";");for(var C=0;C<A.length;C++){var E=A[C];while(E.charAt(0)==" "){E=E.substring(1,E.length)}if(E.indexOf(D)==0){return E.substring(D.length,E.length)}}return null},clear:function(A){this.set(A,"",-1)}};if(typeof TVMDS==="undefined"){alert("TVMDS_ajax: Dependency 'TVMDS_core' not loaded.")}TVMDS.ajax={properties:{reflector_url:undefined},sendRequest:function(B,E,A){if(this.properties.reflector_url){B=this.properties.reflector_url+"?encoded="+encodeURIComponent(B)}var C=this.createXMLHTTPObject();if(!C){return }var D=(A)?"POST":"GET";C.open(D,B);C.setRequestHeader("User-Agent","XMLHTTP/1.0");if(A){C.setRequestHeader("Content-type","application/x-www-form-urlencoded")}C.onreadystatechange=function(){if(C.readyState!=4){return }if(C.status!=200&&C.status!=304){return }E(C)};if(C.readyState==4){return }C.send(A)},fireEvents:function(B,C){for(var A=0;A<=TVMDS[B].events[C].length;A++){if(typeof TVMDS[B].events[C][A]==="function"){TVMDS[B].events[C][A]()}}},XMLHttpFactories:[function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],createXMLHTTPObject:function(){var B=false;for(var A=0;A<this.XMLHttpFactories.length;A++){try{B=this.XMLHttpFactories[A]()}catch(C){continue}break}return B}};if(typeof TVMDS==="undefined"){alert("TVMDS_session: Dependency 'TVMDS_core' not loaded.")}if(typeof TVMDS.cookie==="undefined"){alert("TVMDS_session: Dependency 'TVMDS_cookie' not loaded.")}if(typeof TVMDS.ajax==="undefined"){alert("TVMDS_session: Dependency 'TVMDS_ajax' not loaded.")}TVMDS.session={events:{onLoad:[]},data:{},init:function(){this.data={};var A=TVMDS.cookie.get("id");if(A){this.load(A);this.data.session_id=A}else{A=this.generateNewSessionID();this.data.session_id=A;TVMDS.cookie.set("id",A,1000);this.save();TVMDS.ajax.fireEvents("session","onLoad")}},load:function(A){TVMDS.ajax.sendRequest("http://tvmds.tvpassport.com/php/session.php?mode=g&session_id="+A,this.loadVars)},save:function(){var A="";for(var B in this.data){A=A+encodeURIComponent(B)+"="+encodeURIComponent(this.data[B])+"&"}TVMDS.ajax.sendRequest("http://tvmds.tvpassport.com/php/session.php?mode=s&"+A,this.saveVarsResponse)},loadVars:function(server_response){TVMDS.session.data={};if(server_response.responseText==""){alert("Session load returned no data from the server")}else{var json_data=eval("("+server_response.responseText+")")}if(json_data&&typeof json_data==="object"){TVMDS.session.data=json_data}TVMDS.ajax.fireEvents("session","onLoad")},saveVarsResponse:function(A){},generateNewSessionID:function(){var A="";while(A.length<32){A=A+Math.floor(Math.random()*15).toString(16).toUpperCase()}return A}};TVMDS.lineups={events:{onLoadStep1:[],onSuccess:[]},properties:{target_element_id:"lineup_selector",is_missing_lineup:false,update_session_lineup_id:true,postal_code:null},setTargetElementId:function(A){this.properties.target_element_id=A},onSuccess:function(A){if(typeof A==="function"){TVMDS.lineups.events.onSuccess.push(A)}},draw:function(){var A="http://tvmds.tvpassport.com/php/lineup_selector.php";if(typeof this.properties.postal_code==="undefined"){}else{if(typeof this.properties.postal_code==="string"&&this.properties.is_missing_lineup===false){A=A+"?pc="+encodeURIComponent(this.properties.postal_code)}else{if(typeof this.properties.postal_code==="string"&&this.properties.is_missing_lineup===true){A=A+"?pc="+encodeURIComponent(this.properties.postal_code)+"&missing=1"}}}TVMDS.ajax.sendRequest(A,this._cb_writeLineupSelectorHTML)},_cb_writeLineupSelectorHTML:function(C){document.getElementById(TVMDS.lineups.properties.target_element_id).innerHTML=C.responseText;var B=document.getElementById("tvm_ls_submit_1");var F=document.getElementById("tvm_ls_back");var A=document.getElementById("tvm_ls_submit_2");var E=document.getElementById("tvm_ls_missing");var D=document.getElementById("tvm_ls_missing_submit");if(B!=null){B.onclick=function(){TVMDS.lineups.properties.postal_code=document.getElementById("tvm_postal_code").value;TVMDS.lineups.draw();return false};document.getElementById("tvm_postal_code").focus()}if(F!=null){F.onclick=function(){TVMDS.lineups.properties.postal_code=undefined;TVMDS.lineups.draw();return false}}if(A!=null){A.onclick=function(){var I=document.getElementById("tvm_lineup_selector_ul");if(I){var G=I.getElementsByTagName("input");if(G){for(var H=0;H<G.length;++H){if(G[H].type=="radio"&&G[H].name=="tvm_lineup_select"&&G[H].checked){TVMDS.grid.setLineupId(G[H].value);if(TVMDS.lineups.properties.update_session_lineup_id){TVMDS.session.data.lineup_id=G[H].value;TVMDS.session.save()}}}}}TVMDS.ajax.fireEvents("lineups","onSuccess");return false}}if(E!=null){E.onclick=function(){TVMDS.lineups.properties.is_missing_lineup=true;TVMDS.lineups.draw();return false}}if(D!=null){D.onclick=function(){alert("Votre soumission a été envoyé.");var G="http://tvmds.tvpassport.com/php/feedback.php";G=G+"?pc="+document.getElementById("tvm_postal_code").value;G=G+"&c="+document.getElementById("tvm_city").value;G=G+"&p="+document.getElementById("tvm_provider").value;TVMDS.lineups.properties.is_missing_lineup=false;TVMDS.lineups.properties.postal_code=null;TVMDS.ajax.sendRequest(G,TVMDS.lineups._cb_writeFeedbackFormHTML);return false}}},_cb_writeFeedbackFormHTML:function(A){TVMDS.lineups.draw();return false}};if(typeof TVMDS==="undefined"){alert("TVMDS_grid: Dependency 'TVMDS_core' not loaded.")}if(typeof TVMDS.ajax==="undefined"){alert("TVMDS_grid: Dependency 'TVMDS_ajax' not loaded.")}if(typeof TVMDS.session==="undefined"){alert("TVMDS_grid: Dependency 'TVMDS_session' not loaded.")}TVMDS.grid={events:{onGridDraw:[],onGetGridStartTime:[],onGetLineupChannels:[]},properties:{width:600,num_hours:3,num_channels:0,target_element_id:"tvmds_tv_grid",lineup_id:0,start_index:0,start_time:0,gmt_now:undefined,lineup_channels:undefined},setWidth:function(A){this.properties.width=parseInt(A);this.properties.num_hours=this._getGridHoursForWidth(this.properties.width)},setNumChannels:function(A){this.properties.num_channels=parseInt(A)},setTargetElementId:function(A){this.properties.target_element_id=A},setLineupId:function(A){this.properties.lineup_id=A},setStartTime:function(A){this.properties.start_time=A},setStartIndex:function(A){this.properties.start_index=A},draw:function(){if(!this.properties.lineup_id&&TVMDS.session.data.lineup_id){this.properties.lineup_id=TVMDS.session.data.lineup_id}if(typeof this.properties.gmt_now==="undefined"){TVMDS.grid.events.onGetGridStartTime.push(function(){TVMDS.grid.draw()});this._getGridStartTime();return }if(!this.properties.start_time){this.properties.start_time=this.properties.gmt_now}if(typeof this.properties.lineup_channels==="undefined"){TVMDS.grid.events.onGetLineupChannels.push(function(){TVMDS.grid.draw()});this._getLineupChannels();return }var A="http://tvmds.tvpassport.com/php/grid.php?lu="+encodeURIComponent(this.properties.lineup_id||"")+"&ss="+encodeURIComponent(TVMDS.session.data.session_id||"")+"&st="+encodeURIComponent(this.properties.start_time||"")+"&wd="+encodeURIComponent(this.properties.width||600)+"&nc="+encodeURIComponent(this.properties.num_channels||0)+"&si="+encodeURIComponent(this.properties.start_index||0);TVMDS.ajax.sendRequest(A,this._cb_writeGridHTML)},refresh:function(){this.draw()},nextTimespan:function(){this.properties.start_time=this.properties.start_time+(((this.properties.num_hours-1)*3600)+1);this.draw()},prevTimespan:function(){this.properties.start_time=this.properties.start_time-((this.properties.num_hours-1)*3600);this.draw()},jumpToTime:function(A){this.properties.start_time=A;this.draw()},jumpToChannelIndex:function(A){this.properties.start_index=A;this.draw()},nextChannels:function(){this.properties.start_index=(this.properties.start_index*1)+(this.properties.num_channels*1)-1;if(this.properties.start_index>this.properties.lineup_channels.length){this.properties.start_index=this.properties.lineup_channels.length-1}this.draw()},prevChannels:function(){this.properties.start_index=this.properties.start_index-this.properties.num_channels+1;if(this.properties.start_index<0){this.properties.start_index=0}this.draw()},cellMouseOver:function(A){A.className=A.className.replace("tvm_x","tvm_xo")},cellMouseOut:function(A){A.className=A.className.replace("tvm_xo","tvm_x")},_cb_writeGridHTML:function(B){var A=document.getElementById(TVMDS.grid.properties.target_element_id);A.innerHTML=B.responseText;TVMDS.ajax.fireEvents("grid","onGridDraw")},_getGridHoursForWidth:function(A){return Math.floor((parseInt(A)-105)/150)},_getGridStartTime:function(){var A="http://tvmds.tvpassport.com/php/grid.php?rst";TVMDS.ajax.sendRequest(A,this._cb_gotGridStartTime)},_cb_gotGridStartTime:function(server_response){var json_data=eval("("+server_response.responseText+")");if(json_data&&typeof json_data==="object"){TVMDS.grid.properties.gmt_now=json_data.gmt_now}TVMDS.ajax.fireEvents("grid","onGetGridStartTime")},_getLineupChannels:function(){var A="http://tvmds.tvpassport.com/php/grid.php?rlud="+this.properties.lineup_id+"&ss="+encodeURIComponent(TVMDS.session.data.session_id||"");TVMDS.ajax.sendRequest(A,this._cb_gotLineupChannels)},_cb_gotLineupChannels:function(server_response){var json_data=eval("("+server_response.responseText+")");if(json_data&&typeof json_data==="object"){TVMDS.grid.properties.lineup_channels=json_data}TVMDS.ajax.fireEvents("grid","onGetLineupChannels")}};if(typeof TVMDS==="undefined"){alert("TVMDS_programinfo: Dependency 'TVMDS_core' not loaded.")}if(typeof TVMDS.ajax==="undefined"){alert("TVMDS_programinfo: Dependency 'TVMDS_ajax' not loaded.")}if(typeof TVMDS.session==="undefined"){alert("TVMDS_programinfo: Dependency 'TVMDS_session' not loaded.")}TVMDS.programinfo={events:{onInfoLoad:[]},properties:{target_element_id:"tvm_pi_content",program_id:undefined,mouseX:0,mouseY:0},setTargetElementId:function(A){this.properties.target_element_id=A},getProgramInfo:function(B,C){B=B||this.properties.program_id;this._getMouseXY(C);this.properties.program_id=B;var A="http://tvmds.tvpassport.com/php/program_details_new.php?ltid="+encodeURIComponent(B);TVMDS.ajax.sendRequest(A,this._cb_writeProgramInfoHTML)},_cb_writeProgramInfoHTML:function(B){var A=document.getElementById(TVMDS.programinfo.properties.target_element_id);A.innerHTML=B.responseText;TVMDS.ajax.fireEvents("programinfo","onInfoLoad")},_getMouseXY:function(B){var A=0;var C=0;if(!B){var B=window.event}if(B.pageX||B.PageY){A=B.pageX;C=B.pageY}else{if(B.clientX||B.clientY){A=B.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;C=B.clientY+document.body.scrollTop+document.documentElement.scrollTop}}this.properties.mouseX=A;this.properties.mouseY=C;return[this.properties.mouseX,this.properties.mouseY]}};if(typeof TVMDS==="undefined"){alert("TVMDS_search: Dependency 'TVMDS_core' not loaded.")}if(typeof TVMDS.ajax==="undefined"){alert("TVMDS_search: Dependency 'TVMDS_ajax' not loaded.")}if(typeof TVMDS.session==="undefined"){alert("TVMDS_search: Dependency 'TVMDS_session' not loaded.")}TVMDS.search={events:{onSearchSubmit:[],onSearchResults:[]},properties:{target_element_id:"tvm_search_results",default_search_type:"all",default_search_mode:"any",default_search_range:(24*7+6),search_type:undefined,search_mode:undefined,search_range:undefined,lineup_id:undefined,sort_column:"date",sort_order:"ASC",search_string:undefined},setTargetElementId:function(A){this.properties.target_element_id=A},changeSortColumn:function(A){this.properties.sort_column=A},toggleSortOrder:function(){if(this.properties.sort_order=="ASC"){this.properties.sort_order="DESC"}else{this.properties.sort_order="ASC"}},doSearch:function(F,C,E,A,D){F=F||this.properties.search_string;C=C||this.properties.search_type||this.properties.default_search_type;E=E||this.properties.search_mode||this.properties.default_search_mode;A=A||this.properties.search_range||this.properties.default_search_range;D=D||this.properties.lineup_id||TVMDS.session.data.lineup_id;this.properties.search_string=F;this.properties.search_type=C;this.properties.search_mode=E;this.properties.search_range=A;this.properties.lineup_id=D;var B="http://tvmds.tvpassport.com/php/program_search.php?ss="+encodeURIComponent(F)+"&lu="+encodeURIComponent(D)+"&type="+encodeURIComponent(C)+"&mode="+encodeURIComponent(E)+"&range="+encodeURIComponent(A)+"&sc="+encodeURIComponent(this.properties.sort_column)+"&so="+encodeURIComponent(this.properties.sort_order);TVMDS.ajax.fireEvents("search","onSearchSubmit");TVMDS.ajax.sendRequest(B,this._cb_writeSearchHTML)},_cb_writeSearchHTML:function(A){if (null != A) { if(typeof (TVMDS.search.properties.target_element_id)=="object"){var B=TVMDS.search.properties.target_element_id}else{var B=document.getElementById(TVMDS.search.properties.target_element_id)}B.innerHTML=A.responseText;TVMDS.ajax.fireEvents("search","onSearchResults")}}}