window.addEvent('domready', function() {	
	new jddMenuBar("menu");
});		//END: Window.AddEvent

var jddMenuBar = new Class({
	options: {
	},
	initialize: function(container, options) {
		this.setOptions(options);
		this.container = $(container);
		this.menu_1 = new jddMenu("hmMenuHdr1", "hmMenu1");
		this.menu_2 = new jddMenu("hmMenuHdr2", "hmMenu2");
		this.menu_3 = new jddMenu("hmMenuHdr3", "hmMenu3");
		this.menu_4 = new jddMenu("hmMenuHdr4", "hmMenu4");
		this.menu_5 = new jddMenu("hmMenuHdr5", "hmMenu5");
		this.menu_6 = new jddMenu("hmMenuHdr6", "hmMenu6");
	}
});

jddMenuBar.menuCount = 5;
jddMenuBar.implement(new Events); 	// Implements addEvent(type, fn), fireEvent(type, [args], delay) and removeEvent(type, fn)
jddMenuBar.implement(new Options);	// Implements setOptions(defaults, options)

var jddMenu = new Class({
	options: {
	},

	//Create class instance
	//container = the first argument in "new SlideGroup" call in "window.addEvent("domready"..."
	initialize: function(mHdr, container, options) {
		this.setOptions(options);
		this.container = $(container);
		this.mHdr = $(mHdr);

		this.menuHt = this.container.getStyle('height').toInt();

		this.container.setStyle('height', '18px');
		this.container.setStyle('background-color', 'white');
		
		this.fx = new Fx.Morph(this.container, {duration: 0, transition: Fx.Transitions.Bounce.easeOut});

		this.container.addEvents({
			'mouseenter': function(e){
				//Close any previous menus still open
				this.clearOpenMenus();
				
				this.fx.start({
				    'height': [this.menuHt]
				});
			}.bind(this),

			'mouseleave': function(e){
				//Close any previous menus still open
				this.fx.start({
				    'height': [18]
				});

				//Close any previous menus still open
				this.clearOpenMenus();
			}.bind(this)
		});
	},
	
	clearOpenMenus: function(){
		//Close any previously open menus
		var index;
		for(index = 0; index < jddMenuBar.menuCount; index++){
			menuElement = $('hmMenu'+(index+1));
			menuElement.setStyle('height', '18px');
		}
	}

});

jddMenu.implement(new Events); 		// Implements addEvent(type, fn), fireEvent(type, [args], delay) and removeEvent(type, fn)
jddMenu.implement(new Options);		// Implements setOptions(defaults, options)