var AUTHPOPUP_ACTION={FAVORITE:0,WATCHED:1,LINK:2};(function(A){A.fn.authPopup=function(B,E){var G=A(this).get(0);var C=A.data(G,"authPopup");if(A.authPopup){if(A.isFunction(A.authPopup[B])){A.authPopup[B](E)}}else{var D={};if(B){D=B}var F=A.extend({opacity:0.2,overlay:true,html:'                <div id="auth-popup-wrapper" style="display:none;">                     <table>                         <tbody>                             <tr>                                 <td class="tl"/><td class="b"/><td class="tr"/>                             </tr>                             <tr>                                 <td class="b"/>                                 <td class="body">                                     <div class="content">                                     </div>                                 </td>                                 <td class="b"/>                             </tr>                             <tr>                                 <td class="bl"/><td class="b"/><td class="br"/>                             </tr>                         </tbody>                     </table>                 </div>'},D);A.authPopup=new A.AuthPopup(G,F)}return this};A.AuthPopup=function(F,G){var D=this;A("body").append(G.html);var E=[];A("#auth-popup-wrapper").find(".b:first, .bl, .br, .tl, .tr").each(function(){E.push(new Image());E.slice(-1).src=A(this).css("background-image").replace(/url\((.+)\)/,"$1")});A("#auth-popup-wrapper .content").empty();A("#auth-popup-wrapper .content").append(A(F));A(F).hide();A("#auth-popup-close").click(function(){D.close()});A("#auth-login").click(function(){A("#auth-popup-register").fadeOut(function(){A("#auth-popup-login").fadeIn();if(A("#auth-popup h3").text()=="Register"){A("#auth-popup h3").html("Log In")}});return false});A("#auth-register").click(function(){A("#auth-popup-login").fadeOut(function(){A("#auth-popup-register").fadeIn();if(A("#auth-popup h3").text()=="Log In"){A("#auth-popup h3").html("Register")}});return false});this.open=function(J,I){var H=this;switch(J){case AUTHPOPUP_ACTION.FAVORITE:case AUTHPOPUP_ACTION.WATCHED:case AUTHPOPUP_ACTION.LINK:A("#auth-popup h3").html("You need to login or register to do that!");break;default:A("#auth-popup h3").html("Log In");break}if(A("auth-popup-overlay").length==0){A("body").append('<div id="auth-popup-overlay" class="auth-popup-hide"></div>')}A("#auth-popup-overlay").hide().addClass("auth-popup-overlaybg").css("opacity",G.opacity).click(function(){A(F).authPopup("close")}).fadeIn(200);A("#auth-popup-wrapper").css({top:C()[1]+(B()/10),left:385.5}).show();A(document).bind("keydown.authPopup",function(K){if(K.keyCode==27){H.close()}return true});A(F).fadeIn("normal");A("#auth-popup-wrapper").css("left",A(window).width()/2-(A("#auth-popup-wrapper table").width()/2));A("#login-username").focus()};this.close=function(){A(document).unbind("keydown.authPopup");A("#auth-popup-wrapper").fadeOut(function(){A("#auth-popup-wrapper .content").removeClass().addClass("content");A("#auth-popup-overlay").fadeOut(200,function(){A("#auth-popup-overlay").removeClass("auth-popup-overlaybg");A("#auth-popup-overlay").addClass("auth-popup-hide");A("#auth-popup-overlay").remove()});A(F).hide()})};function C(){var I,H;if(self.pageYOffset){H=self.pageYOffset;I=self.pageXOffset}else{if(document.documentElement&&document.documentElement.scrollTop){H=document.documentElement.scrollTop;I=document.documentElement.scrollLeft}else{if(document.body){H=document.body.scrollTop;I=document.body.scrollLeft}}}return new Array(I,H)}function B(){var H;if(self.innerHeight){H=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){H=document.documentElement.clientHeight}else{if(document.body){H=document.body.clientHeight}}}return H}}})(jQuery);