var carrousel = {
    nbSlide: 0,
    nbCurrent: 1,
    elemCurrent: null,
    elem: null,
    timer: null,
    init: function (elem) {
        this.nbSlide = elem.find(".slide").length;
        elem.append('<div class="quicknavigation"></div>');
        for (var i = 1; i <= this.nbSlide; i++) {
            elem.find(".quicknavigation").append("<span>" + i + "</span>");
        }
        elem.find(".quicknavigation span").click(function () {
            carrousel.gotoSlide(jQuery(this).text());
        })
        this.elem = elem;
        elem.find(".slide").hide();
        elem.find(".slide:first").show();
        this.elemCurrent = elem.find(".slide:first");
        this.elem.find(".quicknavigation").css("opacity", 0.6);
        this.elem.find(".quicknavigation span:first").addClass("active");
        carrousel.play();
        elem.mouseover(carrousel.stop);
        elem.mouseout(carrousel.play);
    },
    gotoSlide: function (num) {
        if (num == this.nbCurrent) {
            return false;
        }
        this.elemCurrent.find(".visu").fadeOut();
        this.elem.find("#slide" + num).show();
		this.elem.find("#slide" + num).css("z-index",0);
        this.elem.find("#slide" + num + " .visu").hide().fadeIn();
        var titleHeight = this.elemCurrent.find(".title").height();
        this.elemCurrent.find(".title").fadeOut();
        this.elem.find("#slide" + num + " .title").fadeIn();
		this.elem.find("#slide" + num + " .title").css("z-index",0);
        this.elem.find(".quicknavigation span").removeClass("active");
        this.elem.find(".quicknavigation span:eq(" + (num - 1) + ")").addClass("active");
        this.nbCurrent = num;
        this.elemCurrent = this.elem.find("#slide" + num);
    },
    next: function () {
        var num = this.nbCurrent + 1;
        if (num > this.nbSlide) {
            num = 1;
        }
        this.gotoSlide(num);
    },
    prev: function () {
        var num = this.nbCurrent - 1;
        if (num < 1) {
            num = this.nbSlide;
        }
        this.gotoSlide(num);
    },
    stop: function () {
        window.clearInterval(carrousel.timer);
    },
    play: function () {
        window.clearInterval(carrousel.timer);
        carrousel.timer = window.setInterval("carrousel.next()", 5000);
    }
}

jQuery(document).ready(function() {
    carrousel.init(jQuery("#carrousel"));
});

// AFFICHAGE DYNAMIQUE
function aff(idDiv) {
    var div = document.getElementById(idDiv);
    if (div.style.display == "none") div.style.display = "";
    else div.style.display = "";
}

function cache(idDiv) {
    var div = document.getElementById(idDiv);
    if (div.style.display == "") div.style.display = "none";
    else div.style.display = "none";
}

function affcache(idDiv) {
    var div = document.getElementById(idDiv);
    if (div.style.display == "none") jQuery(document).ready(function() {
        jQuery(div).slideDown();
        div.style.display = "";
    });
    else div.style.display = "none";
}

function affall(classDiv) {
    var div = document.getElementsByClassName(classDiv);

    for (var i = 0; i < div.length; i++) {
        if (div[i].style.display == "none") {
            jQuery(document).ready(function() {
                jQuery(div[i]).slideDown();
                div[i].style.display = "";
            });
        } else div[i].style.display = "none";
    }

}

// ESPACE MEMBRE
function monprofil(one, two, three, four, five) {
    document.getElementById(one).className = "esscalife_1_2";
    document.getElementById(two).className = "esscalife_2_1";
    document.getElementById(three).className = "esscalife_3_1";
    document.getElementById(four).className = "esscalife_4_1";
    document.getElementById(five).className = "esscalife_5_1";
}

function maphoto(one, two, three, four, five) {
    document.getElementById(one).className = "esscalife_2_2";
    document.getElementById(two).className = "esscalife_1_1";
    document.getElementById(three).className = "esscalife_3_1";
    document.getElementById(four).className = "esscalife_4_1";
    document.getElementById(five).className = "esscalife_5_1";
}

function monpass(one, two, three, four, five) {
    document.getElementById(one).className = "esscalife_3_2";
    document.getElementById(two).className = "esscalife_1_1";
    document.getElementById(three).className = "esscalife_2_1";
    document.getElementById(four).className = "esscalife_4_1";
    document.getElementById(five).className = "esscalife_5_1";
}

function mavieassoc(one, two, three, four, five) {
    document.getElementById(one).className = "esscalife_4_2";
    document.getElementById(two).className = "esscalife_1_1";
    document.getElementById(three).className = "esscalife_2_1";
    document.getElementById(four).className = "esscalife_3_1";
    document.getElementById(five).className = "esscalife_5_1";
}

