
// Override the MA.MoveTo function to reflect a top/right 
// coordinate system instead of top/left.  Delete this function
// if you want to move the dropdowns over to the left
MA.moveTo = function(id,x,y) {
  if(document.getElementById) var unit = "px";
  else var unit = 0;

  x = parseInt(x);
  y = parseInt(y);

  if(!isNaN(x)) MA.getStyles(id).right = x + unit;
  if(!isNaN(y)) MA.getStyles(id).top = parseInt(y) + unit;
}


// Object for managing the actual drop downs
var DropDownTabs = {
	timing: 1000,		//time in ms
	accelleration: -0.999,	//accelleration weighting -1 to 1
	heights: new Array(),

	Setup: function(who, height) {
		if(!document.getElementById) return;

		document.getElementById(who).onclick = DropDownTabs.CancelBubble;
		document.getElementById(who).onmouseover = DropDownTabs.Show;
		//document.getElementById(who).onmouseout = DropDownTabs.Hide;

		MA.moveTo(who, 0, -height);

		this.heights[who] = height;

	},

	Show: function() {
		var found = false;
		for(var id in DropDownTabs.heights) found = found || (id=this.id);
		if(!found) return;

		for(var id in DropDownTabs.heights) if(id != this.id) DropDownTabs.Hide(id);

		// (element, endX, endY, time, accel, endfunc, cancel last anim)
		MA.timeSlide(this.id, 0, 0, DropDownTabs.timing, DropDownTabs.accelleration, null, true);
		
		// mib - activate input element on layer
		if (this.getElementsByTagName("input")[0])
			this.getElementsByTagName("input")[0].focus() 
	},

	Hide: function(id) {
		if(!id) id = this.id;

		// (element, endX, endY, time, accel, endfunc, cancel last anim)
		MA.timeSlide(id, 0, -DropDownTabs.heights[id], DropDownTabs.timing, DropDownTabs.accelleration, null, true);
	},

	CloseAll: function() {
		for(var id in DropDownTabs.heights) {
			if (noMoveSearch == true && id == 'suche') {
				//do nothing DropDownTabs.Hide(id);
			}
			else {
				DropDownTabs.Hide(id);
			}
		} // for
		noMoveSearch = false;
	},

	CancelBubble: function(evt) {
		if(!evt) evt = event;
		if( !evt.stopPropagation ) evt.stopPropagation = function() { this.cancelBubble = true; };
		if( !evt.preventDefault ) evt.preventDefault = function() { this.returnValue = false; };
		if( evt.stopPropagation ) evt.stopPropagation();
		if( evt.cancelBubble == false ) evt.cancelBubble = true;
	}
}
