var child = new Array();
var child_count = 0;

function popup(url, w, h) {
	if (!w) w = 740;
	if (!h) h = 500;	
	child[child_count] = window.open(url, '', 'width='+w+',height='+h+',status=yes,scrollbars=yes,resizable=yes');
	child_count += 1;
	return false;
}

function popup_with_size(url,width,height){
	
	child[child_count] = window.open(url, '', 'width=' + width + ',height=' + height + ',status=yes,scrollbars=yes,resizable=yes');
	child_count += 1;
	
	return false;
}

function popup_modal(url,width,height)
{
	
	child[child_count] = window.open(url, '', 'width=' + width + ',height=' + height + ',status=no,scrollbars=yes,resizable=no');
	child_count += 1;
	
	return false;
}

function refresh_opener() {
	var win = window;
	while(o = win.opener) 
	{
		o.location.reload();
		win.close();
		win = o;
	}
}

function refresh_opener_close() {
	refresh_opener();
	if (window.opener) self.close();
}

function redirect_opener(url) 
{
	var win = window;

	while(o = win.opener) 
	{
		o.location.replace(url);
		window.setTimeout("self.focus();", 800);
		win = o;
	}
}

function close_popup() {
	if (window.opener) window.opener.focus();
	window.close();
	return false;
}

function cleanup(){
	for(i=0;i<child_count;i++){
		if(child[i] && child[i].open && !child[i].closed){
			child[i].close();
		}
	}
}

function mdb_reset(_elem_)
{
	document.getElementById(_elem_+'mdb_file').value = "please choose";
	document.getElementById(_elem_+'mdb_id').value = 0;
	return false;
}

function textCounter(field, countfield, maxlimit) {
/*
* Die Input-Parameter sind: der Feld-Name;
* das Feld mit der Zahl der verbleibenden Stellen;
* die max. Stellenanzahl.
*/

if (field.value.length > maxlimit) { // wenn die eingegebene Länge größer als erlaubt ist
field.value = field.value.substring(0, maxlimit);} // es wird keine weitere Eingabe mehr zugelassen
else { 
//countfield.firstChild.nodeValue = field.value.length;
countfield.firstChild.nodeValue = maxlimit - field.value.length; // die verbleibende Anzahl von Zeichen wird angezeigt
}
}
