Event.observe(window,'load',function(){Submenu.prepareSubMenus();Submenu.getOpenLinks().each (function(link){Event.observe(link,'mouseover',Submenu.open_Click);});Submenu.getCloseLinks().each (function(link){Event.observe(link,'click',Submenu.close_Click);});Submenu.showVideoSpotlight();});var Submenu ={getOpenLinks:function(){return $$('a.SubmenuOpen');},getCloseLinks:function(){return $$('a.SubmenuClose');},prepareSubMenus:function(){$$('.SubMenuHidden').each (function(elem){elem.hide();elem.removeClassName('SubMenuHidden');elem.addClassName('SubMenu');});},open_Click:function(event){var menu=event.element().up().down('div.SubMenu');var openMenuLink=menu.up().down('a.SubmenuOpen');var TIMER_ID;openMenuLink.addClassName('highlight');if(Submenu.isOpen(menu)){}else{Submenu.open(menu);$$('.ie6 select').invoke('hide');Event.observe(menu,'mouseout',function() {clearTimeout(TIMER_ID);TIMER_ID=setTimeout(function(){Submenu.close(menu);},700)});Event.observe(menu.up(),'mouseout',function() {clearTimeout(TIMER_ID);TIMER_ID=setTimeout(function(){Submenu.close(menu);},700)});Event.observe(menu.up(),'mouseover',function() {clearTimeout(TIMER_ID);});};event.preventDefault();},close_Click:function(event){var menu=event.element().up().up();Submenu.close(menu);event.preventDefault();},isOpen:function(menu){return menu.visible();},close:function(menu){var openMenuLink=menu.up().down('a.SubmenuOpen');menu.hide();openMenuLink.removeClassName('highlight');$$('.ie6 select').invoke('show');},open:function(menu){menu.show();},showVideoSpotlight:function() {if($('HideAjax')!=null) {Effect.SlideUp($('HideAjax'),{duration:2});var effettino=new Effect.Highlight($('VideoSpotlight'),{startcolor:"#ffffff",endcolor:"#ffff66",restorecolor:"#ffffff",duration:5});}}};var LocalizationInfo=Class.create({initialize:function(zip,provider,station){this.zip=zip;this.provider=provider;this.station=station;}});var gLocInfoProcess=new LocalizationInfo();var StationInfo=Class.create({initialize:function(provFullString){this.id='';this.name='';this.timezone='';var parts=provFullString.split(";;");if(parts.length>0)this.id=parts[0];if(parts.length>1)this.name=parts[1];if(parts.length>2)this.timezone=parts[2];}});var ProviderInfo=Class.create({initialize:function(provFullString){this.id='';this.name='';this.device='';this.location='';this.MSOStatus='0';var parts=provFullString.split(";;");if(parts.length>0)this.id=parts[0];if(parts.length>1)this.name=parts[1];if(parts.length>2)this.device=parts[2];if(parts.length>3)this.location=parts[3];if(parts.length>4)this.MSOStatus=parts[4];}});var Localization ={saveCookie:function(locInfo){var cInfo=Object.toQueryString({z:locInfo.zip,p:locInfo.provider,s:locInfo.station});Cookie.setRaw('LOCI',cInfo,360);var statInfo=new StationInfo(locInfo.station);Cookie.set('LOCS',statInfo.id,360);try{var sURL=document.location.href;if(sURL.match('tv_and_online_listings/index.html')) { s.events=s.events + ",event17";}if(sURL.match('video/player.html')) {s.events=s.events + ",event13";}s.prop16=statInfo.id.toLowerCase();s.events=s.events + ",event16";s.tl("","o","Localization");}catch(e){}},loadCookie:function(){var objLoc=new LocalizationInfo('','','');var fullInfo=Cookie.get('LOCI');if(fullInfo!=null&&fullInfo.length>0){var parts=fullInfo.toQueryParams();if(parts.z!=undefined&&parts.z!=null)objLoc.zip=parts.z;if(parts.p!=undefined&&parts.p!=null)objLoc.provider=parts.p;if(parts.s!=undefined&&parts.s!=null)objLoc.station=parts.s;}return objLoc;},resetCookie:function(){gLocInfoProcess=Localization.loadCookie();Cookie.erase('LOCI');Cookie.erase('LOCS');},clearLocalization:function(){Localization.resetCookie();window.location.reload();},isLocalized:function(){var locInfo=Localization.loadCookie();return locInfo.station!=null&&locInfo.station.length>0;},getCurrentStation:function(){var stationC=Cookie.get('LOCS');if(stationC==null||stationC==undefined)return '';elsereturn stationC;},getCurrentStationName:function(){if(Localization.isLocalized()){var locInfo=Localization.loadCookie();var stationInfo=new StationInfo(locInfo.station);return stationInfo.name;}elsereturn '';},goPage:function(){document.location.href=Localization.getPage();return false;},getPage:function(){var myCookie=Localization.getCurrentStation();if(myCookie.length>0) {return "/" + myCookie + "/index.html";} else {return "/olympiczone/index.html";}},getLogo:function(){var myCookie=Localization.getCurrentStation();if(myCookie.length>0) {return "/imgml/stationsLogo/" + myCookie + ".jpg";} else {return "/imgml/stationsLogo/nbc.jpg";}},getLogoSmall:function(){var myCookie=Localization.getCurrentStation();if(myCookie.length>0) {return "/imgml/stationsLogo/small/" + myCookie + ".jpg";} else {return "/imgml/stationsLogo/small/nbc.jpg";}},getLogoSmallGif:function(){var myCookie=Localization.getCurrentStation();if(myCookie.length>0) {return "/imgml/stationsLogo/small/" + myCookie + ".gif";} else {return "/imgml/stationsLogo/small/nbc.gif";}},showZip:function(){gLocInfoProcess.zip=null;var destination='/getlocal/library/_selectzip.html';Localization.showStep(destination);},showProviders:function(zip){if(zip!=null){zip=zip.strip();gLocInfoProcess.zip=zip;}if(Localization.isValidZip(gLocInfoProcess.zip)==false){$('zipValError').show();return;}gLocInfoProcess.provider=null;if(gLocInfoProcess.zip!=null&&gLocInfoProcess.zip!=undefined&&gLocInfoProcess.zip.length>0){var destination='/getlocal/library/zip=' + gLocInfoProcess.zip + '/_selectprovider.html';Localization.showStep(destination);}else{Localization.showZip();}},showStations:function(provider){if(provider!=null)gLocInfoProcess.provider=provider;if(gLocInfoProcess.provider==null||gLocInfoProcess.provider==undefined){$('providerValError').show();return;}gLocInfoProcess.station=null;var providerInfo=new ProviderInfo(gLocInfoProcess.provider);if(providerInfo.id!=null&&providerInfo.id!=undefined&&providerInfo.id.length>0){var destination='/getlocal/library/provider=' + providerInfo.id + '/_selectstation.html';Localization.showStep(destination);}else{Localization.showZip();}},save:function(station){if(station==null||station==undefined){$('stationValError').show();return;}gLocInfoProcess.station=station;Localization.saveCookie(gLocInfoProcess);try{var p=$('PlayerMasterContainer');if(p!==undefined&&p!=null){Cookie.erase('NBCREDIR');popupLocalization.terminateLocalization();return;}}catch(ex){};var redir=Cookie.get('NBCREDIR');Cookie.erase('NBCREDIR');if(redir=='ozone'){document.location.href=Localization.getPage();}else if(redir=='reload') {window.location.reload();}else if(redir!=null&&redir.length>0) {document.location.href=Localization.replaceLocalizedContent(redir);}else {window.location.reload();}},Path:function(url){Cookie.set('NBCREDIR',url);},showStep:function(destination){new Ajax.Updater({success:'BoxLocalization'},destination,{method:'get',onComplete:Localization.onComplete});},onComplete:function(transport){if($('lbLocZip')!=null)$('lbLocZip').insert(gLocInfoProcess.zip);if($('lbLocProvider')!=null){var providerInfo=new ProviderInfo(gLocInfoProcess.provider);$('lbLocProvider').insert(providerInfo.name);}Localization.displayLocalizedElements('BoxLocalization');},isValidZip:function(zip){if(zip!=null)zip=zip.strip();if(zip==null||zip.length!=5)return false;else{var numericExpression=/^[0-9]+$/;if(zip.match(numericExpression))return true;elsereturn false;}},displayLocalizedElements:function(container){var locElements=$(container).select('.Localized');var notLocElements=$(container).select('.NotLocalized');if(Localization.isLocalized()){notLocElements.invoke('hide');locElements.invoke('show');if(locElements.length>0) {$(container).show();}locElements.each(function(el){var ajaxcontent=el.readAttribute('src');if(ajaxcontent!=null){ajaxcontent=Localization.replaceLocalizedContent(ajaxcontent);new Ajax.Updater({success:el},ajaxcontent,{method:'get',evalScripts:true});}});$$('span.Localized').each(function(el){el.replace(Localization.replaceLocalizedContent(el.innerHTML));});}else{locElements.invoke('hide');notLocElements.invoke('show');if(notLocElements.length>0) {$(container).show();}notLocElements.each(function(el){var ajaxcontent=el.readAttribute('src');if(ajaxcontent!=null){new Ajax.Updater({success:el},ajaxcontent,{method:'get',evalScripts:true});}});}},displayLocalizedElements2:function(container){var locElements=$(container).select('.Localized');var notLocElements=$(container).select('.NotLocalized');if(Localization.isLocalized()){notLocElements.invoke('hide');locElements.invoke('show');if(locElements.length>0) {$(container).show();}locElements.each(function(el){var ajaxcontent=el.readAttribute('src');if(ajaxcontent!=null){ajaxcontent=Localization.replaceLocalizedContent(ajaxcontent);new Ajax.Updater({success:el},ajaxcontent,{method:'get',evalScripts:true});}});$$('span.Localized').each(function(el){el.replace(Localization.replaceLocalizedContent(el.innerHTML));});}else{try{var el=$(container).down('.Localized').childElements();if(el!==undefined&&el!=null){var l=el.length;for (var i=1;i<l;i++){el[i].hide()}}locElements.invoke('show');}catch(e){}notLocElements.invoke('show');if(notLocElements.length>0) {$(container).show();}notLocElements.each(function(el){var ajaxcontent=el.readAttribute('src');if(ajaxcontent!=null){new Ajax.Updater({success:el},ajaxcontent,{method:'get',evalScripts:true});}});}},replaceLocalizedContent:function(input){if(input=='LISTINGS_TV'||input=='LISTINGS_ONLINE'||input=='LISTINGS_ALL'){input=TVListings.getLocListingPage(input);return input;}var locInfo=Localization.loadCookie();input=input.sub('@ZIP',locInfo.zip);var stationInfo=new StationInfo(locInfo.station);input=input.sub('@STATION_NAME',stationInfo.name.escapeHTML());input=input.sub('@STATION',stationInfo.id);input=input.sub('@TIMEZONE',stationInfo.timezone);var providerInfo=new ProviderInfo(locInfo.provider);input=input.sub('@PROVIDER_NAME',providerInfo.name.escapeHTML());input=input.sub('@PROVIDER',providerInfo.id);return input;},autoLocalize:function(st){if(st!=null&&st!=undefined&&st.length>0&&Localization.isLocalized()==false){new Ajax.Request('/getlocal/instant/stationcode='+st+'.html',{method:'get',onSuccess:function(t){if(t.responseText!=null&&t.responseText!=undefined&&t.responseText.length>0){var cObj=t.responseText.toQueryParams();var cInfo=Object.toQueryString(cObj);Cookie.setRaw('LOCI',cInfo,360);Cookie.set('LOCS',st,360);try{s.prop16=st.toLowerCase();s.events="event15";s.tl("","o","Localization");}catch(e){};window.location.reload();}}});}},readChannels:function(callBack){var locInfo=Localization.loadCookie();var providerInfo=new ProviderInfo(locInfo.provider);var pId=providerInfo.id;if(pId!=null&&pId!=undefined&&pId.length>0){new Ajax.Request('/getlocal/getchannels/provider='+providerInfo.id+'.html',{method:'get',onSuccess:function(t){if(t.responseText!=null&&t.responseText!=undefined&&t.responseText.length>0){var chns=t.responseText.evalJSON();callBack(chns);}}});}},showPopup:function(destPage){var goLocal;if($('GoLocal')!=null){goLocal=$F('GoLocal');}Popup.show($('Localizer'));if(Localization.isValidZip(goLocal)==false){Localization.showZip();}else{Localization.showProviders(goLocal);}Localization.Path(destPage);return false;},Control:function(){Localization.showPopup('/getlocal/postlocalization.html');return false;}};var instantLocalization=function(){var s=window.location.toString().toQueryParams()['aff'];if((s+'')=='')return;Localization.autoLocalize(s);};instantLocalization();var Popup ={overlayOpacity:0.85,overlayDuration:0.2,show:function(contentElement){Popup.showHtml(contentElement.remove());contentElement.show();},showHtml:function(htmlContent){var arrayPageSize=Popup.getPageSize();var pageHeight=arrayPageSize[1];var pageWidth=arrayPageSize[0];var objOverlay=$('overlay');var objOverlayContent=$('overlayContent');objOverlay.style.height=pageHeight+"px";objOverlay.style.width=pageWidth+"px";$$('select').invoke('hide');objOverlayContent.update(htmlContent);objOverlayContent.show();new Effect.Appear('overlay',{ duration:Popup.overlayDuration,from:0.0,to:Popup.overlayOpacity });},hide:function() {var p=$('PlayerMasterContainer');if(p!==undefined&&p!=null){popupLocalization.abortLocalization();return;}$('overlay').hide();$('overlayContent').hide();$$('select').invoke('show');},getPageSize:function(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY) {xScroll=window.innerWidth + window.scrollMaxX;yScroll=window.innerHeight + window.scrollMaxY;} else if(document.body.scrollHeight>document.body.offsetHeight){ xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;} else { xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}var windowWidth,windowHeight;if(self.innerHeight) { if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;} else {windowWidth=self.innerWidth;}windowHeight=self.innerHeight;} else if(document.documentElement&&document.documentElement.clientHeight) { windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;} else if(document.body) { windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}if(yScroll<windowHeight){pageHeight=windowHeight;} else {pageHeight=yScroll;}if(xScroll<windowWidth){pageWidth=xScroll;} else {pageWidth=windowWidth;}arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight)return arrayPageSize;}};function openCrossVersionVideo (url){if(url.indexOf ("/video/index.html")>=0)document.location.href=url;elseopenPopupVideo(url);return false;}var Search ={populateEventsCombo:function(targetCombo,sport){var eventElement=$(targetCombo);if($(targetCombo)){eventElement.enable();new Ajax.Updater(targetCombo,'/athletes/search/sport=' + sport + '/_eventList.html',{method:'get'});}else{return false;}},validateSearchCombo:function(id,url,selectedValue,selectedIndex,buttonId,searchType){var validate=null;if(searchType===undefined){searchType=null;}if(buttonId===undefined){buttonId=null;validate=true;}if($(buttonId)){if($(buttonId).hasClassName("goSearch goSearchActive")){validate=true;}}if(id=='txtAthletes'){var textValue=$('txtAthletes').getValue();if(textValue==null||textValue==""||validate==null){return false;}else{if(searchType==null){location.href=url;}else{new Ajax.Updater('ajaxTarget',url,{method:'get',evalScripts:true});return false;}}}if(!selectedIndex==0&&validate==true){location.href=url;}if(!selectedIndex==0&&searchType==true){location.href=url;}},initAutoComplete:function(){new Ajax.AutocompleterD3('txtAthletes','autoCompleteTarget','',{minChars:3,getUrl:Search.changeUrl,method:'get'});},changeUrl:function(entry){if(entry!=null&&entry.length>=3){return '/athletes/search/searchedString=' + entry.substr(0,3).toLowerCase() + '/_autocomplete.html';}else{return null;}},disableButtons:function(dropDownId,buttonId,formId){if(buttonId===undefined){buttonId=null;}$$('.goSearch').invoke('removeClassName','goSearchActive');$(buttonId).addClassName('goSearchActive');Search.dropDownReset(formId,dropDownId);},dropDownReset:function(formId,dropDownId){var arrselect=$$("#" + formId + " select");for (i=0;i<arrselect.length;i++){if(arrselect[i].getAttribute("id")!=dropDownId){if((dropDownId=="srEvents"&&arrselect[i].getAttribute("id")=="srSport")==false){arrselect[i].selectedIndex=0;}}}if(dropDownId!="txtAthletes"&&$("txtAthletes")){$("txtAthletes").clear();}},athleteFirstLetter:function(letter){var tr=$$('tr[letter]');tr.each(function(el){var currentTr=el.readAttribute('letter');if(currentTr==letter){el.show();}else{el.hide();}});},showAllLetter:function(){var tr=$$('tr[letter]');tr.each(function(el){el.show();});},videoChangeType:function(destUrl){if(destUrl=='localcoverage'){if(Localization.isLocalized()){document.location.href='/' +Localization.getCurrentStation()+ '/video/index.html';}else{document.location.href='/getlocal/index.html';}}else{document.location.href=destUrl;}}};var SearchAjax ={sportUrl:'',currentSearchVal:'',searchAjax2:function(url4){new Ajax.Updater('ajaxTarget',url4,{method:'get',evalScripts:true});},getSearchValue:function(){return SearchAjax.currentSearchVal;},validateSearchCombo:function(id,url,selectedValue,selectedIndex){if(id=='txtAthletes'){SearchAjax.currentSearchVal=$F(id);var textValue=$('txtAthletes').getValue();var hiddenAthId=$('hidden_athid').getValue();if(textValue==null||textValue==""||hiddenAthId==null||hiddenAthId==""){return false;}else{SearchAjax.searchAjax2(url);return;}}if(!selectedIndex==0) {SearchAjax.currentSearchVal=$(id).options[selectedIndex].text;SearchAjax.searchAjax2(url);}},initAutoComplete:function(sportUrlPath){SearchAjax.sportUrl=sportUrlPath;new Ajax.AutocompleterD3('txtAthletes','autoCompleteTarget','',{minChars:3,getUrl:SearchAjax.changeUrl,method:'get'});},changeUrl:function(entry){if(entry!=null&&entry.length>=3){if(SearchAjax.sportUrl!=null){return SearchAjax.sportUrl + 'photos/searchedString=' + entry.substr(0,3).toLowerCase() + '/_autocompletephoto.html';}else{return '/athletes/search/searchedString=' + entry.substr(0,3).toLowerCase() + '/_autocompletephoto.html';}}else {return null;}},underConstruction:function() {alert('Function Under Construction');},setHidden:function(id){$('hidden_athid').value="";$('hidden_athid').value=id;},clearHidden:function(){$('hidden_athid').value="";}};Ajax.AutocompleterD3=Class.create(Ajax.Autocompleter,{initialize:function(element,update,url,options) {this.baseInitialize(element,update,url,options);this.baseInitialize(element,update,options);this.options.asynchronous=true;this.options.onComplete=this.onCompleteD3.bind(this);this.options.defaultParams=this.options.parameters||null;this.geturl=options.getUrl;},onCompleteD3:function(request) {this.onComplete(request);var entry=encodeURIComponent(this.getToken());if($('autoCompleteNameList')!=null){var liList=$('autoCompleteNameList').getElementsByTagName('li');var tot=liList.length;for(var i=0; i<tot; i++){if(liList[i].innerHTML.substr(0,entry.length).toLowerCase()==entry.toLowerCase()){$(liList[i]).show(); }else{$(liList[i]).hide(); }}}},getUpdatedChoices:function() {this.startIndicator();var entry=encodeURIComponent(this.getToken());this.url=this.geturl(entry);if(this.options.defaultParams) {this.options.parameters += '&' + this.options.defaultParams;}if(this.url!=null){new Ajax.Request(this.url,this.options);}}});var PagingAjax={page:function(url,id){new Ajax.Request(url,{method:'get',onSuccess:function(transport) {$(id).replace(transport.responseText);}});}};function ManageSearchBar(){var searchDDwnBox;var searchDropDownBtn;var searchDDwnBoxDxUp;var searchDDwnBoxDxDown;var searchDDwnBoxSxUp;var searchDDwnBoxSxDown;var searchSiteBtnBing;var searchSiteBingBtn;var searchTextBing;var searchBingBtn;var searchInLocalStr="Search NBCOlympics.com";var searchInWebStr="Search web";var searchWebBtn;if($('SearchDDwnBox')!=null){searchDDwnBox=$('SearchDDwnBox');searchDropDownBtn=$('SearchDropDownBtn');searchDDwnBoxDxUp=$('SearchDDwnBoxDxUp');searchDDwnBoxDxDown=$('SearchDDwnBoxDxDown');searchDDwnBoxSxUp=$('SearchDDwnBoxSxUp');searchDDwnBoxSxDown=$('SearchDDwnBoxSxDown');searchSiteBtnBing=$('SearchSiteBtnBing');searchSiteBingBtn=$('SearchSiteBingBtn');if($('SearchTextBing')!=null){searchTextBing=$('SearchTextBing');searchTextBing.value=searchInLocalStr;}searchBingBtn=$('SearchBingBtn');}else searchWebBtn=$('SearchWebBtn');function OpenCloseChooseSearchType(){searchDDwnBox.toggle();var offset=parseInt(searchDropDownBtn.viewportOffset()[0])-parseInt(searchDDwnBox.getStyle('width'))+parseInt(searchDropDownBtn.getStyle('width'))-2;searchDDwnBox.setStyle({left:offset+'px'});}function intSearchOpen(fromKeyboard){if(searchTextBing.value!=''){if(searchTextBing.value!=searchInWebStr){if(searchTextBing.value!=searchInLocalStr){var searchTextTemp=searchTextBing.value;searchTextBing.value=searchInLocalStr;location.href="/search/results.htmx?q="+searchTextTemp;}}else searchTextBing.value=searchInLocalStr;}else if(fromKeyboard==false) searchTextBing.value=searchInLocalStr;}function oldExtSearchOpen(){var query=$F('SearchText');if(query.length>0)window.open("http://search.live.com/results.aspx?q=" + $F('SearchText') +"&FORM=NBCOLM");}function extSearchOpen(fromKeyboard){if(searchTextBing.value!=''){if(searchTextBing.value!=searchInLocalStr){if(searchTextBing.value!=searchInWebStr){var searchTextTemp=searchTextBing.value;searchTextBing.value=searchInWebStr;window.open("http://www.bing.com/search?q=" + searchTextTemp +"&FORM=NBCOLM");}}else searchTextBing.value=searchInWebStr;}else if(fromKeyboard==false) searchTextBing.value=searchInWebStr;}function swapCheck(divToCheck){if(divToCheck==searchDDwnBoxDxUp){searchDDwnBoxSxUp.addClassName('SearchCheck');searchDDwnBoxSxDown.removeClassName('SearchCheck');searchSiteBtnBing.show();searchSiteBingBtn.hide();intSearchOpen(false);}else{searchDDwnBoxSxUp.removeClassName('SearchCheck');searchDDwnBoxSxDown.addClassName('SearchCheck');searchSiteBtnBing.hide();searchSiteBingBtn.show();extSearchOpen(false);}searchDDwnBox.hide();}if(searchTextBing!=null){searchTextBing.observe('focus',function(){if((searchTextBing.value==searchInLocalStr)||(searchTextBing.value==searchInWebStr))searchTextBing.value='';});Event.observe(searchTextBing,'keypress',function(event){if(event.keyCode==13){if(searchDDwnBoxSxUp.hasClassName('SearchCheck')==true) intSearchOpen(true);else extSearchOpen(true);}});}Event.observe(document.body,'click',function(event){var element=Event.element(event);switch (element){case searchWebBtn:oldExtSearchOpen();break;case searchDropDownBtn:OpenCloseChooseSearchType();break;case searchDDwnBoxDxUp:case searchDDwnBoxDxDown:swapCheck(element);break;case searchSiteBingBtn:extSearchOpen(false);break;case searchBingBtn:extSearchOpen(false);searchDDwnBoxSxUp.removeClassName('SearchCheck');searchDDwnBoxSxDown.addClassName('SearchCheck');break;case searchSiteBtnBing:intSearchOpen(false);break;default:if(searchDDwnBox!=null) searchDDwnBox.hide();break;}});}var tzc={tFmt:'dd/MM/yy HH:mm',initialized:false,init:function(sFormat){if(sFormat!==undefined&&sFormat!=null&&sFormat!='') tzc.tFmt=sFormat;tzc.initialized=true;var c=Cookie.get('TZC');if(c!==undefined&&c!=null&&c=='1')tzc.clientTime();elsetzc.localTime();},refreshAfterAjax:function(){if(tzc.initialized!=true) return;var c=Cookie.get('TZC');if(c!==undefined&&c!=null&&c=='1')tzc.clientTime();elsetzc.localTime();},localTime:function(){$('tzcLocal').show();$('tzcClient').hide();var mts=document.getElementsByClassName ('timeConvertible');mts.each(function(mt){if(mt.readAttribute('title')!=null&&mt.readAttribute('title').length>0){var s=mt.readAttribute('title').split(',')if(s.length>0){mt.update(s[0].toLowerCase());mt.removeClassName ('TZCclient');}}});Cookie.set('TZC','0',365,'/');},clientTime:function(){$('tzcClient').show();$('tzcLocal').hide();var mts=document.getElementsByClassName ('timeConvertible');mts.each(function(mt){if(mt.readAttribute('title')!=null&&mt.readAttribute('title').length>0){var s=mt.readAttribute('title').split(',')if(s.length>0){var t=tzc.formatDate(tzc.decodeUTC(s[1]));mt.update(t);mt.addClassName ('TZCclient');}}});Cookie.set('TZC','1',365,'/');},padString:function(s,l,pc){while(s.length<l){s=pc+s};return s;},formatDate:function(d){var _d=tzc.padString(d.getDate().toString(),2,'0'),_M=tzc.padString((d.getMonth()+1).toString(),2,'0'),_y=tzc.padString((d.getFullYear()%1000).toString(),2,'0'),_h=tzc.padString(d.getHours().toString(),2,'0'),_m=tzc.padString(d.getMinutes().toString(),2,'0');var _a_a=(_h>12) ? "pm":"am";_h=(_h==0) ? "12":_h;_h=(_h>12) ? _h - 12:_h;if(tzc.tFmt=='dd/MM/yy HH:mm') return _d+'/'+_M+'/'+_y+' '+_h+':'+_m;if(tzc.tFmt=='dd/MM HH:mm aa') return _M+'/'+_d+' '+_h+':'+_m+_a;return _d+'/'+_M+'/'+_y+' '+_h+':'+_m;},decodeUTC:function(n){var _m=n%100,_h=Math.floor(n/100)%100,_d=Math.floor(n/10000)%100,_M=(Math.floor(n/1000000)%100) -1,_y=Math.floor(n/100000000),_dt=new Date();var localTime=new Date()var msutc= Date.UTC(_y,_M,_d,_h,_m);_dt.setTime(msutc - (8 * 3600000)); return _dt}}var VisitorInfo=Class.create({initialize:function(){this.id='';this.ac='';this.un='';this.dn='';this.s=-1;var c=Registration.cookiedGetLogin();if(c!=null&&c!=undefined){var cVals=c.toQueryParams();if(cVals.id!=null&&cVals.id!=undefined) this.id=cVals.idif(cVals.ac!=null&&cVals.ac!=undefined) this.ac=cVals.ac;if(cVals.un!=null&&cVals.un!=undefined) this.un=cVals.un;if(cVals.dn!=null&&cVals.dn!=undefined) this.dn=cVals.dn;if(cVals.s!=null&&cVals.s!=undefined) this.s=cVals.s;}},isValid:function(){if(this.s=='2')return true;elsereturn false;},getDispalyName:function(){return this.dn;},getActivationCode:function(){return this.ac;},queryData:function(cb){var u='/registration/json/resourcedata/'+ResCodeUtil.scompose(this.ac)+'json.html';new Ajax.Request(u,{method:"get",onSuccess:this.onJSONLoaded.bind(this,cb)});},onJSONLoaded:function(cb,transport){var data=JSON.parse(transport.responseText);cb(data);}});var Registration ={mValidation:undefined,cookiedGetLogin:function(){return Cookie.get('NBCOU');},cookiedDelLogin:function(){return Cookie.erase('NBCOU');},initRegistration:function(){mValidation=new FormValidate([Registration.createValEntry('fUsername',{type:'text',min:1,max:50}),Registration.createValEntry('fDisplayName',{type:'text',min:1,max:20}),Registration.createValEntry('fPassword',{type:'text',min:8,max:20}),Registration.createValEntry('fPassword2',{type:'text',min:8,max:20,idCompare:'fPassword',messageCompare:$('errfPassword2').innerHTML}),Registration.createValEntry('fMobileNumber',{type:'int',required:false}),Registration.createValEntry('fFirstName',{type:'any-text',min:1,max:50}),Registration.createValEntry('fLastName',{type:'any-text',min:1,max:50}),Registration.createValEntry('fZipCode',{type:'zip'}),Registration.createValEntry('fEMail',{type:'email'}),Registration.createValEntry('fSecQuestion',{type:'option'}),Registration.createValEntry('fSecAnswer',{type:'any-text',min:1,max:100}),Registration.createValEntry('fBirthMonth',{type:'option'}),Registration.createValEntry('fBirthDay',{type:'option'}),Registration.createValEntry('fBirthYear',{type:'option'}),Registration.createValEntry('fCaptcha',{type:'text',min:1,max:20}),Registration.createValEntry('fAgree',{type:'check'})]);Registration.initCaptcha();},initUpdate:function(){mValidation=new FormValidate([Registration.createValEntry('fFirstName',{type:'any-text',min:1,max:50}),Registration.createValEntry('fLastName',{type:'any-text',min:1,max:50}),Registration.createValEntry('fMobileNumber',{type:'int',required:false}),Registration.createValEntry('fZipCode',{type:'zip'}),Registration.createValEntry('fEMail',{type:'email'}),Registration.createValEntry('fSecQuestion',{type:'option'}),Registration.createValEntry('fSecAnswer',{type:'any-text',min:1,max:100}),Registration.createValEntry('fBirthMonth',{type:'option'}),Registration.createValEntry('fBirthDay',{type:'option'}),Registration.createValEntry('fBirthYear',{type:'option'})]);},initAlerts:function(){mValidation=new FormValidate([Registration.createValEntry('fEMail',{type:'email'}),Registration.createValEntry('fMobileNumber',{type:'int',required:false})]);},validateAlerts:function(){if(mValidation.validate()){$('boxError').hide();try{s.prop49="alert signups";s.events="event3";s.tl("","o","alert signups");}catch(e){ }return true;}$('boxError').update(mValidation.getValidationErrorList() + ' ');$('boxError').show();$('boxError').focus();window.scrollTo(0,0);return false;},initChangePwd:function(){mValidation=new FormValidate([Registration.createValEntry('fCurrentPassword',{type:'text',min:1,max:20}),Registration.createValEntry('fNewPassword',{type:'text',min:8,max:20}),Registration.createValEntry('fNewPassword2',{type:'text',min:8,max:20,idCompare:'fNewPassword',messageCompare:$('errfNewPassword2').innerHTML})]);},validateChangePwd:function(){if(mValidation.validate()){$('boxError').hide();return true;}$('boxError').update(mValidation.getValidationErrorList() + ' ');$('boxError').show();$('boxError').focus();window.scrollTo(0,0);return false;},createValEntry:function(fieldId,options){var entry=options;entry['id']=fieldId;entry['label']='lb' + fieldId;entry['message']=$('err' + fieldId).innerHTML;return entry;},validateInsUpd:function(){if(mValidation.validate()){$('boxError').hide();return true;}$('boxError').update(mValidation.getValidationErrorList() + ' ');$('boxError').show();$('boxError').focus();window.scrollTo(0,0);return false;},initLogin:function(){mValidation=new FormValidate([Registration.createValEntry('fUsername',{type:'any-text',min:1,max:50}),Registration.createValEntry('fPassword',{type:'text',min:1,max:20})]);},validateLogin:function(){if(mValidation.validate()){$('boxError').hide();return true;}$('boxError').update(mValidation.getValidationErrorList() + ' ');$('boxError').show();$('boxError').focus();window.scrollTo(0,0);return false;},initForgotPsw_1:function(){mValidation=new FormValidate([Registration.createValEntry('fUsername',{type:'any-text',min:1,max:50,required:false}),Registration.createValEntry('fEMail',{type:'email',required:false})]);},initForgotPsw_2:function(){mValidation=new FormValidate([Registration.createValEntry('fUsername',{type:'any-text',min:1,max:50}),Registration.createValEntry('fNewPassword',{type:'text',min:1,max:20}),Registration.createValEntry('fNewPassword2',{type:'text',min:1,max:20,idCompare:'fNewPassword',messageCompare:$('errfNewPassword2').innerHTML}),Registration.createValEntry('fSecAnswer',{type:'any-text',min:1,max:100})]);},validateForgotPsw:function(){if(mValidation.validate()){$('boxError').hide();return true;}$('boxError').update(mValidation.getValidationErrorList() + ' ');$('boxError').show();$('boxError').focus();window.scrollTo(0,0);return false;},logout:function(){Registration.cookiedDelLogin();Registration.regProvider=null;Registration.regStation=null;document.location.href='/index.html';return false;},cancelRegistration:function(){Registration.cookiedDelLogin();Registration.regProvider=null;Registration.regStation=null;document.location.href='/index.html';},cancelLocalize:function(){document.location.href='/registration/profile.htmx';},cancelAlerts:function(){document.location.href='/registration/profile.htmx';},cancelUpdate:function(){document.location.href='/registration/profile.htmx';},changePassword:function(){document.location.href='/registration/changepassword.htmx';},regProvider:null,regStation:null,changeProvider:function(){$('regStep2').removeClassName('step3');$('regStep2').addClassName('step2');$('BoxSelectStation').hide();$('helpStepStations').hide();$('BoxSelectProvider').show();$('helpStepProviders').show();Registration.regProvider=null;},nextLocalizeStep:function(){if(Registration.regProvider==null||Registration.regProvider==undefined)return Registration.saveProvider();elsereturn Registration.saveStation();},saveProvider:function(){var provider=getRadioValue('rdProvider');Registration.regProvider=provider;if(provider==null||provider==undefined){$('providerValError').show();return false;}else$('providerValError').hide();Registration.regStation=null;$('helpStepProviders').hide();$('helpStepStations').show();var providerInfo=new ProviderInfo(provider);var destination='/registration/provider=' + providerInfo.id + '/_selectstation.html';new Ajax.Updater({success:'BoxSelectStation'},destination,{method:'get',onComplete:Registration.onSaveProvider});return false; },onSaveProvider:function(){$('regStep2').removeClassName('step2');$('regStep2').addClassName('step3');$('BoxSelectProvider').hide();$('BoxSelectStation').show();var providerInfo=new ProviderInfo(Registration.regProvider);$('lbLocProvider').update(providerInfo.name);},saveStation:function(){Registration.regStation=getRadioValue('rdStation');if(Registration.regStation==null||Registration.regStation==undefined){$('stationValError').show();return false;}else{$('stationValError').hide();return true;}},initCaptcha:function(){var d=new Date();var ar=new Ajax.Request("/code/Registration/Captcha/Captcha.aspx?t="+d.getMilliseconds(),{method:'get',onComplete:Registration.getCaptchaImg});},getCaptchaImg:function(originalResponse){$('fCaptchaEncoded').value=originalResponse.responseText;Registration.refreshCaptchaImg();},refreshCaptchaImg:function(){var d=new Date();var iu="/code/Registration/Captcha/Captcha.aspx?t="+d.getMilliseconds()+"&c=" + $F('fCaptchaEncoded');$('imgCaptcha').src=iu;$('imgCaptcha').show()},modifyStation:function(zip){document.location.href='/registration/zip=' + zip + '/localize.html';},goToProfile:function(){document.location.href='/registration/profile.htmx';},displayRegElements:function(container){var regElements=$(container).select('.RegisteredUser');var anLocElements=$(container).select('.AnonymousUser');var info=new VisitorInfo();if(info.isValid()){regElements.each(function(el){el.replace(Registration.replaceUserContent(el.innerHTML,info));});regElements.invoke('show');anLocElements.invoke('hide');}else{regElements.invoke('hide');anLocElements.invoke('show');}},replaceUserContent:function(input,visInfo){input=input.sub('@DISPLAYNAME',visInfo.getDispalyName().escapeHTML());return input;},setCompleteRedir:function(url){Cookie.set('NBCREDIR',url);}};var RegAlertsTabs ={changeTab:function(tab,tabC){$$('#BoxAlerts .Tab').invoke('removeClassName','current');$(tab).addClassName('current');$$('#BoxAlerts .TabContent').invoke('hide');$(tabC).show();}};var QuickAlertDialog ={show:function(opt){opt.action='init';new Ajax.Request('/registration/alerts/quickalertdialog.htmx',{method:'get',parameters:opt,onSuccess:function(t){if(t.responseText!=null&&t.responseText!=undefined&&t.responseText.length>0){var html=t.responseText;Popup.showHtml(html);$('boxQuickAlert').focus();}}});return false;},close:function(){Popup.hide();},postForm:function(opt){if($('fEMailAlert').checked==false&&$('fMobileAlert').checked==false){alert('Select EMail or Mobile');return false;}if((QuickAlertDialog.checkField('fEMailAlert','fEMail','lbfEMail')&&QuickAlertDialog.checkField('fMobileAlert','fMobileNumber','lbfMobileNumber')&&QuickAlertDialog.checkField('fMobileAlert','fMobileCarrier','lbfMobileCarrier'))==false){return false;}opt.action='post';opt.fEMail=$F('fEMail');opt.fMobileCarrier=$F('fMobileCarrier');opt.fMobileNumber=$F('fMobileNumber');opt.fMobileAlert=$F('fMobileAlert');opt.fEMailAlert=$F('fEMailAlert');if(opt.timezone!=null&&opt.timezone!=undefined&&opt.timezone=='COOKIE'){if(Localization.isLocalized()) {var locInfo=Localization.loadCookie();var stationInfo=new StationInfo(locInfo.station);opt.timezone=stationInfo.timezone;}else {opt.timezone='ET';}}new Ajax.Request('/registration/alerts/quickalertdialog.htmx',{method:'get',parameters:opt,onSuccess:function(t){if(t.responseText!=null&&t.responseText!=undefined&&t.responseText.length>0){$('overlayContent').update(t.responseText);}}});return false;},enableDisableField:function(chkBoxName,textName,comboName){if($(chkBoxName).checked){$(textName).disabled=false;$(textName).removeClassName('textReadonly');$(textName).addClassName('text');if($(comboName)!='notPresent'){$(comboName).disabled=false;$(comboName).removeClassName('readonly');}}else{$(textName).value='';$(textName).disabled=true;$(textName).removeClassName('text');$(textName).addClassName('textReadonly');if($(comboName)!='notPresent'){$(comboName).selectedIndex=0;$(comboName).addClassName('readonly');$(comboName).disabled=true;}}},checkField:function(chkBoxName,fieldName,labelName){$(labelName).removeClassName('validateError');if($(chkBoxName).checked){if($(fieldName).value==''){$(labelName).addClassName('validateError');return false;}else{if(fieldName=='fEMail'){if(!QuickAlertDialog.isValidEmail($(fieldName).value)){$(labelName).addClassName('validateError');return false;}else{return true;}}if(fieldName=='fMobileNumber'){if(!QuickAlertDialog.isValidMobile($(fieldName).value)){$(labelName).addClassName('validateError');return false;}else{return true;}}}}else{return true;}},isValidEmail:function(str){return (str.indexOf(".")>2)&&(str.indexOf("@")>0);},isValidMobile:function(str){return (!isNaN(parseInt(str)));}};var TVListings={selectActiveRow:function(a){var tvIncr=window.location.toString().toQueryParams()['increment'];if((tvIncr+'')=='')return;$$('tr[increment="' + tvIncr + '"]').invoke('addClassName','Current');},cmbFilterChange:function(cmbFilt){var url=$F(cmbFilt);if(url!=null&&url!='0'){document.location.href=url;}},displayLocIncrement:function(){var sCode=Localization.getCurrentStation();if(sCode!=null&&sCode!=undefined&&sCode.length>0){sCode=sCode.toUpperCase();$$('.Localized[increment]').each(TVListings.checkIncrementStation.bind(this,sCode));}else{$$('.Localized[increment]').invoke('hide');}$$('tr.DayRow').each(function(rDay){var rows=rDay.select('tr');var visibleRows=rows.findAll(function(rI){return rI.visible();});if(visibleRows.size()==0){rDay.hide();}});},displayLocTimeSlot:function(){var sCode=Localization.getCurrentStation();if(sCode!=null&&sCode!=undefined&&sCode.length>0){sCode=sCode.toUpperCase();$$('.Increment .StationList').each(TVListings.checkTimeSlotStation.bind(this,sCode));}},displayLocInfo:function(){var statName=TVListings.getNBCStationName();var statCode=Localization.getCurrentStation();$$('img.NetworkOZoneLogo').each(function(lg){lg.src=Localization.getLogoSmallGif();});$$('span.NetworkOZoneDesc').invoke('update',statName);$$('option.NetworkOZoneDesc').invoke('update',statName);$$('span.NetworkOZoneChannel').invoke('writeAttribute','code',statCode);},getNBCStationName:function(){var sName=Localization.getCurrentStationName();if(sName==undefined||sName==null||sName.length==0)return 'NBC';elsereturn sName;},checkIncrementStation:function(sCode,incr){var dStat=incr.down('div[station="' + sCode + '"]');if(dStat!=undefined){var incrContent=incr.down('.IncrementBox div.IncrData');if(incrContent!=undefined)incrContent.update(dStat.innerHTML);}else {incr.hide();}},checkTimeSlotStation:function(sCode,incr){var dStat=incr.down('li[station="' + sCode + '"]');if(dStat!=undefined){incr.up('div.Increment').show();}},highlightCurrentHour:function(cDay){if(cDay==TVListings.getOlyDateId()){TVListings.highlightHour(TVListings.getCurrentTime() + cDay*1440);}},highlightHour:function(time){$$('div.TimeSlot[time='+time+']').invoke('addClassName','Highlight');},gridOut:function(time,row){$$('table.TVListingAllDay div.Over').invoke('removeClassName','Over');$$('table.TVListingAllDay td.Over').invoke('removeClassName','Over');$$('table.TVListingAllDay th div.Over').invoke('removeClassName','Over');},gridOver:function(time,row){$$('table.TVListingAllDay div.TimeSlot[time='+time+'][row='+row+']').invoke('addClassName','Over');$$('table.TVListingAllDay td.RowH[row='+row+']').invoke('addClassName','Over');$$('table.TVListingAllDay th div.TimeSlot[time='+time+']').invoke('addClassName','Over');},initGrid:function(){TVListings.displayLocInfo();Localization.readChannels(TVListings.onChannelsRead);TVListings.hideAlertMe();},activeHeaderDay:function(selDt){$$('div.TVListingsDays li.AllDays').invoke('removeClassName','Selected');$$('div.TVListingsDays li[date='+selDt+']').invoke('addClassName','Selected');},onChannelsRead:function(channels){channels.stations.each(function(st){var chLbl='&nbsp;('+st.Channel+')';$$('span.ChannelNum[code="'+st.Station.toLowerCase()+'"]').invoke('update',chLbl);if(st.HDChannel!=null&&st.HDChannel!=undefined&&st.HDChannel.length>0&&st.HDChannel!=st.Channel){var chLbl='&nbsp; Also available on HD Channel '+st.HDChannel;$$('span.ChannelNumHD[code="'+st.Station.toLowerCase()+'"]').invoke('update',chLbl);}});},getCurrentTime:function(){var cDate=new Date();var t=cDate.getHours()*60;t=Math.round((t/60))*60;if(t>1380){t=1380;}return t;},getOlyDateId:function(){var refDate=new Date();refDate.setFullYear(2008);refDate.setMonth(7);refDate.setDate(8);var cDate=new Date();if(cDate.getFullYear()==2008&&cDate.getMonth()==7) {if(cDate.getDate()<6||cDate.getDate()>24)return null;elsereturn cDate.getDate()-8;}else {return null;}},getOlyStatus:function(){var cDate=new Date();if(cDate.getFullYear()<2008||(cDate.getFullYear()==2008&&cDate.getMonth()<7)||(cDate.getFullYear()==2008&&cDate.getMonth()==7&&cDate.getDate()<6)){return -1; }else if(cDate.getFullYear()>2008||cDate.getMonth()>7||cDate.getDate()>24){return 1; }else {return 0; }},getPrimetime:function(tz){tz=tz.toUpperCase();if(tz=='MT'||tz=='CT')return 1140;elsereturn 1200;},getLocListingPage:function(page){var status=TVListings.getOlyStatus();var day=TVListings.getOlyDateId();var time=TVListings.getCurrentTime();var locInfo=Localization.loadCookie();var stationInfo=new StationInfo(locInfo.station);var timez=stationInfo.timezone;if(status<0){day=0;}else if(status>0){day=16;}if(page=='LISTINGS_TV'){if(status<0){time=TVListings.getPrimetime(timez);}else if(status>0){time=1320;}return '/tv_and_online_listings/zone='+timez+'/day='+day+'/time='+time+'/_pagetv.html';}else if(page=='LISTINGS_ONLINE'){if(status<0){time=0;}else if(status>0){time=1320;}return '/tv_and_online_listings/zone='+timez+'/day='+day+'/time='+time+'/_pageonline.html';}else if(page=='LISTINGS_ALL'){return '/tv_and_online_listings/zone='+timez+'/day='+day+'/_pageall.html';}elsereturn page; },showLiveContent:function(id,asset){try{var lnks=$('IncrLinks'+id);lnks.down('div.AlertMe').hide();var lHtml='<div class="WatchNow WatchNowLive"><a href="/video/player.html?assetid='+asset+'" onclick="return openPopupVideo(this.href);">Watch Now</a></div>';lnks.insert(lHtml);}catch(e){}},showRewindContent:function(id,asset){try{var lnks=$('IncrLinks'+id);lnks.down('div.AlertMe').hide();var lHtml='<div class="WatchNow"><a href="/video/player.html?assetid='+asset+'" onclick="return openPopupVideo(this.href);">Rewind</a></div>';lnks.insert(lHtml);}catch(e){}},hideAlertMe:function(){var status=TVListings.getOlyStatus();if(status==0){var day=TVListings.getOlyDateId();var cTime=TVListings.getCurrentTime()+1440*day;$$('div.IncrStatus').each(function(iSt){var iTime=parseInt(iSt.readAttribute('stime'),10);if(iTime<(cTime+30)){iSt.down('div.AlertMe').hide();}});}else if(status==1){$$('div.IncrStatus div.AlertMe').invoke('hide');}}};
