function ajouter_favoris(url, text) {
    //window.external.addfavorite(url, text);
    if (navigator.appName != 'Microsoft Internet Explorer') {
        window.sidebar.addPanel(text, url, "");
        return false;
    } else {
        //window.external.addfavorite('http://xhtml.css.free.fr/index.htm', 'XHTML CSS - faire un site en XHTML strict + CSS')
        return true;
    }
}

//fonction utilisee pour l'antispam des adresses mail
function dolink(ad) {
    link = 'mailto:' + ad.replace(/\.\..+t\.\./, "@");
    return link;
}


jQuery(document).ready(function () {

    $("a.thickbox").colorbox({
        transition: "fade",
        height: "80%"
    });
    $("a.flashmap").colorbox({
        transition: "fade",
        innerHeight: 500
    });

    var galleries = $('.ad-gallery').adGallery({

        slideshow: {
            enable: false
        },
        callbacks: {
            init: function () {
                this.preloadAll();
            },
            afterImageVisible: function () {
                var leftPos = (600 - $('.ad-image img').width()) / 2;
                $('.ad-image').css('width', 'auto');
                $('.ad-image').css('left', leftPos);
            }
        }
    });

    var config = {
        sensitivity: 1,
        interval: 10,
        over: megaHoverOver,
        timeout: 10,
        out: megaHoverOut
    };

    $("#meta-nav ul li .sounav").css({
        'opacity': '0'
    });
    $("#meta-nav ul > li").hoverIntent(config);

    function megaHoverOver() {
        var elmt = $(this).find(' > a > span');

        $(this).find(' > a').removeClass('off').addClass('actif');
        $(this).find(' > a > span').css({
            'color': '#F48203'
        });
        $(this).find(".sounav").stop().fadeTo('fast', 1).show(); //Find sub and fade it in
        (function ($) {
            //Function to calculate total width of all ul's
            jQuery.fn.calcSubWidth = function () {
                rowWidth = 0;
                //Calculate row
                $(this).find("ul").each(function () { //for each ul...
                    rowWidth += $(this).width(); //Add each ul's width together
                });
            };
        })(jQuery);

        if ($(this).find(".row").length > 0) { //If row exists...
            var biggestRow = 0;

            $(this).find(".row").each(function () { //for each row...
                $(this).calcSubWidth(); //Call function to calculate width of all ul's
                //Find biggest row
                if (rowWidth > biggestRow) {
                    biggestRow = rowWidth;
                }
            });

            $(this).find(".sounav").css({
                'width': biggestRow
            }); //Set width
            $(this).find(".row:last").css({
                'margin': '0'
            }); //Kill last row's margin
        } else {

            $(this).calcSubWidth(); //Call function to calculate width of all ul's
            $(this).find(".sounav").css({
                'width': rowWidth
            }); //Set Width
        }
    }

    function megaHoverOut() {
        var elmt = $(this).find(' > a > span');
        $(this).find(' > a').removeClass('actif').addClass('off');
        $(this).find(' > a > span').css({
            'color': '#ffffff'
        });

        $(this).find(".sounav").stop().fadeTo('fast', 0, function () { //Fade to 0 opactiy
            $(this).hide(); //after fading, hide it
        });
    }
});
