/*
 *  2008-06-25
 *	bigfish.co.uk
 *	Mark Gerrard
 */
window.addEvent('domready', function(){
	// Homepage flash
	var promo = $('promo');
	if (promo) {
		var promoSwf = new Swiff('/static/flash/promo2008.swf', {
			'width': 570,
			'height': 401
		});
		
		if (Browser.Plugins.Flash.version > 6) {
			promo.empty();
			promoSwf.inject(promo);
		}
	}
	
	
	// If we are on the homepage add the 
	if ($defined($('home'))) {
		var lang = Cookie.read('language');
		
		if (!$defined(lang)) {
			var swf = new Swiff('/static/flash/landingpage.swf', {
				width: 788,
				height: 401,
				wmode: 'opaque'
			});
			
			// Get header, if its defined inject flash
			var head = $('header');
			if ($defined(head)) {
				head.setStyle('position', 'relative');
				
				var swfDiv = new Element('div', {
					'id': '',
					styles: {
						position: 'absolute',
						top: -401,
						left: 0,
						zIndex: 1
					}
				}).adopt(swf); 
				swfDiv.inject(head, 'top');
				
				// Make Morph object global
				fFx = new Fx.Morph(swfDiv, {duration: 1000});
				// Slide the flash in
				fFx.start({
					top: [-401, 0]
				});
			}
		}
	}
});

function languageSelection(lang){
	Cookie.write('language', lang);
	
	var redir = 'http://'+window.location.hostname+'/'+lang;
	
	// Redirect if we are not on the selected language
	if (window.location.pathname.indexOf(lang) == -1)	
		window.location = redir;
	
	// Slide flash out
	fFx.start({
		top: [0, -401]
	});
}