var popupInscription = function(htmlContent){    
    if(htmlContent == undefined) htmlContent = 'no HTML content';

    var node
    var bg;
    var close;
    var content;
    var mask;

    var hide = function(){
        mask.fadeOut();
        node.animate({'height':0}, {complete:function(){node.hide();}});
        return false;
    }
   
    if($('#popup').length == 0){
        node = $('<div id="popup"></div>').appendTo($('#box2'));
        bg = $('<div class="bg"></div>').css('opacity', 0.7).appendTo(node);
        content = $('<div class="ct"></div>').appendTo(node);
        close = $('<a href="#" class="close" title="Fermer la popup">fermer</a>').appendTo(node);
        mask = $('<div id="mask-content" title="retour au site"></div>').appendTo($('#content'));
        node.click(hide)
        mask.click(hide)
    }else{
        mask = $('#mask-content');
        node = $('#popup');
        bg = $('.bg', node);
        close = $('.close', node);
        content = $('.ct', node);
    }
    content.html(htmlContent);

    mask.css({
        'width':$('#content').width(),
        'height':$('#content').height(),
        'display':'block',
        'opacity':0
    }).animate({'opacity':0.7});

    node.css('height',0).animate({'height':168});

}



$(document).ready(function(){

    $('#newsletter_confirm').click(function(){
        dataString = $("#newsletter_form").serialize();
        $.post('inscription_newsletter.php', dataString, function(data){popupInscription(data);})
        
        return false;
    });

});


