function _Byutv(){if(!(this instanceof _Byutv)){return new _Byutv()}return this}_Byutv.prototype={applyMethod:function(d,c){return function(){return c.apply(d,arguments)}},GigyaLogin:function(c){var d={returnURL:window.location.href,UID:c.UID,UIDSignature:c.UIDSignature,signatureTimestamp:c.signatureTimestamp};window.location.href="/account/logon?ReturnURL={0}&UID={1}&UIDSignature={2}&signatureTimestamp={3}".format(d.returnURL,d.UID,d.UIDSignature,d.signatureTimestamp)},addLoader:function(k,o,m,p,j,l){var q,n;m=(typeof m==="undefined"||m<=0)?30000:m;q="";if(isNaN(o)||o<1||o>4||o===1||o===2){o=o===2?2:1;q="<b>loading...</b>"}q=l||q;if($("body").hasClass("dark")&&o===1){o=2}$(k).prepend('<div class="loader">'+q+'<img alt="load" src="../Content/helpers/cmn/images/loaders/'+o+'.gif" /></div>');n=this.applyMethod(this,this.killLoader);p=(typeof p==="undefined"||p.length===0)?"Could not load data.":p;setTimeout(function(){n(k,p,j)},m,this);return k},updateImage:function(c){var d=c==="site"?"Removing Image":"Retrieving Your {0} Image".format(c);Byutv.addLoader("#update-loader",1,30000,"Could not update image","Account",d);$.ajax({url:"/account/changegigyaimage/"+c,success:function(){gigya.services.socialize.getUserInfo(conf,{callback:getUserImage})},error:function(){Byutv.killLoader("#update-loader","Could not update image")}})},killLoader:function(e,f,d){if(typeof f!=="undefined"&&f.length!==0){if($(e+" .loader").length>0){$(e+" .loader").html('<div class="no-result">'+f+"</div>");Byutv.log({message:f,code:"info",filename:d})}}else{$(e+" .loader").remove()}},showBYULogin:function(){$("#popup .byutv-login").show();$("#popup .social-login").hide();$("#popup .byutv-login #UserName").focus()},showLoginForm:function(){$("#login-page .byutv-login").show();$("#login-page .social-login .byutv-desc").hide();$("#login-page .social-login .show-login").hide()},showSocialLogin:function(){$("#popup .byutv-login").hide();$("#popup .social-login").show()},selectItem:function(d,f,e){if($("#"+d+" ul li").size()<(f+1)){return false}e=typeof(e)!=="undefined"?e:"selected";$("#"+d+" ul li").removeClass(e);$("#"+d+" ul").trigger("slideTo",[f,0,true]);$("#"+d+" ul li.item-"+f).addClass(e);return true},deselectItems:function(d,f,e){e=typeof(e)!=="undefined"?e:"selected";$("#"+d+" ul li").removeClass(e);f=typeof(f)!=="undefined"?f:-1;if((f===-1)||($("#"+d+" ul li").length<(f+1))){return false}$("#"+d+" ul").trigger("slideTo",[f,0,true]);return true},loadMediaFromURI:function(m){var j,l,g;var k=getCookie("timezone");if(k===null){k="Mountain Standard Time"}if(m.tzOffset!==null){var i=m.tzOffset}else{var i=-7}numRetrieve=typeof(numRetrieve)!=="undefined"?numRetrieve:0;if(typeof m.vertical==="boolean"){m.vertical=m.vertical?"true":"false"}g=$("#"+m.ribbonID+" ul").carouFredSel();if(g!=="false"&&g!==false){g.destroy()}l="<ul><li>&nbsp;</li></ul>";l+="<div class='pagination' id='"+m.ribbonID+"_pagination'></div><a class='prev' id='"+m.ribbonID+"_prev' href='#'><span>prev</span></a><a class='next' id='"+m.ribbonID+"_next' href='#'><span>next</span></a>";$("#"+m.ribbonID).html(l);j=new Ribbon({ribbonID:m.ribbonID,type:m.type,vertical:m.vertical,numDisplay:m.numDisplay,contentURI:m.contentURI,numRetrieve:m.numRetrieve,hidePageNumber:m.hidePageNumber},i);return j},changeTheme:function(c){var d;$("body").attr("class","");$("body").addClass(c).addClass("set");$(".header-themes a").removeClass("active");$(".header-themes .theme-"+c).addClass("active");clearTimeout(d);d=setTimeout(function(){$("body").removeClass("set")},1010);if($.cookie("BYUTV_THEME")!==c){$.cookie("BYUTV_THEME",c,{expires:365,path:"/"})}$("head #theme").remove();if($.cookie("BYUTV_THEME")==="dark"){$("head").append('<link id="theme" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/dark-hive/jquery-ui.css" rel="Stylesheet" type="text/css" />')}else{$("head").append('<link id="theme" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/overcast/jquery-ui.css" rel="Stylesheet" type="text/css" />')}},loadTheme:function(b){$("body").attr("class","");$.cookie("BYUTV_THEME",$.cookie("BYUTV_THEME")||"light",{expires:365,path:"/"});$("body").addClass($.cookie("BYUTV_THEME"));$("a.theme-"+($.cookie("BYUTV_THEME")||"light")).addClass("active");$("head #theme").remove();if($.cookie("BYUTV_THEME")==="dark"){$("head").append('<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/dark-hive/jquery-ui.css" rel="Stylesheet" type="text/css" />')}else{$("head").append('<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/overcast/jquery-ui.css" rel="Stylesheet" type="text/css" />')}},ajaxPartialView:function(f,e,g){var i=f,e=$(e);$.ajax({url:i,dataType:"html",success:function(a){e.html(a);if(typeof g==="function"){g()}},error:function(){Byutv.log({message:"Error loading partial - {0}".format(f),code:"error",filename:"Byutv.js"})}});return false},styleSelect:function(){$(".widget-header select").css("left","inherit").customStyle();$(".widget-header select").hover(function(){$(this).siblings(".customStyleSelectBox").addClass("select-hover")},function(){$(this).siblings(".customStyleSelectBox").removeClass("select-hover")})},ajaxLoadHash:function(k,j,i){var g=location.hash;if(g.length>1){g=g.substring(11,g.length);if(j.indexOf(g)<0){var f=location.pathname+"/"+g;Byutv.ajaxPartialView(f,k,i)}}},setDynamicLoad:function(b){this.isDynamic=b},getDynamicLoad:function(){return this.isDynamic},changeTimeZone:function(c){var d=window.location;$.ajax({url:c,success:function(){window.location=d}})},log:function(e){var g=new Date().format("hh:nn:ss"),i=["error","warn","info","debug"];message=e.message||"Undefined Log Message";code=e.code||"warn";filename=e.filename!==undefined&&e.filename!=="undefined"?" from {0}".format(e.filename):"";message="BYUTV ({0}){1}: {2}".format(g,filename,message);style="color:blue;background-color:lightblue;";if(window.console&&window.console.log){if($.inArray(code,i)>=0){window.console[code](message)}else{window.console.log("%c{0}".format(message),style)}}else{try{if($.inArray(code,i)>=0){console[code](message)}else{console.log("%c{0}".format(message),style)}}catch(f){}}return false},startTime:function(c){if(window.console&&window.console.time){window.console.time(c)}else{try{console.time(c)}catch(d){}}return false},endTime:function(c){if(window.console&&window.console.time){window.console.timeEnd(c)}else{try{console.timeEnd(c)}catch(d){}}return false},happenedLastWeekOrMore:function(d){var e=new Date(),f=parseInt((e.getTime()-d.getTime())/86400000,10);return(e.getDay()-f)<0},getURIPart:function(k,g){var m=/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/;var j=["url","scheme","slash","host","port","path","query","hash"];var l=j.indexOf(g);var i=m.exec(k);return i[l]},pageInit:function(){Sys.Application.set_enableHistory(true);Sys.Application.add_navigate(Byutv.navigate)},navigate:function(e,j){var k=Byutv.getURIPart(window.location,"path"),l=Byutv.getURIPart(window.location,"hash"),i,m="";if(k==="shows"){Byutv.navigateAllShows()}else{if(/show\//.test(k)||/watch\//.test(k)){Byutv.navigateSingleShow()}}},addToHistory:function(k){var l,j=[],o,i=[],m={},n;k=k===true?true:false;location=k?window.location:this.getAttribute("href");var l=Byutv.getURIPart(location,"hash");if(typeof l!=="undefined"){j=l.split("&");for(o=0;o<j.length;o=o+1){i=j[o].split("=");m["{0}".format(i[0])]="{0}".format(i[1])}}Sys.Application._state={};Sys.Application.addHistoryPoint(m)},loadPartial:function(e,d,f){$.ajax({url:e,success:function(a){$(d).html(a);if(typeof f==="function"){f()}},error:function(){Byutv.log({message:"Error loading partial - {0}".format(e),code:"error",filename:"Byutv.js"})}})},navigateAllShows:function(){var i=Byutv.getURIPart(window.location,"hash");var k;var f={};var j;$.each($("#shows-dropdown option"),function(){var a="{0}".format($(this).html().replace(/\s/g,"-"));if(!j){j=a}f[a]=$(this).attr("id")});if(typeof i==="undefined"||i===""){i="page=1&category={0}".format(j)}else{i=i.replace("!","");if(i==="allshows=false"){$(".atozlist","#with-featured").hide();$("#shows").show();$(".featuredShows","#with-featured").css({visibility:"visible",position:"static"});$(".paging").hide();$(".atoz").show();return}else{if(i==="allshows=true"){if($(".atozlist","#with-featured").html()===""){Byutv.loadPartial("/shows/atoz",".atozlist")}$(".atozlist","#with-featured").show();$("#shows").hide();$(".featuredShows","#with-featured").css({visibility:"hidden",position:"absolute"});$(".paging").show();$(".atoz").hide();return}}}if($("#shows").css("display")==="none"){$(".atozlist","#with-featured").hide();$("#shows").show();$(".featuredShows","#with-featured").css({visibility:"visible",position:"static"});$(".paging").hide();$(".atoz").show()}Byutv.loadPartial("/shows/ShowsPage?{0}".format(i),"#shows");try{k=unescape(/category=([^&]*)&?/.exec(i)[1])}catch(g){k=j}k=f[k];document.getElementById(k).selected=true;$(".customStyleSelectBoxInner").html(k);$("#selected-shows").html(k)},navigateSingleShow:function(){var j=Byutv.getURIPart(window.location,"hash");var i;if(/show\//.test(window.location)){i=/show\/([^&\?\#]*)/.exec(window.location)[1]}else{i=/watch\/([^&\?\#]*)/.exec(window.location)[1]}var k;var l={};$.each($("#ddlSeasons option"),function(){var a="{0}".format($(this).html().replace(/\s/g,"-"));l[a]=$(this).attr("id")});if(typeof j==="undefined"||j===""){j="page=1&season=All-Seasons"}else{j=j.replace("!","")}if(((j.indexOf("Main")>-1||j.indexOf("listMain")>=0)&&j.indexOf("season")<0)||j.indexOf("Airdates")>-1){$("#dEpisode, .shadow").slideDown();$("#partials").css("display","block");Byutv.loadPartial("/show/"+i+"/"+j,"#partials",function(){$(".iframe-tab").css("display","none");Byutv.styleSelect()});return}else{if(j.indexOf("listMain")>-1&&j.indexOf("season")>-1){$("#dEpisode, .shadow").slideDown();$("#partials").css("display","block");Byutv.loadPartial("/shows/EpisodesList?showGuid="+i+"&"+j,"#episodePagerContent",function(){$(".iframe-tab").css("display","none");Byutv.styleSelect()});return}else{if(j.length>1&&j.indexOf("http")>-1){var m=decodeURIComponent(j);iframe(m);setTheActiveTagAtStart(this,globalPreviousObject);return}}}j="showGuid={0}&{1}".format(i,j);if(j.indexOf("listMain")<0){Byutv.loadPartial("/shows/EpisodesPager?{0}".format(j),"#episodePagerContent")}else{Byutv.loadPartial("/shows/EpisodesList?{0}".format(j),"#episodePagerContent")}try{k=unescape(/season=([^&]*)&?/.exec(j)[1])}catch(g){k="All-Seasons"}try{k=l[k];document.getElementById(k).selected=true;$(".customStyleSelectBoxInner").html(k);$("#selected-shows").html(k)}catch(g){}}};String.prototype.format=function(){var f=this;for(var e=0;e<arguments.length;e++){var d=new RegExp("\\{"+e+"\\}","gi");f=f.replace(d,arguments[e])}return f};String.prototype.strsub=function(){var l,j,m,k,g;k=new Array("'","[","]","(",")","{","}","<",">",":",",","!",".","-","?",'"',";","/","\\","|","&","~","`","@","#","$","%","^","*","_","+","=");if(arguments[0]>arguments[1]){var i=arguments[0];arguments[0]=arguments[1];arguments[1]=i}if(arguments[0]>this.length){return}if(this.length<arguments[1]){return this}l=this.substring(arguments[0],arguments[1]);if(this.length>arguments[0]){j=l.lastIndexOf(".");m=l.lastIndexOf(" ");arguments[1]=Math.max(j,m,0)}g=this.substring(arguments[0],arguments[1]);while($.inArray(g.charAt(g.length-1),k)!==-1){g=g.substring(0,g.length-1)}return"{0}...".format(g)};function getDayNames(q){var s=new Date(),p=s.getMonth()+1,k=s.getDate(),o=s.getFullYear(),n=q.getMonth()+1,l=q.getDate(),m=q.getFullYear(),r=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");if(p===n&&k===l&&o===m){r[q.getDay()]="Today"}else{if(happenedYesterday(q)){r[q.getDay()]="Yesterday"}}return r}Date.prototype.isToday=function(){var l=new Date(),n=l.getMonth()+1,j=l.getDate(),o=l.getFullYear(),k=this.getMonth()+1,i=this.getDate(),m=this.getFullYear();if(n===k&&j===i&&o===m){return true}return false};Array.prototype.indexOf=function(c){for(var d=0;d<this.length;d++){if(this[d]==c){return d}}return -1};function happenedYesterday(d){var c=new Date((new Date()).getTime()-86400000);return((d.getYear()==c.getYear())&&(d.getMonth()==c.getMonth())&&(d.getDate()==c.getDate()))}var gsMonthNames=new Array("January","February","March","April","May","June","July","August","September","October","November","December");var gsDayNames=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");Date.prototype.format=function(d){if(!this.valueOf()){return" "}var c=this;return d.replace(/(yyyy|mmmm|mmm|mm|dddd|ddd|dd|d|hh|nn|ss|a\/p|ap|sup)/gi,function(a){switch(a.toLowerCase()){case"yyyy":return c.getFullYear();case"mmmm":return gsMonthNames[c.getMonth()];case"mmm":return gsMonthNames[c.getMonth()].substring(0,3);case"mm":return(c.getMonth()+1).zf(1);case"dddd":return gsDayNames[c.getDay()];case"ddd":return gsDayNames[c.getDay()].substring(0,3);case"dd":return c.getDate().zf(1);case"d":return getDayNames(c)[c.getDay()];case"hh":return((h=c.getHours()%12)?h:12).zf(1);case"nn":return c.getMinutes().zf(2);case"ss":return c.getSeconds().zf(2);case"a/p":return c.getHours()<12?"am":"pm";case"ap":return c.getHours()<12?"AM":"PM";case"sup":switch(c.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th"}}})};String.prototype.zf=function(b){return"0".string(b-this.length)+this};String.prototype.string=function(e){var f="",d=0;while(d++<e){f+=this}return f};Number.prototype.zf=function(b){return this.toString().zf(b)};var Byutv=new _Byutv();function search(){document.forms.searchForm.submit()}function getCookie(f){var k,g,i,j=document.cookie.split(";");for(k=0;k<j.length;k++){g=j[k].substr(0,j[k].indexOf("="));i=j[k].substr(j[k].indexOf("=")+1);g=g.replace(/^\s+|\s+$/g,"");if(g==f){return unescape(i)}}}Sys.Application.add_init(Byutv.pageInit);
