﻿// Fichier JScript

function initMenu() {
    //$('#menu ul:first').show();
    //$('#menu >li:first >a').attr('id','selected');
    $('#menu ul').hide();   
    $('#menu li a').click(
        function() {
            $('#menu li a').removeAttr('id');                          
            $(this).attr('id','selected');
            var checkElement = $(this).next();
            var ul = $(this).parent().parent();
            var firstA = checkElement.find(':nth-child(1)').find(':nth-child(1)'); // on récupère la première balise a du sous menu
            //alert(firstA.attr('href'));
            
            if((checkElement.is('ul')) && (checkElement.is(':visible'))) {                
                checkElement.fadeOut('normal');
                $(this).removeAttr('id');
                //$('#menu ul:visible').hide();
                return false;
            }
            if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
               // $('#menu ul:visible').hide(); 
               // checkElement.fadeIn('normal');
                if(firstA.attr('href') != 'undefined'){                    
                        $(window.location).attr('href', firstA.attr('href'));
                    }
                return false;
            }
            if(!checkElement.is('ul')){
                if(ul.is('[id=menu]')){
                    $('#menu ul:visible').fadeOut('normal');
                }else{
                    ul.prev().attr('id','itemMenuSelected');                    
                }
                return true;
            }
        }
    );     
}

$(document).ready(function() {
    initMenu();
    expandFirst();
    $('a[rel*=facebox]').facebox();
    if($("ul#ticker01"))
    {
        $("ul#ticker01").liScroll();
    }
});
