$(function(){if($("#logout").length>0){$("#logout").click(function(a){var b=$(this);ajaxLoad.run();$.ajax({type:"post",url:"http://"+base_url+b.attr("href"),error:function(){ajaxLoad.end();var c=new InfoBox(1,"Oops! Logout Error");c.addMsg("I don't think that was suppose to happen.<br /><br />It is probably best if you try again.");c.display()},success:function(){ajaxLoad.end();window.location=window.location.toString()}});a.preventDefault()})}if($(".register").length>0){$(".register").click(function(a){var b=$(this);if($("#register-form").length==0){ajaxLoad.run();$.ajax({type:"get",url:"http://"+base_url+b.attr("href"),error:function(){ajaxLoad.end();var c=new InfoBox(1,"Oops! Register Error");c.addMsg("It seems like you cannot register at the moment.<br /><br />Please try again.");c.display()},success:function(c){ajaxLoad.end();$(c).appendTo("#wrapper");$("#username").focus();$("#pwd-re").keyup(function(){if($(this).val()!=$("#pwd").val()){if($(".no-match").length==0){$(this).parent().append('<span class="no-match">The passwords do not match.</span>')}}else{$(".no-match").remove()}});$("#register-close").click(function(){$(this).parent().parent().fadeTo(2000,0,function(){$(this).remove()})});$("#register-form").submit(function(d){var e=$(this);if($(".no-match").length>0){$("#pwd-re").focus()}else{var k=jQuery.trim($("#username").val());var f=jQuery.trim($("#email").val());var i=jQuery.trim($("#pwd").val());var h=$("#terms").attr("checked");var j=new Array();if(k.length>20){j[j.length]="Your username is too long."}else{if(k.length<6){j[j.length]="Your username is too short."}else{if(!RegexTester.testUserName(k)){j[j.length]="A username must start with a letter. And be made up of letters, numbers and underscore."}}}if(f.length<7){j[j.length]="Your email address is too short."}else{if(!RegexTester.testEmail(f)){j[j.length]="Invalid email address."}}if(i.length<6){j[j.length]="A password must not be less than 6 characters."}else{if(i.length>15){j[j.length]="A password must not be longer than 15 characters."}else{if(!RegexTester.testPassword(i)){j[j.length]="A password must contain only uppercaase characters, lowercase characters and numbers. (Must contain 1 of each.)"}}}if(!h){j[j.length]="You must agree to the Terms and Conditions before you register."}if(j.length!=0){$("#register-errors").remove();var g='<ul id="register-errors"></ul>';$(g).prependTo(e.parent());jQuery.each(j,function(){var l="<li>"+this+"</li>";$(l).appendTo("#register-errors")})}else{ajaxLoad.run();$("#register-form-submit").attr("disabled",true);$.ajax({type:"post",url:"http://"+base_url+$(this).attr("action"),data:"username="+k+"&email="+f+"&pwd="+i,error:function(){ajaxLoad.end();$("#register-errors").remove();var l='<ul id="register-errors"></ul>';$(l).prependTo(e.parent());l="<li>Oops! You cannot be registered at the moment. Please try again.</li>";$(l).appendTo("#register-errors")},success:function(l){ajaxLoad.end();if(l!=1){$("#register-errors").remove();var m='<ul id="register-errors"></ul>';$(m).prependTo(e.parent());$("<li>"+l+"</li>").appendTo("#register-errors")}else{window.location=window.location.toString()}}});$("#register-form-submit").attr("disabled",false)}}d.preventDefault()})}})}a.preventDefault()})}if($("#login").length>0){$("#login").click(function(a){var b=$(this);if($("#login-form").length==0){ajaxLoad.run();$.ajax({type:"get",url:"http://"+base_url+b.attr("href"),error:function(){ajaxLoad.end();var c=new InfoBox(1,"Oops! Login Error");c.addMsg("It seems like you cannot login at the moment.<br /><br />Please try again.");c.display()},success:function(c){ajaxLoad.end();$(c).appendTo("#wrapper");$("#username").focus();$("#login-close").click(function(){$(this).parent().parent().fadeTo(2000,0,function(){$(this).remove()})});$("#recover-pwd").click(function(d){var e=$(this);var g=$("#login-form-container");var i=new Array();var h=jQuery.trim($("#username").val());if(h.length>20){i[i.length]="Your username is too long. Password cannot be recovered."}else{if(h.length<6){i[i.length]="Your username is too short. Password cannot be recovered."}}if(i.length!=0){$("#login-errors").remove();var f='<ul id="login-errors"></ul>';$(f).prependTo(g);jQuery.each(i,function(){var j="<li>"+this+"</li>";$(j).appendTo("#login-errors")})}else{ajaxLoad.run();$("#login-form-submit").attr("disabled",true);$.ajax({type:"post",url:"http://"+base_url+e.attr("href"),data:"username="+h,error:function(){ajaxLoad.end();$("#login-errors").remove();var j='<ul id="login-errors"></ul>';$(j).prependTo(g);j="<li>Oops! You cannot be logged in at the moment. Please try again.</li>";$(j).appendTo("#login-errors")},success:function(j){ajaxLoad.end();if(j!=1){$("#login-errors").remove();var k='<ul id="login-errors"></ul>';$(k).prependTo(g);$("<li>"+j+"</li>").appendTo("#login-errors")}else{var l=InfoBox(1,"Password Recovery");l.addMsg("Your password has been updated.<br />A copy of your new password has been sent to your email address.");l.addTimer(7000);l.display()}}});$("#login-form-submit").attr("disabled",false)}d.preventDefault()});$("#login-form").submit(function(d){var e=$(this);var i=jQuery.trim($("#username").val());var g=jQuery.trim($("#pwd").val());var h=new Array();if(i.length>20){h[h.length]="Your username is too long."}else{if(i.length<6){h[h.length]="Your username is too short."}}if(g.length<6){h[h.length]="A password must not be less than 6 characters."}else{if(g.length>15){h[h.length]="A password must not be longer than 15 characters."}}if(h.length!=0){$("#login-errors").remove();var f='<ul id="login-errors"></ul>';$(f).prependTo(e.parent());jQuery.each(h,function(){var j="<li>"+this+"</li>";$(j).appendTo("#login-errors")})}else{ajaxLoad.run();$("#login-form-submit").attr("disabled",true);$.ajax({type:"post",url:"http://"+base_url+$(this).attr("action"),data:"username="+i+"&pwd="+g,error:function(){ajaxLoad.end();$("#login-errors").remove();var j='<ul id="login-errors"></ul>';$(j).prependTo(e.parent());j="<li>Oops! You cannot be logged in at the moment. Please try again.</li>";$(j).appendTo("#login-errors")},success:function(j){ajaxLoad.end();if(j!=1){$("#login-errors").remove();var k='<ul id="login-errors"></ul>';$(k).prependTo(e.parent());$("<li>"+j+"</li>").appendTo("#login-errors")}else{window.location=window.location.toString()}}});$("#login-form-submit").attr("disabled",false)}d.preventDefault()})}})}a.preventDefault()})}});