// initialise menu
jQuery(document).ready(function() {
    jQuery('#header ul').superfish();
    jQuery('#sidebar ul').superfish({
        'animation' : {height : 'show'},   // slide-down effect without fade-in
        delay       : 100,
        autoArrows  : true
    });

    $('a[rel*=facebox]').facebox();

    centreheader();

    $('#header ul ul li.li-niv2').css({
        'padding' : '0 0 0 '+$('#header_menu .ul-niv1').css('marginLeft')
    });

    $("#div-slider-partenaire").easySlider({
        prevText: '',
        nextText: '',
        prevId : 'prevBtnPart',
        nextId : 'nextBtnPart'
    });

    $("#div-slider-dist-web").easySlider({
        prevText: '',
        nextText: '',
        prevId : 'prevBtnDist',
        nextId : 'nextBtnDist'
    });

    $('#diapo').cycle({
        fx:    'fade',
        timeout: 7000
    });

});

/*Vérification de la newsletter*/
function UserNewsletterValidation(theform) {
    if (!TesteEMail(theform.mail, 255, true)) return false;
};

function centreheader() {
    var width = 0;
    $('#header_menu ul li.li-niv1').each(function() {
        width += parseInt($(this).width());
    });
    var margin_left =parseInt(($('#header_menu').width() - width) / 2 - 20);
    $('ul.ul-niv1').css({'margin-left' : margin_left+'px'});
}

function centreAccrocheTopMenu() {
    var height = $('#header_menu ul.ul-niv2').height();
    var paddingTop =parseInt(height / 2);
    $('ul.ul-niv2 li.img').css({'padding-top' : paddingTop+'px'});

}

function in_array(needle, tab) {
    var i = tab.length-1;
    if (i >= 0) {
        do {
            if (tab[i] == needle) {
                if (typeof(tab[i]) != typeof(needle)) {
                    continue;
                }
                return true;
            }
        } while (i--);
    }
    return false;
}


$(function() {
    $("#ajouter_liste_naissance").colorbox();
});




function jPopup(contenu,largeur,hauteur){
    $('body').append('<div id="framePopUp"></div><div id="inPopUp"><div id="close_popup"><a class="closepopup" href="">Close</a></div><div id="content_popup"></div></div>');
    $('#inPopUp').css({'width':largeur+'px','height':hauteur+'px','marginTop':'-'+hauteur/2+'px','marginLeft':'-'+largeur/2+'px'});
    $('#content_popup').append(contenu);
    $('#framePopUp').css({'opacity':0.5});
    $('#framePopUp').fadeIn('fast');
    $('#inPopUp').show();

    $('a.closepopup').live('click',function () {
        $('#framePopUp').remove();
        $('#inPopUp').remove();
        return false;
    });
}


