function getAbsPath() {
    if (!window.location.host.match("localhost")) {
        if (window.location.pathname.match("backoffice"))
            return "http://www.nordjuris.fr/backoffice/";
        return "http://www.nordjuris.fr/";
    }
    else {
        if (window.location.pathname.match("backoffice"))
            return "http://localhost/nordjuris/backoffice/";
        return "http://localhost/nordjuris/";
    }
}

var ABSPATH = getAbsPath();

function doContact(emailId) {
    var mail    = $("#contactEmail").val();
    var name    = $("#contactName").val();
    var texte   = $("#contactMessage").val();
    
    var error   = [];
    
    if (!checkEmail(mail)) {
        error.push('E-mail');
    }
    
    if (name.length == 0) {
        error.push('Nom');
    }
    
    if (texte.length == 0) {
        error.push('Message');
    }
    if (error.length > 0) {
        $("#pageContact .error").html(error.join(", ") + " invalide.");
        $("#pageContact .error").fadeIn(1500);
    } else {
        $.post(ABSPATH + "ajax/sendMail.php", {
            email       : mail,
            id          : emailId,
            name        : name,
            texte       : texte
        },
            function (datas) {
            }, "json"
        );
        $("#pageContact .error").addClass("confirm");
        $("#pageContact .error").html("Votre message a bien &eacute;t&eacute; envoy&eacute;.");
        $("#pageContact .middleContentDesc").fadeOut(1000);
        setTimeout("closeFancy()", 1500);
        
        
    }
}

function closeFancy() {
    $('#fancybox-close').click()    
}

