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 = "
"
+"
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 =
"
"
+"
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.