﻿$(document).ready(function () {

    //
    // Login
    //
    $.getScript(document.skinPath + 'js/login.js');

    //
    // Hack Navigateur
    //
    if ($.browser.msie && $.browser.version == '9.0') {
        $('body').addClass('ie9');
    }
    if ($.browser.msie && $.browser.version == '8.0') {
        $('body').addClass('ie8');
    }
    if ($.browser.msie && $.browser.version == '7.0') {
        $('body').addClass('ie7');
    }
    if ($.browser.webkit) {
        $('body').addClass('webkit');
    }
    if ($.browser.mozilla) {
        $('body').addClass('mozilla');
    }


    // 
    // MENU
    //

    // Initialisation au chargement
    $('div#menu>div>ul').addClass('mainMenu');

    $('ul.mainMenu>li').each(function (index) {
        $(this).addClass('root').addClass('li' + index);
    });

    $('li.root').each(function () {

        // Ajout de classes css au éléments enfants
        if ($(this).find('ul').length > 0) {
            $(this).addClass('parent');
            $(this).find('ul').addClass('child');
        }

        // Détection de la page en cours
        var idEnCours = 'dnn_NAV1_ctlNAV1ctr' + document.tabID;
        if ($(this).attr('id') == idEnCours) {
            // niveau root
            $(this).addClass('sel');
        } else {
            // niveau enfant
            var parent = $(this);
            parent.find('ul.child li').each(function () {
                if ($(this).attr('id') == idEnCours) {
                    parent.addClass('sel');
                }
            });
        }

    });

    // Actions en cours de navigation
    $('li.parent').hover(function () {
        $(this).find('ul.child').show();
    }, function () {
        $(this).find('ul.child').hide();
    });

    // Admin
    if ($('div.ControlPanel').length > 0) {
        $('li.root:last').addClass('admin');
    }
    // Admin catalog
    if ($('div.optaManagement').length > 0) {
        $('div#menu').hide();
    }





    //Slider Accueil
    $('div.containerSliderAccueil').optaSlider({
        mode: 'slide',
        delay: 5000,
        duration: 700,
        autoPrevNextPosition : false 
    });


    // ToolTip
    $('li.liPgLogoAd a').hover(function () {
        $(this).parent().find('div.toolTipAd').show();
    }, function () {
        $(this).parent().find('div.toolTipAd').hide();
    });

    // Login
    $('.optaTiersLogin div.modeLogin a.btnOptaEcomLogin').text('Se connecter');

    // Btn Newsletter
    $('div.optaNewsSubscribe a.btnSubscribe').text('OK');



});





