// write text to div with given id
function writeTextToDiv(text,id) {
	if(text == "") text = "&nbsp;";
	if (document.getElementById) {
		x = document.getElementById(id);
		if(x != undefined) {
			x.innerHTML = '';
			x.innerHTML = text;
		}
	} else if (document.all) {
		x = document.all[id];
		if(x != undefined) x.innerHTML = text;
	}
}

/**
 * show text in a html popup window
 * this is useful e.g. when outputting a large amount of data while debugging
 * @param text the plaintext to write into the popup window
 */
function popAlert(text) {
	var w = window.open('','extendedalertwin','width=297,height=210,toolbar=no,status=no,menubar=no,resizable=yes');
	w.document.write('<html><head><title>extendedAlert</title></head><body><pre style="font-size:11px">'+text+'</pre></body></html>');
	w.focus();
}

function getAbsolutePosition(o){
	var l=0;
	var t=0;
	if(o.offsetParent){
		while(o.offsetParent) {
			l+=o.offsetLeft;
			t+=o.offsetTop;
			o=o.offsetParent;
		}
	} else if(o.x){
		l+=o.x;
		t+=o.y;
	}
	return {x:l,y:t};
}

function getScrollPosition(w) {
	if (w.pageXOffset) return {x:w.pageXOffset,y:w.pageYOffset};
	else if (document.documentElement && document.documentElement.scrollLeft) return {x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop};
	else if (document.body) return {x:document.body.scrollLeft,y:document.body.scrollTop};
}

