function dropdown(element, speed, timeout, direction, maxMargin) {

	var win = window,
		doc = win.document,
		container,
		childDiv = null,
		scroller = null,

		slideup,
		slidedown,
		slideleft,
		slideright,
		open = false,
		caller = this,
		construct;


	if (!maxMargin) {
		maxMargin = "5000";
	}

	if(typeof(element) !== 'object') {
		element = doc.getElementById(element);
	}
	container = element;


	construct = function () {
		var childDivs = container.childNodes;
		for (i=0; i < childDivs.length; i++) {
			if (childDivs[i].className && childDivs[i].className.indexOf("submenu_inner") >= 0){
				childDiv = childDivs[i];
			}
		}
	};

	this.toggle = function (callback) {
		if (open == false) {
			this.slide();
			//open = true;
		} else {
			this.slide(1);
			//open = false;
		}
		if (typeof(callback) == "function") {
			callback(caller,container);
		}
	}

	this.isOpen = function() {
		return open;
	}

	this.slide =  function (close) {
		if (typeof(close) == "undefined") {
			close = 0;
		}
		if (typeof(direction) == "undefined"){
			direction = "down";
		}
		if (close == 0) {
			open = true;
		} else {
			open = false;
		}
		switch (direction) {
			case "down":
				slidedown(close);
				break;
			case "up":
				slideup(close);
				break;
			case "left":
				slideleft(close);
				break;
			case "right":
				slideright(close);
				break;
		}
	}

	this.getHeight = function() {
		var aktuelleHoehe = parseInt(container.style.height.replace("px",""),10);
		if (isNaN(aktuelleHoehe)) {
			aktuelleHoehe = 0;
		}
		return aktuelleHoehe;
	}

	slidedown = function (close){
		clearTimeout(scroller);

		//container.style.width = "auto";
		container.style.display = "block";

		if (typeof(close) == "undefined") {
			close = 0;
		}

		var aktuelleHoehe = parseInt(container.style.height.replace("px",""),10);
		if (isNaN(aktuelleHoehe)) {
			aktuelleHoehe = 0;
		}
		if ((aktuelleHoehe < childDiv.offsetHeight && !close && aktuelleHoehe < maxMargin) || close && aktuelleHoehe > 0) {
			var neueHoehe = 0;
			if (close) {
				neueHoehe = aktuelleHoehe - speed;
			}
			else {
				neueHoehe = aktuelleHoehe + speed;
			}
			container.style.height = neueHoehe + "px";
			// nur bei position: relative
			//container.style.marginBottom = -neueHoehe - 1 + "px";

			scroller = setTimeout(function() {slidedown(close);},timeout);
		}
		else if (close && aktuelleHoehe <= 0) {
			container.style.display = "none";
		}
	};

	slideup = function (close){
		clearTimeout(scroller);

		container.style.width = "auto";
		container.style.display = "block";

		if (typeof(close) == "undefined") {
			close = 0;
		}

		var aktuelleHoehe = parseInt(container.style.height.replace("px",""),10);
		if (isNaN(aktuelleHoehe)) {
			aktuelleHoehe = 0;
		}
		if ((aktuelleHoehe < childDiv.offsetHeight && !close) || close && aktuelleHoehe > 0) {
			var neueHoehe = 0;
			if (close) {
				neueHoehe = aktuelleHoehe - speed;
			}
			else {
				neueHoehe = aktuelleHoehe + speed;
			}
			container.style.height = neueHoehe + "px";
			container.style.marginTop = -neueHoehe + "px";

			scroller = setTimeout(function() {slideup(close);},timeout);
		}
		else if (close && aktuelleHoehe <= 0) {
			container.style.display = "none";
		}
	};

	slideleft = function (close){
		clearTimeout(scroller);

		container.style.height = "auto";
		container.style.display = "block";

		if (typeof(close) == "undefined") {
			close = 0;
		}

		var aktuelleBreite = parseInt(container.style.width.replace("px",""),10);
		if (isNaN(aktuelleBreite)) {
			aktuelleBreite = 0;
		}
		if ((aktuelleBreite < childDiv.offsetWidth && !close) || close && aktuelleBreite > 0) {
			var neueBreite = 0;
			if (close) {
				neueBreite = aktuelleBreite - speed;
			}
			else {
				neueBreite = aktuelleBreite + speed;
			}
			container.style.width = neueBreite + "px";
			container.style.marginLeft = -neueBreite + "px";

			scroller = setTimeout(function() {slideleft(close);},timeout);
		}
		else if (close && aktuelleBreite <= 0) {
			container.style.display = "none";
		}
	};

	slideright = function (close){
		clearTimeout(scroller);

		container.style.height = "auto";
		container.style.display = "block";

		if (typeof(close) == "undefined") {
			close = 0;
		}

		var aktuelleBreite = parseInt(container.style.width.replace("px",""),10);
		if (isNaN(aktuelleBreite)) {
			aktuelleBreite = 0;
		}
		if ((aktuelleBreite < childDiv.offsetWidth && !close) || close && aktuelleBreite > 0) {
			var neueBreite = 0;
			if (close) {
				neueBreite = aktuelleBreite - speed;
			}
			else {
				neueBreite = aktuelleBreite + speed;
			}
			container.style.width = neueBreite + "px";
			container.style.marginRight = -neueBreite - 1 + "px";

			scroller = setTimeout(function() {slideright(close);},timeout);
		}
		else if (close && aktuelleBreite <= 0) {
			container.style.display = "none";
		}
	};

	if (element != null) {
		construct();
	}

}
