var currentHeightShow = 0;
var currentHeightHide = 0;

/* Set platform dependent constants */
if (MS) {
	interval = 25;
	sleep = 1;
} else {
	interval = 5;
	sleep = 2;
}

function Menu(id, content, mouseover)
{
	/* Toggle menu state */
	this.toggle = function ()
	{
		if (!this.active)
			this.show();
		else
			this.hide();
	};


	/* Display menu with a cute roll on effect */
	this.show = function ()
	{
		if (!this.processing) {
			this.processing = true;
			showMenu(this.id);
		}
	};


	/* Hide menu with a cute roll off effect */
	this.hide = function ()
	{
		if (!this.processing) {
			this.processing = true;
			hideMenu(this.id);
		}
	};


	this.enter = function()
	{
  		if (this.inside == false) {
    		mouseover.toggle();
    		this.inside = true;
  		}
	};


	this.leave = function()
	{
		if (this.inside == true) {
			mouseover.toggle();
			this.inside = false;
		}
	};


	/* Attributes */
	this.id = id;
	this.content = content;
	this.mouseover = mouseover;
	this.active = false;
	this.inside = false;
	this.processing = false;
	this.currentHeight = 0;
}



function showMenu(name)
{
	var menu = eval(name);
	var content = getElem("id", menu.content, null);
	var height = content.offsetHeight + 2;

	if(menu.currentHeight == 0)
		content.style.visibility = "visible";

	if(menu.currentHeight <= height) {
		content.style.clip = "rect(0px,140px,"+ menu.currentHeight +"px, 0px)";
		menu.currentHeight += interval;
		window.setTimeout('showMenu(\"' + name + '\")', sleep);
	} else {
		content.style.clip = "rect(0px,140px,"+ height +"px,0px)";
		menu.currentHeight = height;
		menu.processing = false;
		menu.active = true;
	}
}


function hideMenu(name)
{
	var menu = eval(name);
	var content = getElem("id", menu.content, null);

	if(menu.currentHeight > 0) {
		menu.active = false;
		content.style.clip = "rect(0px,140px," + menu.currentHeight + "px, 0px)";
		menu.currentHeight -= interval;
		window.setTimeout('hideMenu(\"' + name + '\")', sleep);
	} else {
		content.style.clip = "rect(0px,140px,0px,0px)";
		menu.currentHeight = 0;
		menu.processing = false;
	}
}


function checkMenu(menu)
{
	if(menu.active && !menu.inside)
	{
		menu.hide();
	}
}

function checkMenus()
{
	checkMenu(WerbefotoMenu);
	checkMenu(PortraitMenu);
	checkMenu(ReportagenMenu);
	checkMenu(InfoMenu);
}


var WerbefotoMenu = new Menu("WerbefotoMenu", "WerbefotoContent", WerbefotoMouseOver);
var PortraitMenu = new Menu("PortraitMenu", "PortraitContent", PortraitMouseOver);
var ReportagenMenu = new Menu("ReportagenMenu", "ReportagenContent", ReportagenMouseOver);
var InfoMenu = new Menu("InfoMenu", "InfoContent", InfoMouseOver);
var ReferenzenMenu = new Menu("", "", ReferenzenMouseOver);
var AktionenMenu = new Menu("", "", AktionenMouseOver);


