function ShowBannerImage(cont_div,img) {
	
   //$('#'+cont_div).BgImageTransition('media/banners_top/'+img);
   $('#banner_gallery').hide();
   $('#banner_gallery').css("z-index","-1");
   $('#'+cont_div).css("background-image","url(media/banners_top/"+img+")");
   //$('#'+cont_div).fadeIn("slow");
}


function StartBannerGallery() {
   
	$('#banner_gallery').show();  
    $('#banner_gallery').css("z-index","0");
}


function StopBannerGallery() {
	
	$('#banner_gallery').css("z-index","-1");
	$('#banner_gallery').hide();
}


//slideshow
var slideshowSpeed = 6000;

/*!!! pole photos*/
$(document).ready(function() {

	
	$("#back").click(function() {
		stopAnimation();
		navigate("back");
	});
	
	
	$("#next").click(function() {
		stopAnimation();
		navigate("next");
	});
	
	var interval;
	$("#control").toggle(function(){
		stopAnimation();
	}, function() {
		
		$(this).css({ "background-image" : "url(images/btn_pause_small.png)" });
		
		
		navigate("next");
		
		interval = setInterval(function() {
			navigate("next");
		}, slideshowSpeed);
		
	});
	
	
	var activeContainer = 1;	
	var currentImg = 0;
	var animating = false;
	var navigate = function(direction) {
		
		if(animating) {
			return;
		}
		
		if(direction == "next") {
			currentImg++;
			if(currentImg == photos.length + 1) {
				currentImg = 1;
			}
		} else {
			currentImg--;
			if(currentImg == 0) {
				currentImg = photos.length;
			}
		}
				
		var currentContainer = activeContainer;
		if(activeContainer == 1) {
			activeContainer = 2;
		} else {
			activeContainer = 1;
		}
		
		showImage(photos[currentImg - 1], currentContainer, activeContainer);
		
	};
	
	var currentZindex = -1;
	var showImage = function(photoObject, currentContainer, activeContainer) {
		animating = true;
				
		currentZindex--;
				
		$("#headerimg" + activeContainer).css({
			"background-image" : "url(media/banners_top/" + photoObject.image + ")",
			"display" : "block",
			"z-index" : currentZindex
		});
		
		
		$("#headertxt").css({"display" : "none"});
				
		$("#firstline").html(photoObject.firstline);
		$("#secondline")
			.attr("href", photoObject.url)
			.html(photoObject.secondline);
		$("#pictureduri")
			.attr("href", photoObject.url)
			.html(photoObject.title);
		
		
		// Fade out
		$("#headerimg" + currentContainer).fadeOut(function() {
			setTimeout(function() {
				$("#headertxt").css({"display" : "block"});
				animating = false;
			}, 500);
		});
	};
	
	var stopAnimation = function() {
		
		$("#control").css({ "background-image" : "url(images/btn_play_small.png)","cursor" : "pointer" });
		
		clearInterval(interval);
	};
	
	
	navigate("next");
		
	interval = setInterval(function() {
		navigate("next");
	}, slideshowSpeed);
	
	//stopAnimation();
	
});






