function get_element_from_event(B,D){var C=$(B.target);var A=null;if(C.is(D)){A=C}else{if(C.parents(D).length){A=C.parents(D+":first")}}return A}$(document).ready(function(){$("#search-input").inputHint("Search","color: #aaa");$("#auth-popup").authPopup();$("#login-link").click(function(){$("#auth-popup-register").hide();$("#auth-popup-login").show();$("#auth-popup").authPopup("open");$("#auth-popup h3").html("Login");return false});$("#register-link").click(function(){$("#auth-popup-register").show();$("#auth-popup-login").hide();$("#auth-popup").authPopup("open");$("#auth-popup h3").html("Register");return false});$(".requires-login").click(function(){if(!loggedIn){$("#auth-popup").authPopup("open",AUTHPOPUP_ACTION.LINK);return false}});$("[id^=follow_]").click(function(){var B=$(this).attr("id").split("_")[1];if(loggedIn){var A=$(this);$.post("/xhr/follow-show/",{show_id:B},function(C){if(C.status=="success"){$("#following_"+B).show();A.hide();$("#unfollow_"+B).show();var D=parseInt($("#num-followers_"+B).html());$("#num-followers_"+B).html(D+1)}},"json")}else{$("#auth-popup").authPopup("open",AUTHPOPUP_ACTION.FAVORITE)}return false});$("[id^=unfollow_]").click(function(){var B=$(this).attr("id").split("_")[1];var A=$(this);$.post("/xhr/unfollow-show/",{show_id:B},function(C){if(C.status=="success"){$("#following_"+B).hide();A.hide();$("#follow_"+B).show();var D=parseInt($("#num-followers_"+B).html());$("#num-followers_"+B).html((D-1).toString())}},"json");return false});$("a[id^=watch_]").click(function(){var B=$(this).attr("id").split("_")[1];if(loggedIn){var A=$(this);$.post("/xhr/watched-episode/",{episode_id:B},function(C){if(C.status=="success"){A.hide();$("#unwatch_"+B).show()}},"json")}else{$("#auth-popup").authPopup("open",AUTHPOPUP_ACTION.WATCHED)}return false});$("a[id^=unwatch_]").click(function(){var B=$(this).attr("id").split("_")[1];var A=$(this);$.post("/xhr/unwatched-episode/",{episode_id:B},function(C){if(C.status=="success"){A.hide();$("#watch_"+B).show()}},"json");return false});$(".next-episode-box").equalHeight();$(".show-box").hover(function(A){$(this).find(".show-box-actions").fadeIn()},function(A){$(this).find(".show-box-actions").fadeOut()});$("#splash-panel").hover(function(){$("#splash-panel-close").show()},function(){$("#splash-panel-close").hide()});$("#splash-panel-close").click(function(){$("#splash-panel").fadeOut()})});jQuery.fn.equalHeight=function(){tallest=0;this.each(function(){thisHeight=$(this).height();if(thisHeight>tallest){tallest=thisHeight}});this.height(tallest)};jQuery.fn.inputHint=function(B,A){var C=this;C.data("changed",false).attr("style",A).val(B).focus(function(){if(!$(this).data("changed")){$(this).attr("style","").val("")}}).blur(function(){if($(this).val()===""){$(this).attr("style",A).val(B).data("changed",false)}}).change(function(){if($(this).val()!==""){$(this).data("changed",true)}});$(C.attr("form")).submit(function(){if(!C.data("changed")){C.val("")}})};