//Animane motivu
var motiveDelay = 5500;
var motiveTimeout = null;

function switchMotives() {
	var $active = $('#slideshow > :visible');

    if($active.length == 0) {
	    $active = $('#slideshow > :first');
    }

    $active.removeClass('active');

    var $next = $active.next().length ? $active.next()
        : $('#slideshow > :first');

    $next.addClass('active');

	$active.fadeOut(100, function () {
		$next.fadeIn(400);
	});

	motiveTimeout = setTimeout("switchMotives()", motiveDelay);
}

$(document).ready(function() {
	if(window.location.hash != "") {
		$('.tab').hide();
		$(window.location.hash).show();
		
		$('.tab-link').parent().removeClass('active');
		$('.tab-link').parent().find('.stin-pravy, .stin-levy').hide();
		
		$('.tab_' + window.location.hash.substring(1)).addClass('active');
		$('.tab_' + window.location.hash.substring(1)).find('.stin-pravy, .stin-levy').show();
	}
	
	$('.tab-link').click(function(){
		$('.tab-link').parent().removeClass('active');
		$('.tab-link').parent().find('.stin-pravy, .stin-levy').hide();
		$(this).parent().addClass('active');
		$(this).parent().find('.stin-pravy, .stin-levy').show();
		
		var url = $(this).attr('href');
		$('.tab').hide();
		$(url.substring(url.indexOf("#"))).show();
	});
	
	// Zalozky na uvodu
	$('.tabs ul.head li a').click(function(){
		$(this).parent().parent().find('a').removeClass('active');
		$(this).addClass('active');
		$(this).parent().parent().parent().find('.tab').hide();
		$(this).parent().parent().parent().find('#' + $(this).attr('rel')).show();
	});
	
	// Animace menu
	$("#menu li")
		.css( {backgroundPosition: "0 6px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:150})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0px 6px)"}, {duration:100})
		});
		
	// Animace submenu
	$("#submenu li")
		.css( {backgroundPosition: "0 23px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0px 6px)"}, {duration:150})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0px 23px)"}, {duration:100})
		});
		
	// Colorbox
	$("a.colorbox").colorbox({
		transition: "elastic",

		maxWidth: "98%",
		maxHeight: "98%",

		close: 'zavřít',
		previous: '&lt;&lt; předchozí',
		next: 'další &gt;&gt;',
		current: '{current} z {total}',

		photo: 1
    });
	
	// Spusteni animace motivu
	$('#slideshow :first').addClass('active');
	$('#slideshow :first').show();
	motiveTimeout = setTimeout("switchMotives()", motiveDelay);
});
	
