/*!
*	Copyright (c) 2007 Bethke et al. GmbH, Berlin, Germany copyright@b-et-a.de
* All rights reserved.
* Authors:
*   Ingo Struck - seen at ingostruck dot de
*   Mathias Schaefer - mathias.schaefer at 9elements dot com
*/
var dynDiv = {
	add: function (id, left, top, width, height, zindex, parent, headerHeight) {

		if (id == undefined || top == undefined || left == undefined || width == undefined || zindex == undefined)
			return false;
		
		var padding = 5;

		var div = $(id);
		if (div)
			return div;
		
		if (!parent)
			parent = document.body;
			
		div = document.createElement('div');
		div.id = id;
		div.className = 'dynAbs';
		div.style.display = 'none';
		
		div.style.zIndex = 50 + (100 * zindex);
		
		div.style.top = top + 'px';
		div.style.left = left + 'px';

		div.style.width = width + 'px';
		div.style.height = height + 'px';

		var ifr = document.createElement('iframe');
		ifr.id = id + '_ifr';
		ifr.className = 'dynAbs';
		ifr.style.display = 'none';
		ifr.style.top = top + 'px'
		ifr.style.left = left + 'px';
		ifr.style.width = width + 'px';
		ifr.style.height = height + 'px';
    ifr.style.zIndex=(100*zindex);
		ifr.style.border='none';
		ifr.style.padding='0';
		ifr.style.margin='0';
		ifr.style.backgroundColor='#000';
		
		if (headerHeight) {
			if (16 > headerHeight) 
				headerHeight = 16;
			var headerElem = document.createElement('div');
			headerElem.className = 'dynHead';
			headerElem.style.margin = padding + 'px ' + padding + 'px 0';
			headerElem.style.height = headerHeight + 'px';
			div.appendChild(headerElem);
			div._header = headerElem;
		} else {
			headerHeight = 0;
		}

		var contentDiv = document.createElement('div');
		contentDiv.className = 'dynCont';
		contentDiv.style.margin = padding + 'px ' + padding + 'px 0';
		contentDiv.style.width = (width - (2 * padding)) + 'px';
		if (height != 'auto') {
			contentDiv.style.height = (height - (2 * padding) - headerHeight) + 'px';
		}
		
		div.appendChild(contentDiv);
		div._content = contentDiv;

		// causes an error, dynDivMouseDn is not defined
		// div.onmousedown=function (evt){return dynDivMouseDn(evt,div,parent);}
		
		parent.appendChild(div);
		parent.appendChild(ifr);

		div.show = function () {
			this.style.display = 'block';
			var ifr = $(this.id+'_ifr');
			if (ifr) ifr.style.display = 'block';
		};
		div.hide = function () {
			this.style.display = 'none';
			var ifr = $(this.id+'_ifr');
			if (ifr) ifr.style.display = 'none';
		};

		return div;
	},

	del: function (that) {
		if (!(that && that.parentNode))
			return false;
		var parent = that.parentNode;
		parent.removeChild(that);
		if (!that.id)
			return false;
		var ifr = $(that.id+'_ifr');
		parent.removeChild(ifr);
		return true;
	}
}; // var dynDiv

