flash.onFail(function(){on_dom_load(function(){$("chat_loading_spinner").hide();$("chat_lines").insert('<div style="text-align: center; padding-top: 160px; font-weight: bold;">'+(MobileBrowser()?s_("Phone not supported."):s_("Plugin missing."))+"</div>")})});
function detect_and_load_chat(){var a=decodeURIComponent(readCookie("chat_saved_on_"+PP.channel)||"");if(a){$("chat_text_input").value=a;eraseCookie("chat_saved_on_"+PP.channel)}create_chat();$("chat_text_input").onkeypress=function(b){return CurrentChat.onkeypress(b)}.bindAsEventListener(CurrentChat);$("chat_text_input").onkeyup=function(b){return CurrentChat.onkeyupordown(b)}.bindAsEventListener(CurrentChat);$("chat_text_input").onkeydown=function(b){return CurrentChat.onkeyupordown(b)}.bindAsEventListener(CurrentChat);
$("chat_settings_switch_type").hide()}function chat_login_with_refresh(a){var b=open(a,"Chat Login Window");if(b)x=new PeriodicalExecuter(function(){if(b.closed){x.stop();location.reload()}});else CurrentChat.admin_message(_("Please enable popups"))}function login_to_chat(){CurrentChat.save_attempted_message();$("chat_login").hide();$("chat_returning").hide();$("temp_cover").hide();$("chat_line_list").update();create_chat();CurrentChat.show_login()}
function create_chat(){if(CurrentChat&&CurrentChat.ircSystem&&CurrentChat.ircSystem.disconnect){CurrentChat.ircSystem.disconnect();CurrentChat.joined_once=false}CurrentChat=new Chat;CurrentChat.connect(PP.channel);CurrentChat.admin_message(_("Loading chat..."));hide_chat_viewers_menu();hide_chat_settings_menu();CurrentChat.clear_user_list();$$("#chat_credentials .chat_settings").invoke("hide");$$("#jtv_settings").invoke("show");$("char_count")&&$("char_count").hide();$("post_to_twitter")&&$("post_to_twitter").hide()}
function toggle_chat(){if($("jtv_chat").style.display==""){log_stat("toggle_chat_click",["action=hide"]);$("chat_redisplay_holder").show();Effect.Fade("jtv_chat",{duration:0.25,from:1,to:0,afterFinish:LateLoader.reposition_all_ads});hide_chat_viewers_menu();hide_chat_settings_menu()}else{log_stat("toggle_chat_click",["action=show"]);$("chat_redisplay_holder").hide();Effect.Appear("jtv_chat",{duration:0.25,from:0,to:1,afterFinish:LateLoader.reposition_all_ads})}}
function start_time_since_commercial(){window.time_since_c_min=-1;window.time_since_c_hour=0;window.commercial_timer!=null&&clearInterval(window.commercial_timer);window.commercial_timer=setInterval("update_commercial_timer()",6E4);update_commercial_timer();$("time_since_commercial").show()}
function update_commercial_timer(){window.time_since_c_min+=1;if(window.time_since_c_min>59){window.time_since_c_min=0;window.time_since_c_hour+=1}$("time_since_commercial").innerHTML=""+window.time_since_c_hour+"h:"+window.time_since_c_min+"m since last /commercial"}
function show_share(){$("share_forms").style.display==""?Element.hide("share_forms"):Element.show("share_forms");if(PP.user_id){if($("share_friends").innerHTML.strip()==""){$("share_friends").innerHTML='<img src="/images/share_spinner.gif" />';new Ajax.Updater("share_friends","/community/share_friends",{onComplete:LateLoader.reposition_all_ads})}if($("share_contacts").innerHTML.strip()==""){$("share_friends").innerHTML='<img src="/images/share_spinner.gif" />';new Ajax.Updater("share_contacts","/community/share_contacts",
{onComplete:LateLoader.reposition_all_ads})}}else $("email-share-form").hide();LateLoader.reposition_all_ads()}function toggle_chat_settings_menu(){CurrentChat.setup_chat_settings_menu();$("chat_settings_dropmenu_button").toggleClassName("toggled");$("chat_settings_dropmenu").toggle();hide_chat_viewers_menu()}function hide_chat_viewers_menu(){$("chat_viewers_dropmenu_button").removeClassName("toggled");$("chat_viewers_dropmenu").hide()}
function toggle_chat_viewers_menu(){$("chat_viewers_dropmenu_button").toggleClassName("toggled");$("chat_viewers_dropmenu").toggle();hide_chat_settings_menu()}function hide_chat_settings_menu(){$("chat_settings_dropmenu_button").removeClassName("toggled");$("chat_settings_dropmenu").hide();$("chat_colors").hide()}
function popout_chat(){toggle_chat();if(!window.popout_chat_window||window.popout_chat_window.closed)window.popout_chat_window=window.open("/chat/embed?channel="+PP.channel+"&popout_chat=true","_blank","right=50,top=50,width=400,height=600,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no");LateLoader.refresh();popout_chat_window.focus();wait_for_chat_popout_close()}
function return_chat(){window.popout_chat_window&&window.popout_chat_window.close()}function wait_for_chat_popout_close(){if(window.popout_chat_window&&window.popout_chat_window.closed)window.location.href=window.location.href;else setTimeout(wait_for_chat_popout_close,100)}function show_category_chooser(a){$("category_chooser").show();$("channel_cover").show();refresh_category_options(a);hide_flash_player();window.scrollTo(0,0)}
function hide_category_chooser(){$("category_chooser").hide();$("channel_cover").hide();show_flash_player()}var ad_timer=15;Event.observe(window,"load",function(){$("ad_container")&&window.setInterval(function(){ad_timer-=1;if(ad_timer>=0)$("ad_counter").innerHTML=ad_timer;ad_timer==0&&toggleAdElements()},1E3)});function toggleAdElements(){$("ad_timer_txt").hide();ad_timer=0;$$(".ad_toggle").each(function(a){Element.toggle(a)})}
function toggle_edit_status(){if(PP.login!=PP.channel)return false;$("channel_status_message").toggle();$("toggle_edit_status").toggle();$("channel_status_form").toggle()}function switch_data_tab(a){$$("#info .content").each(function(b){b.id==a?b.addClassName("selected"):b.removeClassName("selected")});$$("#info .tab").each(function(b){b.className=b.id==a+"_tab"?"tab selected col_bg":"tab"});LateLoader.refresh()}
function selected_data_tab(){return($$("#data_tabs li.selected")||[{id:""}])[0].id.replace(/_tab/g,"")}var channel_action_tab_loaded={};
function switch_action_tab(a){if(a=="report"&&!channel_action_tab_loaded[a]){new Ajax.Updater("report_form","/channel/report_form?channel="+PP.channel,{method:"GET"});channel_action_tab_loaded[a]=true}$$("#actions .tabs .action").each(function(b){b.id==a+"_tab"?b.addClassName("selected"):b.removeClassName("selected")});$$("#action_contents .top").each(function(b){b.id==a+"_contents"?b.addClassName("selected"):b.removeClassName("selected")});a=="clip"&&show_dvr_url()}
function switch_link_embed(a){$$(".share_input_label").each(function(b){b.removeClassName("selected")});$("share_"+a+"_label").addClassName("selected");$$(".share_input").each(function(b){b.hide()});$("share_"+a+"_input").show()}Event.observe(window,"load",make_floaty_buttons);function make_floaty_buttons(){$$("q.floaty_button")&&$$("a.floaty_button button").each(function(a){$(a).onmouseover=function(){show_floaty_text(a)};$(a).onmouseout=function(){hide_floaty_text(a)}})}
function show_floaty_text(a){a=$(a).previous("span",0);new Effect.Appear(a,{duration:0.2});new Effect.Scale(a,100,{scaleFrom:0,scaleY:false,scaleContent:false,scaleMode:"contents",duration:0.2})}function hide_floaty_text(a){a=$(a).previous("span",0);new Effect.Fade(a,{duration:0.2});new Effect.Scale(a,0,{scaleY:false,scaleContent:false,scaleMode:"contents",duration:0.2})}
function show_infotip(a,b){var c=$("info_tip");c.down("p").innerHTML=b;$(c).show();var e={setWidth:false,setHeight:false,offsetLeft:-(c.offsetWidth/2-$(a).offsetWidth/2),offsetTop:-40};c.clonePosition($(a),e)}function resize_status(){var a=$("channel_status_message"),b=a.innerHTML.length;a.setStyle({fontSize:(b<31?2:b<115?1.2:1)+"em"})}function resize_title(){var a=$("channel_title");if(a)a.setStyle({fontSize:(a.innerHTML.length<25?1:0.75)+"em"})}
function setup_one_click_favorites(){switch_action_tab=function(){var a=switch_action_tab,b=!PP.is_favorite?"remove":"add",c=function(e){growl(e);$("favorite_contents").update(e);$$("#actions .tabs .action").each(function(d){d.id=="favorite_tab"?d.addClassName("selected"):d.removeClassName("selected")});$$("#action_contents .top").each(function(d){d.id=="favorite_contents"?d.addClassName("selected"):d.removeClassName("selected")})};return function(e){if(e==="favorite"){if(!PP.user_id){show_login_box("Please log in to follow "+
PP.channel);return false}if(PP.login===PP.channel){c("This is you.");return false}e=Ajax.Request;b=b=="add"?"remove":"add";var d=["/community/",b,"_favorite/",PP.channel_id,"?oneclick="];new e(d.join.call(d,""),{onSuccess:function(f){c(f.responseText)}})}else a(e)}}()}function parse_broadcast_url_hash(){return/^#\/w\/(\w+)\/?(\w+)?/.exec(window.location.hash)}function broadcast_id_from_url(){var a=parse_broadcast_url_hash();if(a)return a[1]}
function broadcast_part_from_url(){var a=parse_broadcast_url_hash();if(a)return a[2]||"1"}EventBank.register_handler("channel:on_broadcast_part_change",function(a,b){var c="/w/"+a;if(b&&parseInt(b,10)>1)c+="/"+b;window.location.hash=c;fill_share_links(c)});
(function(a){a(function(){var b=a("#related_channels");"ajaxDom"in b&&b.ajaxDom("/"+PP.channel+"/related");a("#gameselector_edit_button").click(function(c){if(PP&&PP.category==="gaming"){c.preventDefault();c=_('To manage your game you should use your <a href="http://twitch.tv/broadcast/dashboard">Dashboard</a> on <a href="http://twitch.tv">TwitchTV</a>');a("#gameselector_edit_button").attr("title",c).tipsy({trigger:"manual",clickClose:true,gravity:"nw",fade:true,html:true}).tipsy("show")}})})})($j);

