/*----------------------------------------------------------------------------//
// Javascript pour le site client  -------------------------------------------//
//----------------------------------------------------------------------------//
// Client : Inno-Centre
// Note   : -
// Date   : Mars 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.thicker.js");

/*----------------------------------------------------------------------------*/
// Declarations jQuery
/*----------------------------------------------------------------------------*/

var selectEntreprise = "";
var selectLogo = "";

$(document).ready(function() {

    // Input Label Focus ------------------------------------------------------
    if ($("input.TxtBox").length > 0) {
        $("input.TxtBox").each(function() {
            $(this).focus(function() {
                if ($(this).val().length == 0 || $(this).val() == $(this).attr("title")) {
                    $(this).val("");
                }
            });
            $(this).blur(function() {
                if ($(this).val().length == 0) {
                    $(this).val($(this).attr("title"));
                }
            });
        });
    }

    // Plan du site
    if ($("ul#PlanSite")) {
        $("ul#PlanSite li:first").css("border-top", "0px");
        $("ul#PlanSite li.PlanSiteSousItem").each(function() {
            var sm_height = $(this).height();

            if ($(this).next().height() > sm_height)
                sm_height = $(this).next().height();
            else
                $(this).next().height(sm_height);

            if ($(this).next().next().height() > sm_height)
                sm_height = $(this).next().next().height();
            else
                $(this).next().next().height(sm_height);
        });
    }

    // Affichage des descriptions relatives aux entreprises affichées dans le ticker
    $(".ThickerItem a").each(function() {
        $(".ThickerItem a").click(function() {
            selectLogo = $(this);
            if (selectEntreprise != $(this).attr("rel")) {
                $("#PresentationEntreprise div[@id=" + selectEntreprise + "]").stop().animate({ opacity: 0.0 }, 300, function() {
                    $(this).css("display", "none");
                    $("#PresentationEntreprise div[@id=" + $(selectLogo).attr("rel") + "]").stop().animate({ opacity: 1.0 }, 300);
                    $("#PresentationEntreprise div[@id=" + $(selectLogo).attr("rel") + "]").css("display", "block");
                    selectEntreprise = $(selectLogo).attr("rel");
                });
            }
        });
    });
});


$(window).load(function() {

    // Pour cacher toutes les descriptions du ticker (sauf la première)
    selectEntreprise = $("#PresentationEntreprise div:first").attr("id");
    $("#PresentationEntreprise div").css({ opacity: 0.0 });
    $("#PresentationEntreprise div").css("display", "none");
    $("#PresentationEntreprise div:first").css({ opacity: 1.0 });
    $("#PresentationEntreprise div:first").css("display","block");

    if ($("body").hasClass("Accueil") && $("#ThickerContainer").children(".ThickerItem").length >= 2) {
        jQuery("#ThickerContainer").thicker({
            idThickerPrevious: "#Precedent",
            idThickerNext: "#Suivant",
            effect: "slide",
            delay: 6000,
            speed: 500
        });
    }
    else $(".ThickerItem").css("display","block");

});