var helpBox = null;
function showHelp(obj, text)
{
	if (text === null || text.length < 1)
		return;
	
	if (helpBox === null)
		helpBox = getElement('helpBox');
	
	if (helpBox)
	{
		var pos = findPos(obj);
		var l = pos[0] + obj.offsetWidth + 10;
		var t = pos[1];
		helpBox.innerHTML = text;
		helpBox.style.left = l + 'px';
		helpBox.style.top = t + 'px';
		helpBox.style.display = 'block';
	}
}

function hideHelp()
{
	if (helpBox === null)
		return false;
	helpBox.style.display = 'none';
}

var ovbg = null;
function showOverlaymessage(msg)
{
	var ov = getElement("overlaymessage");
	if (ov)
	{
		ov.innerHTML = msg;
		ov.style.display = 'block';
		ov.style.zIndex = '100';
		ov.onclick = function() { hideOverlaymessage(); }
		centerObject(ov);
	}
	if (ovbg == null)
	{
		var winsize = getBodySize();
		var bodyWidth = document.body.clientWidth;
		var bodyHeight = document.body.clientHeight;
		bodyWidth = (bodyWidth > winsize[0]) ? bodyWidth : winsize[0];
		bodyHeight = (bodyHeight > winsize[1]) ? bodyHeight : winsize[1];
		ovbg = window.document.createElement('div');
		ovbg.style.display = 'block';
		ovbg.style.visibilty = 'visible';
		ovbg.style.top = '0';
		ovbg.style.left = '0';
		ovbg.style.width = bodyWidth +'px';
		ovbg.style.height = bodyHeight +'px';
		ovbg.style.zIndex = '90';
		ovbg.style.position = 'absolute';
		ovbg.style.background = '#000';
		ovbg.style.opacity = '0.5';
		ovbg.style.filter = "Alpha(Opacity=50, style=0)";
		document.body.appendChild(ovbg);
	}
	else
		ovbg.style.display = 'block';
}

function hideOverlaymessage()
{
	var ov = getElement("overlaymessage");
	if (ov)
		ov.style.display = 'none';
	if (ovbg)
		ovbg.style.display = 'none';
}

function findPos(obj) 
{
	var left = 0;
	var top = 0;
	if (obj.offsetParent) 
	{
		left = obj.offsetLeft;
		top = obj.offsetTop;
		while (obj = obj.offsetParent) 
		{
			left += obj.offsetLeft;
			top += obj.offsetTop;
		}
	}
	return [left, top];
}

function getElement(elementId)
{
	return (document.getElementById) ? document.getElementById(elementId) : document.all.elementId;
}

/**
 *	Liefert die Breite und H�he des sichtbaren Browser-Body
 * @return Array [0] = Breite, [1] = H�he
**/
function getBodySize()
{
	var w = -1;
	if(window.innerWidth)
		w = window.innerWidth;
	else if(document.body && document.body.clientWidth)
		w = document.body.clientWidth;
	
	var h = -1;
	if(window.innerHeight)
		h = window.innerHeight;
	else if(document.documentElement)
		h = document.documentElement.offsetHeight;
	else if(document.body && document.body.offsetHeight)
		h = document.body.offsetHeight;
	
	return [w, h];
}

function getScrollPos() {
	return { scrollTop: (window.pageYOffset || document.documentElement.scrollTop || 0),  
		scrollLeft: (window.pageXOffset || document.documentElement.scrollLeft || 0)};
}

function centerObject(targetObj, sourceObj)
{
	var size;
	var scr = getScrollPos();
	if (sourceObj)
	{
		size = [sourceObj.offsetWidth, sourceObj.offsetHeight];
	}
	else
		size = getBodySize();
	
	if (size[0] < 1 || size[1] < 1)
		return;
	
	if (typeof targetObj == 'string')
		targetObj = getElement(targetObj);
	
	if (typeof targetObj == 'object')
	{
		targetObj.style.left = Math.round((size[0] - targetObj.offsetWidth) / 2 - scr.scrollLeft) + 'px';
		targetObj.style.top = Math.round((size[1] - targetObj.offsetHeight) / 2 - scr.scrollTop) + 'px';
	}
	size = 0;
}

function copyValue(srcObj, target, overwrite)
{
	if (overwrite == 'undefined')
		overwrite = false;
	var targetObj = getElement(target);
	if (!srcObj || !targetObj)
		return;
	if (!overwrite && targetObj.value.length > 0)
		return;
	targetObj.value = srcObj.value;
}









