var InfoWindow = null;
var $InfoSID;
var InnerInfo = null;

if (window.attachEvent) { window.attachEvent("onload", InitInfo); } else { window.addEventListener('load', InitInfo, false); }

function InitInfo()
{
InfoWindow = document.createElement("div");
InnerInfo = document.createElement("div");
InnerInfo.className = "InnerInfo";

InfoWindow.className = "InfoPanel";
InfoWindow.style.visibility = "hidden";

InfoWindow.appendChild(InnerInfo);
document.body.appendChild(InfoWindow);
if (window.attachEvent) { InfoWindow.attachEvent("onclick", HideInfo); } else { InfoWindow.addEventListener('click', HideInfo, false); }
}

function SwitchInfo($Obj, $SID)
{
HideInfo();
ShowInfo($Obj, $SID);
}

function ShowInfo($Icon, $InfoSID)
{
if (window.ClearAllPanel()) ClearAllPanel();
PositionInfoWindow($Icon);
InnerInfo.innerHTML = '<img src="/images/ajax.gif">';
InfoWindow.style.visibility = "visible";
LoadInfo($InfoSID);
}

function HideInfo()
{
InfoWindow.style.visibility = "hidden";
InfoWindow.style.top = "0px";
InfoWindow.style.left = "0px";
ResetInfo();
}

function PositionInfoWindow($Icon)
{

var $VersatzX = 390;
var $VersatzY = 0;
var $ScrolledY 	= window.pageYOffset || document.body.scrollTop;

var $Me = $Icon;
var $X = 0;
while ($Me.offsetParent)	{ $X = $X + $Me.offsetLeft; $Me = $Me.offsetParent; }
var $Me = $Icon;
var $Y = 0;
while ($Me.offsetParent)	{ $Y = $Y + $Me.offsetTop; $Me = $Me.offsetParent; }

if (($Y - InfoWindow.offsetHeight) > 20)	{	InfoWindow.className = "InfoPanel";
							var $NewX	= $X - $VersatzX;
							var $NewY	= $Y - InfoWindow.offsetHeight + $VersatzY;
						}
			else			{	InfoWindow.className = "InfoPanelU";
							var $NewX	= $X - $VersatzX;
							var $NewY	= $Y + 30 + $VersatzY;
						}

if ($ScrolledY > $NewY) { window.scrollTo(0, ($NewY - 300)); }
InfoWindow.style.top = $NewY + 'px';
InfoWindow.style.left= $NewX + 'px';
}

function LoadInfo($SID)
{
var req = null;

try{
req = new XMLHttpRequest();
}
catch (ms){
try{
req = new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (nonms){
try{
req = new ActiveXObject("Microsoft.XMLHTTP");
} 
catch (failed){
req = null;
}
} 
}
req.onreadystatechange = function() { InfoReady(req); }
req.open("POST", '/check/info.php', true);
req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
req.send('sid=' + $SID);
}

function InfoReady(Requester)
{
if (Requester.readyState == 4) 
	{ 	if (Requester.status == 200) { InnerInfo.innerHTML = Requester.responseText; }	
				else   { window.alert("Hier ist leider gerade etwas schief gelaufen!"); }
	}
}

function ResetInfo()
{
//Tooltip.innerHTML = '<img src="/images/ajax.gif">';
}

