$(document).ready(function(){
    $("#searchInput").focus(function(){
        $("#searchForm").addClass('focused');
    });
    $("#searchInput").blur(function(){
        //$("#searchForm").removeClass('focused');
        //$("#suggest").css('display', 'none');
    });
    
    $("#searchInput").keyup(function(){
        //var query = $("#searchInput").attr('value');
        var query = $("#searchInput").val();
        
       if(query.length > 2){
           $("#suggest").stop().fadeTo(450, 0.2);
           /*$.ajax({
               type: 'POST',
               url: 'http://figrema.dev.esencia.cz/search/suggest',
               data: {'query': query},
               //dataType: JSON,
               succes: function(data){
                   alert(data);
               },
               error: errorFt
           });*/
           
           $.post('http://www.figrema.cz/search/suggest', {q: query, height: $(window).height()}, function(data){
               //alert(data);
               $("#suggest").html(data);
               
               $("#suggest").stop().fadeTo(450, 1);
           });
       }
    });
    
    
    
    $('.suggest-letter').live('mouseover',  function(){
        $(this).addClass('hover');
        $(this).stop().animate({
            marginLeft: 0,
            width: '309px',
            height: '95px'
        }, 300);
        $(this).children('img').stop().animate({
            'width': '90px',
            'height': '90px'
        });
        $(this).children('p').stop().animate({
            'margin-top': '-90px',
            'height': '90px'
        });
    });
    $('.suggest-letter').live('mouseout',  function(){
         $(this).removeClass('hover');
        $(this).stop().animate({
            marginLeft: '45px',
            width: '263px',
            height: '50px'
        }, 300);
        $(this).children('img').stop().animate({
            'width': '44px',
            'height': '40px'
        });
        $(this).children('p').stop().animate({
            'margin-top': '-45px',
            'height': '44px'
        });
    });
});

function handleFt(data){
    alert('aa');
}

function errorFt(data){
    alert('shot');
}
