
function Init(){
	var arr = $('mainmenu').getElementsByClassName('submenu');
	if (arr) {
		for (var i=0; i<arr.length; i++) {
			var re = new RegExp("^submenu_(\\d+)");
			if (arr[i].id.match(re))
				new DropDownMenu(arr[i].id.substr(8));
		}
	}
}

window.onload = Init;

var DropDownMenu = Class.create();

DropDownMenu.prototype = {
	initialize: function(id) {
		this.element = $('submenu_'+id);
		this.caller = $('menu_'+id);
		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);
		Event.observe(this.element, 'mouseover', this.caller.fx1);
		Event.observe(this.element, 'mouseout', this.caller.fx2);
	},

	onMouseOverMenu: function(event, a) {
		a.addClassName('visited');
		this.element.style.display='block';
	},

	onMouseOutMenu: function(event, a) {
		a.removeClassName('visited');
		this.element.style.display='none';
	}

}

//Event.observe(document, 'dom:loaded', Init, false);