
/**
 * Popups.
 */
function popup(url, name, width, height) {
	var win = window.open(url, name, 'top=100,left=100,width=' + width + ',height=' + height +
	                      ',resizable=yes,scrollbars=yes,toolbar=no,status=no,menubar=no,location=no');

	if (win != null) {
		win.focus();
        return false;
	}
	return true;
}
function popup2(url, name, width, height) {
	var win = window.open(url, name, 'top=100,left=100,width=' + width + ',height=' + height);

	if (win != null) {
		win.focus();
        return false;
	}
	return true;
}

/**
 * Aendern der CSS-Style-Klasse
 */
function changeStyle(el, styleCl) {
	if (el && styleCl) {
		el.className = styleCl;
	}
	return true;
}

/**
 * Setzen der Status-Zeile
 */
function setWindowStatus(status) {
	window.status=status;
	return true;
}

/**
 * Zeigt das Element mit der angegebenen Id.
 */
function show(elemId) {
   	var el = document.getElementById(elemId);

   	if (el) {
        el.style.visibility = "visible";
    }
}

/**
 * Verbirgt das Element mit der angegebenen Id.
 */
function hide(elemId) {
   	var el = document.getElementById(elemId);

   	if (el) {
        el.style.visibility = "hidden";
    }
}

/**
 * Sucht die Position des Elements mit der angegebenen Id.
 */
function findPos(elemId) {
   	var el = document.getElementById(elemId);
	var x = 0;
	var y = 0;
   	var temp;

   	if (el) {
		if (el.offsetParent) {
       		temp = el;
       		while (temp.offsetParent) { //Looping parent elements to get the offset of them as well
         		temp = temp.offsetParent;
         		x += temp.offsetLeft;
         		y += temp.offsetTop;
       		}
     	}
     	x += el.offsetLeft;
     	y += el.offsetTop;
   	}
   	else {
    	x = -1;
    	y = -1;
   	}

  	return [x,y-1];
}

var infoBox = null;
var infoTm = null;
var errorBox = null;
var errorTm = null;

function setInfoBoxesPos(event) {
    if (! event) {
        event = window.event;
    }
    if (document.getElementById && document.getElementById("infoboxes")) {
        document.getElementById("infoboxes").style.left  = event.clientX + "px";
        document.getElementById("infoboxes").style.top = event.clientY + "px";
    } 
    else if (document.all && document.all.infoboxe) {
        document.all.infoboxes.style.left = event.clientX;
        document.all.infoboxes.style.top = event.clientY;
    }
}

function showInfoMsg(msg) {
   	infoBox = document.getElementById('infobox');
   	if (infoBox) {
        infoBox.innerHTML = '<p>' + msg + '<\/p>';
        infoBox.style.visibility = "visible";
        infoTm = setTimeout('closeInfoMsg()', 5000);
    }
}

function closeInfoMsg() {
   	if (infoBox) {
        clearTimeout(infoTm);
        infoTm = null;
        infoBox.style.visibility = "hidden";
        infoBox = null;
    }
}

function showErrorMsg(msg) {
   	errorBox = document.getElementById('errorbox');
   	if (errorBox) {
        errorBox.innerHTML = '<p>' + msg + '<\/p>';
        errorBox.style.visibility = "visible";
        errorTm = setTimeout('closeErrorMsg()', 10000);
    }
}

function closeErrorMsg() {
   	if (errorBox) {
        clearTimeout(errorTm);
        errorTm = null;
        errorBox.style.visibility = "hidden";
        errorBox = null;
    }
}