AidaEvent.onReady(function()
{
	var $load = I('load');
	
	var $loadBar = N(['div', {
		style: {
			width: '0px',
			height: '1px',
			background: '#003366',
			position: 'fixed',
			left: '50%',
			top: '50%',
			marginLeft: '-130px'
		}
	}], $load);
	
	var $loadPerc = N(['div', {
		style: {
			width: '260px',
			position: 'fixed',
			left: '50%',
			top: '50%',
			marginLeft: '-130px',
			paddingTop: '250px',
			marginTop: '-240px',
			textAlign: 'center',
			background: 'url(./media/sandro-lain-logo.png) no-repeat center top'
		}
	}], $load);
	
	var $body = $('body', true);
	
	$body.ajAppend($load);
	
	var loadTO;
	
	AidaEnv.preload({
		onProgress: function(i, t)
		{
			$loadBar.ajCss('width', (260 * i / t) + 'px');
			
			$loadPerc.ajReplaceChilds(Math.round(i / t * 100) + '%');
		},
		onComplete: function()
		{
			clearTimeout(loadTO);
			
			$loadBar.ajCss('width', '260px');
			
			$load.ajCss('opacity', '1').ajMorph('opacity: 0; time: 500ms; delay: 500ms;', function()
			{
				this.ajRemove();
			});
		},
		onImagesComplete: function()
		{
			$loadBar.ajCss('width', '260px');
			
			loadTO = setTimeout(function()
			{
			
				$load.ajCss('opacity', '1').ajMorph('opacity: 0; time: 500ms; delay: 500ms;', function()
				{
					this.ajRemove();
				});
				
			}, 3000);
		}
	});
	
	new AidaScrollBar({
		target: 'root',
		onScrollStart: function()
		{
			this.$topHandle.ajMorph('opacity: 1; time: 300ms');
			this.$leftHandle.ajMorph('opacity: 1; time: 300ms');
		},
		onScrollFinish: function()
		{
			this.$topHandle.ajMorph('opacity: 0; time: 300ms');
			this.$leftHandle.ajMorph('opacity: 0; time: 300ms');
		}
	});
	
	new AidaScrollBar({
		target: 'box-3',
		onScrollStart: function()
		{
			this.$topHandle.ajMorph('opacity: 1; time: 300ms');
			this.$leftHandle.ajMorph('opacity: 1; time: 300ms');
		},
		onScrollFinish: function()
		{
			this.$topHandle.ajMorph('opacity: 0; time: 300ms');
			this.$leftHandle.ajMorph('opacity: 0; time: 300ms');
		}
	});

	$('a', function($a)
	{
		var origColor = $a.ajCssGet('color');
			
		$a.ajHover(function()
		{
			this.ajMorph('color: #FFFFFF');
		}, function()
		{
			this.ajMorph('color: ' + origColor);
		});
	});

});

AidaEvent.onLoad(function()
{
	$('#box-1, #box-2, #box-3, #box-4', function($box, i)
	{
		if(AidaAgent.webkit || AidaAgent.version >= 10)
		{
			$box.ajMorph('opacity: 1; transform: rotateY(0deg); wait: ' + ((i + 1) * 300 + 1000) + 'ms');
		}
		else
		{
			$box.ajMorph('opacity: 1; wait: ' + ((i + 1) * 300 + 1000) + 'ms');
		}
	});
});

