function logger(msg)
{
    if (console && console.log){
        console.log(msg);
    }
}

function sendCotation()
{
    $.ajax({
        url: _server + '/contact/send',
        dataType: 'html',
        type: 'POST',
        error: function( jqXHR, textStatus, errorThrown ) {
            logger(textStatus);
        },
        success: function( data ) {
            logger(data);
            //$('#cotation_request').replaceWith('<div><p>Email envoyé !</p><p>' + data + '</p></div>');
        }
    });
}

$(function(){
    $('#UI_sections .section').hide();
    var sections = $('#UI_header .nav li a.arrow');
    var section_current = 'none';
    for(var i = 0 ; i < sections.length ; i++)
    {
        $('#UI_header .nav li a.arrow').eq(i).parent().attr('alt', i);
        $('#UI_header .nav li a.arrow').eq(i).data('i', i);
        $('#UI_header .nav li a.arrow').eq(i).click(function(){
            $('#UI_header .nav li').removeClass('hover');
            if(section_current == 'none' || section_current != $(this).data('i'))
            {
                //console.log('Afficher la sous-nav ' + $(this).data('i'));
                $(this).parent().addClass('hover');
                $('#UI_sections .section').slideUp('fast');
                $('#UI_sections .section').eq($(this).data('i')).slideDown('fast');
                section_current = $(this).data('i');
            }
            else
            {
                $(this).parent().removeClass('hover');
                $('#UI_sections .section').slideUp('fast');
                section_current = 'none';
            }
        });
    }
    $('#UI_header .nav li').hover(function(){
        $(this).addClass('hover');
    },function(){
        if(section_current != $(this).attr('alt'))
        {
            $(this).removeClass('hover');
        }
    });
    
    $('#UI_header #keyword').blur(function(){
        logger('Blur !')
        if($(this).val() == '')
        {
            logger('Aucun mot-clé saisi !')
            $(this).val('Trouver');
            $(this).animate({width: '60px'}, 800);
        }
    });
    $('#UI_header #keyword').focus(function(){
        logger('Focus !')
        if($(this).val() == 'Trouver')
        {
            $(this).val('');
            $(this).animate({width: '120px'}, 300);
        }
    });
}); 
