current.stub("current.content.channels");current.content.channels.ChannelIndex=Class.create({initialize:function(){},init:function(){this._doVotingSetup();this._doCurretnIs();},setVideo:function(target,id,data,w,h,vw,vh){this._videoTarget=target;this._videoTargetId=id;this._videoData=data;this._width=w;this._height=h;this._videoWidth=vw;this._videoHeight=vh;this._doVideo();},setVideoLink:function(target,text,link,name){$(target).innerHTML=text;$(target).href=link;if(name!=null){$(target).name=name;}},setCurrentIsTarget:function(target){this._currentIsTarget=target;},__onAddSomethingClick:function(event){event.stop();current.Authorize.forceLogin(event,current.components.account.LoginActivity.CLIP,true);},_doVideo:function(){if(this._videoData==null){return ;}this._videoData.w=this._width;this._videoData.h=this._height;this._videoData.vw=this._videoWidth;this._videoData.vh=this._videoHeight;this._videoData.hideLogo=true;this._videoData.externalContext="cdc";this._videoData.context="homepage";this._videoData.sitePage="current.com/homepage";this._video=new current.components.video.Veep(this._videoTarget,this._videoTargetId,this._videoData);this._video.init();},_doCurretnIs:function(){var currentIs=new current.content.channels.CurrentIs(this._currentIsTarget);currentIs.init();},_doVotingSetup:function(){var _user=current.User.getInstance();this._voting=$H();scope=this;var count=0;$$(".voting").each(function(v){var vote=new current.components.voting.VoteControls(v);vote.init();scope._voting.set(vote._id.toString()+"_"+count,vote);count++;});if(_user.isLoggedIn()){var ids="";var arr=this._voting.keys();for(var i=0;i<arr.length;i++){if(i>0){ids+=",";}ids+=arr[i].substring(0,arr[i].indexOf("_"));}current.proxy.CCCP.execute("user","votes",{id:_user.getName(),items:ids},this.__onVoteData.bindAsEventListener(this));}},__onVoteData:function(data){var scope=this;var count=0;$A(data).each(function(v){var vote=scope._voting.get(v.contentId+"_"+count);vote.setVoteData(v.voteState);count++;});current.components.voting.VoteControls.executeDelayed();}});function onPlayStatusChange(num){if(num==7){setSessionCookie(current.Cookies.PLAYER_AUDIO_ON,-1);}}current.content.channels.CurrentIs=Class.create({initialize:function(element){this._target=$(element);var clicks=$$(".currentIsLink");for(var i=0;i<clicks.length;i++){Event.observe(clicks[i],"click",this.__onLinkClick.bindAsEventListener(this));}},init:function(){this.__setStaticList();},__onLinkClick:function(element){if(this._checkedList.length>0){this._randomSeed=parseInt(Math.random()*this._checkedList.length);this._target.innerHTML=this._checkedList[this._randomSeed].text;this._checkedList.splice(this._randomSeed,1);}else{this.init();this._checkedList[this._checkedList.length]={text:current.locale.Bundle.get("current_is.default")};}},__setStaticList:function(){this._checkedList=new Array();var taglineArray=current.locale.Bundle.get("current_is.taglines").split("|");for(var i=0;i<taglineArray.length;i++){this._checkedList[i]={text:taglineArray[i]};}}});current.stub("current.components.alerts");current.components.alerts.SystemMessage=Class.create({initialize:function(target,id){var ids=getCookieValue(current.Cookies.SYSTEM_MESSAGE_HIDE+"-"+id);if(ids!=null){$(target).up().remove();return ;}$(target).up().show();this._systemMessageId=id;$(target).observe("click",this.__onSystemMessageCloseClick.bindAsEventListener(this));},__onSystemMessageCloseClick:function(event){event.stop();event.element().up(0).remove();setTimedCookie(current.Cookies.SYSTEM_MESSAGE_HIDE+"-"+this._systemMessageId,this._systemMessageId,current.Cookies.SYSTEM_MESSAGE_HIDE_EXPIRE);}});current.components.alerts.ProfileAlert=Class.create({initialize:function(target){$(target).observe("click",this.__onProfileAlertCloseClick.bindAsEventListener(this));},__onProfileAlertCloseClick:function(event){event.stop();event.element().up(0).remove();deleteCookie(current.Cookies.PROFILE_COMPLETION);}});current.stub("current.components.schedule");current.components.schedule.PrimetimeModule=Class.create({initialize:function(){this._activeDayNum=0;this._dayData=[];},init:function(moduleId,zeroDay){this._module=$(moduleId);this._zeroDay=zeroDay;this.setActiveDayName(this._zeroDay);this._titleHolder=$("primetimeModuleTitle");this._showsHolder=$("primetimeShowsList");this._getNavLinkHolders($(document.getElementsByTagName("body")[0]));this._observeNavLinks($(document.getElementsByTagName("body")[0]));},_getNavLinkHolders:function(target){this._navList=$(target).select(".dayLinkLi");},_observeNavLinks:function(target){this._navLinks=$(target).select(".dayLink");this._navLinks.invoke("observe","click",this.__onNavClick.bindAsEventListener(this));},__onNavClick:function(event){event.stop();this.setActiveDayId(event.element().rel);this.setActiveDayName(event.element().title);this.setActiveDayLink(event.element());if(!this.getDayData(this.getActiveDayId())){this._getScheduleData();}else{this._buildSchedule();}},setActiveDayId:function(num){this._activeDayNum=num;},getActiveDayId:function(){return this._activeDayNum;},setActiveDayName:function(name){this._activeDayName=name;},getActiveDayName:function(){return this._activeDayName;},setActiveDayLink:function(element){this._activeDayLink=element;},getActiveDayLink:function(){return this._activeDayLink;},setDayData:function(id,data){this._dayData[id]=data;},getDayData:function(id){if(isUndefined(this._dayData[id])){return false;}return this._dayData[id];},_buildSchedule:function(){var data=this.getDayData(this.getActiveDayId());var shows=data.evalJSON();this._showsHolder.update("");var scope=this;var i=0;shows.each(function(s){i++;var li=new Element("li");if(i==shows.length){li.addClassName("last");}li.insert(new Element("h3").insert(s.airTime));li.insert(new Element("a",{href:s.linkUrl,title:s.linkText}).insert(s.linkTextTrunc));if(s.isNew){li.insert(new Element("span").insert("&nbsp;\f"));li.insert(new Element("span",{"class":"new"}).insert("new"));}scope._showsHolder.insert(li);});var dayname=this.getActiveDayName();if(dayname==this._zeroDay){dayname=current.locale.Bundle.get("days.Tonight");}else{dayname=current.locale.Bundle.get("days."+dayname.capitalize());}var message=new Template(current.locale.Bundle.get("schedule.tonight_on_current_tv"));var sub={day:dayname};this._titleHolder.update(message.evaluate(sub));this._navList.invoke("removeClassName","active");this.getActiveDayLink().up().addClassName("active");},_getScheduleData:function(){new Ajax.Request(current.Constants.getInstance().getScriptName()+"/tv/primetime_schedule/"+this.getActiveDayId(),{method:"get",evalJS:false,onSuccess:this.__onSuccess.bindAsEventListener(this),onFailure:this.__onFailure.bindAsEventListener(this)});},__onSuccess:function(data){this.setDayData(this.getActiveDayId(),data.responseText);this._buildSchedule();},__onFailure:function(data){console.log("ajax error");return false;}});Object.Event.extend(current.components.schedule.PrimetimeModule);document.__primetimeModule__=new current.components.schedule.PrimetimeModule();Object.extend(current.components.schedule.PrimetimeModule,{getInstance:function(){return document.__primetimeModule__;}});