function Menu() {
}

Menu.init = function() {
	this.updateIcons();
	//this.updateSubMenu();
	this.updatePhotos();
}

Menu.updatePhotos = function() {
	var photos = $$("a.photolink");
	$(photos).each(function(item) {
		Event.observe(item, 'click', function(event) {
			//var el = event.element();
			var el = Event.element(event);
			var imgFile = String(el.src);
			imgFile = imgFile.replace(/\.(jpg)$/, '_gr.$1');
			imgFile = imgFile.replace(/\.(png)$/, '_gr.$1');
			var photoBoxEl = $("photobox");
			var imgEl = $(photoBoxEl).childNodes[0].childNodes[0];
			imgEl.src = imgFile;
			//alert($(photoBoxEl).getStyle('display'));
			Effect.Appear(photoBoxEl);
			Event.stop(event);
		});
	});
}

Menu.hidePhoto = function() {
	Effect.Fade('photobox');
	return false;
}

Menu.updateSubMenu = function() {
	var pageName = String(window.location.href);
	if(pageName.match("Itemid=120")) {
	//if(pageName.match("forschung-und-entwicklung")) {
		$$("li#current.active").each(function (item) {
			var el = $(item).getElementsByTagName("ul");
			el[0].style.display="none";
		});
	}
}

Menu.updateIcons = function() {
    var el = $$("li#current.active");
    if(el == null) return false;

    if(el[0].parentNode.parentNode.parentNode.parentNode.tagName == "LI") {
	el[0] = el[0].parentNode.parentNode;
    }

    var item = el[0].className.match(/item\d+/);
    var id = String(item);
    id = id.replace("item", "icon");
    if($(id) != null) $(id).style.display='block';
    return false;
}
