﻿function getParamValue(param, url) {
    var u = url == undefined ? document.location.href : url;
    var reg = new RegExp('(\\?|&|^)' + param + '=(.*?)(&|$)');
    matches = u.match(reg);
    if (matches == null) {
        matches = '';
        return matches;
    }
    else {
        return matches[2] != undefined ? decodeURIComponent(matches[2]).replace(/\+/g, ' ') : '';
    }
}

var count = Math.round((Math.random() * 10));
var countprec = count;

function slideshow() {
    while (count == countprec) {
        count = Math.round((Math.random() * 10));
    }
    $('#diapo img:eq(' + count + ')').fadeIn(1000);
    setTimeout(function() { $('#diapo img:eq(' + (countprec) + ')').fadeOut(1000); }, 2500);
    setTimeout(function() {
        countprec = count;
        count = Math.round((Math.random() * 10));
        slideshow();
    }, 5000);
}


$(document).ready(function() {
    var menuOuvert = getParamValue('menuOuvert');

    if (menuOuvert != '') {
        $('#diapo img:eq(' + count + ')').show();
        setTimeout(function() { slideshow(); }, 3000);
    }

    var le_nbli = $('#smenu_' + menuOuvert).children().size();
    $('#smenu_' + menuOuvert).stop().animate({ 'height': (le_nbli * 16) + 'px', 'marginTop': '80px', 'paddingTop': '10px', 'paddingBottom': '10px'});
    $('#smenu_' + menuOuvert + '~.ombre').stop().animate({ 'height': (le_nbli * 16) + 'px', 'marginTop': '80px', 'padding': '10px 5px' });

    $('#menu .menu').live('mouseover', function() {
        var nbli = $('.sousmenu', this).children().size();
        $('.sousmenu', this).not('#smenu_' + menuOuvert).stop().animate({ 'height': (nbli * 16) + 'px', 'marginTop': '80px', 'paddingTop': '10px', 'paddingBottom': '10px' });
        /*$('.ombre', this).not('#smenu_' + menuOuvert + '~.ombre').stop().animate({ 'height': (nbli * 16) + 'px', 'marginTop': '80px', 'padding': '10px 5px' });*/
    });

    $('#menu .menu').live('mouseout', function() {
        $('.sousmenu', this).not('#smenu_' + menuOuvert).each(function() { $(this).stop().animate({ 'height': '0', 'marginTop': '-200px', 'paddingTop': '0px', 'paddingBottom': '0px' }) });
        /*$('.ombre', this).not('#smenu_' + menuOuvert + '~.ombre').each(function() { $(this).stop().animate({ 'height': '0', 'marginTop': '-200px', 'padding': '0px 5px' }) });*/
    });

});
  
  
    
