var glbNumImagesLoaded = 0;
var glbImageCounter =0;
var glbImageCounter =0;

function imageLoaded()
{
	glbNumImagesLoaded++;
	if(glbNumImagesLoaded==images.length)
	{
		$("#loading").hide();
		startAnimation();
	}
}

function startAnimation()
{
	$("#slideShowImage1").hide();
	$("#slideShowImage2").hide();
	$("#replayContainer").hide();
	$("#merryChristmas").hide();
	glbImageCounter = 0;
	$("#slideShowImage1").attr("src",images[0]);
	$("#slideShowImage1").fadeIn(2500);
	setTimeout(nextSlide,5000);
	glbImageCounter++;
	if(images.length == 1)
	{
		setTimeout('$("#merryChristmas").fadeIn(1000)',4500);
	}
}


function nextSlide()
{	
	if(glbImageCounter > images.length-1)
	{
		$("#replayContainer").fadeIn(1000);
	}
	else
	{
		var prevImage = "#slideShowImage1";
		var nextImage = "#slideShowImage2";
		if(glbImageCounter%2==0)
		{
			prevImage = "#slideShowImage2";
			nextImage = "#slideShowImage1";
		}
		
		$(nextImage).attr("src",images[glbImageCounter]);

		$(prevImage).fadeOut(1500);
		setTimeout('$("'+nextImage+'").fadeIn(1000);',1500);
		setTimeout(nextSlide,6000);
	}
	if(glbImageCounter==images.length-1)
	{
		setTimeout('$("#merryChristmas").fadeIn(1000)',1500);
	}
	glbImageCounter++;
}