$(document).ready(function(){

   $('#menu > ul > li').hover(
        function(e){$(this).addClass('hover')},
        function(e){$(this).removeClass('hover')}
    );
   $('#menu > ul > li').each(function(){ $('li:last', this).addClass('last');});


   //init menu position
   $('#menu > ul > li > a').each(function(e){
        if( (this.toString() == document.location.toString()) ){
            $(this).parent().addClass('on');
        };
   });

   $('#menu > ul > li > ul > li a').each(function(e){
        if( (this.toString() == document.location.toString()) ){
            $(this).parent().parent().parent().addClass('on');
        };
   });

});

function showBlock( id2show, show,  style)
{
    if(style == "block")
    {
        if(show == true)
        {
            style = "block";
        }
        else
        {
            style = "none";
        }

        document.getElementById(id2show).style.display = style;
    }
    else if(style == "visibility")
    {
        if(show == true)
        {
            style = "visible";
        }
        else
        {
            style = "hidden";
        }

        document.getElementById(id2show).style.visibility = style;
    }

}

function showContactFields(value)
{
    showBlock( 'society', 0,  'block');
    showBlock( 'function', 0,  'block');
    showBlock( 'activity', 0,  'block');
    showBlock( 'products', 0,  'block');
    showBlock( 'recipients', 0,  'block');
    showBlock( 'limit_delivery', 0,  'block');
    showBlock( 'number_delivery', 0,  'block');
    showBlock( 'weight', 0, 'block');

    if( value == 2 || value == 3 )
    {
        showBlock( 'society', 1,  'block');

        //Si entreprise
        if( value == 3 )
        {
            showBlock( 'function', 1,  'block');
            showBlock( 'activity', 1,  'block');
            showBlock( 'products', 1,  'block');
            showBlock( 'recipients', 1,  'block');
            showBlock( 'limit_delivery', 1,  'block');
            showBlock( 'number_delivery', 1,  'block');
            showBlock( 'weight', 1,  'block');
        }
    }
}
