function insertFlash(flashContainer,flashURL,flashWidth,flashHeight,flashParams,flashVars){
	if(parseInt(window.Browser.Plugins.Flash.version)<8)
		return
	if($chk($(flashContainer)))
	{
		new Swiff(flashURL,{width:flashWidth,height:flashHeight,container:$(flashContainer),vars:flashVars,params:flashParams});
	}
		
 	else
	{
		window.addEvent('domready',function(){
			new Swiff(flashURL,{width:flashWidth,height:flashHeight,container:$(flashContainer),vars:flashVars,params:flashParams});
		})
	}
		
 }

var NewsModule = new Class({
	options:{
		contentClass:'AbsoluteContent'
	},
	initialize:function(mainID,options)
	{
		this.setOptions(options);
		this.main = $(mainID);
		this.content = this.main.getElement('div.'+this.options.contentClass);
		this.content.setStyles({'visibility':'visible','opacity':'0'});
		
		if(!this.main || !this.content)
			return;
		
		this.main.addEvent('mouseover',this.showContent.bind(this));
		this.main.addEvent('mouseout',this.hideContent.bind(this));
		
		this.fx = new Fx.Tween(this.content,{link:'cancel',duration:500});
	},
	showContent: function()
	{
		this.fx.start('opacity',0.9);
	},
	hideContent: function()
	{
		this.fx.start('opacity',0);
	}
});
NewsModule.implement(new Options());

var RollMenu = new Class({
	options:{
	
	},
	initialize: function(buttonID,menuID)
	{
		this.shown = false;
		this.hidden = true;
		
		this.timer = false;
		
		this.Button = $(buttonID);
		this.Menu = $(menuID);
		
		if(!this.Button || !this.Menu)
			return;
		
		this.maxHeight = this.Menu.getDimensions().x;
		
		this.Button.addEvent('mouseenter',this.showMenu.bind(this));
		this.Button.addEvent('mouseleave',this.hideMenu.bind(this));

		this.fx = new Fx.Morph(this.Menu,{link:'cancel',duration:500});
	},
	showMenu:function(e)
	{
		var ev = new Event(e);
		ev.stop();
		
		this.shown = true;
		
		if(!this.hidden)
			return;
		
		this.Menu.setStyles({
			'opacity':0,
			'display':'block'
		});
		this.fx.start({
			'opacity':1
		}).chain(
			(function(){
				this.hidden = false;
			}).bind(this)
		)
	},
	hideMenu:function(e)
	{
		var ev = new Event(e);
		ev.stop();
		
		if(!this.shown)
			return;
		
		this.shown = false;
		if(this.timer)
			$clear(this.timer);
		this.timer = this.hideFunc.delay(200,this)
	},
	hideFunc:function()
	{
		if(this.shown)
			return;	
			
		this.fx.start({
			'opacity':0
		}).chain(
			(function(){ 
				this.Menu.setStyle('display','none') 
				this.shown = false;	
				this.hidden = true;
			}).bind(this)
		)
	}
});

window.addEvent('domready',function(){
	var nm = new NewsModule('NewsModule');
	var menu = new RollMenu('buttonHome','homeNav');
	
	var menus = $('mainMenu').getElements('li');
	var menuList = [];
	menus.each(function(menu,i){
		var subnode = menu.getElement('ul');
		if(subnode)
		{
			menuFunc = [menu,subnode];
			menuList.push(menuFunc);
		}	
		
	})
	
	menuList.each(function(element){
		new RollMenu(element[0],element[1]);
	})
	
});