// Handlers
//
document.getElementById('confirmation_form').onsubmit = submit_confirmation;
document.getElementById('login_form').onsubmit = submit_login;
document.getElementById('resend_form').onsubmit = submit_resend;
document.getElementById('login_form').rememberme.onclick = rememberme_warning;


// handler functions
//

function submit_confirmation() {
    // do = function in SHOEUSER
    // elm = element to display the results

    var data = seralize_form(this);
    var div  = 'confirmation_status';
    var func = 'activate';

    document.getElementById("submit_confirmation").style.display = "none";
    document.getElementById(div).style.display = 'block';
    document.getElementById(div).innerHTML = 'Activating.... Please Wait... This may take several minutes...';
    dispatch('dispatcher.php?elm='+div+'&do='+func+'&'+data);
    document.getElementById("submit_confirmation").style.display = "block";
    return false;
}

function submit_login() {
    // do = function in SHOEUSER
    // elm = element to display the results

    var data = seralize_form(this);
    var div  = 'login_status';
    var func = 'login';

    document.getElementById(div).style.display = 'block';
    document.getElementById(div).innerHTML = 'Logging in....';
    dispatch('dispatcher.php?elm='+div+'&do='+func+'&'+data);
    return false;
}

function submit_resend() {
    // do = function in SHOEUSER
    // elm = element to display the results

    var data = seralize_form(this);
    var div  = 'resend_status';
    var func = 'sendpin';

    document.getElementById(div).style.display = 'block';
    document.getElementById(div).innerHTML = 'Retrieving PIN....';
    dispatch('dispatcher.php?elm='+div+'&do='+func+'&'+data);
    return false;
}

function rememberme_warning() {
    // do = function in SHOEUSER
    // elm = element to display the results

    var div  = 'login_status';
    
    if(!this.checked) {
	document.getElementById(div).style.display = 'none';
    } else {
	document.getElementById(div).style.display = 'block';
    }
    document.getElementById(div).innerHTML = '<h3>Warning</h3><p>The <em>remember me</em> feature will allow anyone from this computer to automatically login. Your login data is stored in a persistent cookie that will only be deleted when you click logout. This feature is not recommended for use on public or shared computers.</p>';
}
