function hide_auth_panel() { if (typeof(MOOdalBox) != 'undefined') { MOOdalBox.close(); } $('authPanel_content').style.display = 'none'; $('authPanel_iframe').style.display = 'none'; if (auth_type == 'panel' || auth_type == 'panel_by_backup') { authPanel = 'error'; } if (auth_type == 'login' || auth_type == 'login_by_backup') { authLogin = 'error'; } } function display_auth_panel(async_ajax, additional_func) { async_authentication = false; additional_auth_func = ''; var px = document.layers ? "" : "px"; auth_type = 'panel'; if (document.documentElement && document.documentElement.scrollTop) { sctop = document.documentElement.scrollTop; } else { sctop = document.body.scrollTop; } if (async_ajax) { async_authentication = true; } if ($('auth_error')) { $('auth_error').innerHTML = ''; } if (additional_func) { additional_auth_func = additional_func; } if ($('authPanel_content') && authPanel == 'loaded') { $('authPanel_content').innerHTML = authPanel_saved; $('authPanel_content').style.display = 'block'; $('authPanel_iframe').style.display = 'block'; if (additional_func && additional_func != "window.location='/'") { $('auth_error').innerHTML = "You need to log in to do this."; $('auth_error').style.display = 'block'; } $('txt_login_username').focus(); window.addEvent('keydown', catch_enter_key); $('authPanel_content').style.top = (200 + sctop) +px; resize_auth_panel(); auth_type = 'login'; authLogin = ''; return; } auth_type = 'panel'; if (!$('authPanel_content')) { var authDiv = document.createElement("DIV"); authDiv.style.top= (200 + sctop) +px; authDiv.style.position="absolute"; authDiv.style.background="#996600"; authDiv.id= 'authPanel_content'; var authIframe = document.createElement("IFRAME"); authIframe.style.top= (200 + sctop) +px; authIframe.style.position="absolute"; authIframe.id= 'authPanel_iframe'; document.body.appendChild(authIframe); document.body.appendChild(authDiv); } else { $('authPanel_content').style.display = 'block'; $('authPanel_iframe').style.display = 'block'; $('authPanel_content').style.top = (200 + sctop) +px; authPanel = 'loading'; } waiting_msg = 'Contacting server ......'; $('authPanel_content').innerHTML = "
" +waiting_msg +"

Please wait" +"
" +"" +"
"; resize_auth_panel(); load_script('http://www.shmoop.com' +'/ajax/authPanel.php?ver=' +$random(0, 65535)); } function authenticate() { uname = document.getElementById('txt_login_username').value; passwd = document.getElementById('txt_login_password').value; auth_type = 'login'; authLogin = ''; if (uname == '' || passwd == '') { $('auth_error').innerHTML = ' Come on...You have to at least enter your username and password'; $('auth_error').style.display = 'block'; resize_auth_panel(); $('txt_login_username').focus(); return false; } waiting_msg = 'Contacting server ......'; $('authPanel_content').innerHTML = "
" +waiting_msg +"

Please wait" +"
" +"" +"
"; resize_auth_panel(); load_script('http://www.shmoop.com' +'/ajax/login.php?u=' +encodeURIComponent(uname) +'&p=' +encodeURIComponent(passwd) +'&ver=' +$random(0, 65535)); } function signout () { auth_type = 'signout'; authSignout = ''; load_script('http://www.shmoop.com' +'/ajax/signout.php?ver=' +$random(0,65535)); } function authPanel_Response(_response) { if (authPanel == 'error' || authPanel == 'loaded') { return; } $('authPanel_content').innerHTML = _response; if (additional_auth_func != '' && additional_auth_func != "window.location='/'") { $('auth_error').innerHTML = "You need to log in to do this."; $('auth_error').style.display = 'block'; } else { $('auth_error').innerHTML = ''; $('auth_error').style.display = 'none'; } resize_auth_panel(); authPanel_saved = _response; authPanel = 'loaded'; auth_type = 'login'; $('txt_login_username').focus(); window.addEvent('keydown', catch_enter_key); } function authenticate_Response(_response) { if (authLogin == 'error' || authLogin == 'done') { return; } $('authPanel_content').innerHTML = authPanel_saved; if (typeof(_response) == "string" && _response.substr(0, 12) == 'Incorrect ID') { $('auth_error').innerHTML = ' Incorrect ID/Password combination. Please try again.'; $('auth_error').style.display = 'block'; resize_auth_panel(); $('txt_login_username').focus(); } else { sessionDataObj = _response; $('authPanel_iframe').style.display = 'none'; $('authPanel_content').style.display = 'none'; ShmoopUser_auth = true; if (typeof(MOOdalBox) != 'undefined') { MOOdalBox.close(); } if ($('LoggedInText')) { topnav_header_v1d3_LoggedInText = "Hello " +sessionDataObj.UName +" | " +"My Shmoop | " +"Help | " +"Logout"; $('LoggedInText').innerHTML = topnav_header_v1d3_LoggedInText; } if ($('div_benefits')) { $('div_myshmoop').style.display = 'block'; $('div_logout').style.display = 'block'; $('div_login').style.display = 'none'; $('div_join').style.display = 'none'; } if ($('div_benefits_topnav')) { $('div_myshmoop').style.display = 'block'; $('div_logout').style.display = 'block'; $('div_login').style.display = 'none'; $('div_join').style.display = 'none'; } if (additional_auth_func != '') { if (additional_auth_func == 'FORM') { additional_auth_func_form.submit(); } else { setTimeout("eval(additional_auth_func)", 0); } } if ($('stick_container')) { var showBox = false; refreshStickies(showBox); } } authLogin = 'done'; } function signout_Response(_response) { if (authSignout == 'signed_out' || authSignout == 'error') { return; } if (_response == 'HOME_URL') { window.location = '/'; } else if(_response != 'CURRENT_URL') { window.location = _response; } else { ShmoopUser_auth = false; sessionDataObj.UFirstName = ''; sessionDataObj.UName = ''; sessionDataObj.UEncrypt = ''; if ($('LoggedInText')) { topnav_header_v1d3_LoggedOutText = 'Login | ' +"Help | " +"Sign Up!"; $('LoggedInText').innerHTML = topnav_header_v1d3_LoggedOutText; $('loginAuthPanelFadeIn').addEvent('click', function(e) { MOOdalBox.open("javascript:display_auth_panel(true, '')", "", ""); }); } if ($('div_benefits')) { $('div_myshmoop').style.display = 'none'; $('div_logout').style.display = 'none'; $('div_login').style.display = 'block'; $('div_join').style.display = 'block'; } if ($('div_benefits_topnav')) { $('div_myshmoop').style.display = 'none'; $('div_logout').style.display = 'none'; $('div_login').style.display = 'block'; $('div_join').style.display = 'block'; } if ($('ModalWindow_MyFolders')) { $('ModalWindow_MyFolders').innerHTML = ''; $('ModalWindow_MyFolders').style.display = 'none'; } if ($('stick_container')) { removeAllStickies(); } if ($('ModalWindow_ChooseFolder')) { $('ModalWindow_ChooseFolder_Select').length = 0; document.getElementById('ModalWindow_ChooseFolder').style.display = 'none'; } if ($('ModalWindow_CreateFolder')) { $('ModalWindow_CreateFolder').style.display = 'none'; } if ($('ModalWindow_CreateStickies')) { $('ModalWindow_CreateStickies').style.display = 'none'; } if ($('ModalWindow_Delete')) { $('ModalWindow_Delete').style.display = 'none'; } } authSignout = 'signed_out'; } function load_script(scr) { var head = document.getElementsByTagName("head").item(0); var script = document.createElement("script"); script.setAttribute("type", "text/javascript"); script.setAttribute("src", scr); head.appendChild(script); check_status.delay(2000, auth_type); } var check_status = function() { if ((this == 'panel' || this == 'panel_by_backup') && authPanel == 'loaded') { return; } if ((this == 'login' || this == 'login_by_backup') && authLogin == 'done') { return; } if ((this == 'signout' || this == 'signout_by_backup') && authSignout == 'signed_out') { return; } if (this == 'panel') { auth_type = 'panel_by_backup'; load_script('http://www.shmoop.com' +'/ajax/authPanel.php?ver=' +$random(0, 65535)); return; } if (this == 'login') { auth_type = 'login_by_backup'; load_script('http://www.shmoop.com' +'/ajax/login.php?u=' +encodeURIComponent(uname) +'&p=' +encodeURIComponent(passwd) +'&ver=' +$random(0, 65535)); return; } if (this == 'panel_by_backup') { authPanel = 'error'; } if (this == 'login_by_backup') { authLogin = 'error'; } if (this != 'signout' && this != 'signout_by_backup') { if (additional_auth_func != '') { auth_msg = "You need to log in to do this.
But the authentication server is off line."; } else { auth_msg = "Authentication server is off line."; } $('authPanel_content').innerHTML = "
" +auth_msg +"
Please try again later." +"
" +"" +"
"; resize_auth_panel(); } else if (this == 'signout') { auth_type = 'signout_by_backup'; load_script('http://www.shmoop.com' +'/ajax/signout.php?ver=' +$random(0, 65535)); } else { shmoop_cookie = Cookie.get('MyShmoop'); if (shmoop_cookie != '') { cookie_obj = eval ('(' + shmoop_cookie + ')'); delete cookie_obj['UFirstName']; delete cookie_obj.UName; delete cookie_obj.UEncrypt; delete cookie_obj.UStart; shmoop_cookie = '{'; for (i in cookie_obj) { shmoop_cookie +='"' +i +'":"' +cookie_obj[i] +'",'; } shmoop_cookie += '}'; shmoop_cookie = shmoop_cookie.replace(',}', "}"); if (shmoop_cookie.length > 2) { Cookie.set('MyShmoop', shmoop_cookie, {path: '/', domain: '.shmoop.com'}); } else { Cookie.remove('MyShmoop', {path: '/', domain: '.shmoop.com'}); } } signout_Response('CURRENT_URL'); } }; function resize_auth_panel() { var px = document.layers ? "" : "px"; if (document.documentElement && document.documentElement.scrollTop) { sctop = document.documentElement.scrollTop; } else { sctop = document.body.scrollTop; } auth_div = $('authPanel_content'); auth_iframe = $('authPanel_iframe'); auth_div.style.top = (200 + sctop) +px; auth_iframe.style.width = (auth_div.offsetWidth - 5) +px; auth_iframe.style.height = (auth_div.offsetHeight - 10) +px; auth_iframe.style.left = '25%'; auth_iframe.style.top = (auth_div.offsetTop+2) +px; } function invite_friends() { if (sessionDataObj.UEncrypt && sessionDataObj.UEncrypt != '') { window.location = '/InviteFriends/'; } else { additional_func = "window.location = '/InviteFriends/'"; MOOdalBox.open("javascript:display_auth_panel(false, additional_func)", "", ""); } } function write_paper_nav(formObj) { if (!sessionDataObj || sessionDataObj.UEncrypth == '') { additional_auth_func_form = formObj; MOOdalBox.open("javascript:display_auth_panel(false, 'FORM')", "", ""); return false; } formObj.submit(); } function catch_enter_key(e) { var event = new Event(e); if (event.key == 'enter') { event.stop(); authenticate(); } } function load_auth_button() { if ($('loginHomeAuthPanelFadeIn')) { $('loginHomeAuthPanelFadeIn').addEvent('click', function(e) { MOOdalBox.open("javascript:display_auth_panel(false, \"window.location='/'\")", "", ""); }); } if ($('loginAuthPanelFadeIn')) { $('loginAuthPanelFadeIn').addEvent('click', function(e) { MOOdalBox.open("javascript:display_auth_panel(true, '')", "", ""); }); } if ($('loginAuthPanel_1_FadeIn')) { $('loginAuthPanel_1_FadeIn').addEvent('click', function(e) { MOOdalBox.open("javascript:display_auth_panel(true, '')", "", ""); }); } if ($('toolBarStickieAuthPanelFadeIn')) { $('toolBarStickieAuthPanelFadeIn').addEvent('click', function(e) { toolBarRedirectLogin(e, 'stickie'); }); } if ($('toolBarDiscussAuthPanelFadeIn')) { $('toolBarDiscussAuthPanelFadeIn').addEvent('click', function(e) { toolBarRedirectLogin(e, 'discuss'); }); } if ($('toolBarFolderAuthPanelFadeIn')) { $('toolBarFolderAuthPanelFadeIn').addEvent('click', function(e) { toolBarRedirectLogin(e, 'myfolders'); }); } if ($('inviteFriendsAuthPanelFadeIn')) { $('inviteFriendsAuthPanelFadeIn').addEvent('click', function(e) { invite_friends(); }); } if ($('div_promo_invitefriends')) { $('div_promo_invitefriends').addEvent('click', function(e) { invite_friends(); }); } } if(window.addEventListener) { window.addEventListener('load', load_auth_button, false); } else if(window.attachEvent) { window.attachEvent('onload', load_auth_button); } var sessionDataObj = {"UFirstName":"","UName":"","UEncrypt":""}; var async_authentication = false; var additional_auth_func = ''; var additional_auth_func_form = null; var auth_type = ''; var authPanel = ''; var authLogin = ''; var authSignout = ''; var authPanel_saved = '';