var ie4 = document.all && navigator.userAgent.indexOf("Opera")==-1;
var ns6 = document.getElementById && !document.all;
var ns4 = document.layers;

var lastwin=null, lastwin2=null, lastcaller=null, lastcaller2=null, lastcombotype=null;

function eigener_ort(targ, caller, val, width, height) {
	var args = new Array();
	var arr = null;
	args["bits"] = val;
	if (screen.width<width) wx = screen.width; else wx = width;
	if (screen.height<height) wy = screen.height; else wy = height;
	px = (screen.width - wx)/2;
	py = (screen.height - wy)/2;
	if (ie4) {
	  arr = showModalDialog(targ,args,"font-family:Verdana; font-size:12;  dialogWidth:"+wx+"px; dialogHeight:"+wy+"px");
	  if (arr != null) {
    	Hinzufuegen(caller, arr['anzeige'], arr['wert'], true);
		caller.form.pos_id.value = arr['pos_id'];
	  }
  } else {
  	
	window.top.captureEvents(Event.CLICK|Event.FOCUS);
	
	window.top.onclick = ignoreevents;
	window.top.onfocus = modalhandle;
	
	
	subwnd = window.open(targ+"?NS4=1", "Auswahl", "dependent=yes,hotkeys=no,fullscreen=yes");
	if (subwnd != null) {
		subwnd.resizeTo(wx, wy);
		subwnd.moveTo(px, py);
		subwnd.focus();
	}
	lastwin = subwnd;
  }
}

function Hinzufuegen(elem, text, value, bAuswahl) {
 	NeuerEintrag = new Option(text,value,false,true);
	index = elem.length;
 	elem.options[index] = NeuerEintrag;
	if (bAuswahl) {
		elem.selectedIndex = index;
	}
}

function ignoreevents(e) {
	return false;
}

function modalhandle() {
	var foc = false;
	if (lastwin) {
		if (!lastwin.closed) {
			lastwin.focus();
			foc = true;
		}
	}
	if ((!foc) && (lastwin2)) {
		if (!lastwin2.closed) {
			lastwin2.focus();
			foc = true;
		}
	}
	if (!foc) {
		window.top.releaseEvents(Event.CLICK|Event.FOCUS);
		window.top.onclick = "";
	}
	return false;
}

