/**
* open window with following parameters
*
* @param string link
* @param string wname
* @param int xsize
* @param int ysize
* @param int xpos
* @param int ypos
* @param string scrollbars
* @return bool (false)
*/

	function wopen(link,wname,xsize,ysize,xpos,ypos,scrollbars)
	{
		if (scrollbars == '')
		{
			scrollbars = 'no';
		}

		if (xsize==-1)
			xsize=screen.availWidth-10;
		if (ysize==-1)
			ysize=screen.availHeight-60;
		if (xpos==-1)
			xpos=(screen.availWidth-xsize)/2;
		if (ypos==-1)
			ypos=(screen.availHeight-ysize)/2;

   	features = 'width='+xsize+',height='+ysize+',status=no,scrollbars='+scrollbars+',noresizable,top='+ypos+',left='+xpos+',screenY='+ypos+',screenX='+xpos;

		nwindow  = open(link, wname, features);
		nwindow.focus();

		return false;
	}

/**
* setzt alle <input type="hidden" name="PJS" value="0"> auf value="1"
* sofern JavaScript aktiviert ist
*        => Erkennung zum Anzeigen von Form Fehlern via DHTML/JavaScript
*/

	function setPJS()
	{
		input_array = document.getElementsByTagName('input');

		for (z=0;z<input_array.length;z++)
		{
			if (input_array[z].type == 'hidden'
			&&  input_array[z].name == 'PJS')
			{
				input_array[z].value = '1';
			}
		}
	}

/**
* change background-color to "co" within Style of element identied by "id"
*
* @param string id
* @param string co
*/

	function chBGColor(id,co)
	{
		document.getElementById(id).style.backgroundColor = co;
	}

/**
* change className for an element identified by id
*
* @param string id
* @param string classname
*/

	function chClassName(id,classname)
	{
		document.getElementById(id).className = classname;
	}

/**
* display large image within a div in current page and set position to (currently) 10,10
*
* @param string id
* @param string img_src
* @return bool
*/

	function displayLargeImage(id,img_src)
	{
		var DivLarge = document.createElement('div');
		DivLarge.innerHTML = '<div id="_largeimage" style="position:absolute; top:10px; left:10px;"><a href="#" onClick="removeLargeImage(\'_largeimage\'"><img src="'+img_src+'" border="0"></a></div>';
		// div_large.className = 'fakefile';

		obj = document.getElementById(id);
		obj.appendChild(DivLarge);

		return false;
	}

	function removeLargeImage(id)
	{
//		alert('.');
	}


/**
* generelle DOM Funktionen
*/

function findPosX(obj)
{
	var curleft = 0;

	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
	{
		curleft += obj.x;
	}

	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
	{
		curtop += obj.y;
	}

	return curtop;
}

function getObject(id)
{
	var obj = document.getElementById(id);

	if (!obj)
	{
		alert('getObject(): Element <'+id+'> not found');
	}

	return obj;
}

function setClassNameForID(id,classname)
{
	obj = getObject(id);
	obj.className = classname;
}

function setDiplayForID(id,display)
{
	obj = getObject(id);
	obj.style.display = display;
}

function setInnerHTMLForID(id,html)
{
	obj = getObject(id);
	obj.innerHTML = html;
}

function setVisibilityByID(id,visibility)
{
	obj = getObject(id);
	obj.style.visibility = visibility;
}

function setPosForID(id,left,top,visiblity)
{
	obj = getObject(id);
	obj.style.left 				= left;
	obj.style.top 				= top;
	obj.style.visibility 	= visiblity;
}

function setTopForID(id,top)
{
	obj = getObject(id);
	obj.style.top = top;
}

function updateMouseInfoPos()
{
	obj = getObject('mouseinfo');

	obj.style.left			 = mx+2;
	obj.style.top				 = my+10;
}

function displayMouseInfo(html)
{
	obj = getObject('mouseinfo');

	updateMouseInfoPos();
	obj.innerHTML 			 = html;
	obj.style.visibility = 'visible';

	if (mouseinfo_interval == null)
	{
		mouseinfo_interval = window.setInterval("updateMouseInfoPos()", 50);
	}
}

function hideMouseInfo()
{
	obj = getObject('mouseinfo');
	obj.style.visibility = 'hidden';

	if (mouseinfo_interval != null)
	{
		window.clearInterval(mouseinfo_interval);
		mouseinfo_interval = null;
	}
}

function displayInfo(id,obj,html,offset)
{
  obj_x = findPosX(obj);
  obj_y = findPosY(obj);

  setInnerHTMLForID(id, html);

	setPosForID(id, obj_x, obj_y+offset, 'visible');
}

function hideInfo(id)
{
	setPosForID(id, 0, 0, 'hidden');
}
