
/**
 * Gibt die Position im Dokument des Objektes e zurück.
 */
function getPosition(e) {
	var x = 0, y = 0, width = e.offsetWidth || 0, height = e.offsetHeight || 0;       
	do {
		x += e.offsetLeft;
		y += e.offsetTop; //alert(e.tagName + " id='" + e.id + "' class='" + e.className + "' offsetTop='" + e.offsetTop +"' y='" + y + "' height='" + height +"'");
	}
	while((e = e.offsetParent) && e.tagName && e.tagName.toLowerCase() != 'body');
//	alert("ReturnValue von getPosition() x='" + x + "' y='" + y + "' width='" + width +"' height='" + height +"'");   
	return { x : x, y : y, width : width, height : height };
}

/**
 * Ermittelt die Mausposition
 * pos.left, pos.top innerhalb des Fensters
 * pos.scrollLeft, pos.scrollTop innerhalb des Dokuments
 */
function getMousePosition(evt) {
    if(!evt) evt = window.event;
    var pos = new Object();
    pos.left = evt.clientX;
    pos.top = evt.clientY;
    var b = (window.document.compatMode && window.document.compatMode == "CSS1Compat") ? 
   window.document.documentElement : window.document.body || null;
    if (b){
        pos.scrollLeft= pos.left + b.scrollLeft;
        pos.scrollTop = pos.top + b.scrollTop;
    }
    return pos;
}

/**
 * Verhindert, dass HTML-Zeichen interpretiert werden.
 */
function HTMLEncode(result) {
	// ampersands (&)
	result = result.replace(/\&/g,'&amp;');

	// less-thans (<)
	result = result.replace(/\</g,'&lt;');

	// greater-thans (>)
	result = result.replace(/\>/g,'&gt;');
	return result;
}

/**
 * Nimmt einen Pfad an, und gibt die XML-Datei als Objekt zurück.
 */
function loadXML(path) {
	try { //Internet Explorer
  		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  	}
	catch(e) {
		try { //Firefox, Mozilla, Opera, etc.
			xmlDoc=document.implementation.createDocument("","",null);
    	} catch(e) {
			alert(e.message);
			return;
    	}
  	}
	xmlDoc.async=false;
	xmlDoc.load(path);
}