function mesalertes(one, two, three, four, five) {
    document.getElementById(one).className = "esscalife_5_2";
    document.getElementById(two).className = "esscalife_1_1";
    document.getElementById(three).className = "esscalife_2_1";
    document.getElementById(four).className = "esscalife_3_1";
    document.getElementById(five).className = "esscalife_4_1";
}

// MOTEUR DE RECHERCHE DU SITE
function affsearch() {
    var div = document.getElementById('lookfor');
    var diw = document.getElementById('welcome');
    if (div.style.display == "none") jQuery(document).ready(function() {
        jQuery(diw).hide();
        jQuery(div).show();
    });
    else jQuery(document).ready(function() {
        jQuery(diw).show();
        jQuery(div).hide();
    });
}


function affavance() {

jQuery(document).ready(function() {
	
	var aff = jQuery("#rechercheavancee").css("display");
	
	if (aff=="none")
	{
								
		jQuery("#recherchedirecte").hide();		
        jQuery("#recherchedirecte").css("display","none");
        jQuery("#rechercheavancee").show();
        jQuery("#rechercheavancee").css("display","");
		
	}
	else
	{

		jQuery("#rechercheavancee").hide();		
        jQuery("#rechercheavancee").css("display","none");
        jQuery("#recherchedirecte").show();
        jQuery("#recherchedirecte").css("display","");

	}
	
    });
}




function followme() {
    location.replace('http://www.youtube.com/watch?v=nF54GJMhyNc');
}

function followmeto() {
    location.replace('http://www.youtube.com/watch?v=hGNQBeZqr2s');
}

// ROLLOVERS
function MM_swapImgRestore() { //v3.0
    var i,
    x,
    a = document.MM_sr;
    for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}
function MM_preloadImages() { //v3.0
    var d = document;
    if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i,
        j = d.MM_p.length,
        a = MM_preloadImages.arguments;
        for (i = 0; i < a.length; i++) if (a[i].indexOf("#") != 0) {
            d.MM_p[j] = new Image;
            d.MM_p[j++].src = a[i];
        }
    }
}

function MM_findObj(n, d) { //v4.01
    var p,
    i,
    x;
    if (!d) d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (! (x = d[n]) && d.all) x = d.all[n];
    for (i = 0; ! x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; ! x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n);
    return x;
}

function MM_swapImage() { //v3.0
    var i,
    j = 0,
    x,
    a = MM_swapImage.arguments;
    document.MM_sr = new Array;
    for (i = 0; i < (a.length - 2); i += 3) if ((x = MM_findObj(a[i])) != null) {
        document.MM_sr[j++] = x;
        if (!x.oSrc) x.oSrc = x.src;
        x.src = a[i + 2];
    }
}

// MENU DE NAVIGATION PRINCIPAL
(function($) {
    $.fn.hoverIntent = function(f, g) {
        var cfg = {
            sensitivity: 7,
            interval: 100,
            timeout: 0
        };
        cfg = $.extend(cfg, g ? {
            over: f,
            out: g
        }: f);
        var cX,
        cY,
        pX,
        pY;
        var track = function(ev) {
            cX = ev.pageX;
            cY = ev.pageY;
        };
        var compare = function(ev, ob) {
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) {
                $(ob).unbind("mousemove", track);
                ob.hoverIntent_s = 1;
                return cfg.over.apply(ob, [ev]);
            } else {
                pX = cX;
                pY = cY;
                ob.hoverIntent_t = setTimeout(function() {
                    compare(ev, ob);
                },
                cfg.interval);
            }
        };
        var delay = function(ev, ob) {
            ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            ob.hoverIntent_s = 0;
            return cfg.out.apply(ob, [ev]);
        };
        var handleHover = function(e) {
            var p = (e.type == "mouseover" ? e.fromElement: e.toElement) || e.relatedTarget;
            while (p && p != this) {
                try {
                    p = p.parentNode;
                } catch(e) {
                    p = this;
                }
            }
            if (p == this) {
                return false;
            }
            var ev = jQuery.extend({},
            e);
            var ob = this;
            if (ob.hoverIntent_t) {
                ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
            }
            if (e.type == "mouseover") {
                pX = ev.pageX;
                pY = ev.pageY;
                $(ob).bind("mousemove", track);
                if (ob.hoverIntent_s != 1) {
                    ob.hoverIntent_t = setTimeout(function() {
                        compare(ev, ob);
                    },
                    cfg.interval);
                }
            } else {
                $(ob).unbind("mousemove", track);
                if (ob.hoverIntent_s == 1) {
                    ob.hoverIntent_t = setTimeout(function() {
                        delay(ev, ob);
                    },
                    cfg.timeout);
                }
            }
        };
        return this.mouseover(handleHover).mouseout(handleHover);
    };
})(jQuery);

