// les fonctions
$(function() {
    $("#bloc_recrute .vertical").scrollable({
        vertical: true
    });
    $("#bloc_actu .vertical").scrollable({
        vertical: true
    });
    $("#bloc_tv .horizontal").scrollable({});

    $("#diapo .horizontal").scrollable({
        easing: 'custom',
        speed: 700,
        circular: true
    });


    return false;
});


// custom easing called "custom"
$.easing.custom = function(x, t, b, c, d) {
    var s = 1.70158;
    if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
    return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
}




$(document).ready(function() {
	
	
    $(".navigation ul.subMenu").hide();
    // On sélectionne tous les items de liste portant la classe "toggleSubMenu"
    // On modifie l'évènement "click" sur les liens dans les items de liste
    // qui portent la classe "toggleSubMenu" :
    $(".navigation li.toggleSubMenu > a").click(function() {
        // Si le sous-menu était déjà ouvert, on le referme :
        if ($(this).next("ul.subMenu:visible").length != 0) {
            $(this).next("ul.subMenu").slideUp("normal");
        }
        // Si le sous-menu est caché, on ferme les autres et on l'affiche :
        else {
            $(".navigation ul.subMenu").slideUp("normal");
            $(this).next("ul.subMenu").slideDown("normal");
        }
        // On empêche le navigateur de suivre le lien :
        return false;
    });

    $(".imageVideoLightbox").click(function() {
        //var found = $(this.parentNode).find(".visualVideoLightbox");
        var found = $(this.parentNode).children("div .visualVideoLightbox");
        var objwidth = $(found).width();
        var objheight = $(found).height();

        // TODO Thomas : found = [Object object]... ne fonctionne que si plusieurs innovations s'affichent
        $.blockUI({
            message: found,
            css: {
                border: 'none',
                top: ($(window).height() - objheight) / 3 + 'px',
                left: ($(window).width() - objwidth) / 2 + 'px',
                width: objwidth + 'px',
                height: objheight + 'px',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                color: '#FFFFFF'
            }
        });
        return false;
    });

	$(".colorbox").colorbox({
		href:$(this).attr('href'), height:"auto"
	});

    $(".blockOverlay").click(function() {
        $.unblockUI();
    });
    $(".apple_close").click(function() {
        $.unblockUI();
    });

});




