$(document).ready(function()
{
    $('a[href=#top]').click(function(){
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });
	$("a[rel='kbox']").colorbox({
            maxWidth    :   800,
            maxHeight   :   600,
            current     :   "foto {current} z {total}",
            next        :   "následující",
            previous    :   "předchozí",
            close       :   "zavřít"
    });
    $(":submit,a").focus(function(){$(this).blur()});
    $(".head .search input.text").focus(function(){$(this).addClass('active')}).blur(function(){$(this).removeClass('active')});
    $(".head .search input[name=s]").defaultValue('zadejte hledaný text ...');
    $('.home .team .cyc') 
        .cycle({ 
            fx:         'fade',
            speed:      500, 
            timeout:    5000,
            delay:      0,
            pause:      1,
            random:     1,
            prev:       '.home .team .prev',
            next:       '.home .team .next'
    });
    $('.banners .cyc') 
        .cycle({ 
            fx:         'fade',
            speed:      400, 
            timeout:    5000,
            pause:      1, 
            pager:      '.banners .index',
            pagerAnchorBuilder: function(idx, slide){
                return '<a href="#" class="idx'+idx+'">'+(idx+1)+'</a>';
            },
            cleartypeNoBg: true
    });
    $('.bigbanner') 
        .cycle({ 
            fx:         'fade',
            speed:      2000, 
            timeout:    5000,
            delay:      0,
            pause:      1,
            random:     1,
            timeoutFn: function(currElement, nextElement, opts, isForward) {
                var duration = $(currElement).attr('class').substring($(currElement).attr('class').indexOf('dur')+3)
                return parseInt(duration);
            }
    });

    $.setupJMPopups({screenLockerBackground:'#000000',screenLockerOpacity:'0.7'});    
    $('.mainmenu ul:not(.ft) li a[href*=nabidka]').click(function(e){
        e.preventDefault();
        var href = $(this).attr('href');
        $('.layer-map a').each(function(){
            $(this).attr('href', href + '?country=' + $(this).attr('rel'));
        });
        $.openPopupLayer({
            name:   'popup',
            width:  840,
            height: 389,
            target: 'layer-map'
        });
    });
    
    $(window).scroll(function () {
        if ($(window).scrollTop())  
            var offset = ($(window).height()-100)+$(document).scrollTop()+"px";
        else
            var offset = $(window).height();
        $('#toup').animate({top:offset},{duration:500,queue:false});    
    });  
});
