var onloadFunctions = Array();

/**
 * Onload function Load all functions stored in onloadFunctions
 */
function doOnload()
{
	for(var myIndex = 0; myIndex < onloadFunctions.length; myIndex++ )
	{
		if(onloadFunctions[myIndex])
		{
			onloadFunctions[myIndex]( );
		}
	}
}


/**
 * Store a function to run in window.Onload
 */
window.addOnloadFunction = function(sName)
{
	iElement = onloadFunctions.length + 1;
	onloadFunctions[iElement] = sName;
}

/**
 * Show and Hide Content
 */
function showhideContent(sEL)
{
	var showhide = document.getElementById(sEL);

	if(showhide.style.display == 'none')
	{
		new Effect.BlindDown(sEL,{queue:'end'});
	}

	else

	{
		var showhide = document.getElementById(sEL);
		new Effect.BlindUp(sEL,{queue:'end'});
	}
}



var PreLoaderClass = Class.create();
PreLoaderClass.prototype = 
{   	 
	initialize : function(element) 
   	{
		this.active = 0;
		var instant = this;

		$('woonlinieLogo').hide();
		$('containerBottom').hide();
		new Effect.Move('containerBottom', { x: -2800, y: 0, duration: 1});

		Event.observe($('skipintro'),'click',this.hideAnimation.bindAsEventListener(this),false)
		$('skipintro').onclick = function() {return false;};
		this.changeItem();
		
		// Effects
		new Effect.Move('blueThreadHome', { x: 0, y: 100});
		Effect.BlindDown('buttonSkip');
		$('animation').show();	
		
		setTimeout("$('container').show();", 1500);
		this.interval = new PeriodicalExecuter(function(){ instant.changeItem();},4);
		
 	},
 	changeItem : function()
	{
 		if(this.active < 3)
 		{
 			this.active = this.active + 1;
 			var elementID = 'animation'+this.active;
 			new Effect.Fade(elementID,{ duration: 1, from: 0, to: 1 });
 		}
 		else
 		{
 			this.hideAnimation();
 		}
	},
	hideAnimation : function()
	{
		this.interval.stop();

		Effect.SwitchOff('buttonSkip'); 
		
		$('containerBottom').show();
		
		Effect.Appear('woonlinieLogo');
		new Effect.Move('containerBottom', { x: 2800, y: 0, duration: 1});
		new Effect.Move('blueThreadHome', { x: 0, y: -100});

		new Effect.Fade('animation',{ duration: 1, from: 1, to: 0 });
	}
}

function setAnimation()
{
	if ( document.referrer.indexOf(window.location) == -1 )
	{
		new PreLoaderClass();
	}
	else
	{
		$('container').show();
	}
}
