function hide_auth_panel() { if (typeof(MOOdalBox) != 'undefined') { MOOdalBox.close(); } jQuery('#authPanel_content').hide(); jQuery('#authPanel_iframe').hide(); 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; } jQuery('#auth_error').html(''); if (additional_func) { additional_auth_func = additional_func; } if (jQuery('#authPanel_content').length > 0 && authPanel == 'loaded') { jQuery('#authPanel_content').html('authPanel_saved'); jQuery('#authPanel_content').show(); jQuery('#authPanel_iframe').show(); if (additional_func && additional_func != "window.location='/'") { jQuery('#auth_error').html("You need to log in to do this."); jQuery('#auth_error').show(); } jQuery('#txt_login_username').focus(); window.addEvent('keydown', catch_enter_key); jQuery('#authPanel_content').css('top',(200 + sctop) +'px'); resize_auth_panel(); auth_type = 'login'; authLogin = ''; return; } auth_type = 'panel'; if (jQuery('#authPanel_content').length == 0) { 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 { jQuery('#authPanel_content').show(); jQuery('#authPanel_iframe').show(); jQuery('#authPanel_content').css('top',(200 + sctop) +'px'); authPanel = 'loading'; } waiting_msg = 'Contacting server ......'; jQuery('#authPanel_content')[0].innerHTML = "
"
+"
Come on...You have to at least enter your username and password';
jQuery('#auth_error').show();
resize_auth_panel();
jQuery('#txt_login_username').focus();
return false;
}
waiting_msg = 'Contacting server ......';
jQuery('#authPanel_content')[0].innerHTML =
"
"
+"
Incorrect ID/Password combination. Please try again.');
jQuery('#auth_error').show();
resize_auth_panel();
jQuery('#txt_login_username').focus();
} else {
sessionDataObj = _response;
jQuery('#authPanel_iframe').hide();
jQuery('#authPanel_content').hide();
ShmoopUser_auth = true;
if (typeof(MOOdalBox) != 'undefined') {
MOOdalBox.close();
}
if (jQuery('#LoggedInText').length > 0) {
topnav_header_v1d3_LoggedInText = "Hello " +sessionDataObj.UName +" | "
+"My Shmoop | "
+"Help | "
+"Logout";
jQuery('#LoggedInText').html( topnav_header_v1d3_LoggedInText );
}
if (jQuery('#div_benefits').length > 0) {
jQuery('#div_myshmoop').show();
jQuery('#div_logout').show();
jQuery('#div_login').hide();
jQuery('#div_join').hide();
}
if (jQuery('#div_benefits_topnav').length > 0) {
jQuery('#div_myshmoop').show();
jQuery('#div_logout').show();
jQuery('#div_login').hide();
jQuery('#div_join').hide();
}
if (additional_auth_func != '') {
if (additional_auth_func == 'FORM') {
additional_auth_func_form.submit();
} else {
setTimeout("eval(additional_auth_func)", 0);
}
}
if (jQuery('#stick_container').length > 0) {
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;
user.logout();
sessionDataObj.UFirstName = '';
sessionDataObj.UName = '';
sessionDataObj.UEncrypt = '';
if (jQuery('#LoggedInText').length > 0) {
topnav_header_v1d3_LoggedOutText = 'Login | '
+"Help | "
+"Sign Up!";
jQuery('#LoggedInText').html(topnav_header_v1d3_LoggedOutText);
jQuery('#loginAuthPanelFadeIn').on('click', function(e) {
MOOdalBox.open("javascript:display_auth_panel(true, '')", "", "");
});
}
if (jQuery('#div_benefits').length > 0) {
jQuery('#div_myshmoop').hide();
jQuery('#div_logout').hide();
jQuery('#div_login').show();
jQuery('#div_join').show();
}
if (jQuery('#div_benefits_topnav').length > 0) {
jQuery('#div_myshmoop').hide();
jQuery('#div_logout').hide();
jQuery('#div_login').show();
jQuery('#div_join').show();
}
if (jQuery('#ModalWindow_MyFolders').length > 0) {
jQuery('#ModalWindow_MyFolders').html('');
jQuery('#ModalWindow_MyFolders').hide();
}
if (jQuery('#stick_container').length > 0) {
removeAllStickies();
}
if (jQuery('#ModalWindow_ChooseFolder').length > 0) {
jQuery('#ModalWindow_ChooseFolder_Select')[0].length = 0;
document.getElementById('ModalWindow_ChooseFolder').style.display = 'none';
}
jQuery('#ModalWindow_CreateFolder').hide();
jQuery('#ModalWindow_CreateStickies').hide();
jQuery('#ModalWindow_Delete').hide();
}
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('' +'/ajax/authPanel.php?ver=' +$random(0, 65535));
return;
}
if (this == 'login') {
auth_type = 'login_by_backup';
load_script('' +'/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.