var $swf, 
	$mask, 
	$btn, 
	btnX = 30,
	btnY = 34,
	swfW = 900, 
	swfH = 500,
	aspect = swfH / swfW,
	boxW = 1000,
	boxH = Math.round(aspect * boxW);

$(function()
{
	$swf = $('<div id="swf-container"></div>')
		.css({
			position: 'absolute',
			width: boxW,
			height: boxH,
			border: 'solid 1px #fff',
			background: '#000',
			textAlign: 'center',
			paddingTop: (boxH - swfH) / 2,
			zIndex: 1001 			
		});
	
	$mask = $('<div id="site-mask"></div>')
		.css({
			position: 'fixed',
			top: 0,
			left: 0,
			width: $(window).width() + 'px',
			height: $(window).height() + 'px',
			background: '#000',
			opacity: 0.9,
			zIndex: 1000
		})
		.click(skipIntro);
	
	$btn = $('<a id="close-btn">X</a>')
		.css({
			display: 'block',
			position: 'absolute',						
			background: '#000',
			color: '#fff',
			fontSize: '16px',
			fontWeight: 'bold',
			padding: '4px 10px',
			zIndex: 1002,
			cursor: 'pointer' 			
		})
		.hover(
			function(){ $(this).css({ background: '#444' }); },
			function(){ $(this).css({ background: null }); }
		)
		.click(skipIntro);	
	
	// Set position of elements
	$(window)
		.resize(setPosition)
		.resize();	
	
	// Load intro animation
	$swf.flash({
		swf: '/images/intro.swf',
		width: swfW,
		height: swfH	
	});
	
	// Append to DOM
	$('body:first')
		.append($mask)
		.append($swf)
		.append($btn);
});

var skipIntro = function()
{
	$swf.remove();
	$mask.remove();
	$btn.remove();
};

var setPosition = function()
{	
	var posX = $(window).width() / 2 - boxW / 2,
		posY = $(window).height() / 2 - boxH / 2;
		
	$swf.css({left: posX + 'px', top: posY + 'px'});

	$btn.css({left: (posX + boxW - btnX) + 'px', top: (posY - btnY) + 'px'});
};

