Init = function (){
	var submenus = $('mainmenu').select('li.submenu');
	submenus.each(function(item) {
		new PopupMenu(item);
	});
}

window.onload = Init;

var PopupMenu = Class.create();

PopupMenu.prototype = {
	initialize: function(el) {
		this.element = el.down("ul");
		this.caller = el;
		if (!this.caller.hasClassName('open')) {
			this.caller.fx1 = this.onMouseOverMenu.bindAsEventListener(this, this.caller);
			this.caller.fx2 = this.onMouseOutMenu.bindAsEventListener(this, this.caller);		
			Event.observe(this.caller, 'mouseover', this.caller.fx1);
			Event.observe(this.caller, 'mouseout', this.caller.fx2);
		}

	},

	onMouseOverMenu: function(event, el) {
		this.element.style.display = 'block';
		el.addClassName("open");
	},

	onMouseOutMenu: function(event, el) {
		this.element.style.display = 'none';		
		el.removeClassName("open");
	}

}
