$(document).ready(function() {

    $('input[name=search_button]').attr('disabled', true);

    $('input[name=search_text]').bind('focus', function() {
       
        $(this).val('');
        $(this).css({
            color: '#000000',
            fontStyle: 'normal'
        });
        $('input[name=search_button]').removeAttr('disabled');
       
    });
    
    $('input[name=search_button]').bind('click', function() {
        
        if($('input[name=search_text]').val().length < 3) {
            alert('Hledaný výraz je příliš krátký.');
            return false;
        }
    });

    $('li.link').hover(
        function(){
            $('span', $(this)).css({
                color: '#000000'
            });
            $('.effect',$(this)).css({
                top: '25px'
            });
                
            $('.effect',$(this)).animate({
                height: '33px',
                top: '0px'
            }, 200);
        }, 
        function(){
            if(!$(this).hasClass('active')) {
                $('span', $(this)).css({
                    color: '#FFFFFF'
                });
            }
            $('.effect',$(this)).stop();
            $('.effect',$(this)).css({
                height: '0px', 
                top: '0px'
            });
        });


    $(".subgallery .arrow").bind('click', function() {

        var blok = $(this).parents('.subgallery:first').find('.gallery');
        if($(this).hasClass('down')) {

            blok.animate({
                height: '160px'
            }, 'normal', function() {

                });

            $(this).removeClass('down');
        } else {

            var h = Math.round(blok.find('img').length / 3 + 0.49)*163;
            blok.animate({
                height: h+'px'
            }, 'normal', function() {
                });
            $(this).addClass('down');   
        }
    });

    var i = 0;
    $(".subgallery").each(function() {
        
        $(this).find('a').attr('rel', 'lightbox'+i);
        $('a[rel=lightbox'+i+']').lightBox();

        i++;
    });

    $('a[rel=lightbox]').lightBox();
});
