var spawn;
var flag = false;
var t_file;
var t_name;
var t_gx;
var t_gy;
var t_px;
var t_py;
var t_options;

function popup(mfile, name, gx, gy, px, py, options) {
	t_file=mfile;
	t_name=name;
	t_gx=gx;
	t_gy=gy;
	t_px=px;
	t_py=py;
	t_options=options;
	if (!flag) {
		setTimeout('tpopup()',500)
		flag = true;
	} else {
		tpopup();
		flag = false;
	}
	return false;
}



function tpopup() {
	var mfile = t_file;
	var name = t_name;
	var gx = t_gx;
	var gy = t_gy;
	var px = t_px;
	var py = t_py;
	var options = t_options;

	if (name==null) {
		if (this.name=='opener') {
			name = 'microsite';
			gx = 625;	// breite
			gy = 600;	// hoehe
			var x=0, y=0, xm=0, ym=0, woff=0, hoff=0;
			if (window.screenX)    x = window.screenX;
			if (window.screenLeft) x = window.screenLeft;
			if (window.screenY)    y = window.screenY;
			// if (window.screenTop))  y = window.screenTop-20;
			if (window.screenTop)  y = window.screenTop;



	// url-leiste, tabbars etc. rausrechnen
			woff = hoff = 0;
			if (window.outerWidth) {
				woff = window.outerWidth  - window.innerWidth;
				hoff = window.outerHeight - window.innerHeight;
			}

			x = x + woff + 240;		// x-offset
			y = y + hoff + 0;		// y-offset


			xm = screen.width;
			ym = screen.height;

			if (x > xm-gx) x = xm-gx;
			if (y > ym-gy) y = ym-gx;

			options = 'scrollbars=yes,resizable=yes';
			px = x;
			py = y;


		} else {
			return true;
		}
	}
	spawn = window.open(mfile, name, 'width=' + gx + ',height=' + gy + ',left=' + px + ',top=' + py + ((options && options!='') ? ',' + options : ''));
	if (!spawn) {
		if (document.getElementById('seiteninhalt')) {
			merk = document.getElementById('seiteninhalt').innerHTML;
			document.getElementById('seiteninhalt').innerHTML =
				'<h1>Popup-Blocker erkannt</h1><div class="text"><p>Sie haben einen Popup-Blocker installiert. Dieser muss deaktiviert werden, um alle Funktionen dieser Website zu nutzen.<br><br>Bitte klicken Sie <a href="#" onclick="document.getElementById(\'seiteninhalt\').innerHTML=merk; popup(\''+mfile+'\',\''+name+'\',\''+gx+'\',\''+gy+'\',\''+px+'\',\''+py+'\',\''+options+'\'); return false;">hier</a>, um das gew&uuml;nschte Popup manuell zu &ouml;ffnen.</p><div>';
		}
	} else {
		try {
			spawn.resizeTo(gx, gy);
			spawn.moveTo(px, py);
			spawn.focus();
			return false;
		} catch (e) {
		}
	}
}
var merk = '';

function popupModal(pfad, name, gx, gy, px, py, options) {
	if (document.all && !navigator.userAgent.match(/opera/i)) {
		var ausgabe = showModalDialog(pfad, '' ,'resizable:no; scroll:no; center:no; dialogWidth:'+gx+'px; dialogHeight:'+gy+'px; dialogTop:'+py+'px; dialogLeft:'+px+'px; status:no;');
	} else {
		spawn = window.open(pfad, name, 'alwaysRaised=yes,dependent=yes, width=' + gx + ',height=' + gy + ',left=' + px + ',top=' + py + ((options != '') ? ',' + options : ''));
		// spawn.resizeTo(gx, gy);
		spawn.moveTo(px, py);
		spawn.focus();
	}
	return;
}

function confirmModal(pfad, name, gx, gy, px, py, options) {
	if (document.all && !navigator.userAgent.match(/opera/i)) {
		var ausgabe = showModalDialog(pfad, '' ,'resizable:no; scroll:no; center:no; dialogWidth:'+gx+'px; dialogHeight:'+gy+'px; dialogTop:'+py+'px; dialogLeft:'+px+'px; status:no;');
		if (ausgabe) {
			if (ausgabe=='ja') jaclick();
			else neinclick();
		}
	} else {
		spawn = window.open(pfad, name, 'alwaysRaised=yes,dependent=yes, width=' + gx + ',height=' + gy + ',left=' + px + ',top=' + py + ((options != '') ? ',' + options : ''));
		spawn.resizeTo(gx, gy);
		spawn.moveTo(px, py);
		spawn.focus();
	}
	return;
}
