var $states;

$(function() {
    Cufon.now();
    
    $('html').removeClass('no-js').addClass('js');

    // Start the slideshow
    if (jQuery().cycle) {
        $('#slider').cycle({
            timeout: 10000,
            pager: '#pager',
            slideExpr: '.slide'
        });
    }
        
    // Placeholders
    $('input[placeholder], textarea[placeholder]').live('addPlaceholder', function() {
        if ($(this).val() == '') {
            $(this).val($(this).attr('placeholder'));
        }
    }).live('clearPlaceholder', function() {
        if ($(this).val() == $(this).attr('placeholder')) {
            $(this).val('');
        }
    }).live('click', function() {
        $(this).trigger('clearPlaceholder');
    }).live('focus', function() {
        $(this).trigger('clearPlaceholder');
    }).live('blur', function() {
        $(this).trigger('addPlaceholder');
    }).trigger('addPlaceholder');
    
    // Colorbox
    if (jQuery().colorbox) {
      $('.colorbox').colorbox({transition: 'fade'});
    }
    
    // Start the slideshow
    if (jQuery().cycle) {
        if ($('#detail .container_image .colorbox').length > 1) {
            $('#detail .container_image').cycle({
                timeout: 0,
                next: $('.container_image .next'),
                prev: $('.container_image .prev'),
                slideExpr: '.colorbox'
            });
        }
        else {
            $('#detail .container_image .arrows').remove();
        }
    }
    
    // Partners
    $('.cities > li').addClass('closed');
    
    $('.city').click(function() {
        var closed = $(this).closest('li').hasClass('closed');
        
        $(this).parents('.cities').find('> li').removeClass('opened').addClass('closed');
        
        if (closed) {
            $(this).closest('li').addClass('opened').removeClass('closed');
        }
    });
    
    $states = $('#country_cs > ul > li').addClass('hidden');
    
    // Header navigation for IE6/7
    var $subnav = $('#header > .container > .nav > li ul').show().hide();
    $('#header > .container > .nav > li').hover(function() {
        $(this).find('ul').show();
    }, function() {
        $subnav.hide();
    });
});

function zobrazKraj(name) {
    $states.addClass('hidden');
    $('#country_cs > ul > li[title=' + name + ']').removeClass('hidden');
}

