function initializeSplash()
{
	animateSplashIn();
}

function initialize()
{
	Cufon.replace('#navigation-sub', {hover: true});
	Cufon.replace('#content h1');
	
	addNavigationEvents();
	
	addThumbnailEvents();
}

function animateSplashIn()
{
	new Fx.Tween('splash-logo', {duration: 1750}).start('opacity', '0', '1');
	
	animateSplashNameIn.delay(1500);
	
	animateSplashSubTextIn.delay(2500);
	
	animateShowIn.delay(3250);
	
	loadSplashShow.delay(4500);
	
	addSplashEvents.delay(3400);
}

function animateSplashNameIn()
{
	new Fx.Tween('splash-name', {duration: 1000}).start('opacity', '0', '1');
}

function animateSplashSubTextIn()
{
	new Fx.Tween('splash-subtitle', {duration: 1250}).start('opacity', '0', '1');
	new Fx.Tween('splash-subtitle', {duration: 1000, transition: 'expo:Out'}).start('background-position', 'center 50px', 'center 0px');
}

function animateShowIn()
{
	new Fx.Tween('show', {duration: 1000}).start('opacity', '0', '1');
	new Fx.Tween('show', {duration: 750, transition: 'expo:inOut'}).start('width', '0px', '550px').addEvent('onComplete', function(e) {
		new Fx.Tween('show', {duration: 750, transition: 'expo:inOut'}).start('height', '0px', '300px');
	});
	
}

function loadSplashShow()
{
	var show = new Slideshow.Flash('show', data, {captions: true, color: ['#ffffff'], controller: false, delay: 2800, duration: 500, height: 300, hu: '', width: 550, href: '/home'});
}

function animateProceedIn()
{
	new Fx.Tween('splash-continue', {duration: 1000}).start('opacity', '0', '1');
}

function addSplashEvents()
{
	$$('.splash').each(function(e) {
		if (e.getProperty('class') !== 'active') {
			e.addEvents({
				'mouseover': function() {
					e.setStyle('cursor', 'pointer');
				},
				'click': function() {
					document.location = '/home';
				}
			});
		}
	});
}

// Adds navigation mouseover/mouseout events using IE workaround.
function addNavigationEvents()
{
	$$('#navigation a').each(function(e) {
		var bgPosId;
		var bgPosX;
		var bgHoverPos;
		var bgNormalPos;
		var navId = e.getProperty('id');
		
		if (Browser.ie6 || Browser.ie7 || Browser.ie8) {
			bgPosId = 'background-position-y';
			bgHoverPos = '-41px';
			bgNormalPos = '0px';
		} else {
			bgPosId = 'background-position';
			bgPosX = e.getStyle(bgPosId).split(' ');
			bgPosX = bgPosX[0];
			bgHoverPos = bgPosX + ' -41px';
			bgNormalPos = bgPosX + ' 0px';
		}
		
		var fxNavHover = new Fx.Tween(e, {duration: 300, link: 'chain', transition: 'expo:inOut'});
		
		if (e.getProperty('class') !== 'active') {
			e.addEvents({
				'mouseover': function() {
					fxNavHover.start(bgPosId, bgHoverPos);
				},
				'mouseout': function() {
					fxNavHover.start(bgPosId, bgNormalPos);
				}
			});
		}
	});
}


function addThumbnailEvents() {
	$$('.thumbnails img').each(function(e) {
		var src = e.getProperty('src');
		
		var opacityChange = new Fx.Tween(e, {duration: 300});
		
		if (e.getProperty('class') !== 'active') {
			e.set('opacity', 0.6);
			
			e.addEvents({
				'mouseover': function() {
					e.setStyle('cursor', 'pointer');
					opacityChange.start('opacity', 0.8);
				},
				'mouseout': function() {
					opacityChange.start('opacity', 0.6);
				},
				'click': function() {
					opacityChange.start('opacity', 1);
					removeActiveThumbnail();
					e.set('class', 'active');
					e.setStyle('cursor', 'default');
					e.removeEvents();
					addThumbnailEvents();
				}
			});
		}
	});
}

function removeActiveThumbnail() {
	$$('.thumbnails img.active').each(function(e) {
		e.set('opacity', 0.6);
		e.set('class', '');
	});
}
