/*----------------------------------------------------------------------------//
// Javascript pour le site client  -------------------------------------------//
//----------------------------------------------------------------------------//
// Client : Groupe Performance Marine
// Date   : Avril 2009
//----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
// Inclusion dynamique des fichiers externes javascripts
/*----------------------------------------------------------------------------*/
function importJavascript(src)
{
	document.write("<script type=\"text/javascript\" src=\"" + src + "\"></scr" + "ipt>");
}
function importCss(href, media)
{
	document.write('<link rel="stylesheet" type="text/css" media="' + media + '" href="' + href + '" />');
}

/*----------------------------------------------------------------------------*/
// Importations de fichiers
/*----------------------------------------------------------------------------*/
// importJavascript("../includes/js/plugins/jquery.plugin.js");
// importCss("../includes/js/plugins/jquery.plugin.css", "screen");
importJavascript("/includes/js/swfobject.js");
importJavascript("/includes/js/plugins/abso.caroussel.js");
importJavascript("/includes/js/plugins/jquery.colorbox.js");

/*----------------------------------------------------------------------------*/
// Declarations jQuery
/*----------------------------------------------------------------------------*/

//--Accordeons-------------------------------
function closeAccordeon(instance, anim){
	(anim) ? $(".Section", instance).slideUp(150) : $(".Section", instance).hide();
	$("li", instance).removeClass("On");
}

//--Gallery Pics-----------------------------
var currentGalleryPic = 0;
function showGalleryPic(a){
	$("#ColD .Thumbs img").each(function(){ $(this).css("opacity", 1.0); });
	$("img", a).css("opacity", 0.2);
	$("#ColD .Photo img").not(".Masque").attr("src", $(a).attr("href"));
	currentGalleryPic = $("#ColD .Thumbs a").index(a);
	return false;
}

$(document).ready(function() {

    //--Accueil----------------------------------
    $("input:text").focus(function() {
        if ($(this).val() == $(this).attr("title")) { $(this).val(""); };
    }).blur(function() {
        if ($(this).val() == "") { $(this).val($(this).attr("title")); };
    });

    //--Accordeons-------------------------------
    $("ul.Accordeon").each(function() {
        var current = this;
        closeAccordeon(current, false);
        $(".Titre", current).click(function() {
            $(this).parent().toggleClass("On");
            $(this).next(".Section").slideToggle(150);
            return false;
        });
    });

    //--Usagés, Résultats------------------------
    $("body.BateauxUsages #Resultats li").each(function() {
        if (!$(this).hasClass("Vendu")) {
            var currLI = this;
            $(".Texte", currLI)
				.css("opacity", 0.0)
				.hover(function() {
				    $(this).css("opacity", 1).css("z-index", 100);
				    $("img", currLI).css("opacity", 0.2).not(".Masque").css("z-index", 50);
				}, function() {
				    $(this).css("opacity", 0.0).css("z-index", 50);
				    $("img", currLI).css("opacity", 1).not(".Masque").css("z-index", 100);
				});
        }
    });

    //--Locations, Top 10------------------------
    $("body.BateauxLocation #ColD li").each(function() {
        if (!$(this).hasClass("Loue")) {
            $(".Texte", this).css("opacity", 0.0);
            $(this).hover(function() {
                $(".Texte", this).css("opacity", 1).css("z-index", 100);
                $("img", this).css("opacity", 0.2).css("z-index", 50);
            }, function() {
                $(".Texte", this).css("opacity", 0.0).css("z-index", 50);
                $("img", this).css("opacity", 1).css("z-index", 100);
            });
        }
    });

    //--Locations & Usagés, Fiche-----------------
    $("#ColD .Thumbs a").mouseover(function() {
        showGalleryPic(this);
    })//.click(function(){
    //	return false;
    //});
    $("#ColD .Thumbs a:eq(" + currentGalleryPic + ")").mouseover();

    //--Caroussel----------------------------------
    Abso.Caroussel.init({
        id: 'Fournisseurs',
        wrap: true
    });

    //--Colorbox-----------------------------------
    $("#ColD ul.Thumbs li a[rel='GrandePhoto']").colorbox({ maxWidth: "760", maxHeight: "570", onOpen: function() { videoCode = $('#YouTubePlayer').html(); $('#YouTubePlayer').empty(); }, onClosed: function() { $("#YouTubePlayer").append(videoCode); } });

});
