var old_sec = "";
var curLangy = "";
var curSection = "";
function chooseLanguage(iso) {
    if(old_sec != "") {
        $('#' + old_sec).fadeOut('slow');
        old_sec = "";
    }
    if(iso != chosenLang && chosenLang != "") {
        $('#choice_' + chosenLang).fadeOut('slow',function() {
            $('#choice_' + iso).fadeIn('slow');
        });  
    } else {
        $('#choice_' + iso).fadeIn('slow');
    }
    chosenLang = iso;
}
function showSec(section,lang,sec) {
    if(old_sec != "") {
         $('#' + old_sec).fadeOut('slow',function() {
            $('#' + section + "_" + lang + "_" + sec).fadeIn('slow');
        });
    } else {
        $('#' + section + "_" + lang + "_" + sec).fadeIn('slow');
    }
    old_sec = section + "_" + lang + "_" + sec;
}
function checkDocChkSec(lang,section) {
    xmlHttp = getHTTPObjectUser();
    if(xmlHttp == null) { alert('Your browser does not support AJAX! Please contact life-saver.org technical support.'); return; }
    pswd = document.getElementById('docchk_pswd_' + section + '_' + lang).value;
    var url = "scripts/functions/ajaxCalls.php?callname=checkDocChkSec&lang=" + lang + "&pswd=" + pswd + "&section=" + section;
    curSection = section;
    curLangy = lang;
    xmlHttp.onreadystatechange = checkDone;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function checkPartSec(lang,section) {
    xmlHttp = getHTTPObjectUser();
    if(xmlHttp == null) { alert('Your browser does not support AJAX! Please contact life-saver.org technical support.'); return; }
    pswd = document.getElementById('prt_pswd_' + section + '_' + lang).value;
    var url = "scripts/functions/ajaxCalls.php?callname=checkPartSec&lang=" + lang + "&pswd=" + pswd + "&section=" + section;
    curSection = section;
    curLangy = lang;
    xmlHttp.onreadystatechange = checkDone;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}
function checkDone() {
    if (xmlHttp.readyState==4) {
        oktogo = xmlHttp.responseText;
        if(oktogo == "1") {
            location.href = "checkLogin.php?section=" + curSection + "&lang=" + curLangy;
        } else {
            document.getElementById('curError_' + curSection + '_' + curLangy).innerHTML = oktogo + "<br />&nbsp;";
        }
    }
}
function text_focused(obj_e,wrds) { if(obj_e.value == wrds) { obj_e.value = ""; } obj_e.style.color="#333333";  obj_e.style.fontStyle="normal"; }
function text_unfocused(obj_e,wrds) { if(obj_e.value == "") { obj_e.value = wrds;  obj_e.style.color="#aaa";  obj_e.style.fontStyle="normal"; } }
function checkFndSec(lang,section) {
    xmlHttp = getHTTPObjectUser();
    if(xmlHttp == null) { alert('Your browser does not support AJAX! Please contact life-saver.org technical support.'); return; }
    uname = document.getElementById('fnd_uname_' + section + '_' + lang).value;
    pswd = document.getElementById('fnd_pswd_' + section + '_' + lang).value;
    if(uname == "" || pswd == "") { alert(enterUP); }
    else {
        var url = "scripts/functions/ajaxCalls.php?callname=checkFndSec&lang=" + lang + "&pswd=" + pswd + "&uname=" + uname + "&section=" + section;
        curSection = section;
        curLangy = lang;
        xmlHttp.onreadystatechange = checkDone;
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
    }
}
function registerFnd(lang,section) {
    xmlHttp = getHTTPObjectUser();
    if(xmlHttp == null) { alert('Your browser does not support AJAX! Please contact life-saver.org technical support.'); return; }
    uname = document.getElementById('fnd_reg_name_' + section + '_' + lang).value;
    gmc = document.getElementById('fnd_reg_gmc_' + section + '_' + lang).value;
    email = document.getElementById('fnd_reg_email_' + section + '_' + lang).value;
    if(uname == "" || email == "" || gmc == "" || uname == nameInLang || gmc == gmcInLang || email == emailInLang) { alert(enterUEG); }
    else {
        var url = "scripts/functions/ajaxCalls.php?callname=register&lang=" + lang + "&email=" + email + "&uname=" + uname + "&gmc=" + gmc + "&section=" + section;
        curSection = section;
        curLangy = lang;
        xmlHttp.onreadystatechange = registerDone;
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
    }
}
function registerDone() {
    if (xmlHttp.readyState==4) {
        oktogo = xmlHttp.responseText;
        document.getElementById('register_wrds').innerHTML = oktogo;
        document.getElementById('fnd_reg_name_' + curSection + '_' + curLangy).value = "";
        document.getElementById('fnd_reg_gmc_' + curSection + '_' + curLangy).value = "";
        document.getElementById('fnd_reg_email_' + curSection + '_' + curLangy).value = "";
    }
}
function checkBatchNum(lang,section) {
    xmlHttp = getHTTPObjectUser();
    if(xmlHttp == null) { alert('Your browser does not support AJAX! Please contact life-saver.org technical support.'); return; }
    bn = document.getElementById('bn_' + section + '_' + lang).value;
    if(bn == "") { alert(enterB); }
    else {
        var url = "scripts/functions/ajaxCalls.php?callname=checkBatchNum&lang=" + lang + "&bn=" + bn + "&section=" + section;
        curSection = section;
        curLangy = lang;
        xmlHttp.onreadystatechange = checkDone;
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
    }
}
function forgotPassword(lang,section) {
    document.getElementById('forgotPswd_' + lang + '_' + section).style.display = "block";
}
function sendReminder(lang,section) {
    xmlHttp = getHTTPObjectUser();
    if(xmlHttp == null) { alert('Your browser does not support AJAX! Please contact life-saver.org technical support.'); return; }
    email = document.getElementById('fnd_forgotemail_' + section + '_' + lang).value;
    if(email == "") { alert(enterE); }
    else {
        var url = "scripts/functions/ajaxCalls.php?callname=sendPswdReminder&lang=" + lang + "&email=" + email + "&section=" + section;
        curSection = section;
        curLangy = lang;
        xmlHttp.onreadystatechange = reminderDone;
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
    }
}
function reminderDone() {
    if (xmlHttp.readyState==4) {
        oktogo = xmlHttp.responseText;
        document.getElementById('reminder_words').innerHTML = oktogo;
    }
}

