//Mes Variables de site
var popupStatus = 0;

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

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

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

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

//Event
$(document).ready(function(){
    $("#accueil-actualite-savoirplus-lien").click(function(){ //Quand le bouton "#Button" est cliqué
        //on centre
        centerPopupnews();
        //on charge
        loadPopupnews();
    });
	
    //FERMETURE DU POPUP
    $("#popupContactClose-news").click(function(){ //Quand le bouton "X" est cliqué
        disablePopupnews();
    });
	
    //ON CLIQUE EN DEHORS
    $("#backgroundPopup-news").click(function(){
        disablePopupnews();
    });
	
    //ON APPUI SUR ECHAP
    $(document).keypress(function(e){
        if (e.keyCode == 27 && popupStatus == 1) {
            disablePopupnews();
        }
    });    
});

