/**
 * Crossbrowser abled Javascript Dropdown - Menu,
 * optimiert für www.diewerke.ch,
 */
function DropDownMenu(id) {
	if (!document.getElementById || !document.getElementsByTagName)
		return false;
	this.menu = document.getElementById(id);
	this.submenus = this.menu.getElementsByTagName("div");
	this.activeMenu = false;
	this.opacity = 70;
}
DropDownMenu.prototype.init = function() {
	var mainInstance = this;

	// Transparenz der Menues festlegen
	for (var i = 0; i < this.submenus.length; i++)
		this.changeOpacity(this.submenus[i], this.opacity);
		
	// Onclick - Handler festlegen
	document.getElementsByTagName('body')[0].onclick = function () {
		mainInstance.hideAll();	
	};
}
DropDownMenu.prototype.openMenu = function(id) {
	this.hideAll();
	var menu = document.getElementById(id);
	if (menu) {
		menu.style.display = "block";
		this.activeMenu = menu;
	}
}
DropDownMenu.prototype.hideAll = function() {
	if (this.activeMenu != false)
		this.hideMenu(this.activeMenu);
	this.activeMenu = false;
}
DropDownMenu.prototype.hideMenu = function(mnu) {
	if (mnu) {
		with (mnu) {
			style.display = "none";
		}
	}
}
DropDownMenu.prototype.changeOpacity = function(obj, _opacity) {
	if (obj) {
		with (obj) {
			style.opacity = (_opacity / 100);
			style.MozOpacity = (_opacity / 100);
			style.KhtmlOpacity = (_opacity / 100);
			style.filter = "alpha(opacity=" + _opacity + ")";
		}
	}
}
