window.onload = function()
{
	initImages();
	initSplash();
}



function initImages()
{
	setOpacityForId("image_1", 0);
	setOpacityForId("image_2", 0);
	setOpacityForId("image_3", 0);
	setOpacityForId("image_4", 0);
	setOpacityForId("image_5", 0);
	setOpacityForId("image_6", 0);
	setOpacityForId("image_7", 0);





//	cycleIn("image_", 1, 7, 0);

//	fadeIn("image_1", 0);
}


//	setOpacity takes an object and an opacity value (0..100)
//	and sets the appropriate opacity.

function setOpacity(object, opacity)
{
	opacity = (opacity == 100 ? 99.999 : opacity);
	
	//	Safari 1.2, Firefox, Mozilla, CSS3...
	object.style.opacity = opacity / 100;

	//	Old Mozilla, Firefox...
	object.style.MozOpacity = opacity / 100;

	//	Old Safari, Konqueror...
	object.style.KHTMLOpacity = opacity / 100;

	//	IE/Win...
	object.style.filter = "alpha(opacity:"+opacity+")";
}



function setOpacityForId(objectId, opacity)
{
	if (document.getElementById)
	{
		object = document.getElementById(objectId);
		setOpacity(object, opacity);
	}
}


//	fadeIn takes an object and opacity, and uses a timer to 
//	update the opacity until it reaches 100%.

function fadeIn(objectId, opacity)
{

	if (document.getElementById)
	{
		object = document.getElementById(objectId);
		if (opacity <= 100)
		{
			setOpacity(object, opacity);
			opacity += 1;
			window.setTimeout("fadeIn('" + objectId + "', " + opacity + ")", 20);
		}
	}
}

function fadeOutSplash(objectId, opacity)
{
	if (document.getElementById)
	{
		object = document.getElementById(objectId);
		if (opacity >= 0)
		{
			setOpacity(object, opacity);
			opacity -= 10;
			window.setTimeout("fadeOutSplash('" + objectId + "', " + opacity + ")", 10);
		}
		else
		{
			divStyle = object.style;
			divStyle.visibility = 'hidden';
			divStyle.display = 'none';
			cycleIn("image_", 1, 7, 0);

		}
	}
}


function cycleIn(objectIdPrefix, initial, count, opacity)
{
	objectId = objectIdPrefix + initial;

	if (document.getElementById)
	{
		object = document.getElementById(objectId);
		if (opacity <= 100)
		{
			setOpacity(object, opacity);
			opacity += 5;
			window.setTimeout("cycleIn('" + objectIdPrefix + "', " + initial + ", " + count + ", " + opacity + ")", 20);
		}
		else
		{
			initial += 1;
			if (initial <= count)
			{
				opacity = 0;
				window.setTimeout("cycleIn('" + objectIdPrefix + "', " + initial + ", " + count + ", " + opacity + ")", 2000);
			}

		}
	}
}

function initSplash()
{
	random_quote = Math.floor(Math.random() * 5);

	var quotes = new Array(5);
	quotes[0] = "We shape our buildings thereafter they shape us";
	quotes[1] = "Life is not measured by the number of breaths we take, but by the moments that take our breath away";
	quotes[2] = "No matter how good you get you can always get better and that's the exciting part.";
	quotes[3] = "The best way to predict the future is to create it";
	quotes[4] = "If you're not interfering with play, you shouldn't be on the pitch";

	var sources = new Array(5);
	sources[0] = "Sir Winston Churchill";
	sources[1] = "Anonymous";
	sources[2] = "Tiger Woods";
	sources[3] = "Peter F Drucker (Author and Management Consultant)";
	sources[4] = "Brian Clough";


	quoteDiv = document.getElementById("splash_quote");

	newQuote = document.createElement("h1");
	newQuote.appendChild(document.createTextNode(quotes[random_quote]));

	newSource = document.createElement("h2");
	newSource.appendChild(document.createTextNode(sources[random_quote]));

	quoteDiv.appendChild(newQuote);
	quoteDiv.appendChild(newSource);
}

function hideSplash()
{
	object = document.getElementById("splash");
	fadeOutSplash("splash", 100);
	
}
