function submitLogin(action) {
    email = document.login.email.value;
    pwd = document.login.password.value;
    resetLoginErrors();
    if (email=="" || !isValidEmail(email)) {
        Element.update("loginResponse","Merci de verifier votre email");
        document.login.email.focus();
        Element.addClassName("iemail","inputErr");
        Element.addClassName("lemail","labelErr");
        return false;
    }
    if (pwd=="") {
        Element.update("loginResponse","Merci de saisir votre mot de passe");
        document.login.password.focus();
        Element.addClassName("ipwd","inputErr");
        Element.addClassName("lpwd","labelErr");
        return false;
    }
    callLogin(action);
    return false;
}
function resetLoginErrors() {
    Element.removeClassName("iemail","inputErr");
    Element.removeClassName("lemail","labelErr");
    Element.removeClassName("ipwd","inputErr");
    Element.removeClassName("lpwd","labelErr");
    Element.update("loginResponse","<br><br>");
}
function passwordForgotten() {
    email = document.login.email.value;
    resetLoginErrors();
    if (email=="" || !isValidEmail(email)) {
        Element.update("loginResponse","Merci de verifier votre email");
        document.login.email.focus();
        Element.addClassName("iemail","inputErr");
        Element.addClassName("lemail","labelErr");
        return false;
    }
    callLogin("passwordForgotten");
}
var clicked=0;
function callLogin(action) {
    if (clicked == 0) {
        params = Form.serialize(document.login);
        //alert (params);
        params+="&action="+action
        clicked=1;
        Element.update("loginResponse","<center><img src='img/loading_small.gif'></center>");
        new Ajax.Updater("loginResponse","modules/account/login.php", { onComplete: function() {clicked=0;}, evalScripts:true, parameters: params, method:'post' });
    }
}