window.addEvent('domready', function () {
		 var menu       = $('nav'),
	     button1Link   = menu.getElement('.button1 a').get('href'),
		 button2Link = menu.getElement('.button2 a').get('href'),
		 button3Link  = menu.getElement('.button3 a').get('href'),
		 button4Link = menu.getElement('.button4 a').get('href'),
		 button5Link = menu.getElement('.button5 a').get('href'),
		 button1Title     = menu.getElement('.button1 a').get('text'),
		 button2Title     = menu.getElement('.button2 a').get('text'),
		 button3Title     = menu.getElement('.button3 a').get('text'),
		 button4Title     = menu.getElement('.button4 a').get('text'),
		 button5Title   = menu.getElement('.button5 a').get('text'),
		 params, flashVars, currentTopic = '';

	if (menu.getElement('.button1').hasClass('active')) {
		currentTopic = '1';

	} else if (menu.getElement('.button2').hasClass('active')) {
		currentTopic = '2';

	} else if (menu.getElement('.button3').hasClass('active')) {
		currentTopic = '3';

	} else if (menu.getElement('.button4').hasClass('active')) {
		currentTopic = '4';

	} else if (menu.getElement('.button5').hasClass('active')) {
		currentTopic = '5';
	}

	params = {
		menu: "false",
		wMode: "transparent"
	}

	flashVars = {
		currentTopic: currentTopic,
		Name1: button1Title.toUpperCase(),
		Name2: button2Title.toUpperCase(),
		Name3: button3Title.toUpperCase(),
		Name4: button4Title.toUpperCase(),
		Name5: button5Title.toUpperCase(),
		URL1: button1Link,
		URL2: button2Link,
		URL3: button3Link,
		URL4: button4Link,
		URL5: button5Link
	}

	new Swiff('/images/nav.swf', {
		id: 'flashnav',
		params: params,
		vars: flashVars,
		width: 310,
		height: 400,
		container: menu
	});

	new Swiff('/images/header.swf', {
		id: 'flashheader',
		width: 940,
		height: 200,
		params: params,
		vars: {},
		container: $('header')
	});
});

window.addEvents({'load': setWrapperHeight, 'resize': setWrapperHeight});

function setWrapperHeight() {
	var bodyHeight = $$('body')[0].getSize().y - 200,
	    contentHeight = $('content').getSize().y + $('content').getStyle('margin-bottom').toInt(),
		 height;

	if (contentHeight > bodyHeight) {
		height = contentHeight;
	} else {
		height = bodyHeight;
	}

	$('wrapper').setStyle('height', height);
}
