jQuery.fn.exists = function() { return jQuery(this).length > 0; }



/*var outline = "";
var details = "";

var uriCourant = document.location.pathname;

var indiceDepart = uriCourant.lastIndexOf('/') + 1; // Plus 1 car on ne veut pas le '/'.
var indiceArrivee = uriCourant.length - 0; // Moins les 4 caractères de l'extension.

var idPage = uriCourant.substring(indiceDepart, indiceArrivee);*/

$(document).ready(function() {

    // convert (at) to @ for spam bot!

    $('div#contact_us span.at').html('@');


    

    /* great display infobule */

    $(function() {
        $("span.icon img").mouseover(function() {

            if ($(this).attr("title") == "") return false;

            $("body").append('<span class="infobulle"></span>');
            var bulle = $(".infobulle:last");
            bulle.append($(this).attr("title"));
            $(this).attr("title", "");
            var posTop = $(this).offset().top - $(this).height();
            var posLeft = $(this).offset().left + $(this).width() / 2 - bulle.width() / 2;
            bulle.css({
                left: posLeft,
                top: posTop - 20,
                opacity: 0
            });
            bulle.animate({
                top: posTop - 10,
                opacity: 0.90
            });
        });

        $("span.icon img").mouseout(function() {
            var bulle = $(".infobulle:last");
            $(this).attr("title", bulle.text());
            bulle.animate(
                {
                    top: bulle.offset().top + 10,
                    opacity: 0
                },
                500,
                "linear",
                function() {
                    bulle.remove();
                }
            );
        });
    });

    //    $("#dynamic a#outline").click(function() {
    //        $("#dynamic a").removeClass("current");
    //        $(this).addClass("current");
    //        $("#dynamicContent").html(outline);
    //    });

    //    $("#dynamic a#details").click(function() {
    //        $("#dynamic a").removeClass("current");
    //        $(this).addClass("current");
    //        outline = $("#dynamicContent").html();
    //        $('#dynamicContent').load('/test.html');
    //        //$('#dynamicContent').load('/en-US/Training/Details/' + idPage);
    //    });



    // acordeon only if element exist
    // simple accordion
    if ($('#search_result').exists()) {
        jQuery('#search_result').accordion({
            autoheight: false,
            header: '.onglet',
            alwaysOpen: false
            //active: "a.onglet"
        });

        if ($.browser.msie && $.browser.version == 6) // display error with IE6 with the height // fix height
        {
            $('#content').height($('#left').height());
        }
    }



    // display print if js was activate
    if ($('span.print').exists()) {
        $('span.print').css('display', 'inline');
    }

    // pop up for "pop up"
    if ($("a[rel^='prettyPhoto']").exists()) {
        $(document).ready(function() {
            $("a[rel^='prettyPhoto']").prettyPhoto();
        });
    }

});

