function divcrtl(name, hidedelay, objname)
{
	// hide it when user clicks
  var oldfunc = document.onclick;
  if (typeof oldfunc != 'function')
  {
		document.onclick = function() {eval(name+'.hide();');};
  }
  else
  {
    document.onclick = function()
	    {
	      oldfunc();
	      eval(name+'.hide();');
	    };
  }
	
	this.name = name; // name of object you are creating
	this.hidedelay = hidedelay; // hide how many miliseconds after onmouseout
	this.objname = objname;
	this.obj = null;
	
	this.op = window.opera;
	this.ie = document.all && !this.op;
	this.ns = document.getElementById && !this.ie && !this.op;
	
	this.timeout = null;
	if (this.ie)
	{
		document.write('<iframe id="iframe_'+objname+'" name="iframe_'+objname+'" src="/img/blank.gif"  style="position: absolute; left:0; top:0; width:0; height:0; visibility:hidden; filter:alpha(opacity=0); z-index: 1"></iframe>');
		this.iframeobjname = 'iframe_'+objname;
		this.iframeobj = null;
	}

	this.cancelbubble =
		function(e)
		{
			if (window.event)
				event.cancelBubble=true;
			else if (e.stopPropagation)
				e.stopPropagation();

			return false;
		};

	this.hide =
		function()
		{
			if (this.obj == null)
				return false;
		
			this.obj.style.left = this.obj.style.top = -500;
			this.obj.style.visibility = 'hidden';
		
			if (this.ie)
				this.iframeobj.style.visibility = 'hidden';

			clearTimeout(this.timeout);

			return false;
		};

	this.delayhide =
		function()
		{
			clearTimeout(this.timeout);

			if (this.hidedelay > 0)
				this.timeout = setTimeout(this.name+'.hide()', this.hidedelay);

			return false;
		};
	
	this.swap =
		function(obj, e, content, width)
		{
			this.obj = document.getElementById(this.objname);
			if (this.ie)
				this.iframeobj = document.getElementById(this.iframeobjname);
		
			this.cancelbubble(e);

			if (window.event)
				event.cancelBubble=true;
			else if (e.stopPropagation)
				e.stopPropagation();
			
			if (e.type=="click" && (this.obj.style.visibility=='hidden' || this.obj.style.visibility=='') || e.type=="mouseover")
				this.show(obj, content, width);
			else if (e.type=="click")
				this.hide();
		
			return false;
		};

	this.show =
		function(obj, content, width)
		{
			this.obj = document.getElementById(this.objname);
			if (this.ie)
				this.iframeobj = document.getElementById(this.iframeobjname);
		
			this.obj.innerHTML = content;
			if (width != '')
				this.obj.style.width = width;
			
			this.obj.style.left = this.obj.style.top = -500;
			this.obj.style.left = this.getoffset(obj, 'x') + "px";
			this.obj.style.top = this.getoffset(obj, 'y') + obj.offsetHeight + "px";
		
			this.obj.style.visibility = 'visible';
		
			if (this.ie)
			{
				this.iframeobj.style.left = this.obj.style.left;
				this.iframeobj.style.top = this.obj.style.top;
				this.iframeobj.style.width = this.obj.offsetWidth;
				this.iframeobj.style.height = this.obj.offsetHeight;
				this.iframeobj.style.visibility = 'visible';

			return false;
			}

			clearTimeout(this.timeout);
		};
	
	this.iecompat =
		function()
		{
			return (document.compatMode && document.compatMode != 'BackCompat') ? document.documentElement : document.body;
		};

	this.getoffset =
		function(obj, which)
		{
			var offset = (which == 'x') ? obj.offsetLeft : obj.offsetTop;
			var parent = obj.offsetParent;
			while (parent!=null)
			{
				offset += (which == 'x') ? parent.offsetLeft : parent.offsetTop;
				parent = parent.offsetParent;
			}
			
			// check, if there is enough space in the broser
			if (which == 'x')
			{
				var windowedge = this.ie ? this.iecompat().scrollLeft+this.iecompat().clientWidth-15 : window.pageXOffset+window.innerWidth-15;
				if (windowedge-offset < this.obj.offsetWidth)
					offset -= this.obj.offsetWidth - obj.offsetWidth;
			}
			else
			{
				var topedge = this.ie ? this.iecompat().scrollTop : window.pageYOffset;
				var windowedge = this.ie ? this.iecompat().scrollTop+this.iecompat().clientHeight-15 : window.pageYOffset+window.innerHeight-18;
				if (windowedge-offset < this.obj.offsetHeight)
				{
					offset -= this.obj.offsetHeight + obj.offsetHeight;
					if (offset-topedge < this.obj.offsetHeight)
						offset = topedge - obj.offsetHeight;
				}
			}
		
			return offset;
		};

	this.hidedynamic =
		function(e)
		{
			if (this.ie && !this.obj.contains(e.toElement))
				this.delayhide();
			else if ((this.ns || this.op) && e.currentTarget!=e.relatedTarget && !this.contains_ns(e.currentTarget, e.relatedTarget))
				this.delayhide();

			return false;
		};

	this.contains_ns =
		function(a, b)
		{
			while (b.parentNode)
				if ((b = b.parentNode) == a)
					return true;
			return false;
		};

	return true;
}
