//Mes Variables de site
var popupStatus = 0;

//Chargement du popup avec jQuery
function loadPopuplegal(){
    //loads popup only if it is disabled
    if (popupStatus == 0) {
        $("#backgroundPopup-legal").css({
            "opacity": "0.7"
        });
        $("#backgroundPopup-legal").fadeIn("slow");
        $("#mentions-legales-lightbox").fadeIn("slow");
        popupStatus = 1;
    }
}

//Suppression du popup avec jQuery
function disablePopuplegal(){
    //disables popup only if it is enabled
    if (popupStatus == 1) {
        $("#backgroundPopup-legal").fadeOut("slow");
        $("#mentions-legales-lightbox").fadeOut("slow");
        popupStatus = 0;
    }
}

//On centre le popup
function centerPopuplegal(){
    //request data for centering
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $("#mentions-legales-lightbox").height();
    var popupWidth = $("#mentions-legales-lightbox").width();
    //centering
    $("#mentions-legales-lightbox").css({
        "position": "absolute",
        "top": windowHeight / 2 - popupHeight / 2,
        "left": windowWidth / 2 - popupWidth / 2
    });
    //only need force for IE6
    
    $("#backgroundPopup-legal").css({
        "height": windowHeight
    });
}

//On affiche la fiche correspondante
function showDiv(divToShow){
}
//On masque la fiche correspondante
function hideDiv(divToHide){
}

//Event
$(document).ready(function(){
    $("#mentions-legales-lien").click(function(){ //Quand le bouton "#Button" est cliqué
        //on centre
        centerPopuplegal();
        //on charge
        loadPopuplegal();
    });
	
    //FERMETURE DU POPUP
    $("#popupContactClose-legal").click(function(){ //Quand le bouton "X" est cliqué
        disablePopuplegal();
    });
	
    //ON CLIQUE EN DEHORS
    $("#backgroundPopup-legal").click(function(){
        disablePopuplegal();
    });
	
    //ON APPUI SUR ECHAP
    $(document).keypress(function(e){
        if (e.keyCode == 27 && popupStatus == 1) {
            disablePopuplegal();
        }
    });    
});

