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]);
}
function popup(aurl, awidth, aheight, aname)
{
	win = window.open(aurl, aname, 'width='+awidth+', height='+aheight +', status=yes,resizable=yes,menubar=no,locationbar=no,scrollbars=yes,dependent=yes,left=00,top=00');
	win.opener = self;
	win.focus();
	return;
}


function printpopup()
{
	popup(document.location.href + "&printit=1", 780,500,"PRINT")
	return
}


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="popup.js"></script>');
		    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('index.php?cSID='+ExtractID()+'&action=ShowPage&which=admin/editor_popup&param=minitemplate', 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=images/', 800, 600, 'FILEPOPUP');
}
function setLanguage(S)
{
	var ref = document.location.href
	if (ref.search('language') != -1)
	{
		ref = ref.replace("&language=en", "")
		ref = ref.replace("&language=de", "")
		ref = ref.replace("&language=fr", "")
	}
	if (ref.search('cSID') != -1)
	{document.location.href=ref+'&language='+S}
	else
	{document.location.href=ref+'?language='+S}
}


