$(document).ready(function(){
    
    containerWidth = $(window).width();
    containerHeight = $(window).height();
    
    /***************************************/
    /* Affichage du popin d'identification */
    /***************************************/

    popinIdentificationWidth = 407;
    popinIdentificationHeight = 262;
    
    xPositionPopin = (containerWidth/2)-(popinIdentificationWidth/2);
    yPositionPopin = (containerHeight/2)-(popinIdentificationHeight/2)-100;
    
    $('#popinIdentification').css('top',yPositionPopin+'px');
    $('#popinIdentification').css('left',xPositionPopin+'px');
    $('#popinIdentification').css('position','fixed');
    
    $('#btnFooterCarteFidelite').click(function(){
        $('#carteFideliteIdentification').click();
    });
    
    $('#carteFideliteIdentification').click(function(){
        
        if($('#popinIdentification').is(':visible')){
            $('#popinIdentification').fadeOut('slow');
        }
        else{
            $('#popinIdentification').fadeIn('slow');
        }
        
    });
    
    $('#btnCloseLogin').click(function(){
        $('#popinIdentification').fadeOut('slow');
    });
    
    
    /****************************************************/
    /* Affichage du popin d'inscription à la newsletter */
    /****************************************************/
    
    popinInscriptionNewsletterWidth = 407;
    popinInscriptionNewsletterHeight = 362;
    
    xPositionInscriptionNewsletterPopin = (containerWidth/2)-(popinInscriptionNewsletterWidth/2);
    yPositionInscriptionNewsletterPopin = (containerHeight/2)-(popinInscriptionNewsletterHeight/2)-100;
    
    $('#popinInscriptionNewsletter').css('top',yPositionPopin+'px');
    $('#popinInscriptionNewsletter').css('left',xPositionPopin+'px');
    $('#popinInscriptionNewsletter').css('position','fixed');
    
    $('#btnFooterNewsletter').click(function(){
        $('#menu_droite_newsletter').click();
    });
    
    $('#menu_droite_newsletter').click(function(){
        
        if($('#popinInscriptionNewsletter').is(':visible')){
            $('#popinInscriptionNewsletter').fadeOut('slow');
        }
        else{
            $('#popinInscriptionNewsletter').fadeIn('slow');
        }
        
    });
    
    $('#btnCloseNewsletter').click(function(){
        $('#popinInscriptionNewsletter').fadeOut('slow');
    });

});
