window.maxFotoNr = 1;
window.currentFoto = 1;
window.timelen = 2000;
window.introticker = null;

$(document).ready(function(){
	
	PrepareIntro();
	StartIntro();
});


function PrepareIntro()
{
	var iObj = $("#intro");
	var counter = 0;
	iObj.children("img").each(function(){
		counter++;
		$(this).attr('id', 'foto_'+counter);
	});
	window.maxFotoNr = counter;
}


function StartIntro()
{
	window.introticker = setInterval("TickerChangeImage()", window.timelen);
}

function TickerChangeImage()
{
	var curr = window.currentFoto;
	var next = curr + 1;
	if (curr == window.maxFotoNr) {
		//next = 1;
		StopIntro();
	}

	$('#foto_'+next).fadeIn(window.timelen);
	$('#foto_'+curr).fadeOut(window.timelen);
	window.currentFoto = next;
}

function StopIntro()
{
	clearInterval(window.introticker);
	document.location.href = window.mainpage;
}
