jQuery(document).ready(function(){jQuery.preLoadImages("/images/login/login.png","/images/login/dialog-flat.gif","/images/login/close.gif","/images/login/login-text.gif","/images/login/forgotten-password.gif","/images/faq/bubble.gif","/images/faq/bubble.png");jQuery("div#dialog").dialog({autoOpen:false,height:205,width:544,modal:true});var a=jQuery("base").attr("href");jQuery("div#main div.genericForm").each(function(){jQuery(this).find("input:text:visible:first").focus()});jQuery("a#addCodeBtn").click(function(){openDialog("#addCodeDialogForm");return false});jQuery("#addCodeButton").click(function(){var c=jQuery("#addCodeDialogForm p.message span");var h=jQuery("#activation_code1").val();var g=jQuery("#activation_code2").val();var f=jQuery("#activation_code3").val();var e=jQuery("#activation_code4").val();if((h.length==0)||(h.length<4)){setDialogMessage(c,"Invalid Code.")}else{if((g.length==0)||(g.length<4)){setDialogMessage(c,"Invalid Code.")}else{if((f.length==0)||(f.length<4)){setDialogMessage(c,"Invalid Code.")}else{if((e.length==0)||(e.length<4)){setDialogMessage(c,"Invalid Code.")}else{var b=a+"en/ajax/setcode";var d=({activation_code1:h,activation_code2:g,activation_code3:f,activation_code4:e});jQuery.post(b,d,function(i,j){if(i=="success"){setDialogMessage(c,"Code Accepted.");window.location.href=a+"en/profile"}else{if(i=="invalid"){setDialogMessage(c,"Invalid Code.")}else{if(i=="inactive"){setDialogMessage(c,"You need to activate your account before you can login.")}}}})}}}}return false});if(loggedIn==0){jQuery("li#navAccount a").click(function(){openDialog("#loginForm");return false});jQuery("#loginForm a#forgottenPassword").click(function(){openDialog("#forgottenPasswordForm");return false});jQuery("#forgottenPasswordForm a#loginLink").click(function(){openDialog("#loginForm");return false});jQuery("#loginButton").click(function(){var e=jQuery("#loginForm p.message span");var d=jQuery("#loginForm input[name='email']").val();var c=jQuery("#loginForm input[type='password']").val();if(!validate_email(d)){setDialogMessage(e,"Please provide a valid email address.")}else{if(!c.length){setDialogMessage(e,"Please provide your password.")}else{setDialogMessage(e,"");var b=a+"en/ajax/login";var f=({email:d,password:c});jQuery.post(b,f,function(g,h){if(g=="success"){window.location.href=a+"en/profile"}else{if(g=="invalid"){setDialogMessage(e,"Invalid login details.")}else{if(g=="inactive"){setDialogMessage(e,"You need to activate your account before you can login.")}}}},"json")}}return false});jQuery("#forgottenPasswordButton").click(function(){var d=jQuery("#forgottenPasswordForm p.message span");var c=jQuery("#forgottenPasswordForm input[name='email']").val();if(!validate_email(c)){setDialogMessage(d,"Please provide a valid email address.")}else{setDialogMessage(d,"");var b=a+"en/ajax/forgotten-password";var e=({email:c});jQuery.post(b,e,function(f,g){if(f=="success"){setDialogMessage(d,"Please check your email for reset instructions.")}},"json")}return false})}jQuery("#vote_button").click(function(){var b=jQuery("input[name='vote']:checked").val();var e=jQuery("#poll_id").val();var c=a+"en/ajax/castvote";if(b!==undefined&&typeof(voteInProgress)=="undefined"){var d=({poll_id:e,choice:b});voteInProgress=true;jQuery.post(c,d,function(f,h,g){jQuery("#vote-container").html(f)})}return false})});function setDialogMessage(a,b){a.hide();if(b.length){a.html(b);a.fadeIn("medium")}else{a.html("");a.hide()}}function openDialog(b){var a=jQuery("div#dialog");jQuery("form").attr("autocomplete","off");a.children(".dialogForm").hide();a.children(b).show();if(!a.dialog("isOpen")){a.dialog("open");jQuery(".cui-widget-overlay").bind("click",closeDialogOnFocusLost)}a.find("input:text:visible:first").focus()}function closeDialogOnFocusLost(a){closeDialog()}function closeDialog(){jQuery("div#dialog").dialog("close")}function validate_email(a){var b=/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;if(b.test(a)==false){return false}return true}var JQ=jQuery.noConflict();var loaded=false;var anchor=null;var offset=null;JQ(function(){JQ("#faqContent").addClass("faqHide");JQ("a.topLink").hide();loaded=true;dialogHeight=221;JQ("#bubble").dialog({autoOpen:false,bgiframe:true,height:dialogHeight,width:531,modal:true,closeOnEscape:true,resizable:false,bgiframe:true})});function closePopupOnFocusLost(a){closePopup()}function closePopup(){JQ("#bubble").dialog("close")}function loadPopup(a){if(loaded){JQ("#bubble").show();var b="q_"+a;a="item_"+a;var c=jQuery(a).html();moveToDialog();JQ("#bubble div.bubbleText").html(document.getElementById(a).innerHTML);JQ("#bubble h2").html(document.getElementById(b).innerHTML);JQ("#bubble").dialog("option","position",getDialogOffset());JQ("#bubble").dialog("open");JQ(".cui-widget-overlay").bind("click",closePopupOnFocusLost)}}function isScrolledIntoView(c){var d=JQ(window).scrollTop();var b=d+JQ(window).height();var a=c+dialogHeight;return((a>=d)&&(c<=b)&&(a<=b)&&(c>=d))}function moveToDialog(){setOffset();var a=offset.top;if(!isScrolledIntoView(a)){JQ(document).scrollTop(a)}}function getDialogOffset(){setOffset();var a=offset.top-jQuery(document).scrollTop();var b=offset.left-jQuery(document).scrollLeft();return[b,a]}function setOffset(){anchor=jQuery("#genericTitle");offset=anchor.offset();offset.top=offset.top+55};
