(function(a){a.fn.newsTicker=a.fn.newsticker=function(b){b=b||4000;initTicker=function(c){stopTicker(c);c.items=a("li",c);c.items.not(":eq(0)").hide().end();c.currentitem=0;startTicker(c)};startTicker=function(c){c.tickfn=setInterval(function(){doTick(c)},b)};stopTicker=function(c){clearInterval(c.tickfn)};pauseTicker=function(c){c.pause=true};resumeTicker=function(c){c.pause=false};doTick=function(c){if(c.pause){return}c.pause=true;a(c.items[c.currentitem]).fadeOut("slow",function(){a(this).hide();c.currentitem=++c.currentitem%(c.items.size());a(c.items[c.currentitem]).fadeIn("slow",function(){c.pause=false})})};this.each(function(){if(this.nodeName.toLowerCase()!="ul"){return}initTicker(this)}).addClass("newsticker").hover(function(){pauseTicker(this)},function(){resumeTicker(this)});return this}})(jQuery);$.fn.extend({adCarousel:function(a){var b={transitionSpeed:500,displayTime:10000,imgHeight:100,imgWidth:100,imagesToDisplay:5,hasCategories:0};var a=$.extend(b,a);return this.each(function(){var d=$(this).get(0);var c=$(this).parent();d.numImages=$("img",d).length;d.opts=a;$.extend(d,{anim:function(g,h,e){if($("ul",d).hasClass("animating")){return}var f=e||d.opts.transitionSpeed;if(d.opts.hasCategories){d.removeLeftCategory()}if(g=="next"){if(h>1){$("li:lt(2)",d).clone().insertAfter($("li:last",d));if(d.opts.hasCategories){$(".ad_cat_inner",c).animate({left:-d.opts.imgWidth*(h+1)},f)}$("ul",d).addClass("animating").animate({left:-d.opts.imgWidth*(h+1)},f,function(){$("li:lt(2)",d).remove();for(j=1;j<=h-2;j++){$("li:first",d).clone().insertAfter($("li:last",d));$("li:first",d).remove()}$(this).removeClass("animating").css("left",-d.opts.imgWidth+"px");if(d.opts.hasCategories){$(".ad_cat_inner",c).css("left",-d.opts.imgWidth+"px");d.displayCategories();d.fixLeftCategory()}})}else{$("li:first",d).clone().insertAfter($("li:last",d));if(d.opts.hasCategories){$(".ad_cat_inner",c).animate({left:-d.opts.imgWidth*2},f)}$("ul",d).addClass("animating").animate({left:-d.opts.imgWidth*2},f,function(){$("li:first",d).remove();$(this).removeClass("animating").css("left",-d.opts.imgWidth+"px");if(d.opts.hasCategories){$(".ad_cat_inner",c).css("left",-d.opts.imgWidth+"px");d.displayCategories();d.fixLeftCategory()}})}d.curr=d.curr+h;if(d.curr>d.numImages){d.curr=d.curr-d.numImages}}if(g=="prev"){if(h>1){$("li:gt("+(d.numImages-(h+1))+")",d).clone().insertBefore($("li:first",d));if(d.opts.hasCategories){d.displayCategories();$(".ad_cat_inner",c).css({left:(-d.opts.imgWidth*(h+1))}).animate({left:-d.opts.imgWidth},f)}$("ul",d).addClass("animating").css({left:(-d.opts.imgWidth*(h+1))}).animate({left:-d.opts.imgWidth},f,function(){$("li:gt("+(d.numImages-1)+")",d).remove();$(this).removeClass("animating");if(d.opts.hasCategories){d.fixLeftCategory()}})}else{$("li:last",d).clone().insertBefore($("li:first",d));if(d.opts.hasCategories){d.displayCategories();$(".ad_cat_inner",c).css("left",-d.opts.imgWidth*2+"px").animate({left:-d.opts.imgWidth},f)}$("ul",d).addClass("animating").css("left",-d.opts.imgWidth*2+"px").animate({left:-d.opts.imgWidth},f,function(){$("li:last",d).remove();$(this).removeClass("animating");if(d.opts.hasCategories){d.fixLeftCategory()}})}d.curr=d.curr-h;if(d.curr<=0){d.curr=d.numImages+d.curr}}if(d.opts.animationCallback){setTimeout(d.opts.animationCallback+"("+(d.curr-1)+")",f)}},startScrolling:function(){if(d.numImages>d.opts.imagesToDisplay){if(!d.autopilot){clearInterval(d.clearInt);d.autopilot=1;d.clearInt=setInterval(function(){d.anim("next",d.opts.imagesToDisplay)},d.opts.displayTime+d.opts.transitionSpeed)}}},stopScrolling:function(){if(d.autopilot){clearInterval(d.clearInt);d.autopilot=0}},scrollTo:function(h,g){if(d.numImages>d.opts.imagesToDisplay){if(d.curr!=h){d.stopScrolling();var f=d.curr-h;if(f<0){f=d.numImages+f}var e=h-d.curr;if(e<0){e=d.numImages+e}if(f<e){d.anim("prev",f,g)}else{d.anim("next",e,g)}d.startScrolling()}}},displayCategories:function(){$(".ad_cat_inner",c).html("");var s=$("li",d);var h=s.length;var m=-1;var p,f,r,k;for(var o=0;o<h;o++){f=getAdCategory(s[o]);if(f!=p){r=d.opts.imgWidth*(o-m);$(".cat_start:last div.cat_bg",c).width(r-70);$(".cat_start:last",c).width(r-40);var q=$(".cat_name:last",c);var e=$(".cat_left:last",c).width();var g=q.width();if(g>e){q.html(p.substr(0,Math.floor(p.length*e/g)-3)+"...")}r=(d.numImages+1)*d.opts.imgWidth;k=$(s[o]).position().left;$(".ad_cat_inner",c).append("<div class='cat_start' style='left:"+k+"px;width:"+r+"px;'><div class='cat_left'><div class='cat_name' style='left:20px;top:0;white-space:nowrap;z-index:10'>"+f+"</div><div class='cat_bg' style='width:"+(r-20)+"px;'>&nbsp;</div>&nbsp;</div></div>");p=f;m=o}}if(d.numImages<=d.opts.imagesToDisplay){r=d.opts.imgWidth*(h-m);$(".cat_start:last div.cat_bg",c).width(r-70);$(".cat_start:last",c).width(r-40)}},removeLeftCategory:function(){$(".fixed_cat",c).remove();$(".cat_name",c).show()},fixLeftCategory:function(){var l=$("ul",d).position().left;var o=$("li",d);var k=o.length;var m=-1;var g;var p=false;while(!p){m++;g=getAdCategory(o[m]);if((l+$(o[m]).position().left)==0){p=true}}var e=$(".ad_cat_inner",c).position().left;var f=500;$(".cat_start",c).each(function(){var i=$(this).find(".cat_left").width();if(($(this).position().left+e)<=0){i=i+($(this).position().left+e);if(i>0){f=i}$(this).find(".cat_name").hide()}});$(".ad_cat_inner",c).append("<div class='cat_name fixed_cat' style='left:"+(35-$(".ad_cat_inner",c).position().left)+"px;top:"+$(".cat_start",c).position().top+"px;white-space:nowrap;z-index:5'>"+g+"</div>");var h=$(".fixed_cat",c).width();if(h>f){$(".fixed_cat",c).html(g.substr(0,Math.floor(g.length*f/h)-3)+"...")}if(typeof(categoryChanged)=="function"){categoryChanged(g)}}});$(".btn_rt",d).click(function(){d.stopScrolling();d.anim("next",d.opts.imagesToDisplay);d.startScrolling()});$(".btn_lt",d).click(function(){d.stopScrolling();d.anim("prev",d.opts.imagesToDisplay);d.startScrolling()});$(".content_window ul",d).width(d.opts.imgWidth*(d.numImages+d.opts.imagesToDisplay));$(".content_window",d).width(d.opts.imgWidth*d.opts.imagesToDisplay).height(d.opts.imgHeight);if(d.numImages>d.opts.imagesToDisplay){$("li:last",d).prependTo($("ul",d));$("ul",d).css("left",-d.opts.imgWidth+"px")}if(d.opts.hasCategories){d.displayCategories();if(d.numImages>d.opts.imagesToDisplay){$(".ad_cat_inner",c).css("left",-d.opts.imgWidth+"px")}}d.curr=1;d.startScrolling()})}});$.fn.extend({fader:function(a){var b={transitionSpeed:500,displayTime:10000,imgHeight:100,imgWidth:100};var a=$.extend(b,a);return this.each(function(){var d=$(this).get(0);var c=$(this).parent();d.numImages=$("img",d).length;d.opts=a;$.extend(d,{fade:function(e,i,f){var h=d.curr+i;if(h>d.numImages){h=h-d.numImages}if(e=="prev"){h=d.curr-i;if(h<=0){h=h+d.numImages}}if($("ul",d).hasClass("fading")){return}var g=f||d.opts.transitionSpeed;$("ul",d).addClass("fading");$(".content_window",d).append("<div class='fade_next' style='display:none;position:absolute;z-index:2;'>"+$("li:eq("+(h-1)+")",d).html()+"</div>");$(".fade_next",d).fadeIn(g,function(){$("ul",d).removeClass("fading");$(".fade_curr",d).remove();$(".fade_next",d).addClass("fade_curr");$(".fade_curr",d).removeClass("fade_next").css({"z-index":"1"});d.curr=h});if(d.opts.fadeCallback){setTimeout(d.opts.fadeCallback+"("+(h-1)+")",2*g/3)}},startFading:function(){if(!d.autopilot){clearInterval(d.clearInt);d.autopilot=1;d.clearInt=setInterval(function(){d.fade("next",1)},d.opts.displayTime+d.opts.transitionSpeed)}},stopFading:function(){if(d.autopilot){clearInterval(d.clearInt);d.autopilot=0}},fadeTo:function(h,g){if(d.curr!=h){d.stopFading();var f=d.curr-h;if(f<0){f=d.numImages+f}var e=h-d.curr;if(e<0){e=d.numImages+e}if(f<e){d.fade("prev",f,g)}else{d.fade("next",e,g)}d.startFading()}}});$(".btn_rt",d).click(function(){d.stopFading();d.fade("next",1);d.startFading()});$(".btn_lt",d).click(function(){d.stopFading();d.fade("prev",1);d.startFading()});$(".content_window",d).width(d.opts.imgWidth).height(d.opts.imgHeight);$(".content_window",d).append("<div class='fade_curr' style='position:absolute;z-index:1;'>"+$("li:first",d).html()+"</div>");d.curr=1;d.startFading()})}});$(document).ready(function(){if($(".ad_content img.viz_ad").length>0){var a=$("<div></div>");$(".ad_content img.viz_ad").each(function(){a.append("<img src='"+$(this).attr("src")+"' />")});a.find("img").batchImageLoad({loadingCompleteCallback:function(){$(".ad_content").show();if(typeof(scaleImg)=="function"){scaleImg(".ad_content img.viz_ad",182,191)}$(".ad_content").adCarousel({imgHeight:191,imgWidth:188,imagesToDisplay:5,transitionSpeed:500,displayTime:10000,hasCategories:1});$("div.viz_ad_container").each(function(){initCaption($(this))})}})}$(".viz_ad_container").live("mouseover",function(){$(".cover",this).stop().animate({bottom:"0px"},{queue:false,duration:300});var b=$(this).parents(".ad_content").get(0);if(b){b.stopScrolling()}});$(".viz_ad_container").live("mouseout",function(){$(".cover",this).stop().animate({bottom:"-90px"},{queue:false,duration:300});var b=$(this).parents(".ad_content").get(0);if(b){b.startScrolling()}});$(".ad_row button, .ad_row button").live("click",function(){$(this).removeClass("gray_tab_34_nosel").addClass("gray_tab_34_sel");$(this).siblings(".gray_tab_34").removeClass("gray_tab_34_sel").addClass("gray_tab_34_nosel");var b=$(".ad_content",$(this).parents(".ad_row")).get(0);if(b){b.scrollTo(parseInt($(this).attr("ad_idx")))}});$(".ad_row .btn_rt").live("click",function(){var b=$(".ad_content",$(this).parents(".ad_row")).get(0);if(b){b.stopScrolling();b.anim("next",5);b.startScrolling()}});$(".ad_row .btn_lt").live("click",function(){var b=$(".ad_content",$(this).parents(".ad_row")).get(0);if(b){b.stopScrolling();b.anim("prev",5);b.startScrolling()}})});function categoryChanged(a){$(".ad_row ."+a.replace(/ /g,"_")).each(function(){$(this).removeClass("gray_tab_34_nosel").addClass("gray_tab_34_sel");$(this).siblings(".gray_tab_34").removeClass("gray_tab_34_sel").addClass("gray_tab_34_nosel")})}var adData={};function loadAds(a,b){if(!b){alert("Must provide 'dataVar' arg when calling 'ads.loadAds()'.");return}params={};if(typeof(episode_id)!=="undefined"){params.episode_id=episode_id}if(typeof(series_id)!=="undefined"){params.series_id=series_id}if(typeof(imprint_id)!=="undefined"){params.imprint_id=imprint_id}if(typeof(page_type)!=="undefined"){params.page_type=page_type}if(typeof(page_type_id)!=="undefined"){params.page_type_id=page_type_id}if(a){params.display_format=a}$.ajax({type:"GET",url:"/ad/get_ads",data:params,dataType:"json",success:function(c){adData[b]=c;showAds(adData[b])},error:function(c,d){showErr("An error has occured ("+d+")",c.responseText)}})}function getAdContents(d,g){var f=g||"ad",e=null,c="Viz Media advertisement",b=appendAdCampaign(d.href);if(d.product_name||d.desc||d.price){e='<div class="cover viz_ad_caption"><a class="track ad" path="'+f+'" target="_new" href="'+b+'">';if(d.product_name){e=e+'<span class="ad_title">'+d.product_name+"</span>"}if(d.price){e=e+'<span class="ad_price">'+d.price+"</span>"}e=e+"<a></div>"}if(d.product_name){c=d.product_name}var a='<a class="track ad" path="'+f+'" target="_new" href="'+b+'"><img class="viz_ad" src="'+d.img_url+'" alt="'+c+'" ad_id="'+d.id+'"';if(d.product_type){a=a+' category="'+d.product_type+'"'}a=a+" /></a>"+e;return a}function getAdId(b){var a=null;var c=$(".viz_ad",b);if(c){a=$(c).attr("ad_id")}return a}function getAdCategory(b){var a=null;var c=$(".viz_ad",b);if(c){a=$(c).attr("category")}return a}function initCaption(a,c){var e=c||"center";var k=$("img.viz_ad",a).width();var l=$(".viz_ad_caption",a);if(e=="center"){l.css("left",(a.width()-k)/2)}else{if(e=="right"){l.css("right",0)}else{l.css("left",0)}}l.width(k);var g=$(".ad_title",l);var i=l.height()-32;var b,d;if(g&&g.html()&&g.html()!=""&&g.css("font-size")){d=parseInt(g.css("font-size").replace(/px/,""));while(g.height()>i&&d>8){b=d-1;g.css("font-size",b+"px");d=parseInt(g.css("font-size").replace(/px/,""))}}}function trackAdView(c){if(!c){return}var d="";if(c.constructor.toString().indexOf("Array")==-1){c=(c+"").replace(/ /g,"");if(c){d=c}}else{var b;for(var e=c.length-1;e>=0;--e){if(c[e]){b=(c[e]+"").replace(/ /g,"")}if(b){d=d+b+","}}if(d.length>0){d=d.substr(0,d.length-1)}}if(d&&d!=""){trackVizEvent({type:"viz/asset_view",asset_id:d})}}function appendAdCampaign(a){var b="va-unknown";if(typeof(ad_campaign_name)!=="undefined"&&ad_campaign_name){b=ad_campaign_name}return appendCampaignParams(a,"www.vizanime.com","product_scroller",b)}$(document).ready(function(){$("a.ad").each(function(){var a=$(this).attr("href");$(this).attr("href",appendAdCampaign(a))});$("a.ad").live("click",function(){var a=getAdId(this);if(a){trackVizEvent({type:"viz/asset_click",asset_id:a})}})});function showJustPosted(a){hide_scroller("yourShowsContainer");var b=$(".just_posted_tab").length;if(a==0){$("#yourShowsContainer, #surveyContainer, #survey_bg").hide();$("#justPostedContainer").show();$("#just_posted_just_posted").removeClass("gray_tab_38_nosel").addClass("gray_tab_38_sel");$("#just_posted_my_shows, #just_posted_survey").removeClass("gray_tab_38_sel").addClass("gray_tab_38_nosel")}else{if(a==1){$("#justPostedContainer, #surveyContainer, #survey_bg").hide();$("#yourShowsContainer").show();$("#just_posted_just_posted, #just_posted_survey").removeClass("gray_tab_38_sel").addClass("gray_tab_38_nosel");$("#just_posted_my_shows").removeClass("gray_tab_38_nosel").addClass("gray_tab_38_sel");init_scroller("yourShowsContainer")}else{$("#justPostedContainer, #yourShowsContainer").hide();$("#survey_bg").show();showSurveyContainer();$("#just_posted_just_posted, #just_posted_my_shows").removeClass("gray_tab_38_sel").addClass("gray_tab_38_nosel");$("#just_posted_survey").removeClass("gray_tab_38_nosel").addClass("gray_tab_38_sel")}}return false}function forceSeriesOffset(a,d,c,b){d[c]=b;layoutAllShowsCols(a,d)}function changeSeriesOffset(a,d,c,b){d[c]+=b;layoutAllShowsCols(a,d,b)}function layoutAllShowsCols(a,g,c){var d=new Array("0","0");var e=new Array();for(var i=0;i<=2;i++){var b=(g[i]+2);var f="";if(b>seriescount[i]){f=(g[i]+1)}else{f=(g[i]+1)+"-"+(g[i]+2)}$("#allShowsPage-"+i).html(f);for(h=0;h<=a[i];h++){if(h==g[i]){e.push($("#serie-"+i+"-"+h))}else{if(h==(g[i]+1)){e.push($("#serie-"+i+"-"+h))}else{$("#serie-"+i+"-"+h).hide()}}$.each(e,function(k,l){if(c>0){$(this).show()}else{$(this).show()}})}}for(var i=0;i<=2;i++){if(numdots[i]>0){for(var h=0;h<=numdots[i];h++){$("#allshows-dot-"+i+"-"+h).removeClass("allShowsDotSelected");$("#allshows-dot-"+i+"-"+h).removeClass("allShowsDotNotSelected");if((g[i]/2)==h){$("#allshows-dot-"+i+"-"+h).addClass("allShowsDotSelected")}else{$("#allshows-dot-"+i+"-"+h).addClass("allShowsDotNotSelected")}}}}for(var i=0;i<=2;i++){if(g[i]>0){$("#allshows-left-"+i).show();$("#allshows-left-"+i+"-disabled").hide()}else{$("#allshows-left-"+i).hide();$("#allshows-left-"+i+"-disabled").show()}if(g[i]<(a[i]-1)){$("#allshows-right-"+i).show();$("#allshows-right-"+i+"-disabled").hide()}else{$("#allshows-right-"+i).hide();$("#allshows-right-"+i+"-disabled").show()}}}function reload_your_shows_following(c){for(var a=0;a<series_ids.length;a++){var b=series_ids[a];if(!c||c==b){$("#all_shows_following_"+b).html('<div style="margin:4px;"><img src="/images/ajax-loader.gif" /></div>')}}$.ajax({url:"/account/get_your_series_data",success:function(f){for(var d=0;d<series_ids.length;d++){var e=series_ids[d];if(!c||c==e){if(f.no_user_data==1){$("#all_shows_following_"+e).html("")}else{if(f[e]&&f[e]==1){$("#all_shows_following_"+e).html('<a class="requires_login stop_follow_btn track" path="all_shows/stop_follow_btn" href="javascript:void(0);" clickFn="javascript:follow_series('+e+', 0, 0)" title="Stop following'+(f.not_logged_in==1?' (requires login)"':'"')+"></a>")}else{$("#all_shows_following_"+e).html('<a class="requires_login follow_btn track" path="all_shows/follow_btn" href="javascript:void(0);" clickFn="javascript:follow_series('+e+', 1, 0)" title="Follow'+(f.not_logged_in==1?' (requires login)"':'"')+"></a>")}}}}},error:function(f){for(var d=0;d<series_ids.length;d++){var e=series_ids[d];$("#all_shows_following_"+e).html("Error")}},dataType:"json"})}var evtMark=0,lastCommentID,lastActivityID,eventsComments,eventsActivity,commentsInt,activityInt;function loadCommunityStuff(){$.ajax({url:"/home/community",dataType:"html",success:function(a){if(a&&$.trim(a)!=""){$("#community").html(a);eventsComments=$("#latest_comments .community_event:lt(10)");$("#latest_comments .community_event:lt(10)").remove();$("#latest_comments .comment_excerpt").each(function(){$(this).html(fitStringToWidth($(this).html(),260))});eventsActivity=$("#latest_activity .community_event:lt(30)");$("#latest_activity .community_event:lt(30)").remove();$("#community").show();showUserChart(userMostViews);commentsInt=setInterval("showNextComment()",300000/eventsComments.length);activityInt=setInterval("showNextActivity()",300000/eventsActivity.length);init_scroller("latest_comments");init_scroller("latest_activity")}},error:function(a){return}})}function hide_scroller(a){$("#"+a).jScrollPaneRemove()}function init_scroller(a){if($("#"+a).is(":visible")){$("#"+a).jScrollPane({showArrows:true,scrollbarWidth:19,arrowSize:18,dragMinHeight:128,dragMaxHeight:128})}}function loadNextEvents(){$.ajax({url:"/home/community_latest_activity",dataType:"html",data:{lastCommentID:lastCommentID,lastActivityID:lastActivityID},success:function(b){var a=$(b);eventsComments=$("#more_comments .community_event",a);eventsActivity=$("#more_activity .community_event",a);if(eventsComments.length>0){commentsInt=setInterval("showNextComment()",300000/eventsComments.length)}if(eventsActivity.length>0){activityInt=setInterval("showNextActivity()",300000/eventsActivity.length)}if(eventsComments.length==0&&eventsActivity.length==0){getNextEvents=setTimeout("loadNextEvents()",150000)}evtMark=0},error:function(a){evtMark=0;return}})}function showUserChart(c){var a={h:0,s:0,b:1},b={h:0,s:0.91,b:0.98};$("#user_chart").remove();$("#user_most_chart").html('<div style="padding-top:10px;"><div id="user_chart"></div></div>');Raphael("user_chart").barChart2D(0,0,300,385,c,{stroke:"#bbb",raw:true,color:a,colorHover:b})}function showNextComment(){if(eventsComments&&eventsComments.length>0){$("#latest_comments .community_event:eq(0)").before($(eventsComments[eventsComments.length-1]).hide());$("#latest_comments .comment_excerpt:eq(0)").each(function(){$(this).html(fitStringToWidth($(this).html(),260))});$("#latest_comments .community_event:eq(0)").slideDown();$("#latest_comments .community_event:gt(99)").remove();eventsComments.length=eventsComments.length-1;if(eventsComments.length==0){lastCommentID=$("#latest_comments .community_event:eq(0)").attr("event_id")}init_scroller("latest_comments")}checkLoadEvents()}function showNextActivity(){if(eventsActivity&&eventsActivity.length>0){$("#latest_activity .community_event:eq(0)").before($(eventsActivity[eventsActivity.length-1]).hide());$("#latest_activity .community_event:eq(0)").slideDown();$("#latest_activity .community_event:gt(99)").remove();eventsActivity.length=eventsActivity.length-1;if(eventsActivity.length==0){lastActivityID=$("#latest_activity .community_event:eq(0)").attr("event_id")}init_scroller("latest_activity")}checkLoadEvents()}function checkLoadEvents(){if((!eventsComments||eventsComments.length==0)&&(!eventsActivity||eventsActivity.length==0)){if(typeof(evtMark)!=="undefined"&&evtMark==1){return}evtMark=1;clearInterval(commentsInt);clearInterval(activityInt);loadNextEvents()}}function showMost(a){if(!a){return false}$("#most_ctl_"+a).removeClass("gray_tab_34_nosel").addClass("gray_tab_34_sel");$("#most_ctl_"+a).siblings().removeClass("gray_tab_34_sel").addClass("gray_tab_34_nosel");$("#most_"+a).siblings(".community_content").hide();$("#most_"+a).show();return false}function showUserMost(a){if(!a){return false}$("#user_most_ctl_"+a).removeClass("gray_tab_34_nosel").addClass("gray_tab_34_sel");$("#user_most_ctl_"+a).siblings().removeClass("gray_tab_34_sel").addClass("gray_tab_34_nosel");if(a=="views"){showUserChart(userMostViews)}else{if(a=="comments"){showUserChart(userMostComments)}else{if(a=="likes"){showUserChart(userMostLikes)}}}return false}function showLatest(a){hide_scroller("latest_comments");hide_scroller("latest_activity");if(!a){return false}$("#latest_ctl_"+a).removeClass("gray_tab_34_nosel").addClass("gray_tab_34_sel");$("#latest_ctl_"+a).siblings().removeClass("gray_tab_34_sel").addClass("gray_tab_34_nosel");$("#latest_"+a).siblings(".community_content").hide();$("#latest_"+a).show();init_scroller("latest_comments");init_scroller("latest_activity");return false}function scrollToPromo(a,b){var c=document.getElementById("promo_vid");if(c){c.fadeTo(a+1,b)}}function setMainPromo(a){$(".paging div.promo_ctl").removeClass("active");$(".paging div.promo_ctl:eq("+a+")").addClass("active");$("body").css("background","#fff url('"+promo_bgs[a]+"') no-repeat center top")}$(document).bind("post_login",function(){reload_your_shows_following()});$(document).ready(function(){if(promo_bgs.length>1){$("#promo_vid").fader({imgHeight:375,imgWidth:640,transitionSpeed:1000,displayTime:7000,fadeCallback:"setMainPromo"});var b=$("#bg_images");b.html("");for(var a=promo_bgs.length;a>0;a--){b.append("<img src='"+promo_bgs[a-1]+"' />")}b.find("img").batchImageLoad();$("body").css("background","#fff url('"+promo_bgs[0]+"') no-repeat center top");$(".paging div.promo_ctl:first").addClass("active");$(".paging div.promo_ctl").live("mouseover",function(){$(".paging div.promo_ctl").removeClass("active");scrollToPromo($(this).prevAll("div.promo_ctl").length,50)})}else{$("body").css("background","#fff url('"+promo_bgs[0]+"') no-repeat center top")}$(".sm_ep_row").live("mouseover",function(){$(".episode_img_hover",this).css("visibility","visible");$("a",this).css("color","#bd0000");$(".vote_icon a, .comment_icon a",this).css("background-position","0 0");$(".rating_activity_number").css("color","#000000")});$(".sm_ep_row").live("mouseout",function(){$(".episode_img_hover",this).css("visibility","hidden");$("a",this).css("color","#000");$(".vote_icon a, .comment_icon a",this).css("background-position","0 -23px");$(".rating_activity_number").css("color","#777777")});$("#allshows .all_shows_serie_title a, #allshows .all_shows_serie_link, #all_shows .subdub").hover(function(){var c=$(this).parents(".all_shows_serie");$(".all_shows_serie_link, .all_shows_serie_title a",c).css({color:"#bd0000",cursor:"pointer"});$(".subdub",c).css({"background-color":"#bd0000",color:"#fff",cursor:"pointer"});Cufon.refresh()},function(){var c=$(this).parents(".all_shows_serie");$(".all_shows_serie_link, .all_shows_serie_title a",c).css({color:"#000",cursor:"default"});$(".subdub",c).css({"background-color":"#aaa",cursor:"default"});Cufon.refresh()});$("#allshows .episode_img a, #allshows .all_shows_serie_episode a:not(.new_ep)").hover(function(){var c=$(this).parents(".all_shows_serie");$(".episode_img_hover",c).css("visibility","visible");$(".all_shows_serie_episode a:not(.new_ep)",c).css({color:"#bd0000",cursor:"pointer"});$(".icon_votes_16_wbg, .icon_comments_16_wbg",c).css("background-position","0 0");$(".icon_votes_13_wbg, .icon_comments_13_wbg",c).css("background-position","0 0");$(".rating_activity_number").css("color","#000000")},function(){var c=$(this).parents(".all_shows_serie");$(".episode_img_hover",c).css("visibility","hidden");$(".all_shows_serie_episode a:not(.new_ep)",c).css({color:"#000",cursor:"default"});$(".icon_votes_16_wbg, .icon_comments_16_wbg",c).css("background-position","0 -26px");$(".icon_votes_13_wbg, .icon_comments_13_wbg",c).css("background-position","0 -23px");$(".rating_activity_number").css("color","#777777")});$("#what_to_watch a").hover(function(){var c=$(this).parents(".all_shows_serie");$(".episode_img_hover",c).css("visibility","visible");$(".collection_link",c).css("color","#bd0000");Cufon.refresh()},function(){var c=$(this).parents(".all_shows_serie");$(".episode_img_hover",c).css("visibility","hidden");$(".collection_link",c).css("color","#000");Cufon.refresh()});reload_your_shows_following();loadCommunityStuff();$.getJSON("home/sec_to_next_ep",function(d){if(d){for(seriesID in d){var c=seriesID,e=null;if(d[c].episode_id){if(d[c].episode_number){e='<a class="new_ep" href="/ep/'+d[c].episode_id+'">Episode '+d[c].episode_number+" Now Online!</a>"}else{e='<a class="new_ep" href="/ep/'+d[c].episode_id+'">New Episode Available!</a>'}}if(d[c].seconds_left<0){if(d[c].episode_id){$("#time_to_next_"+c).html(e).show()}}else{$("#countdown_"+c).countdown({until:d[c].seconds_left,compact:true,layout:"{dn}{dl},{hnn}{sep}{mnn}{sep}{snn}",onExpiry:function(){if(e){$("#time_to_next_"+c).html(e)}else{$("#time_to_next_"+c).fadeOut("fast")}}});$("#time_to_next_"+c).show()}}}})});function reload_your_series(){$("#your_shows").html('<div style="padding:12px 10px;"><img src="/images/ajax-loader.gif" /></div>');load_your_series()}function load_your_series(){var b="";var a={};if(typeof(series_id)!=="undefined"){b="?series_id="+series_id}if(typeof(page_type)!=="undefined"){a.page_type=page_type}if(typeof(page_type_id)!=="undefined"){a.page_type_id=page_type_id}$.ajax({url:"/account/get_your_series"+b,data:a,success:function(c){show_your_series_from_data(c)},error:function(c){$("#your_shows").html('<div style="margin:10px 13px;">There was an error loading this section - please refresh the page to try again</div>')}})}function show_your_series_from_data(a){$("#your_shows").html(a);$(".your_shows_serie_container:last").addClass("your_shows_serie_last");$(".your_shows_serie_container:first").addClass("your_shows_serie_first");$(".your_shows_serie_container").each(function(){show=$(this);if(!show.hasClass("your_shows_serie_first")){show.addClass("your_shows_serie_not_first")}if(!show.hasClass("your_shows_serie_last")){show.addClass("your_shows_serie_not_last")}});Cufon.refresh();setUpHoverThumbs();if(page_type=="page"&&page_type_id==1){init_scroller("yourShowsContainer")}}function follow_series(d,a,b){var c=1;if(a==0){showConfirm("Stop Following?","Are you sure you want to stop following this show?",getFollowAjax(d,a,b))}else{getFollowAjax(d,a,b).call()}return false}function getFollowAjax(c,a,b){return function(){$("#your_shows").html('<div style="margin:10px 13px;">'+formatLoadingMessage("Saving and refreshing...")+"</div>");if(isHomePage()||isProfilePage()){$("#all_shows_following_"+c).html('<div style="margin:4px;"><img src="/images/ajax-loader.gif" /></div>')}data={};data.series_id=c;data.follow=a;data.last_ep_version_id=b;if(typeof(page_type)!=="undefined"){data.page_type=page_type}if(typeof(page_type_id)!=="undefined"){data.page_type_id=page_type_id}if(typeof(series_id)!=="undefined"){data.view=series_id}$.ajax({type:"POST",url:"/account/follow",data:data,success:function(d){show_your_series_from_data(d);if(isHomePage()||isProfilePage()){reload_your_shows_following(c)}},error:function(d){$("#your_shows").html("<div style='padding:10px 13px;'>There was an error loading this section - please refresh the page to try again</div>")}})}}function isHomePage(){if(typeof(page_type)!=="undefined"&&page_type=="page"&&typeof(page_type_id)!=="undefined"&&page_type_id==1){return true}return false}function isProfilePage(){if(typeof(page_type)!=="undefined"&&page_type=="page"&&typeof(page_type_id)!=="undefined"&&page_type_id==4){return true}return false}$(document).ready(function(){load_your_series();$(document).bind("post_login",function(){reload_your_series()});$(".your_shows_serie_container .episode_img, .your_shows_serie_container .your_shows_img, .your_shows_serie_container .your_shows_text_line:not(.last_seen)").live("mouseover",function(){var a=$(this).parents(".your_shows_serie_container");$(".episode_img_hover",a).css("visibility","visible");$(".your_shows_text_line:not(.last_seen) a",a).css("color","#bd0000");$(".your_shows_text: a.series_title",a).css("color","#bd0000");$(".vote_icon a, .comment_icon a",a).css("background-position","0 0");$(".rating_activity_number",a).css("color","#000000")});$(".your_shows_serie_container .episode_img, .your_shows_serie_container .your_shows_img, .your_shows_serie_container .your_shows_text_line:not(.last_seen)").live("mouseout",function(){var a=$(this).parents(".your_shows_serie_container");$(".episode_img_hover",a).css("visibility","hidden");$(".your_shows_text_line:not(.last_seen) a",a).css("color","#000");$(".your_shows_text: a.series_title",a).css("color","#000000");$(".your_shows_activity .vote_icon a, .your_shows_activity .comment_icon a",a).css("background-position","0 -23px");$(".your_shows_text_line .vote_icon a, .your_shows_text_line .comment_icon a",a).css("background-position","0 -26px");$(".rating_activity_number",a).css("color","#777")});$("a.follow_link").live("mouseover",function(){$("a.follow_link").css("text-decoration","underline");$("a.follow_btn").css("background-position","0 0")});$("a.follow_link").live("mouseout",function(){$("a.follow_link").css("text-decoration","none");$("a.follow_btn").css("background-position","0 0")})});(function(a){a.jScrollPane={active:[]};a.fn.jScrollPane=function(c){c=a.extend({},a.fn.jScrollPane.defaults,c);var b=function(){return false};return this.each(function(){var u=a(this);var F=this;var ao=0;var M;var ap;var s;var ae=c.topCapHeight;var k;if(a(this).parent().is(".jScrollPaneContainer")){k=a(this).parent();ao=c.maintainPosition?u.position().top:0;var r=a(this).parent();M=r.innerWidth();ap=r.outerHeight();a(">.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown, >.jScrollCap",r).remove();u.css({top:0})}else{u.data("originalStyleTag",u.attr("style"));u.css("overflow","hidden");this.originalPadding=u.css("paddingTop")+" "+u.css("paddingRight")+" "+u.css("paddingBottom")+" "+u.css("paddingLeft");this.originalSidePaddingTotal=(parseInt(u.css("paddingLeft"))||0)+(parseInt(u.css("paddingRight"))||0);M=u.innerWidth();ap=u.innerHeight();k=a("<div></div>").attr({className:"jScrollPaneContainer"}).css({height:ap+"px",width:M+"px"});if(c.enableKeyboardNavigation){k.attr("tabindex",c.tabIndex)}u.wrap(k);k=u.parent();a(document).bind("emchange",function(aq,ar,p){u.jScrollPane(c)})}s=ap;if(c.reinitialiseOnImageLoad){var t=a.data(F,"jScrollPaneImagesToLoad")||a("img",u);var i=[];if(t.length){t.each(function(p,aq){a(this).bind("load readystatechange",function(){if(a.inArray(p,i)==-1){i.push(aq);t=a.grep(t,function(au,at){return au!=aq});a.data(F,"jScrollPaneImagesToLoad",t);var ar=a.extend(c,{reinitialiseOnImageLoad:false});u.jScrollPane(ar)}}).each(function(ar,at){if(this.complete||this.complete===undefined){this.src=this.src}})})}}var Z=this.originalSidePaddingTotal;var ak=M-c.scrollbarWidth-c.scrollbarMargin-Z;var V={height:"auto",width:ak+"px"};if(c.scrollbarOnLeft){V.paddingLeft=c.scrollbarMargin+c.scrollbarWidth+"px"}else{V.paddingRight=c.scrollbarMargin+"px"}u.css(V);var X=u.outerHeight();var S=ap/X;var W=S<0.99;k[W?"addClass":"removeClass"]("jScrollPaneScrollable");if(W){k.append(a("<div></div>").addClass("jScrollCap jScrollCapTop").css({height:c.topCapHeight}),a("<div></div>").attr({className:"jScrollPaneTrack"}).css({width:c.scrollbarWidth+"px"}).append(a("<div></div>").attr({className:"jScrollPaneDrag"}).css({width:c.scrollbarWidth+"px"}).append(a("<div></div>").attr({className:"jScrollPaneDragTop"}).css({width:c.scrollbarWidth+"px"}),a("<div></div>").attr({className:"jScrollPaneDragBottom"}).css({width:c.scrollbarWidth+"px"}))),a("<div></div>").addClass("jScrollCap jScrollCapBottom").css({height:c.bottomCapHeight}));var al=a(">.jScrollPaneTrack",k);var v=a(">.jScrollPaneTrack .jScrollPaneDrag",k);var an;var g=[];var ab;var T=function(){if(ab>4||ab%4==0){aj(ag+an*J)}ab++};if(c.enableKeyboardNavigation){k.bind("keydown.jscrollpane",function(p){switch(p.keyCode){case 38:an=-1;ab=0;T();g[g.length]=setInterval(T,100);return false;case 40:an=1;ab=0;T();g[g.length]=setInterval(T,100);return false;case 33:case 34:return false;default:}}).bind("keyup.jscrollpane",function(aq){if(aq.keyCode==38||aq.keyCode==40){for(var p=0;p<g.length;p++){clearInterval(g[p])}return false}})}if(c.showArrows){var Q;var z;var q=function(p){a("html").unbind("mouseup",q);Q.removeClass("jScrollActiveArrowButton");clearInterval(z)};var I=function(){a("html").bind("mouseup",q);Q.addClass("jScrollActiveArrowButton");ab=0;T();z=setInterval(T,100)};k.append(a("<a></a>").attr({href:"javascript:;",className:"jScrollArrowUp",tabindex:-1}).css({width:c.scrollbarWidth+"px",top:c.topCapHeight+"px"}).html("Scroll up").bind("mousedown",function(){Q=a(this);an=-1;I();this.blur();return false}).bind("click",b),a("<a></a>").attr({href:"javascript:;",className:"jScrollArrowDown",tabindex:-1}).css({width:c.scrollbarWidth+"px",bottom:c.bottomCapHeight+"px"}).html("Scroll down").bind("mousedown",function(){Q=a(this);an=1;I();this.blur();return false}).bind("click",b));var w=a(">.jScrollArrowUp",k);var n=a(">.jScrollArrowDown",k)}if(c.arrowSize){s=ap-c.arrowSize-c.arrowSize;ae+=c.arrowSize}else{if(w){var ac=w.height();c.arrowSize=ac;s=ap-ac-n.height();ae+=ac}}s-=c.topCapHeight+c.bottomCapHeight;al.css({height:s+"px",top:ae+"px"});var ah=a(this).css({position:"absolute",overflow:"visible"});var d;var G;var J;var ag=0;var D=S*ap/2;var H=function(aq,at){var ar=at=="X"?"Left":"Top";return aq["page"+at]||(aq["client"+at]+(document.documentElement["scroll"+ar]||document.body["scroll"+ar]))||0};var P=function(){return false};var af=function(){Y();d=v.offset(false);d.top-=ag;G=s-v[0].offsetHeight;J=2*c.wheelSpeed*G/X};var e=function(p){af();D=H(p,"Y")-ag-d.top;a("html").bind("mouseup",A).bind("mousemove",R);if(a.browser.msie){a("html").bind("dragstart",P).bind("selectstart",P)}return false};var A=function(){a("html").unbind("mouseup",A).unbind("mousemove",R);D=S*ap/2;if(a.browser.msie){a("html").unbind("dragstart",P).unbind("selectstart",P)}};var aj=function(aq){k.scrollTop(0);aq=aq<0?0:(aq>G?G:aq);ag=aq;v.css({top:aq+"px"});var ar=aq/G;u.data("jScrollPanePosition",(ap-X)*-ar);ah.css({top:((ap-X)*ar)+"px"});u.trigger("scroll");if(c.showArrows){w[aq==0?"addClass":"removeClass"]("disabled");n[aq==G?"addClass":"removeClass"]("disabled")}};var R=function(p){aj(H(p,"Y")-d.top-D)};var aa=Math.max(Math.min(S*(ap-c.arrowSize*2),c.dragMaxHeight),c.dragMinHeight);v.css({height:aa+"px"}).bind("mousedown",e);var U;var x;var m;var ad=function(){if(x>8||x%4==0){aj((ag-((ag-m)/2)))}x++};var am=function(){clearInterval(U);a("html").unbind("mouseup",am).unbind("mousemove",O)};var O=function(p){m=H(p,"Y")-d.top-D};var B=function(p){af();O(p);x=0;a("html").bind("mouseup",am).bind("mousemove",O);U=setInterval(ad,100);ad();return false};al.bind("mousedown",B);k.bind("mousewheel",function(aq,at){at=at||(aq.wheelDelta?aq.wheelDelta/120:(aq.detail)?-aq.detail/3:0);af();Y();var ar=ag;aj(ag-at*J);var p=ar!=ag;return !p});var f;var E;function K(){var p=(f-ag)/c.animateStep;if(p>1||p<-1){aj(ag+p)}else{aj(f);Y()}}var Y=function(){if(E){clearInterval(E);delete f}};var ai=function(au,p){if(typeof au=="string"){try{$e=a(au,u)}catch(at){return}if(!$e.length){return}au=$e.offset().top-u.offset().top}Y();var ar=X-ap;au=au>ar?ar:au;u.data("jScrollPaneMaxScroll",ar);var aq=au/ar*G;if(p||!c.animateTo){aj(aq)}else{k.scrollTop(0);f=aq;E=setInterval(K,c.animateInterval)}};u[0].scrollTo=ai;u[0].scrollBy=function(aq){var p=-parseInt(ah.css("top"))||0;ai(p+aq)};af();ai(-ao,true);a("*",this).bind("focus",function(au){var at=a(this);var aw=0;while(at[0]!=u[0]){aw+=at.position().top;at=at.offsetParent()}var p=-parseInt(ah.css("top"))||0;var av=p+ap;var ar=aw>p&&aw<av;if(!ar){var aq=aw-c.scrollbarMargin;if(aw>p){aq+=a(this).height()+15+c.scrollbarMargin-ap}ai(aq)}});if(c.observeHash){if(location.hash&&location.hash.length>1){setTimeout(function(){ai(location.hash)},a.browser.safari?100:0)}a(document).bind("click",function(aq){$target=a(aq.target);if($target.is("a")){var p=$target.attr("href");if(p&&p.substr(0,1)=="#"&&p.length>1){setTimeout(function(){ai(p,!c.animateToInternalLinks)},a.browser.safari?100:0)}}})}function C(p){a(document).bind("mousemove.jScrollPaneDragging",y);a(document).bind("mouseup.jScrollPaneDragging",o)}var N;var h;function L(){direction=N<0?-1:1;u[0].scrollBy(N/2)}function l(){if(h){clearInterval(h);h=undefined}}function y(ar){var at=u.parent().offset().top;var p=at+ap;var aq=H(ar,"Y");N=aq<at?aq-at:(aq>p?aq-p:0);if(N==0){l()}else{if(!h){h=setInterval(L,100)}}}function o(p){a(document).unbind("mousemove.jScrollPaneDragging").unbind("mouseup.jScrollPaneDragging");l()}k.bind("mousedown.jScrollPane",C);a.jScrollPane.active.push(u[0])}else{u.css({height:ap+"px",width:M-this.originalSidePaddingTotal+"px",padding:this.originalPadding});u[0].scrollTo=u[0].scrollBy=function(){};u.parent().unbind("mousewheel").unbind("mousedown.jScrollPane").unbind("keydown.jscrollpane").unbind("keyup.jscrollpane")}})};a.fn.jScrollPaneRemove=function(){a(this).each(function(){$this=a(this);var b=$this.parent();if(b.is(".jScrollPaneContainer")){$this.css({top:"",height:"",width:"",padding:"",overflow:"",position:""});$this.attr("style",$this.data("originalStyleTag"));b.after($this).remove()}})};a.fn.jScrollPane.defaults={scrollbarWidth:10,scrollbarMargin:5,wheelSpeed:18,showArrows:false,arrowSize:0,animateTo:false,dragMinHeight:1,dragMaxHeight:99999,animateInterval:100,animateStep:3,maintainPosition:true,scrollbarOnLeft:false,reinitialiseOnImageLoad:false,tabIndex:0,enableKeyboardNavigation:true,animateToInternalLinks:false,topCapHeight:0,bottomCapHeight:0,observeHash:true};a(window).bind("unload",function(){var c=a.jScrollPane.active;for(var b=0;b<c.length;b++){c[b].scrollTo=c[b].scrollBy=null}})})(jQuery);