	var ie = document.all ? true:false;

function Popup(sUrl, nWidth, nHeight, sPos)
{	// Calc Position
	var nWinX = 0, nWinY = 0;

	if (sPos == "RB" || sPos == "") // RightBottom
	{	nWinX = screen.width - nWidth - 8;
		nWinY = screen.height - nHeight - 64;
	}
	else if (sPos == "RT")			// RightTop
	{	nWinX = screen.width - nWidth - 8;
		nWinY = 0;
	}
	else if (sPos == "RTV")			//RightTopVollesbild		
	{	nWinX = screen.width - nWidth - 8;
		nWinY = 0;
		nHeight = screen.height - 64;
	}
	else if (sPos == "RC")			//RightCenter
	{	nWinX = screen.width - nWidth - 8;
		nWinY = (screen.height - nHeight - 64)/2
	}
	
	// Open Popup
	var pop;	
	// pop = window.open(sDomain+"/layout/popup_frames.php4?Title="+sTitle+"&Pic="+sKapPic+"&Width="+nWidth+"&Url="+sUrl, sTitle, 'width='+nWidth+',height='+nHeight+',top='+nWinY+',left='+nWinX+'),toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
	//pop = window.open(sDomain+"/layout/popup_frames.htm?Title="+sTitle+"&Pic="+sKapPic+"&Width="+nWidth+"&Url="+sUrl, sTitle, 'width='+nWidth+',height='+nHeight+',top='+nWinY+',left='+nWinX+'),toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
	pop = window.open(sUrl, "PopupTT", 'width='+nWidth+',height='+nHeight+',top='+nWinY+',left='+nWinX+'),toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
	pop.focus();
	return false;
}

function Printversion(sUrl)
{	var PrintWin = window.open(sUrl+'?g_bPrint=true','Drucken','scrollbars=yes,width=460,height=500');
	PrintWin.focus();
	return false;
}

function PrintPage()
{	if (window.print)
			window.print();
	else	alert("Ihr Browser unterstützt diese Funktion nicht. Bitte nutzen Sie den Print-Button des Browsers.");
}

function Rollover(pThis)
{	var sSrc = pThis.src;
	sSrc = sSrc.replace(/.gif/, "h.gif");
	sSrc = sSrc.replace(/.jpg/, "h.jpg");
	pThis.src = sSrc;
}

function Rollout(pThis)
{	var sSrc = pThis.src;
	sSrc = sSrc.replace(/h.gif/, ".gif");
	sSrc = sSrc.replace(/h.jpg/, ".jpg");
	pThis.src = sSrc;
}

function UseLayers()
{	return document.getElementById ? true:false;
}

function Abs(fNumber)
{	if (fNumber < 0) return -fNumber;
	return fNumber;
}

function SetPos(pObj, x, y)
{	pObj.style.left = x + 'px';
	pObj.style.top = y + 'px';
}

function SetX(pObj, x)
{	pObj.style.left = x + 'px';	
}

function SetY(pObj, y)
{	pObj.style.top = y + 'px';
}

function SetWidth(pObj, w)
{	pObj.style.width = w + 'px';
}

function SetHeight(pObj, h)
{	pObj.style.height = h + 'px';
}

function GetX(pObj)
{	return parseInt(pObj.style.left.replace(/px/, ""));
}

function GetY(pObj)
{	return parseInt(pObj.style.top.replace(/px/, ""));
}

function GetAbxX(pObj)
{	return GetAbsX(pObj, -1);
}

function GetAbsX(pObj, nMaxCount)
{	nX = 0;
	nCount = 0;
	while (pObj)
	{	nX += pObj.offsetLeft;
		pObj = pObj.offsetParent;
		nCount++;
		if (nCount == nMaxCount) break;
	}
	return nX;
}

function GetAbxY(pObj)
{	return GetAbsY(pObj, -1);
}

function GetAbsY(pObj, nMaxCount)
{	nY = 0;
	nCount = 0;
	while (pObj)
	{	nY += pObj.offsetTop;
		pObj = pObj.offsetParent;
		nCount++;
		if (nCount == nMaxCount) break;
	}
	return nY;
}

function GetWidth(pObj)
{	return pObj.offsetWidth;	
}

function GetHeight(pObj)
{	return pObj.offsetHeight;	
}

// Mouse-Functions
	var m_nMouseX = 0;
	var m_nMouseY = 0;

function GetMousePos(evt)
{	m_nMouseX = 0;
	m_nMouseY = 0;
	if (ie)
	{	m_nMouseY = event.clientY + document.body.scrollTop;
		m_nMouseX = event.clientX + document.body.scrollLeft;
	}
	else 
	{	m_nMouseY = evt.pageY;
		m_nMouseX = evt.pageX;
	}
}

// Window-Functions
function GetWindowX()
{	if (typeof window.pageXOffset != 'undefined')
	{	return window.pageXOffset;
	}
	else if (document.body && typeof document.body.scrollLeft != 'undefined')
	{	return document.body.scrollLeft;
	}
	return 0;
}

function GetWindowY()
{	if (typeof window.pageYOffset != 'undefined')
	{	return window.pageYOffset;
	}
	else if (document.body && typeof document.body.scrollTop != 'undefined')
	{	return document.body.scrollTop;
	}
	return 0;
}

function GetWindowWidth()
{	width = 0;
	if(typeof window.innerWidth != 'undefined')
	{	width = window.innerWidth;
	} 
	else 
		if (document.body && typeof document.body.clientWidth != 'undefined')
		{	width = document.body.clientWidth;
		}
  return width;
}

function GetWindowHeight()
{	height = 0;
	if(typeof window.innerHeight != 'undefined')
	{	height = window.innerHeight;
	} 
	else 
		if (document.body && typeof document.body.clientHeight != 'undefined')
		{	height = document.body.clientHeight;
		}
	return height;
}

/* Forms */
function SubmitAndJump(nPage)
{	if (document.forms["TTForm"] != null)
	{	document.forms["TTForm"].action += "?g_nPage="+nPage;
		document.forms["TTForm"].submit();
	}
}

/* Toggle */
function ToggleVis(sId)
{	if (document.getElementById(sId).style.display == "none")
	{	document.getElementById(sId).style.display = "block";
	}
	else
	{	document.getElementById(sId).style.display = "none";
	}
}

/* Bookmarks */
function BookmarkLink(sLink, sUrl, sTitle)
{	BookmarkLink(sLink, sUrl, sTitle, true, "");
}
function BookmarkLink(sLink, sUrl, sTitle, bStatistik, sClass)
{	if (window.sidebar || window.external)
	{	if (sClass != "") sClass = " class=\""+sClass+"\"";
		document.write('<a href="javascript:Bookmark(\''+sUrl+'\', \''+sTitle+'\', '+bStatistik+');"'+sClass+'>'+sLink+'</a>');
	}	
}

function Bookmark(sUrl, sTitle, bStatistik)
{	var bCalled = false;
	if (window.sidebar)
	{	// FF
		window.sidebar.addPanel(sTitle, sUrl, "");
		bCalled = true;
	}
	else if (window.external)
	{	// IE
		window.external.AddFavorite(sUrl, sTitle);
		bCalled = true;
	}
	if (bStatistik)
		document.location.replace(document.location.href+"?fav");	
}

/* Ajax */
function AjaxPostForm(sUrl, sQuery, sIdForm, sIdDiv)
{	var pHttp_request = null;
	
	if (window.XMLHttpRequest) 
	{	pHttp_request = new XMLHttpRequest();
		if (pHttp_request.overrideMimeType)
		{	pHttp_request.overrideMimeType('text'); // text/xml text
		}
	} else if (window.ActiveXObject)
	{	try
		{	pHttp_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{	try
			{	pHttp_request = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) {}
		}
	}
	if (!pHttp_request)
	{	return false;
	}

	if (sIdForm != "")
	{	for (i = 0; i < document.forms[sIdForm].elements.length; i++)
		{	if (sQuery != "") sQuery += "&";
			sQuery += document.forms[sIdForm].elements[i].name+"="+document.forms[sIdForm].elements[i].value;
		}
	}

	// Anzeige: Aktualisieren...
	if (sIdDiv != "" && document.getElementById(sIdDiv))
	{	var nHeight = document.getElementById(sIdDiv).offsetHeight;
		document.getElementById(sIdDiv).style.height = nHeight;	
		document.getElementById(sIdDiv).innerHTML = "<div style=\"height:"+nHeight+"px;\">Aktualisierung...</div>"; // DIV mit height setzen, sonst scrollt FF
	}
	else
		sIdDiv = "";

	// Request absenden
	pHttp_request.onreadystatechange = function(){OnAjaxLoaded(pHttp_request, sIdDiv)};
	pHttp_request.open('POST', sUrl, true);
	pHttp_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
	pHttp_request.send(sQuery);	
}

function OnAjaxLoaded(pHttp_request, sIdDiv)
{	if (pHttp_request.readyState == 4)
	{	if (pHttp_request.status == 200)
		{	if (sIdDiv != "")
			{	document.getElementById(sIdDiv).style.height = 'auto';
				document.getElementById(sIdDiv).innerHTML = pHttp_request.responseText;
			}
		}
		else 
		{	if (sIdDiv != "") document.getElementById(sIdDiv).innerHTML = "Fehler beim Laden.";
		}
	}
}