; (function($) {
    $.fn.superfish = function(op) {

        var sf = $.fn.superfish,
        c = sf.c,
        $arrow = $(['<span class="', c.arrowClass, '"></span>'].join('')),
        over = function() {
            var $$ = $(this),
            menu = getMenu($$);
            clearTimeout(menu.sfTimer);
            $$.showSuperfishUl().siblings().hideSuperfishUl();
        },
        out = function() {
            var $$ = $(this),
            menu = getMenu($$),
            o = sf.op;
            clearTimeout(menu.sfTimer);
            menu.sfTimer = setTimeout(function() {
                o.retainPath = ($.inArray($$[0], o.$path) > -1);
                $$.hideSuperfishUl();
                if (o.$path.length && $$.parents(['li.', o.hoverClass].join('')).length < 1) {
                    over.call(o.$path);
                }
            },
            o.delay);
        },
        getMenu = function($menu) {
            var menu = $menu.parents(['ul.', c.menuClass, ':first'].join(''))[0];
            sf.op = sf.o[menu.serial];
            return menu;
        },
        addArrow = function($a) {
            $a.addClass(c.anchorClass).append($arrow.clone());
        };

        return this.each(function() {
            var s = this.serial = sf.o.length;
            var o = $.extend({},
            sf.defaults, op);
            o.$path = $('li.' + o.pathClass, this).slice(0, o.pathLevels).each(function() {
                $(this).addClass([o.hoverClass, c.bcClass].join(' ')).filter('li:has(ul)').removeClass(o.pathClass);
            });
            sf.o[s] = sf.op = o;

            $('li:has(ul)', this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent': 'hover'](over, out).each(function() {
                if (o.autoArrows) addArrow($('>a:first-child', this));
            }).not('.' + c.bcClass).hideSuperfishUl();

            var $a = $('a', this);
            $a.each(function(i) {
                var $li = $a.eq(i).parents('li');
                $a.eq(i).focus(function() {
                    over.call($li);
                }).blur(function() {
                    out.call($li);
                });
            });
            o.onInit.call(this);

        }).each(function() {
            var menuClasses = [c.menuClass];
            if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
            $(this).addClass(menuClasses.join(' '));
        });
    };

    var sf = $.fn.superfish;
    sf.o = [];
    sf.op = {};
    sf.IE7fix = function() {
        var o = sf.op;
        if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity != undefined) this.toggleClass(sf.c.shadowClass + '-off');
    };
    sf.c = {
        bcClass: 'sf-breadcrumb',
        menuClass: 'sf-js-enabled',
        anchorClass: 'sf-with-ul',
        arrowClass: 'sf-sub-indicator',
        shadowClass: 'sf-shadow'
    };
    sf.defaults = {
        hoverClass: 'sfHover',
        pathClass: 'overideThisToUse',
        pathLevels: 1,
        delay: 800,
        // one second delay on mouseout 
        animation: {
            height: 'show',
            duration: 'slow'
        },
        // fade-in and slide-down animation 
        speed: 'fast',
        // faster animation speed 
        autoArrows: false,
        dropShadows: false,
        disableHI: false,
        // true disables hoverIntent detection
        onInit: function() {},
        // callback functions
        onBeforeShow: function() {},
        onShow: function() {},
        onHide: function() {}
    };
    $.fn.extend({
        hideSuperfishUl: function() {
            var o = sf.op,
            not = (o.retainPath === true) ? o.$path: '';
            o.retainPath = false;
            var $ul = $(['li.', o.hoverClass].join(''), this).add(this).not(not).removeClass(o.hoverClass).find('>ul').hide().css('visibility', 'hidden');
            o.onHide.call($ul);
            return this;
        },
        showSuperfishUl: function() {
            var o = sf.op,
            sh = sf.c.shadowClass + '-off',
            $ul = this.addClass(o.hoverClass).find('>ul:hidden').css('visibility', 'visible');
            sf.IE7fix.call($ul);
            o.onBeforeShow.call($ul);
            $ul.animate(o.animation, o.speed,
            function() {
                sf.IE7fix.call($ul);
                o.onShow.call($ul);
            });
            return this;
        }
    });

})(jQuery);

jQuery(document).ready(function(){
jQuery(function() {
    jQuery('ul.sf-menu').superfish();
});
								});