function AttachEvent(obj, evt, fnc, useCapture) {
	if (!useCapture) useCapture = false;
	
	if (obj.addEventListener) {
		obj.addEventListener(evt, fnc, useCapture);
		return true;
	} else
	if (obj.attachEvent) {
		return obj.attachEvent("on" + evt, fnc);
	}
}

function GetTarget(e)
{
	if (e.target)
	{
		target = e.target;
	} else
	if (e.srcElement)
	{
		target = e.srcElement;
	}
	
	if (target.nodeType == 3) // Safari bug !
		target = target.parentNode;
	
	return target;
}

function dhtml_HttpPost(URL_TO_POST, POST_DATA) {
	var HttpRequest = false;
	
	if (window.XMLHttpRequest) {
		HttpRequest = new XMLHttpRequest();
	} else 
	if (window.ActiveXObject) {
		HttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	HttpRequest.open('POST', URL_TO_POST, true);
	HttpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

	HttpRequest.onreadystatechange = function() {
		if (HttpRequest.readyState == 4) {
			if (HttpRequest.status == 200) {
				eval(HttpRequest.responseText);
				//alert("Debug: " + HttpRequest.responseText);
			}
		}
	}
	HttpRequest.send(POST_DATA);
}

function dhtml_clearList(form, list)
{
	var element = document.getElementsByName(list)[0];
	while (element.length) {
		element.options[0] = null;
	}
}

function dhtml_addToList(list, value, name, selected)
{
	var element = document.getElementById(list);
	
	element.options[element.length] = new Option(name, value);
	if (selected)
		element.selectedIndex = element.length - 1;
}

function dhtml_setStatus(form, item, status)
{
	document.getElementsByName(item)[0].disabled = (!status);
}

function JSAddSlashes(str)
{
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\0/g,'\\0');
	return str;
}

function JSTrim(string_to_trim)
{
  return string_to_trim.replace (/^\s+/, '').replace(/\s+$/, '');
}

function GetWindowSize()
{
	var window_data = new Object();
	
	/* Höhe + Breite des Fensters */
	if (window.innerWidth || window.innerHeight) {
		/* Firefox, Opera, ... */
		window_data['width']  = window.innerWidth;
		window_data['height'] = window.innerHeight;
	} else if (document.documentElement) {
		/* Internet Explorer */
		window_data['width']  = document.documentElement.clientWidth;
		window_data['height'] = document.documentElement.clientHeight;
	} else {
		/* Internet Explorer */
		window_data['width']  = document.body.clientWidth;
		window_data['height'] = document.body.clientHeight;
	}
	
	window_data['x'] = (document.all ? window.screenLeft : window.screenX);
	window_data['y'] = (document.all ? (window.screenTop - 105) : window.screenY); // - 105 wg. Internetexplorer
	
	window_data['sx'] = (document.body.scrollLeft + document.documentElement.scrollLeft);
	window_data['sy'] = (document.body.scrollTop  + document.documentElement.scrollTop);
	// window_data['y'] = window.posy; // Maus!?
	
	return window_data;
}
