$(function(){

activeLink();

});

function activeLink()
{
	urlStr = window.location;
	urlStr = urlStr.toString();
	urlPart = urlStr.split("/");

	linkOnPath = '';
	for ( i in urlPart)
	{
		if (i > 2 && urlPart[i] != '')
		{
			linkOnPath += '/'+urlPart[i];
			$("a[href="+linkOnPath+"]").addClass('active').parent().addClass('active');
		}
		if(i > 2 && urlPart[i] == '')
		{
			linkOnPath += '/'+urlPart[i];
			$("a[href="+linkOnPath+"]").addClass('active').parent().addClass('active');
		}
	}

}

function cycle(){
	$('#akce div:first').addClass('show').show(0);
	setInterval('rotate()',6000);
}

function rotate() {
	// Current or first one
	var current = ($('#akce div.show')?  $('#akce div.show') : $('#akce div:first'));
	
	// Next or go back to first
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#akce div:first') :current.next()) : $('#akce div:first'));

	//Set the fade in effect for the next image, the show class has higher z-index
	next.addClass('show').slideDown(1000);

	//Hide the current image
	current.slideUp(500).removeClass('show');
};

function cycleClankyBaner(){
	$('#clanky-slider a:first').addClass('show').show(0);
	setInterval('rotateClankyBaner()',4000);
}

function rotateClankyBaner() {
	// Current or first one
	var current = ($('#clanky-slider a.show')?  $('#clanky-slider a.show') : $('#clanky-slider a:first'));

	// Next or go back to first
	elmPost = Math.floor(Math.random()*$('#clanky-slider a').length);
	var next = $('#clanky-slider a').eq(elmPost);

	if( next.index() != current.index())
	{
		//Set the fade in effect for the next image, the show class has higher z-index
		next.addClass('show').fadeIn(1000);

		//Hide the current image
		current.hide(0).removeClass('show');
	}
};

function cycleImageSlider(){
	$('.slider img:first').addClass('show').show(0);
	setInterval('rotateImageSlider()',3500);
}

function rotateImageSlider() {
	// Current or first one
	var current = ($('.slider img.show')?  $('.slider img.show') : $('.slider img:first'));

	// Next or go back to first
	elmPost = Math.floor(Math.random()*$('.slider img').length);
	var next = $('.slider img').eq(elmPost);

	if( next.index() != current.index())
	{
		//Set the fade in effect for the next image, the show class has higher z-index
		next.addClass('show').fadeIn(1000);

		//Hide the current image
		current.hide(0).removeClass('show');
	}
};



