/*
 * Learn the tune
 */ 
 
var avoids = ['logoMenuContainer', 'pageFooter'];

var flashvars = {};
flashvars.assetsUrl = "MHFrontLib.swf";
flashvars.dataUrl = "data.xml";
flashvars.debugMode = "true";

var params = {};
params.loop = "false";
params.bgcolor = "#ffffff";
params.menu = "false";
params.quality = "best";
params.scale = "noscale";
params.salign = "tl";
params.allowfullscreen = "false";
params.wmode = "transparent";

var attributes = {};
attributes.id = "Main";

/*
 * Lets rock!
 */ 
 
window.addEvent('domready', function(){
	var sizes = make_size(avoids);
	swfobject.embedSWF("Main.swf?t=" +new Date().getTime(), "frontPageFlashContainer", sizes.width, sizes.height, "9.0.124", "expressInstall.swf", flashvars, params, attributes);	
});

/*
 * Lets rock again on resize!
 */

window.addEvent('resize', function(){
	resize_flash(avoids,$('Main'));
});


/*
 * The riff
 */

function resize_flash(avoidElements,flash){
	try { 

		var offsetHeight = 0;
		var windowHeight = window.getSize().y;
		
		avoidElements.each(function(el,i){
			offsetHeight += $(el).getSize().y;
		});
		
		var newHeight = windowHeight - offsetHeight;

		flash.height = newHeight;
		flash.width = window.getSize().x;
		
	} 
	catch (e){ /* console.log(e);*/ }
}

/* 
 * The raff
 */

function make_size(avoidElements){
	try { 

		var sizes = {};
		
		var offsetHeight = 0;
		var windowHeight = window.getSize().y;
		
		avoidElements.each(function(el,i){
			offsetHeight += $(el).getSize().y;
		});
		
		var newHeight = windowHeight - offsetHeight;

		sizes.height = newHeight;
		sizes.width = window.getSize().x;
		
		return sizes;
	} 
	catch (e){ /* console.log(e);*/ }	
}
