function General(){var b=this;jQuery("ul#errors").ajaxError(function(f,e,c,d){if(jQuery(this).children("li").length==0){jQuery.post("/index.php?znfModule=general&znfAction=uncheckedExceptions",{response:e.responseText});b.appendError(generalMessages.unknownServerError);jQuery("div#loading").hide()}f.stopPropagation();return false});jQuery("div.content div#login form#loginForm input#loginKey").val(jQuery("div.content div#login form#loginForm input#loginKey").attr("name"));jQuery("div.content div#login form#loginForm input#loginKey").attr("name",jQuery("div.content div#login form#loginForm input#loginKey").attr("id"));jQuery("div#menu ul li a#user").click(function(){return b.userAction(this)});jQuery("div#menu div#admin a#userList").click(function(){return b.userAction(this)});jQuery("div#menu ul li:lt(3) a").click(function(){return b.textbookAction(this)});var a={beforeSubmit:function(){return b.checkLoginFormData("div#menu")},resetForm:true,type:"post",success:function(c){b.loginResponse(c)},dataType:"xml"};jQuery("div#menu div#login form#loginForm").ajaxForm(a);jQuery("div#menu div#logout a").click(function(){return b.logoutAction(this)});jQuery("div#menu div#login a#passwordLost").click(function(){return b.passwordLost(this)});jQuery("div#loading").ajaxSend(function(){jQuery(this).show()}).ajaxStop(function(){jQuery(this).hide()});jQuery("div#errorDialog").ajaxSend(function(){b.clearError()});jQuery("body").ajaxSuccess(function(f,e,d){if(d.dataType=="xml"){var g=/^[\w\.\/]*\?\S*znfModule=(\w+)/;var i=/^[\w\.\/]*\?\S*znfAction=(\w+)/;var h=d.url.match(g);var c=d.url.match(i);pageTracker._trackPageview("/"+h[1]+"/"+c[1])}})}General.prototype.clearError=function(){jQuery("div#errorDialog").hide();jQuery("ul#errors").empty()};General.prototype.appendError=function(a){jQuery("ul#errors").append("<li>"+a+"</li>");jQuery("div#errorDialog").show()};General.prototype.target=null;General.prototype.user=null;General.prototype.textbook=null;General.prototype.userAction=function(a){if(this.user==null){this.user=new User()}return this.user.doAction(a)};General.prototype.textbookAction=function(a){if(this.textbook==null){this.textbook=new Textbook()}this.textbook.doAction(a);return false};General.prototype.unescapeHTML=function(a){return a.replace(/&(amp|[lg]t|quot);/g,function(b,d){var c={amp:"&",lt:"<",gt:">",quot:'"'};return c[d]})};General.prototype.checkResponse=function(c,e){var b=this;if(jQuery(c).find("errors").length>0){jQuery(c).find("errors error").each(function(){b.appendError(jQuery(this).text())});return false}if(jQuery(c).find("login").length>0){jQuery("div#page div#content").empty().html("<h3>"+generalMessages.authRequired+"</h3>");var d=jQuery("div#menu div#login").clone().removeClass("small").show();d.attr("id","loginClone");d.find("form#loginForm").attr("id","loginFormClone");d.find("input#loginKey").attr("id","loginKeyClone");d.find("input#username").attr("id","usernameClone");d.find("input#password").attr("id","passwordClone");d.find("a#passwordLost").attr("id","passwordLostClone");d.find("button#submitButton").attr("id","submitButtonClone");jQuery("div#page div#content").append(d);jQuery("div#page div#content div#loginClone a#passwordLostClone").click(function(){return b.passwordLost(this)});var a={beforeSubmit:function(){return b.checkLoginFormData("div#page","Clone")},resetForm:true,type:"post",success:function(f){b.loginResponse(f)},dataType:"xml"};jQuery("div#page div#content div#loginClone form#loginFormClone").ajaxForm(a);jQuery("div#menu div#login").hide();if(typeof e!=="undefined"){this.target=e}return false}if(jQuery(c).find('login-roles role[name="admin"]').length>0){jQuery("div#menu div#admin").show()}return true};General.prototype.checkLoginFormData=function(b,d){var c=new Array();var a=0;if(typeof(d)=="undefined"){d=""}this.clearError();if(jQuery.trim(jQuery(b+" div#login"+d+" form#loginForm"+d+" input#username"+d).val()).length==0){c[a]=userMessages.emptyUsername;++a}if(jQuery.trim(jQuery(b+" div#login"+d+" form#loginForm"+d+" input#password"+d).val()).length==0){c[a]=userMessages.emptyPassword;++a}if(c.length>0){for(var a=0;a<c.length;++a){this.appendError(c[a])}jQuery("div#errorDialog").show();return false}return true};General.prototype.showResponse=function(a){if(!this.checkResponse(a)){return false}jQuery("div#page div#content").empty();jQuery("div#page div#content").html(this.unescapeHTML(jQuery(a).find("content html").text()));return true};General.prototype.loginResponse=function(a){if(!this.checkResponse(a)){return}jQuery("div#menu div#login").hide();jQuery("div#menu div#logout").show();if(this.target!==null){jQuery(this.target).trigger("click");this.target=null;return true}};General.prototype.logoutAction=function(a){var c=this;var b=jQuery(a).attr("href");jQuery.get(b,null,function(d){if(!c.checkResponse(d)){return false}window.location="index.php"},"xml");return false};General.prototype.passwordLost=function(a){var c=this;var b=jQuery(a).attr("href");jQuery.get(b,null,function(d){if(!c.checkResponse(d)){return false}jQuery("div#page div#content").empty();jQuery("div#page div#content").html(c.unescapeHTML(jQuery(d).find("content html").text())).ready(function(){jQuery("div#page div#content form#lostPasswordForm input#key").val(jQuery("div#page div#content form#lostPasswordForm input#key").attr("name"));jQuery("div#page div#content form#lostPasswordForm input#key").attr("name",jQuery("div#page div#content form#lostPasswordForm input#key").attr("id"));var e={beforeSubmit:function(){c.checkForgotPasswordFormData},resetForm:false,type:"post",success:function(f){c.showResponse(f)},dataType:"xml"};jQuery("div#page div#content form#lostPasswordForm").ajaxForm(e)})},"xml");return false};General.prototype.checkForgotPasswordFormData=function(b){var c=new Array();var a=0;this.clearError();if(jQuery.trim(jQuery("div#content form#lostPasswordForm input#username").val()).length==0){c[a]=userMessages.emptyUsername;++a}if(jQuery.trim(jQuery("div#content form#lostPasswordForm input#email").val()).length==0){c[a]=userMessages.emptyEmail;++a}if(c.length>0){for(var a=0;a<c.length;++a){this.appendError(c[a])}jQuery("div#errorDialog").show();return false}return true};jQuery(document).ready(function(){var a=new General()});