var player;
var video;
$(document).ready(function(){
$(".blok").hide().prev().addClass('plus').click(function() {
  $(this).next().slideToggle(200);
  $(this).toggleClass('minus');
});
 $('#contextmenu a[href="'+(location.pathname)+'"]').parent().parent(".blok").show().prev().toggleClass('minus');
 $('#contextmenu a[href="'+(location.pathname)+'"]').parent().parent(".blok").show().parent(".blok").show().prev().toggleClass('minus');

var str=location.pathname;
var re=/\/domy\/galerie\/(\d+)/;
var r=str.match(re);
if(r) {
    var rr=r[1];
    $(".h2").eq(rr-1).next().show();
    $(".h2").eq(rr-1).toggleClass('minus');


}



var imgGal = $("#triggers a").size();
if(imgGal)
$("#triggers a").overlay({
	target: '#gallery',
	expose: '#f1f1f1'
}).gallery({
	speed: 800
});




$("a[href*=.flv]").attr('rel','div.overlay').click(function() {
  video=$(this).attr('href');
	}).overlay({
            expose: '#f1f1f1',
    onLoad: function() {
       
	player = $("#player").flowplayer("http://www.okal.cz/swf/flowplayer.swf",video,{play: { replayLabel: 'Přehrát znovu' }});
        player.load();
	player.flowplayer(0).play();

    },
 onClose: function() {
        $("#player").unload();
    }

});

if($(".zoom").size())
$(".zoom").overlay({ target: '#gallery', expose: '#f1f1f1'}).gallery({ speed: 500 });



});


function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 8000 );
});

