/*
author: justynaj
*/

var images = [
	 '_img/main1.jpg',
	 '_img/main2.jpg',
	 '_img/main3.jpg',
	 '_img/main4.jpg',
	 '_img/main5.jpg',
	 '_img/main6.jpg' 
   ];

var imgCount = images.length;   
var imgAct = 0;
var img;
var mainPage = false;

$(document).ready(function(){
		/* animacja dla linku do wersji jezykowej */
		$('#lang').find('a').hover(function(){ 
				$(this).stop().animate({paddingTop: "5px"}, 200) 
		}, function(){ 
			$(this).stop().animate({paddingTop: "0"}, 400) 
		});	
		
		
		/* animacje dla menu */
		$('#menu').find('a').hover(function(){ 
				$(this).stop().animate({paddingTop: "5px"}, 200) 
		}, function(){ 
			$(this).stop().animate({paddingTop: "0"}, 400) 
		});
});




function animateMainPage() {
		if ($("#images").children().length != 0 ) {
			img = $("#images").children()[0];
			$(img).fadeOut("slow", function() {
					$(img).remove();
					animateMainPage();
				});
		}
		else {
			imgAct++;
			if (imgAct >= imgCount) {
				imgAct = 0;
			}			
			$("#images").append("<img src='"+images[imgAct]+"' alt='' />");
			img = $("#images").children()[0];
			$(img).fadeIn("slow", function() {
					setTimeout("animateMainPage();",2000);
			});
		}
}

function preloadImages() {
	return ;
}

function MainPageAnimation() {
	preloadImages();
	animateMainPage();
}

