
xx1 = 0;
yy1 = 0;
id = "pbox";
id2 = "overlay";
id3 = "ix";

function getPageSize ()
{
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY)
	{
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	// all but Explorer Mac
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	}
	// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	else
	{
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}


	var windowWidth, windowHeight;

	// nicht IE
	if (self.innerHeight)
	{
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	}
	// IE6
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	}
	// alle anderen IE
	else if (document.body)
	{
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if (yScroll < windowHeight)	{ pageHeight = windowHeight; }
	else												{ pageHeight = yScroll; }

	// for small pages with total width less then width of the viewport
	if (xScroll < windowWidth)	{ pageWidth = windowWidth; }
	else												{ pageWidth = xScroll; }

	arrayPageSize = new Array (pageWidth, pageHeight, windowWidth, windowHeight);

	return arrayPageSize;
}

function getPageScroll ()
{
	var yScroll;

	if (self.pageYOffset)
	{ yScroll = self.pageYOffset; }
	// IE 6
	else if (document.documentElement && document.documentElement.scrollTop)
	{ yScroll = document.documentElement.scrollTop; }
	// alle anderen IE
	else if (document.body)
	{ yScroll = document.body.scrollTop; }

	arrayPageScroll = new Array ('', yScroll);

	return arrayPageScroll;
}

function show_pbox (pic, pic_x, pic_y, ptext)
{
	if (ptext != '') { ptext = ptext + '<br>'; }

	xx1 = eval (pic_x);
	yy1 = eval (pic_y);
	xx2 = xx1;
	yy2 = yy1;

	var a_o = 30;
	var a_l = 20;

	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var objBody = document.getElementsByTagName("body").item(0);

	if ((xx1 + (2 * a_l)) > arrayPageSize[0])
	{
		xx1 = arrayPageSize[0] - (2 * a_l);
		yy1 = (xx1 * yy2) / xx2;
	}

// höhe nicht kürzen
//	if ((yy1 + (4 * a_o)) > arrayPageSize[3])
//	{
//		yy1 = arrayPageSize[3] - (4 * a_o);
//		xx1 = (yy1 * xx2) / yy2;
//	}

	xx1 = Math.round (xx1);
	yy1 = Math.round (yy1);

	obj0 = document.getElementById (id3);
  obj0.innerHTML = '<a href="#" onClick="hide_pbox(); return false;"><img src="./pics/common/pbox_ix.gif" width="20" height="20" border="0" alt=""></a>';
	obj0.style.display = "block";
	obj0.style.position = 'absolute';
	obj0.style.zIndex = '200';
//	obj0.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - a_o - yy1 - 10) / 2) + 'px');
	obj0.style.top = (a_o / 2) + 'px';
	obj0.style.left = (((arrayPageSize[0] - a_l + xx1 - 10) / 2) + 'px');

	obj1 = document.getElementById (id);
  obj1.innerHTML = '<center><a href="#" onClick="javascript:hide_pbox(); return false;"><img src="' + pic + '" border="0" width="' + xx1 + '" height="' + yy1 + '" alt=""></a><br><br>' + ptext + '<br><a href="#" onClick="javascript:hide_pbox(); return false;">schliessen</a></center>';
	obj1.style.display = "block";
	obj1.style.position = 'absolute';
	obj1.style.zIndex = '150';
//	obj1.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - a_o - yy1 - 20) / 2) + 'px');
	obj1.style.top = '10px';
	obj1.style.left = (((arrayPageSize[0] - a_l - xx1) / 2) + 'px');
	obj1.style.width = pic_x + 'px';


	// png-höhe anpassen
	// 1. popupbild <= seite -> png größe gleich seitengröße setzen
	// 2. popupbild > seite -> png größe auf größe des bildes + abstände oben/unten setzen
	var obj2_height = 0; // ovly
	if (arrayPageSize[1] > yy1)	{ obj2_height = arrayPageSize[1]; }
	else												{ obj2_height = (a_o / 2) + (2 * a_o) + yy1; }

	obj2 = document.getElementById (id2);
  obj2.innerHTML = '<a href="#" onClick="hide_pbox(); return false;"><img src="./pics/common/trans.gif" width="100%" height="100%" border="0" alt=""></a>';
	obj2.style.display = "block";
	obj2.style.position = 'absolute';
	obj2.style.top = '0';
	obj2.style.left = '0';
	obj2.style.zIndex = '100';
	obj2.style.height = obj2_height + 'px';
 	obj2.style.width = '100%';

	objBody.insertBefore(obj2, objBody.firstChild);
	objBody.insertBefore(obj1, obj2.nextSibling);
	objBody.insertBefore(obj0, obj1.nextSibling);
}

function hide_pbox ()
{
	obj1 = document.getElementById (id);
	obj1.style.display = "none";
	obj2 = document.getElementById (id2);
	obj2.style.display = "none";
	obj0 = document.getElementById (id3);
	obj0.style.display = "none";

	return false;
}

function preiswechsel (val_q, id_z)
{
//	if (val_q != "" && document.getElementById(id_z) != null)
	if (document.getElementById(id_z) != null)
	{ document.getElementById(id_z).innerHTML = val_q; }
}

function div_show_hide (key)
{
	item_div = document.getElementById(key);
	if (item_div != null)
	{ item_div.style.display = 'block'; }
}
