function ExtractID()
{
	var url = document.location.href;
	var i = url.indexOf("?");
	var s = url.substring(i+1, url.length);
	var w = s.split("&");
	w = w[0].split("=");
	return(w[1]);
}
var popupwin
function closepopup()
{
	if (opener) opener.popupwin = null;
/*	if (popupwin) popupwin.close()	*/
}
function apopup(aurl, awidth, aheight, aname)
{
	closepopup()
	popupwin = window.open(aurl, aname, 'width='+awidth+', height='+aheight +', status=yes,resizable=yes,menubar=no,locationbar=no,scrollbars=yes,dependend=yes,left=00,top=00');
	popupwin.opener = self;
	popupwin.focus();
	return;
}
function confirmpopup(aurl)
{
	if (confirm("Eintrag löschen ?")) popup(aurl);
}
function popup(aurl, awidth, aheight, aname)
{
	if ((popupwin) && (aname == 'EDITDB')) { alert('Es ist bereits ein Eintrag offen ?\nBitte schliessen !');popupwin.focus();  return;}
//	if ((popupwin) && (aname == 'POPUPEDITOR')) { alert('Es ist bereits ein Editor offen ?\nBitte schliessen !'); popupwin.focus(); return;}
	if (!awidth) awidth=950
	if (!aheight) aheight=850
	aleft = Math.floor((screen.width - awidth) / 2)
	atop = Math.floor((screen.height - aheight) / 2) - 50
	param = 'width='+awidth+',height='+aheight +',status=no,resizable=yes,menubar=no,locationbar=no,scrollbars=yes,dependend=yes,left='+aleft+',top='+atop
	try
	{
		popupwin = window.open(aurl, aname, param);
		popupwin.opener = self;
		popupwin.focus();
	}
	catch (e) 
	{
		alert('Exception: ' + e);
	}
	return;
}
function popupfrage(aurl, awidth, aheight, aname)
{
	if ((popupwin) && (aname == 'EDITDB')) { popupwin.focus(); alert('Es ist bereits ein Editorfenster offen ?\nBitte schliessen !'); return;}
	if (!awidth) awidth=950
	if (!aheight) aheight=850
	aleft = Math.floor((screen.width - awidth) / 2)
	atop = Math.floor((screen.height - aheight) / 2) - 50
	param = 'width='+awidth+',height='+aheight +',status=no,resizable=yes,menubar=no,locationbar=no,scrollbars=yes,dependend=yes,left='+aleft+',top='+atop
	popupwin = window.open(aurl, aname, param);
	popupwin.opener = self;
	popupwin.focus();
	return;
}

function DoConfirm(MSG, aurl, awidth, aheight, aname)
{
	closepopup()
	check = confirm(MSG)
	if (check == false) return
	popupwin = window.open(aurl, aname, 'width='+awidth+', height='+aheight +', status=yes,resizable=yes,menubar=no,locationbar=no,scrollbars=yes,dependend=yes,left=00,top=00');
	popupwin.opener = self;
	popupwin.focus();
	return;
}

function popup1(aurl, awidth, aheight, aname)
{
	closepopup()
	popupwin = window.open(aurl, aname, 'width='+awidth+', height='+aheight +', status=yes,resizable=yes,menubar=yes,toolbar=yes,location=yes,scrollbars=yes,dependend=no,left=0,top=0');
	popupwin.opener = self;
	popupwin.focus();
	return;
}

function OpenerGoto(aurl)
{
	if (opener)
	{
		opener.document.location.href=aurl
		self.close()
	}
}
var	DebugWin;
function debug(was)
{
	if (!DebugWin)
	{
		if (window.opener == null)
		{
    		    DebugWin = window.open('', 'DEBUG', 'width='+ (screen.width-10) +',height=200,left=0,top=0,status=yes,resizable=yes,scrollbars=yes');
		    DebugWin.document.open();
		    DebugWin.document.writeln('<HTML>');
		    DebugWin.document.writeln('<HEAD>');
		    DebugWin.document.writeln('<TITLE>DEBUG</TITLE>');
		    DebugWin.document.writeln('<link rel="stylesheet" href="cont.css">');

		    DebugWin.document.writeln('<script language="JavaScript1.2" src="md5.js"></script>');
		    DebugWin.document.writeln('<META HTTP-EQUIV="Expires" CONTENT="0">');
		    DebugWin.document.writeln('<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">');

		    DebugWin.document.writeln('</HEAD><BODY bgcolor=#A5BBD1>');
		    DebugWin.document.writeln('</BODY></HTML>');
		    DebugWin.document.close();
		}
		else
		DebugWin = window.opener;
	}
	DebugWin.document.body.innerHTML = DebugWin.document.body.innerHTML + was;
}

function EditHtmlText(FELDNAME, FELDTYP)
{
	EDITORTEXT   = document.getElementById(FELDNAME)
	EDITORTEXT_A = document.getElementById(FELDNAME+'_'+FELDTYP)
	HTMLTOTEXT   = document.getElementById(FELDNAME+'_totext')
	if (FELDTYP == '') FELDTYP = 'INPUT'
	EDITORTYPE = FELDTYP
	EDITORTITLE = "Bearbeite Feld " + FELDNAME
	popup('htshow.php?which=htedit', 800, 600, 'POPUPEDITOR');
//	popup('index.php?cSID='+ExtractID()+'&action=ShowPage&which=admin/editor_popup&param=notemplate', 800, 600, 'POPUPEDITOR');
//	popup('index.php?action=ShowPage&which=admin/editor_popup&param=notemplate', 800, 600, 'POPUPEDITOR');
}

// Soll Dateinamen aus Workspace "files" zurueckliefern
function SetFileText(A)
{
	FILETEXT.value = A;	
}
function EditFileText(FELDNAME)
{
	FILETEXT   = document.getElementById(FELDNAME);
	SETFUNC = SetFileText;
	popup('file.php?cSID='+ExtractID()+'&dir=/', 800, 600, 'FILEPOPUP');
}

function DHTML_SetImage(A)
{
	RunCom("InsertImage", A);
}
function DHTML_GetImage()
{
	SETFUNC = DHTML_SetImage;
	popup('file.php?cSID='+ExtractID()+'&dir=/', 800, 600, 'FILEPOPUP');
}

function setdateiauswahl(id)
{
	alert(id);
}
function adateiauswahl(dir, id)
{
//	alert('Hier kommt Dateiauswahl hin');
	B = '';//<input type=button value=ok onclick=setdateiauswahl(\''+id+'\')>';
	T = new Transporter();
	W = null;//'ax_'+id;
	S = 'file.php?dir='+dir+'&id='+id;
	T.Start(S, W, -1, 
		null /* function() {document.images['progress'].src = 'images/progressbar.gif';} */ ,
		null /* function() {document.images['progress'].src = 'images/transparent.gif';} */ ,
		function(Result) {document.getElementById('ax_'+id).innerHTML = B + Result;}
	);

//	cmdto('ax_'+id, 'file.php');
//	alert(id);
//	document.getElementById(id).value = dir;
//	document.getElementById('ax_'+id).style.visibility = 'hidden';
}
