
function setCookieMinutes(key, value, minutes) {
    value = encodeURIComponent(value); // hodnota value by měla být minimálně escapována pomocí funkce escape()
    value+='; path=/';
    // expirace
    var date = new Date();
    date.setTime(date.getTime() + minutes * 60 * 1000);
    value+='; expires=' + date.toGMTString();
    // secure
    document.cookie = key + '=' + value;
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


function slideSwitch() {
    var $active = $('#slideshow DIV.active');
    var $activeobr = $('#homepage-clanky-obrazky A.active');

    if ( $active.length == 0 ) $active = $('#slideshow DIV:last');
    if ( $activeobr.length == 0 ) $activeobr = $('#homepage-clanky-obrazky A:last');

    var $next =  $active.next().length ? $active.next() : $('#slideshow DIV:first');
    var $nextobr =  $activeobr.next().length ? $activeobr.next() : $('#homepage-clanky-obrazky A:first');

    $active.addClass('last-active');
    $activeobr.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
        
    $nextobr.css({opacity: 0.5})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $activeobr.removeClass('active last-active');
        });
    $activeobr.animate({opacity: 0.5}, 1000, function() {
    });

}



$('document').ready(function(){
    setInterval( "slideSwitch()", 3000 );
    
    var time = new Date();
    var hour = time.getHours(); 
    var x = 1;
    if(hour >= 20 || hour <= 6){
        if(readCookie("pozadi") > 0){
            x = readCookie("pozadi");
            setCookieMinutes("pozadi", x, 15, "/");
        } else {
            x = 1+Math.round(Math.random()*2);
            setCookieMinutes("pozadi", x, 15, "/");
        }
    }
/*
    $('body').css("background","url('/images/pozadi.jpg')");
    if(x == 1){
        $('body').css("background","url('/images/pozadi.jpg')");
    } else if(x == 2) {
        $('body').css("background","url('/images/pozadi2.png')");
    } else {
        $('body').css("background","url('/images/pozadi3.png')");
    }*/
    
    $('#s6').after('<div id="nav">').cycle({
        fx:     'scrollUp',
        timeout: 6000,
        delay:  -2000,
        pager:  '#nav',
        random:0
    });
    
    $('#js_skladem').click(function(){
        if($(this).attr('class')=="prep_pas"){
            $(this).removeClass("prep_pas");
            $(this).addClass("prep_akt");
            $('#js_novinky').removeClass("prep_akt");
            $('#js_novinky').addClass("prep_pas");
            $('#jezditko2').hide();
            $('#jezditko3').show();
            return false;
        }
    });
    $('#js_novinky').click(function(){
        if($(this).attr('class')=="prep_pas"){
            $(this).removeClass("prep_pas");
            $(this).addClass("prep_akt");
            $('#js_skladem').removeClass("prep_akt");
            $('#js_skladem').addClass("prep_pas");
            $('#jezditko3').hide();
            $('#jezditko2').show();
            return false;
        }
    });
    
    $('#jezditko3').hide();
    
    $('#katPopisek p').hide();
    $('#katPopisek p:first').show();
    $('#katPopisek h2').hide();
    $('#katPopisek h2:first').show();
    $('a.morePopisku').click(function(){
        $('#katPopisek p').show();
        $('#katPopisek h2').show();
    });
    
});

<!-- Start of Zopim Live Chat Script -->

window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=
z.s=d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o
){z.set._.push(o)};$.setAttribute('charset','utf-8');$.async=!0;z.set.
_=[];$.src=('https:'==d.location.protocol?'https://ssl':'http://cdn')+
'.zopim.com/?fCTamCLRU0ijCAftsxPfZxbWUOC5GbK7';$.type='text/java'+s;z.
t=+new Date;z._=[];e.parentNode.insertBefore($,e)})(document,'script')

<!-- End of Zopim Live Chat Script -->
