function member_signin(a){var b=$("#signin_remember").is(":checked")?90:0;if($("#signin_email_address").val().indexOf("@")&&$("#signin_password").val().length>2){$.get("/cgi-bin/signin.cgi",$("#signin_form").serialize(),function(c){$(c).find("results").each(function(){var c=parseInt($(this).find("reason").text());if(c==1){$.cookie("no_facebook",0,{path:"/",domain:".studylight.org",expires:-90});$.cookie("memberData",$(this).find("memberData").text(),{path:"/",domain:".studylight.org",expires:b});$.cookie("biblegroupData",$(this).find("biblegroupData").text(),{path:"/",domain:".studylight.org",expires:b});$.cookie("searchData",$(this).find("searchData").text(),{path:"/",domain:".studylight.org",expires:b});$.cookie("resourcesData",$(this).find("resourcesData").text(),{path:"/",domain:".studylight.org",expires:b});var f=$(this).find("biayData").text();if(f!=null){$.cookie("biayData",f,{path:"/",domain:".studylight.org",expires:b})}$.cookie("languageData",$(this).find("languageData").text(),{path:"/",domain:".studylight.org",expires:b});if(!a){$("#nav_signin").hide();alert("You have been logged into the system. Enjoy!");window.location.reload()}else{$("#nav_signin").hide();$("#nav_signout").show()}}else if(c==2){alert("Sorry but you have not confirmed your email address.\nPlease check your email box for the confirmation email.")}else if(c==3){alert("Sorry but your records show that this email\nhas been blacklisted due to activity that violates the 'Terms of Use'.")}else if(c==4){alert("Your email address was found in the system.\nHowever your password didn't match what is on record.\nPlease try again or use the link to recover a lost password.")}else{alert("Sorry but the system was unable to find a member\nmatching this email address.\nPlease check the spelling and try again.")}})},"xml");return false}else{alert("You must enter a valid email address and password");return false}}function member_signup(){if($("#register_name_first").val().length<2||$("#register_name_last").val().length<2){alert("You must supply a first and last name.");$("#register_name_first").focus();return false}else if($("#register_email_address").val().indexOf("@")==-1){alert("Sorry but your email address does not seem valid.  Please check your spelling.");$("#register_email_address").focus();return false}else if($("#register_password").val().length<2){alert("Sorry but you must supply a password.");$("#register_password").focus();return false}else if($("#register_gender option[value='none']").attr("selected")){alert("Sorry but you must select your gender.");$("#register_gender").focus();return false}else if($("#register_birthday_month option[value='00']").attr("selected")||$("#register_birthday_day option[value='00']").attr("selected")||$("#register_birthday_year option[value='00']").attr("selected")){alert("Sorry but you must select a month, day AND year of your birthday.");$("#register_birthday_month").focus();return false}else{$.get("http://new.studylight.org/cgi-bin/signup.cgi",$("#signup_form").serialize(),function(a){$(a).find("results").each(function(){var a=parseInt($(this).find("reason").text());if(a==1){alert("An email had been sent to your inbox with\ninstructions regarding activating your account.");window.location.reload()}else if(a==2){alert("Sorry but you have not confirmed your email address.\nPlease check your email box for the confirmation email.")}else if(a==3){alert("Sorry but your records show that this email has\nbeen blacklisted due to activity that violates the 'Terms of Use'.")}else if(a==5){alert("Your email address was already found in the system.\nIf you have forgotten your password,\nplease use the link to recover a lost password.")}else{alert("Sorry but the system encounterd a problem\nduring the process. Please try again later.")}})},"xml")}return false}var signin_ajax=0;var signup_ajax=0;$(window).resize(function(){$("fieldset#signin_menu").get_position(".signin",{anchor:["tr","br"],offset:[-2,-8]});$("fieldset#signup_menu").get_position(".signin",{anchor:["tr","br"],offset:[-2,-8]})});$(document).ready(function(){$("fieldset#signin_menu").get_position(".signin",{anchor:["tr","br"],offset:[-2,-8]});$("fieldset#signup_menu").get_position(".signin",{anchor:["tr","br"],offset:[-2,-8]});if($.cookie("memberData")){$("#nav_signin").hide();$("#nav_signout").show()}else{if($.cookie("no_facebook")!=1){FB.getLoginStatus(function(a){if(a.authResponse){FB.api("/me",function(a){$("#signin_menu").html("").load("/ajax/signin.html",function(){signin_ajax=1;$("#signin_email_address").val(a.email);$("#signin_password").val("facebook_signin");$("#signin_remember").attr("checked",true);$("#user_id").val(a.id);$("#user_first_name").val(a.first_name);$("#user_last_name").val(a.last_name);$("#user_gender").val(a.gender);$("#user_birthday").val(a.birthday);member_signin("stealth")});return false})}else{FB.Event.subscribe("auth.statusChange",function(a){if(a.authResponse){FB.api("/me",function(a){signin_ajax=1;$("#signin_email_address").val(a.email);$("#signin_password").val("facebook_signin");$("#signin_remember").attr("checked",true);$("#user_id").val(a.id);$("#user_first_name").val(a.first_name);$("#user_last_name").val(a.last_name);$("#user_gender").val(a.gender);$("#user_birthday").val(a.birthday);member_signin()});return false}})}})}else{$.cookie("no_facebook",1,{path:"/",domain:".studylight.org",expires:90})}}$(".signup").click(function(){if(signup_ajax!=1){$("#signup_menu").html("").load("/ajax/signup.html");signup_ajax=1}$("fieldset#signin_menu").toggle();$("fieldset#signup_menu").toggle()});$(".signout").click(function(){$.cookie("memberData",null,{path:"/",domain:".studylight.org",expires:-90});$.cookie("biblegroupData",null,{path:"/",domain:".studylight.org",expires:-90});$.cookie("biayData",null,{path:"/",domain:".studylight.org",expires:-90});$.cookie("resourcesData",null,{path:"/",domain:".studylight.org",expires:-90});$.cookie("searchData",null,{path:"/",domain:".studylight.org",expires:-90});$.cookie("languageData",null,{path:"/",domain:".studylight.org",expires:-90});$.cookie("fbs_38d1e3d23e6e0048b4114008c5d80f64",null,{path:"/",domain:".studylight.org",expires:-90});$.cookie("no_facebook",0,{path:"/",domain:".studylight.org",expires:-90});alert("you have been logged out of the system.  Good bye!");window.location.reload();return false});$(".signin").click(function(a){a.preventDefault();if($(".signin").hasClass("menu-open")){if($("fieldset#signin_menu:visible")||$("fieldset#signup_menu:visible")){$("fieldset#signup_menu").hide();$("fieldset#signin_menu").hide();$(".signin").removeClass("menu-open")}}else{if(signin_ajax!=1){var b="<img src='/images/progress.gif' alt='loading...' />";$("#signin_menu").html(b).load("/ajax/signin.html");signin_ajax=1}$("fieldset#signin_menu").show();$(".signin").toggleClass("menu-open")}});$("fieldset#signin_menu").mouseup(function(a){return false});$("fieldset#signup_menu").mouseup(function(a){return false});$(document).mouseup(function(a){if($(a.target).parent("a.signin").length==0){$(".signin").removeClass("menu-open");$("fieldset#signin_menu").hide();$("fieldset#signup_menu").hide()}})})

