function CreateBookmarkLink() {
 title = "Warex"; 
 url = "http://www.warex.cz";
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
}

function theRotator(current) {
	//Set the opacity of all images to 0
	$('div#slideshow ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#slideshow ul li:first').css({opacity: 1.0});
	
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds	
	timerval = setInterval('rotate()',3000);
	//clearInterval(timerval); 
	
}

function thumbCreator() {
	$('div#slideshow').append('<div id="thumbs"></div>');
	$('div#slideshow ul li').each(function(i){
		var img = $(this).children('img').attr('src');
		$('#thumbs').append('<div class="slide-'+i+'"><img src="'+img+'" width="100" height="30" alt="thumb-'+i+'" /></div>')
		//$(this).
	});
	$('#thumbs div').mouseenter(function(){
		clearInterval(timerval);		
		var numero = $(this).children("img").attr("alt").split('-');
		$("#thumbs div").removeClass('active');
		$(this).addClass('active');
		$('#slideshow ul li.show').animate({opacity: 0.0}, 1000).removeClass('show');
		$('#slide-' + numero[1]).css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
		timerval = setInterval('rotate()',8000);
	})

}

function rotate() {	
	//Get the first image
	var current = ($('div#slideshow ul li.show')?  $('div#slideshow ul li.show') : $('div#slideshow ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#slideshow ul li:first') :current.next()) : $('div#slideshow ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	var prom = next.attr("id");	
	$("#thumbs div").removeClass('active');
	//alert(next.attr("id"));

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');		
	$("#thumbs div[class="+prom+"]").addClass('active')
	
};

$(document).ready(function() {	
	$('#slideshowheadline').css({'opacity': '0.9'});
	$('#rozcestnik .sekce h2 a').each(function(){
		var nadpis = $(this).text();
		//alert(nadpis);
		$(this).css({'position': 'relative'}); //, 'background': 'none'
		$(this).text('').append('<span>'+ nadpis +'</span>')
		
		$(this).find('span').css({'position': 'absolute', 'z-index': '100'});
		
		var imgName = $(this).css('background-image').replace(/^url|[\(\"\"\)]/g, '');
		//alert(imgName);
		
		$(this).append('<div class="" style=" position: absolute; z-index:80; top: 0; left: 0; display: block; width: 215px; height: 130px; overflow: hidden; "></div>');
		var innerDiv = '<div style="position: relative; display: block;"><img style="position: absolute" src="'+ imgName +'" width="215" height="130" alt="" /></div>';
		$(this).children('div').append(innerDiv);
		$(this).hover(function(){
			$(this).find('img').animate({
				width: '235',
				left: '-10',
				height: '140',
				top: '-3'
			}, 100, 'swing')
							   
		
		}, function(){
			$(this).find('img').animate({
				width: '215',
				left: '0',
				height: '130',
				top: '0'
			}, 200, 'swing')
		
		})
	})
	//Load the slideshow
	thumbCreator();
	$('div#slideshow ul li:first').addClass('show');
	var prom = $('div#slideshow ul li:first').attr("id");
	$("#thumbs div[class="+prom+"]").addClass('active')
	theRotator();
});