function $Browser()
{
	var result = new Object();
	result.userAgent = navigator.userAgent;
	result.code = "";
	result.version = "0";
	result.fileExtension = "";
	result.name = "";
		
	var regExps = new Array
	(
		/MSIE ([0-9])\./,
		/Firefox\/([0-9])\./,
		/Version\/([0-9]).+Safari/,
		/Opera\/([0-9])\./
	);
	
	var codes = new Array
	(
		"ie",
		"ff",
		"sf",
		"op"
	);
	
	var names = new Array
	(
		"Internet Explorer",
		"Firefox",
		"Safari",
		"Opera"
	);
	
	var matches;
	for (var idx = 0; idx < regExps.length; idx++)
	{
		matches = regExps[idx].exec(navigator.userAgent);
		if(matches)
		{
			result.code =  codes[idx];
			result.version = matches[1];
			result.fileExtension = codes[idx] + matches[1];
			result.name =  names[idx];
			break;
		}
	}

	return result;
}

function $Node(pId)
{
	return document.getElementById(pId);
}

function $Offset(pNode)
{
	var result = new Object();
	result.left = pNode.offsetLeft;
	result.top = pNode.offsetTop;
	
	while(pNode.offsetParent)
	{
		pNode = pNode.offsetParent;
		result.left += pNode.offsetLeft;
		result.top += pNode.offsetTop;
	}

	return result;
}

function $OffsetLeft(pNode)
{
	return $Offset(pNode).left;
}

function $OffsetTop(pNode)
{
	return $Offset(pNode).top;
}

function $ScrollBar()
{
	var result = new Object();
	result.horizontal = 0;
	result.vertical = 0;

	// Safari kennt documentElement.scrollHeight nicht,
	// nur body.scrollHeight.
	var scrollHeight
		= window.document.documentElement.scrollHeight
		? window.document.documentElement.scrollHeight
		: window.document.body.scrollHeight;
		
	var clientHeight
		= window.document.documentElement.clientHeight;
		
	if(scrollHeight > clientHeight)
	{
		// Internet Explorer zeigt immer einen vertikalen
		// ScrollBar bzw. einen Platzhalter an.
		if ($Browser().code != "ie")
		{
			if ($Browser().code == "sf")
				result.vertical = 15;
			else
				result.vertical = 16;
		}
	}
		
	var scrollWidth
		= window.document.documentElement.scrollWidth;
		
	var clientWidth
		= window.document.documentElement.clientWidth;
				
	if(scrollWidth > clientWidth)
	{
		if ($Browser().code == "sf")
			result.horizontal = 15;
		else
			result.horizontal = 16;
	}
	
	return result;
}

function $Size()
{
	var result = new Object();
	
	result.width
		= window.document.body.clientWidth
		? window.document.body.clientWidth
		: window.document.documentElement.clientWidth;
	result.height
		= window.document.body.clientHeight
		? window.document.body.clientHeight
		: window.document.documentElement.clientHeight;

	return result;
}


function $Scroll()
{
	var result = new Object();
	
	result.left
		= window.document.documentElement.scrollLeft
		? window.document.documentElement.scrollLeft
		: window.document.body.scrollLeft;
	result.top
		= window.document.documentElement.scrollTop
		? window.document.documentElement.scrollTop
		: window.document.body.scrollTop;
	
	return result;
}

function $Id(pId)
{
	return document.getElementById(pId);
}

function $Body()
{
	return window.document.documentElement
		? window.document.documentElement
		: window.document.body;
}

function $Width()
{
	return window.document.body.clientWidth;
}

function $Height()
{
	return window.document.body.clientHeight
		? window.document.body.clientHeight
		: window.document.documentElement.clientHeight;
}

function $CenterFixed(pElement)
{
	var left = ($Size().width - pElement.clientWidth + $ScrollBar().vertical) / 2;	
	// Nicht nach links aus dem Fenster wandern lassen
	pElement.style.left = Math.max(left, 0) + 'px';
}

function $MiddleFixed(pElement, pUpShift)
{
	if(pUpShift == null)
		pUpShift = 0;
	else
		pUpShift = Math.min(1, pUpShift);
	var top = ($Size().height - pElement.clientHeight) / 2;
	top -= top * pUpShift;
	// max: nicht nach oben aus dem fenster wandern lassen
	pElement.style.top = Math.max(top, 0) + 'px';
}

function $CenterScrolled(pElement)
{
	var left = ($Width() - pElement.clientWidth) / 2;
	left += $Body().scrollLeft - 4;
	// max: nicht nach links aus dem fenster wandern lassen
	pElement.style.left = Math.max(left, 0) + 'px';
}

function $MiddleScrolled(pElement, pUpShift)
{
	if(pUpShift == null)
		pUpShift = 0;
	else
		pUpShift = Math.min(1, pUpShift);
	var top = ($Height() - pElement.clientHeight) / 2;
	top += $Body().scrollTop - 2;
	top -= top * pUpShift;
	// max: nicht nach oben aus dem fenster wandern lassen
	pElement.style.top = Math.max(top, $Body().scrollTop) + 'px';
}


function $Info()
{
	var result = new Object();
	result.client = new Object();
	result.body = new Object();
	
	result.client.width
		= window.document.documentElement.clientWidth;
	result.client.height
		= window.document.documentElement.clientHeight;
	
	result.body.width
		= window.document.documentElement.scrollWidth	
	result.body.height
		= window.document.documentElement.scrollHeight
		? window.document.documentElement.scrollHeight
		: window.document.body.scrollHeight;
	
	return result;
}