﻿/* Tooltip */

$(document).ready(function() {

    $(".tooltip.hover").hide();
    $(".tooltip.click").hide();
    $(".tooltip.ok").hide();
    $(".tooltip.ko").hide();
    $(".tooltip.wait").hide();
    $(".tooltip.hover-detail").hide();

    $("a#tooltip").hover(function() {
    if ($(".tooltip.ko").is(':hidden') && $(".tooltip.ok").is(':hidden')) {
            $(".tooltip.hover").fadeIn("fast");
        }
        return false;
    }, function() {
        $(".tooltip.hover").fadeOut("fast")();
        return false;
    }
    );

    $("a#tooltip-detail").hover(function() {
        $(".tooltip.hover-detail").fadeIn("fast");
        return false;
    }, function() {
        $(".tooltip.hover-detail").fadeOut("fast")();
        return false;
    }

    );
    $("a#tooltip").click(function() {
        $(".tooltip.hover").hide();
        $(".tooltip.wait").fadeIn("fast");
        return false;
    }
    );
    $(".tooltip-close a").click(function() {
        $(".tooltip.click").fadeOut("fast");
        $(".tooltip.ok").fadeOut("fast");
        $(".tooltip.ko").fadeOut("fast");
        $(".tooltip.wait").fadeOut("fast");
        return false;
    }
    );
    $(".tooltip-close-error a").click(function() {
        $(".tooltip.click").fadeOut("fast");
        $(".tooltip.ok").fadeOut("fast");
        $(".tooltip.ko").fadeOut("fast");
        $(".tooltip.wait").fadeOut("fast");
        return false;
    }
    );
    $(".tooltip-close-success a").click(function() {
        $(".tooltip.click").fadeOut("fast");
        $(".tooltip.ok").fadeOut("fast");
        $(".tooltip.ko").fadeOut("fast");
        $(".tooltip.wait").fadeOut("fast");
        return false;
    }
    );
})

/* Select */

$(document).ready(function() {

    $('.selectButton').click(function() {

        $('.selectContent').slideUp('normal');

        if ($(this).next().is(':hidden') == true) {

            $(this).next().slideDown('normal');
        }

    });

    $('.selectContent').hide();

    $(document).click(function(e) {
        try {
            var object;

            if (e) {
                if (e.target) {
                    object = e.target;
                }
                if (e.srcElement) {
                    object = e.srcElement;
                }
            }

            if (object.id != 'divSelect' && object.tagName != 'A') {
                $('.selectContent').slideUp('normal');
            }
        }
        catch (e) {
            alert(e.message);
        }
    })



});

/* Cacher le select Collection sur IE6 */

if ($.browser.version < 7) {
    $(document).ready(function() {
        $("#mainmenu").hover(function() {
            $("select.select").css({ visibility: "hidden" });
        }, function() {
            $("select.select").css({ visibility: "visible" });
        });
    });
}

/* Accordeon */

jQuery.fn.initMenu = function() {
    return this.each(function() {
        var theMenu = $(this).get(0);
        $('.acitem', this).hide();
        $('li.expand > .acitem', this).show();
        $('li.expand > .acitem', this).prev().addClass('active');
        $('li a', this).click(
            function(e) {
                e.stopImmediatePropagation();
                var theElement = $(this).next();
                var parent = this.parentNode.parentNode;
                if ($(parent).hasClass('noaccordion')) {
                    if (theElement[0] === undefined) {
                        window.location.href = this.href;
                    }
                    $(theElement).slideToggle('normal', function() {
                        if ($(this).is(':visible')) {
                            $(this).prev().addClass('active');
                        }
                        else {
                            $(this).prev().removeClass('active');
                        }
                    });
                    return false;
                }
                else {
                    if (theElement.hasClass('acitem') && theElement.is(':visible')) {
                        if ($(parent).hasClass('collapsible')) {
                            $('.acitem:visible', parent).first().slideUp('normal',
                            function() {
                                $(this).prev().removeClass('active');
                            }
                        );
                            return false;
                        }
                        return false;
                    }
                    if (theElement.hasClass('acitem') && !theElement.is(':visible')) {
                        $('.acitem:visible', parent).first().slideUp('normal', function() {
                            $(this).prev().removeClass('active');
                        });
                        theElement.slideDown('normal', function() {
                            $(this).prev().addClass('active');
                        });
                        return false;
                    }
                }
            }
    );
    });
};

$(document).ready(function() { $('.accordeon').initMenu(); });



/* Player video */

var playVideo = function(videoPath) {
    var flashvars = {};
    flashvars.cheminFLV = videoPath;
    flashvars.autoplay = "true";

    var params = {};
    params.wmode = "transparent";

    var attributes = {};

    swfobject.embedSWF("swf/video.swf", "videoPlayer", "398", "333", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);
}


/* Page Charte */

$(document).ready(function() {

    //Larger thumbnail preview 

    $(".txt-long").hide();

    $("ul.thumb li").hover(function() {
        $(this).css({ 'z-index': '10' });
        $(this).find('img').addClass("hover").stop()
		.animate({
		    width: '170px',
		    height: '170px'
		}, 200);
		$(this).find(".txt-court").hide()
		$(this).find(".txt-long").show();

    }, function() {
        $(this).css({ 'z-index': '0' });
        $(this).find('img').removeClass("hover").stop()
		.animate({
		    marginTop: '0',
		    marginLeft: '0',
		    top: '0',
		    left: '0',
		    width: '140px',
		    height: '140px',
		    padding: '0px'
		}, 400);
		$(".txt-court").show()
		$(".txt-long").hide();
    });

});

