obj = null;

if (self.pageYOffset)
{ document.onmousemove = pic_move; }
// IE 6
else if (document.documentElement)
{ document.documentElement.onmousemove = pic_move; }
// alle anderen IE
else if (document.body)
{ document.body.onmousemove = pic_move; }

xx = 0;
yy = 0;


function pic_move (e)
{
if(!e) e = window.event;

	var zw_px = 20;

	// scrollabstand nach links/oben
	var scroll_links = 0;
	var scroll_oben = 0;
	var x_anzeige = 0;
	var y_anzeige = 0;
	if (self.pageYOffset)
	{
		scroll_links = self.pageXOffset;
		scroll_oben = self.pageYOffset;
		x_anzeige = window.innerWidth;
		y_anzeige = window.innerHeight;
maus_x = e.pageX;
maus_y = e.pageY;
	}
	// IE 6+ in 'standards compliant mode'
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
	{
		scroll_links = document.documentElement.scrollLeft;
		scroll_oben = document.documentElement.scrollTop;
		x_anzeige = document.documentElement.clientWidth;
		y_anzeige = document.documentElement.clientHeight;
maus_x = e.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft;
maus_y = e.clientY + document.documentElement.scrollTop - document.documentElement.clientTop;
	}
	//IE 4 compatible
	else if (document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		scroll_links = document.body.scrollLeft;
		scroll_oben = document.body.scrollTop;
		x_anzeige = document.body.clientWidth;
		y_anzeige = document.body.clientHeight;
maus_x = e.clientX + document.body.scrollLeft - document.body.clientLeft;
maus_y = e.clientY + document.body.scrollTop - document.body.clientTop;
	}


	// mauskoordinaten
//	x = (document.all) ? window.event.x : e.pageX;
//	y = (document.all) ? window.event.y : e.pageY;
x=maus_x;
y=maus_y;
	// mauskoordinaten absolut zum fenster
	x2 = x - scroll_links;
	y2 = y - scroll_oben;

	// abstand (links/rechts/oben/unten) zum jeweiligen fensterrand
	r = x_anzeige - x2;
	u = y_anzeige - y2;
	l = x_anzeige - r;
	o = y_anzeige - u;

	// maximalwert der horizontalen/vertikalen achse
	if (l > r) { max_x = l; } else { max_x = r; }
	if (o > u) { max_y = o; } else { max_y = u; }

	if (obj != null)
	{
		bild_l = zw_px;
		bild_t = zw_px;

		// wenn bild horizontal auf den bildschirm passt
		if ((xx + 3*zw_px) <= max_x && (yy + 3*zw_px) <= y_anzeige)
		{
			if (l > r)	{ bild_l = (x - zw_px - xx); }
			else				{ bild_l = (x + zw_px); }

			bild_t = y - (yy/2);

			if (bild_t < (scroll_oben + zw_px)) { bild_t = scroll_oben + zw_px; }

			while ((bild_t+yy+(2*zw_px)) > (scroll_oben+y_anzeige)) { bild_t = bild_t - 1; }
		}
		else
		{
			// wenn bild vertikal auf den bildschirm passt
			if ((yy + 3*zw_px) <= max_y && (xx + 3*zw_px) <= x_anzeige)
			{
				if (o > u)	{ bild_t = (y - zw_px - yy); }
				else				{ bild_t = (y + 2*zw_px); }

				bild_l = x - (xx/2) + zw_px;

				if (bild_l < (scroll_links + zw_px)) { bild_l = scroll_links + zw_px; }
				
				while ((bild_l+xx+(2*zw_px)) > (scroll_links+x_anzeige)) { bild_l = bild_l - 1; }
			}
			else
			{
				pic_hide ();
			}
		}



		obj.style.left = bild_l + "px";
		obj.style.top = bild_t + "px";

//		obj.style.left = eval (scroll_links + 10) + "px";
//		obj.style.top = eval (scroll_oben + 10) + "px";
//		obj.innerHTML = x_anzeige + "px - " + y_anzeige + "px";
//		obj.style.display = "block";
	}
}


function pic_show (id, pic, pic_x, pic_y)
{
	xx = eval (pic_x);
	yy = eval (pic_y);

	obj = document.getElementById(id);
	if (obj != null)
	{
	  obj.innerHTML = '<img src="' + pic + '" border="0" width="' + pic_x + '" height="' + pic_y + '" alt="">';
		obj.style.display = "block";
	}
}

function pic_hide ()
{
	if (obj != null)
	{
		obj.style.display = "none";
	}
}
