/* /modules/overlays/tv_headend.js */
var HeadEndWindow={window_id:"headend",zip:"",topWindowQS:window.location.search,update_headend:function(evt){var headendId=this.getAttribute("headend");if(headendId){Prefs.set("headEndId",headendId,Prefs.COOKIE);if(tvGrid&&tvGrid.update_headend){tvGrid.update_headend(headendId);}}var tz=this.getAttribute("tz");if(tz){Prefs.set("tz",tz,Prefs.COOKIE);if(tvGrid&&tvGrid.update_tz){tvGrid.update_tz(tz);}}var timeoffset=this.getAttribute("timeoffset");if(timeoffset){Prefs.set("timeoffset",timeoffset,Prefs.COOKIE);if(tvGrid&&tvGrid.update_timeoffset){tvGrid.update_timeoffset(timeoffset);}}if(HeadEndWindow.zip!=""){Prefs.set("tvZip",HeadEndWindow.zip,Prefs.COOKIE);}if(tvGrid.headend&&headendId){tvGrid.headend=headendId;tvGrid.updateAWS=true;tvGrid.build_grid(tvGrid.currentStartTime);Window.hide_all();tvGrid.displayHeadendSettings(HeadEndWindow.zip,this.innerHTML);return false;}},localizationError:'<div class="localization-error-message"><b>We are Sorry</b><p>We are unable to find a match in our system for the zip code you entered.  You have a few options with which to proceed:</p><ol><li>You can provide another zip code (try one near your house).</li><li class="error-feedback">If you currently subscribe to Comcast cable, you can reach a customer service representative at 1-800-COMCAST, or <a href="http://www.comcastsupport.com/sdcxuser/lachat/user/tvplannerfeedback.asp">send us a note</a> at Comcast Support.</li><li class="error-signup">If you are not a Comcast subscriber, check back soon for expanded listings, or <a href="http://www.comcast.com">sign up</a> for Comcast Cable!</li></ol></div>',create_window:function(zip){if(!$(this.window_id)&&!this.load_overlay()){alert("Provider selection is currently unavailable. Please try again.");return false;}var zipForm=$("headend-zip-form");zipForm.onsubmit=function(){HeadEndWindow.check_rdvr($("headend-zip").value);HeadEndWindow.zip=$("headend-zip").value;new Ajax.Request("/zip?zip="+$("headend-zip").value,{method:"get",onSuccess:function(resp){var headends=[];try{var headend_data=resp.responseXML;if(is_ie){xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async="false";xmlDoc.loadXML(resp.responseText);headend_data=xmlDoc;}var headends=headend_data.getElementsByTagName("headend");}catch(e){}var headend_list=$("headend-list");while(headend_list.childNodes.length>0){headend_list.removeChild(headend_list.childNodes[0]);}if(headends.length==0){var li=document.createElement("li");li.innerHTML=HeadEndWindow.localizationError;headend_list.appendChild(li);}for(var i=0;i<headends.length;i++){var li=document.createElement("li");var anchor=document.createElement("a");if(document.getElementById("odlistings-module")){anchor.href=document.location+HeadEndWindow.topWindowQS;}else{anchor.href="/tv/tv-listings/"+HeadEndWindow.topWindowQS;}anchor.setAttribute("headend",headends[i].getAttribute("id"));anchor.setAttribute("tz",headends[i].getAttribute("tz"));anchor.setAttribute("timeoffset",headends[i].getAttribute("timeoffset"));anchor.innerHTML=headends[i].getAttribute("title");anchor.onclick=HeadEndWindow.update_headend;li.appendChild(anchor);headend_list.appendChild(li);}}});return false;};if(zip){$("headend-zip").value=zip;HeadEndWindow.zip_submit();}var win=new Window(this.window_id,this.window_id+"-close");return win;},zip_submit:function(){HeadEndWindow.check_rdvr($("headend-zip").value);HeadEndWindow.zip=$("headend-zip").value;new Ajax.Request("/zip?zip="+$("headend-zip").value,{method:"get",onSuccess:function(resp){var headends=[];try{var headend_data=resp.responseXML;if(is_ie){xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async="false";xmlDoc.loadXML(resp.responseText);headend_data=xmlDoc;}var headends=headend_data.getElementsByTagName("headend");}catch(e){}var headend_list=$("headend-list");while(headend_list.childNodes.length>0){headend_list.removeChild(headend_list.childNodes[0]);}if(headends.length==0){var li=document.createElement("li");li.innerHTML=HeadEndWindow.localizationError;headend_list.appendChild(li);}for(var i=0;i<headends.length;i++){var li=document.createElement("li");var anchor=document.createElement("a");anchor.href="/tv/tv-listings/"+HeadEndWindow.topWindowQS;anchor.setAttribute("headend",headends[i].getAttribute("id"));anchor.setAttribute("tz",headends[i].getAttribute("tz"));anchor.setAttribute("timeoffset",headends[i].getAttribute("timeoffset"));anchor.innerHTML=headends[i].getAttribute("title");anchor.onclick=HeadEndWindow.update_headend;li.appendChild(anchor);headend_list.appendChild(li);}}});},check_rdvr:function(zip){var zipForm=$("headend-zip-form");var rdvrZips=zipForm["rdvr-zips"].value.split(",");for(var i=0;i<rdvrZips.length;i++){}return ;},load_overlay:function(){var req=new Ajax.Request("/tv/tv-listings/lineups/",{method:"get",asynchronous:false});if(req.responseIsFailure()){return false;}var placeholder=document.createElement("div");placeholder.innerHTML=req.transport.responseText;document.body.appendChild(placeholder);setTimeout(function(){$("headend-zip").focus();},100);return true;}};addLoadEvent(function(){var headEnd=Prefs.get("headEndId");if(HeadEndWindow.topWindowQS.indexOf("zipcode=")!=-1){var zipVal=HeadEndWindow.topWindowQS.substring(HeadEndWindow.topWindowQS.indexOf("zipcode=")+8);}if(!headEnd){showOverlay(function(){if(zipVal){return HeadEndWindow.create_window(zipVal);}else{return HeadEndWindow.create_window();}});}});
