FCELL = null
FROW = null
FTABLE = null

dlg_Ok = 1
dlg_Cancel = 2
dlg_Reset = 3
dlg_Clear = 4

codeOk = 200;
codeErr = 500;

src_Fulltext = 0;
src_Column = 1;
src_Contains = 0;
src_HasToBegin = 2;
src_HasToEnd = 4;
src_Equal = 8;
src_Fragment = 0;
src_HoleWord = 16;

tw_Start = 0;
tw_Login = 1;
tw_Logout = 2;
tw_Modul = 3;

tw_Website = 10;
tw_Shop = 11;
tw_WebSite_Meta = 12;
tw_Shop_Meta = 13;
tw_Shop_Class = 14;

tw_WebSite_Meta_Vars = 12001;
tw_WebSite_Meta_Save = 12002;
tw_WebSite_Page_Save = 12003;
tw_WebSite_Search = 12004;
tw_WebSite_Cache = 12006;
tw_WebSite_MapNode = 12007;
tw_WebSite_ClearData = 12008;
tw_WebSite_NaviNames = 12009;
tw_WebSite_CopyIdxData = 12010;
tw_WebSite_EditPage = 12011;

tw_Shop_Class_Features = 14000;
tw_Shop_Class_Search = 14001;

tw_Xml_SetAttribute = 15000;
tw_Xml_CreateNode = 15001;

tw_File_DirsOfDir = 20000;
tw_File_FilesOfDir = 20001;
tw_File_Get = 20002;
tw_File_ImportDB = 20003;
tw_File_Upload = 20004;
tw_File_Delete = 20005;
tw_File_Rename = 20006;
tw_File_Transform = 20007;
tw_File_Download = 20008;
tw_File_SyncServer = 20009;

tw_Tree_Text = 20100;
tw_Tree_Insert = 20101;
tw_Tree_Delete = 20102;
tw_Tree_Paste = 20103;
tw_Tree_Move = 20104;
tw_Tree_Order = 20105;
tw_Tree_Update = 20106;
tw_Tree_ChangeId = 20107;
tw_Tree_Children = 20108;
tw_Tree_RootPath = 20109;

tw_Image_Scale = 20200;

tw_Sql_Backup = 20300;
tw_Sql_Restore = 20301;
tw_Sql_Update = 20302;
tw_Sql_SetTagStr = 20303;
tw_Sql_GetRecord = 20304;
tw_Sql_UpdateField = 20305;
tw_Sql_FieldNames = 20306;
tw_Sql_ReplaceFields = 20307;
tw_Sql_GetTagStr = 20308;
tw_Sql_SetTime = 20309;
tw_Sql_AsString = 20310;
tw_Sql_Run = 20311;
tw_Sql_Delete = 20312;
tw_Sql_LoadDataInfile = 20313;
tw_Sql_NextKey = 20314;
tw_Sql_SetRecord = 20315;

grNone = 0;
grAsXML = 1;
grXMLEncode = 2;
grXMLAttr = 4;
grXMLCData = 8;

grXMLHeader = 16;
grXMLProlog = 32;
grXMLEndTag = 64;
grXMLNoEndTag = 1024;

grNoZFields = 128;
grNoInfo = 256;
grNoHeader = 512;
grNoProlog = 2048;
grNoFrameTag = 4096;

oNone = 0;
oInc = 1;
oTPt = 2;
oDShow = 4;
oDShort = 8;
oDLong = 16;
oReadOnly = 32;
oFramed = 64;
oNoDelete = 128;
oNoChange = 256;
oNoInsert = 512;
oHidden = 1024;

foNone = 0;
foWholeWord = 1;
foSelectable = 2;
foSelected = 4;

oNoDelete = 1;
oNoRename = 2;
oNoHidden = 4;

optNone = 0;
optCancel = 1;
optOk = 2;

optPrint = 4;
optWindow = 4;

optLegend = 8;
optSql = 16;
optDel = 32;
optGroup = 64;
optEdit = 128;
optAdd = 256;
optUpdate = 512;
optGet = 1024;
optTable = 2048;
optCheck = 4096;
optOnlyGroup = 8192;
optDownload = 16384
optTest = 32768
optReferences = 65536
optFragment = 131072
optNoCheck = optFragment * 2
optSave = optNoCheck * 2
optSelect = optSave * 2
optBack = optSelect * 2
optForward = optBack * 2
optShow = optForward * 2
optHide = optShow * 2
optComplete = optHide * 2
optRoot = optComplete * 2
optUrl = optRoot * 2
optArticle = optUrl * 2

toCheckIst   = 1;
toCanHaveArt = 2;
toVKFixLikeVK = 4;
toGroupSplit = 8;
toMustHaveHnd = 16;

suBUTTON = 1;
suURL = 2;
suFILE = 3;
suARTREF = 4;
suSEARCH = 5;
suWK = 6;
suMERKER = 7;
suEDIT = 8;
suARTLST = 9;

tabNews = 'news';
tabNewsTemp = 'newstemp';
tabArtikel = 'artikel';
tabArtGruppen = 'artgruppen';
tabKunden = 'kunden';

xmlDefinitions = 'xml/definitions.xml';

cSysPath  = '../sys/';
cSysButPath  = cSysPath + 'sysbut/';
cSysFlagsPath  = cSysButPath + 'flags/';
cSysButtonPath  = cSysButPath + 'buttons/';
cImagePath  = cSysPath + 'media/graphic/';

cDayNames = ['So','Mo','Di','Mi','Do','Fr','Sa'];
cMonthNames = ['Jan','Feb','Mrz','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez'];
function cMonthDays (M, Y) {
	var a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
	a = a[M]
	if (M == 1 && (Y % 4) == 0 && ((Y % 100) != 0 || (Y % 400) == 0))
		a += 1
	return a
}
function UniqueID() {
	var T = new Date();
	var R = T.getTime();
	T = null;
	return R;
}
cForms = [];
cShop = [];
cShopObjectList = [];
cGlobalVar = [];
cSessionId = 0;
cSessionInfo = {id:-1, kd:-1, u:-1, p:'', un:'', ut:0};

cSearchStr = document.location.href.toUpperCase();
IsOnline = cSearchStr.indexOf('/') == 0 || cSearchStr.indexOf('HTTP') == 0;
cSearchStr = '';
cUnLoadSaveVar = '';
cIsReplace = false;
cShowBorders = 0;

cModalResult = 0;
cReset = 'RESET';
cSave = 'SAVE';
cUserIdStart = 8000;
cSplitter = '[@@]';

isMac = (navigator.appVersion.indexOf("Mac") != -1) ? true : false;
isNavM = (document.layers) ? true : false;
isNav = (!isNavM && navigator.userAgent.indexOf('Gecko') != -1) ? true : false;
isOpera = navigator.userAgent.toLowerCase().indexOf("opera") != -1;
isIE = (document.all) ? true : false;
isDOM = (document.getElementById) ? true : false;
isSafari = navigator.userAgent.toLowerCase().indexOf("safari") != -1 || navigator.userAgent.toLowerCase().indexOf("konqueror") != -1;

String.prototype.LPAD = function (s, L, c) {
	while (s && s.length < L)
		s = c + s;
	return s;
}
String.prototype.RPAD = function (s, L, c) {
	while (s && s.length < L)
		s = s + c;
	return s
}
function SKS_unescapeHTML (s) {
	var V = String(ChkStr(s));
	if (V != '') {
		var div = document.createElement('div');
		div.innerHTML = V.stripTags();
		V = div.childNodes[0] ? (div.childNodes.length > 1 ?
			$A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) :
			div.childNodes[0].nodeValue) : '';
	}
	return V;
}
function _als (s) {
	var r = '';
	var s = SKS_unescapeHTML(ChkStr(s));
	for (var i = 0; i < s.length; i++)
		if (s.charAt(i) == 'Ä') r += '%C4'; else
		if (s.charAt(i) == 'Ö') r += '%D6'; else
		if (s.charAt(i) == 'Ü') r += '%DC'; else
		if (s.charAt(i) == '%') r += '%E4'; else
		if (s.charAt(i) == 'ö') r += '%F6'; else
		if (s.charAt(i) == 'ü') r += '%FC'; else
		if (s.charAt(i) == 'ß') r += '%DF'; else
		if (s.charAt(i) == '€') r += '%20AC'; else
		if (s.charAt(i) == '$') r += '%24'; else
		if (s.charAt(i) == '%') r += '%25'; else
			r += s.charAt(i);
	return unescape(r);
}
function _scec (s) {
	return s.replace(/€/g,'&#8364;').replace(/»/g,'&#9679;');
}
function IsStr (s) {
	return (null == s || s == 'undefined' || typeof(s) == 'undefined') ? false : true;
}
function ChkStr (s) {
	return (IsStr(s)) ? s : '';
}
function IfStr (s1, s2, b) {
	return (b) ? s1 : s2;
}
function NoEvent () {
	if (window.event)
		return false;
}
function EnableSelection (B, E) {
	var e = E || document.body
	if (B)
		if (isIE)
			e.onselectstart = null
		else e.setAttribute('unselectable', '0', 0)
	else
		if (isIE)
			e.onselectstart = function () { return false }
		else e.setAttribute('unselectable', '1', 0)
}
if (IsOnline && hpSlashDomain == 1)
	hpDomain = '/';
hpCgi = hpDomain + hpCgi;
hpCgiProg = hpCgi + serverCOM;
hpSksProg = 'http://www.stefan-krauth-software.de/cgi-bin/' + serverCOM;
// ------------------------------
// Shop
// ------------------------------
function ShopRestoreHeight (Options) {
	if (window.name == 'SHOPFRAME') {
		if (window.DoPreloadImages)
			window.DoPreloadImages();
		if (ChkStr(document.title) != '')
			parent.document.title = ChkStr(document.title);
		e = window.parent.document.getElementById('SHOPFRAME');
		if (e && !hpFixShopFrame)
			e.style.height = document.body.scrollHeight + 'px';
		if (!BitsEnabled(Options, 2))
			window.parent.scrollTo(0, 0);
	}
}
// ------------------------------
// Allgemein
// ------------------------------
function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function SetCookie (name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}
function GoFocusA (F) {
	for (var i = 0; i < F.elements.length;  i++) {
		var E = F.elements[i];
		if (E.type.toUpperCase() != 'HIDDEN' && ChkStr(E.getAttribute('canfocus')) == '' && !E.disabled && !E.readOnly) {
			try {
				E.focus();
				E.select();
				return true;
			} catch(e) {
			}
		}
	}
	return false;
}
function GoFocus (F) {
	if (F)
		GoFocusA(F);
	else for (var i = 0; i < document.forms.length; i++)
		if (GoFocusA(document.forms[i]))
			return true;
	return false;
}
function decryptCharcode (n, start, end, offset) {
	n = n + offset;
	if (offset > 0 && n > end)	{
		n = start + (n - end - 1);
	} else if (offset < 0 && n < start)	{
		n = end - (start - n - 1);
	}
	return String.fromCharCode(n);
}
function decryptString (enc, offset) {
	var dec = "";
	var len = enc.length;
	for(var i=0; i < len; i++)	{
		var n = enc.charCodeAt(i);
		if (n >= 0x2B && n <= 0x3A)	{
			dec += decryptCharcode(n,0x2B,0x3A,offset);	// 0-9 . , - + / :
		} else if (n >= 0x40 && n <= 0x5A)	{
			dec += decryptCharcode(n,0x40,0x5A,offset);	// A-Z @
		} else if (n >= 0x61 && n <= 0x7A)	{
			dec += decryptCharcode(n,0x61,0x7A,offset);	// a-z
		} else {
			dec += enc.charAt(i);
		}
	}
	return dec;
}
function DoMailto (s) {
	document.location.href = decryptString(s, -1);
}
function AddBookmark () {
	if (document.all)
		window.external.AddFavorite(hpDomain, hpLogo);
	else alert('CTRL-D druecken um diese Seite zu den Lesezeichen hinzuzufuegen.');
}
function GetMethode (s) {
	var i = -1;
	while (s.indexOf('{', i + 1) != -1)
		i = s.indexOf('{', i + 1);
	if (i >= 0)
		return Trim(s.substring(i+1, s.indexOf('}',i+1)));
	return Trim(s);
}
function GetProperties (e) {
	var S = '<table>';
	for (var i in e)
		S += '<tr><td>' + i + '</td><td>' + e[i] + '</td></tr>';
	OpenWindowWrite('', '', 0, 0, 500, 500, 'scrollbars=yes', S + '</table>');
	return false;
}
function ShowTags (t, v) {
	var c = document.getElementsByTagName(t)
	if (c != null)
		for (var i = 0; i < c.length; i++)
			c[i].style.visibility = IfStr('visible', 'hidden', v)
}
function BitsEnabled (s, b) {
	return ((ToInt(s,0) & b) != 0)
}
function EnableBits (s, b, e) {
	var X = ToInt(s,0)
	X = (e) ? X |= b : X &= (~b)
	return X
}
function HideDocContextMenu () {
	if (window.DocContextMenu)
		DocContextMenu();
	window.event.returnValue = false;
}
function HideDocumentContextMenu (e) {
	if(isIE && (hpNoRightClick || e))
		document.oncontextmenu = HideDocContextMenu;
}
function SetRedirect (s) {
	return s.replace(/\&/g,'**')
}
// ------------------------------
// Stringfunktionen
// ------------------------------
function DToU (s) {
	return s.replace(/\\/g,'/')
}
function TrimLeft (s) {
	return s.replace(/^\s*/g,'')
}
function TrimRight (s) {
	return s.replace(/\s*$/g,'')
}
function Trim (s) {
	return TrimRight(TrimLeft(s))
}
function HtmlToText (s) {
	return SKS_unescapeHTML(String(ChkStr(s)).stripTags());
}
// ------------------------------
// Zahlen - Format
// ------------------------------
function ToNum (s, d) {
	var r = Number(s).toFixed(12);
	if (isNaN(r)) {
		var k = ChkStr(s).toString();
		if (k.length > 0 && (k.charAt(0) == '.' || k.charAt(0) == ','))
			k = '0' + k;
		var r = '';
		for (var i = 0; i < k.length; i++)
			if ((k.charAt(i) >= '0' && k.charAt(i) <= '9') || k.charAt(i) == '.' || k.charAt(i) == ',' || k.charAt(i) == '-')
				r += k.charAt(i);
			else
			if (r != '')
				break;
		if (r == '')
			return (d) ? d : 0;
		r = r.replace(/,/g,'.');
		if (r == '-' || r == '.')
			r = 0;
	}
	return r.toString();
}
function ToFloat (s, d) { return parseFloat(ToNum(s, d)) }
function ToInt (s, d) { return parseInt(ToNum(s, d)) }
function ToFmt (s, c) {
	var S = ToFloat(s, 0);
	S = Number(S).toFixed(c);
	if (c <= 0)
		return parseInt(S).toString();
	return S.toString();
}
function ToDecimal (s, c) { return parseFloat(ToFmt(s, c)) }
function ToCurrency (s) { return ToDecimal(s, 2) }
// ------------------------------
// Url
// ------------------------------
function DoSendMail (a) {
  var d = a.split('@')
  var l = d[0].split(''); l = l.reverse(); l = l.join('');
  var r = d[1].split(''); r = r.reverse(); r = r.join('');
  document.location.href = 'mailto:' + l + '@' + r
}
function DoDownload (a) {
  LPPO('TWINKLE', '', tw_File_Get, DoParams(['filename', 'personal'], [a, 1]))
}
function IsOnlineUrl (Url) {
  var s = Url.substr(0, 32).toLowerCase()
  return (s.indexOf('/') == 0 || s.indexOf('http:') == 0 || s.indexOf('https:') == 0 || s.indexOf('ftp:') == 0);
}
function IsReadyUrl (Url) {
  var s = Url.substr(0, 32).toLowerCase()
  return IsOnlineUrl(s) || (s.indexOf('javascript:') == 0 || s.indexOf('mailto:') == 0);
}
function DoParams (P, V, NoEsc) {
  var R = ''
  for (var i=0; i<P.length; i++)
    if (Trim(P[i]) != '')
      R += P[i] + '=' + ((NoEsc) ? V[i] : escape(V[i])) + '&'
  return R
}
function DoTwinkle (O, P, V, NoEsc) {
  return DoParams(['param','options'], ['TWINKLE',O], NoEsc) + DoParams(P, V, NoEsc)
}
function DoCGI (aParams) {
  var R = hpCgiProg + '?' + DoParams(['lang'], [ToInt(GetCookie('SESSIONLANG'), 0)]) + aParams
  if (document.location.protocol == 'https:')
    R = R.replace(/http:/i,'https:')
  return R
}
function DoSKSCGI (aParams) {
  return hpSksProg + '?' + DoParams(['lang'], [ToInt(GetCookie('SESSIONLANG'), 0)]) + aParams
}
function DoLPaCGI (aParam, aParams) {
  return DoCGI(DoParams(['param'], [aParam]) + aParams)
}
function DoPPO (aParam, aParameter, aOptions, aParams) {
  return DoLPaCGI(aParam, DoParams(['parameter', 'options'], [aParameter, aOptions]) + aParams)
}
function LPPO (aParam, aParameter, aOptions, aParams) {
  document.location.href = DoPPO(aParam, aParameter, aOptions, aParams)
}
function LoadAnswerPage (aTemplate, aParameter, aOptions, aParams, aDoc) {
  var P = (aDoc) ? aDoc : document
  P.location.href = DoPPO('ANSWERPAGE', aParameter, aOptions, DoParams(['template'], [aTemplate]) + aParams)
}
function LoadPageStr (aId, aHRef, aParams, aLang) {
  if (ToInt(aId,0) < 0 || aId == '' || !IsOnline)
    return aHRef
  var L = parseInt(aLang)
  if (L) {
    for (var i = 0; i < cLangIds.length; i++)
      if (cLangIds[i][0] == L) {
	SetCookie('SESSIONLANG', i)
	break
      }
  }
  var s = 'tid=' + aId
  if (aParams && aParams != '') s += '&' + aParams
  return DoLPaCGI('page', s)
}
function LoadPage (aId, aHRef, aParams, aDoc, aLang) {
  var s = LoadPageStr(aId, aHRef, aParams, aLang)
  var e = document.location
  if (aDoc && aDoc != '')
    e = aDoc.location
  if (top.cIsReplace)
    e.replace(s)
  else e.href = s
}
function MkUrl (u, s) {
  if (!IsReadyUrl(u)) {
    if (u.indexOf('../') != 0) u = '../' + u
    if (s) u += '?' + s
  }
  return u
}
function MkUrlRel (u) {
  if (u.indexOf(hpDomain) != -1) u = u.substr(hpDomain.length, u.length)
  if (u.indexOf('../') == 0) u = u.substr(3, u.length)
  return u
}
function OpenTag (t, tcl, tcr) {
  return IfStr(tcl, '<', IsStr(tcl)) + t + IfStr(tcr, '>', IsStr(tcr))
}
function CloseTag (t, tcl, tcr) {
  return IfStr(tcl, '<', IsStr(tcl)) + '/' + t + IfStr(tcr, '>', IsStr(tcr))
}
function MakeTag (t, s, tcl, tcr) {
  return OpenTag(t, tcl, tcr) + s + CloseTag(t, tcl, tcr)
}
function MakeTagE (t, s, tcl, tcr) {
  if (Trim(s)!='') return MakeTag(t,s,tcl,tcr)
  return ''
}
function MakeTagI (t, s, tcl, tcr) {
  if (ToInt(s,0)!=0) return MakeTag(t,s,tcl,tcr)
  return ''
}
function EdgeTag (t, s, tcl, tcr) {
  var p = t.toString()
  var a = []
  if (IsStr(s)) {
    a['L'] = s.search(new RegExp(OpenTag(p, tcl, tcr),'gi'))
    a['RI'] = s.search(new RegExp(CloseTag(p, tcl, tcr),'gi'))
    a['LI'] = a['L'] + p.length + 2
    a['R'] = a['RI'] + p.length + 3
    a['?'] = (a['RI'] >= 0 && a['RI'] >= a['LI'])
  }
  return a
}
function HasTag (t, s, tcl, tcr) {
  var a = EdgeTag(t, s, tcl, tcr)
  return a['?']
}
function GetTag (t, s, tcl, tcr) {
  var a = EdgeTag(t, s, tcl, tcr)
  return (a['?']) ? s.substring(a['LI'], a['RI']) : ''
}
function SetTag (s, t, d, nt, tcl, tcr) {
  d = d.toString()
  if (d != '' && (!nt || nt == 0))
    d = MakeTag(t, d, tcl, tcr)
  var a = EdgeTag(t, s, tcl, tcr)
  return (a['?']) ? s.substr(0, a['L']) + d + s.substr(a['R'], s.length) : s + d
}
function SetTagAll (s, t, d, nt, tcl, tcr) {
  while (HasTag(t, s, tcl, tcr))
    s = SetTag(s, t, d, nt, tcl, tcr)
  return s
}
function ClearNoPrintFrags (aHtml) {
  return SetTagAll(aHtml, 'NOPRINT', '')
}

function DocCommend () {
  OpenWindow(LoadPageStr('commendPageFor','',''),'',10,10,100,100,'scrollbars=no')
}
function DocPrint () {
  OpenWindow(LoadPageStr('sysPrintPage','',''),'',10,10,800,600,'scrollbars=yes,menubar=yes,resizable=yes')
}
function FitWindow (f) {
  if (!f) f = window
  var d = f.document.getElementById('DIALOGBODY')
  if (!d) return false
  if (f.innerHeight) {
    f.innerWidth = d.clientWidth
    f.innerHeight = d.clientHeight
  } else
    f.resizeTo(d.clientWidth + 10, d.clientHeight + 40)
}
function OpenWindow (aUrl, aName, aLeft, aTop, aWidth, aHeight, aParams) {
  if (aParams != '')
    aParams = ',' + aParams
  if (isNavM)
    var f = window.open(aUrl, aName, 'screenx='+aLeft+',screeny='+aTop+',width='+aWidth+',height='+aHeight + aParams)
  else var f = window.open(aUrl, aName, 'left='+aLeft+',top='+aTop+',width='+aWidth+',height='+aHeight + aParams)
  if (f != null) f.focus()
  if (aName != '') return f
}
function OpenWindowWrite (aUrl, aName, aLeft, aTop, aWidth, aHeight, aParams, aText, aTitle) {
	var f = OpenWindow(aUrl, IfStr('TEMPNAME', aName, aName == ''), aLeft, aTop, aWidth, aHeight, aParams)
	if (f != null) {
		f.document.open()
		f.document.write('<HTML><HEAD><TITLE>' + IfStr(aTitle, '', IsStr(aTitle))+ '</TITLE>'+
		     '<link rel=stylesheet type="text/css" href="../sys/styles.css">'+
		     '<script language="javascript" src="../js/init.txt" type="text/javascript"></script>'+
		     '<script language="javascript" src="../js/consts.js" type="text/javascript"></script>'+
		     '</HEAD><BODY>'+ aText + '</BODY>\n</HTML>')
		f.document.close()
	}
	if (aName != '')
		return f
}
function Waiter (e, Txt, NoWH) {
	var S = '<Table cellpadding="0" cellspacing="0" border="0"' + IfStr('', ' width="100%" height="100%"', NoWH) + '>' +
			'<tr>' +
				'<td align="center">' +
					ChkStr(Txt) +
					IfStr('', '<br /><br />', NoWH) +
					'<img src="../sys/sysbut/waiting.gif" border="0" />' +
				'</td>' +
			'</tr>' +
		'</Table>'
	if (e)
		e.innerHTML = S
	else return S
}
function Spacer (W, H) {
	return '<img src="' + cImagePath + 'dist.gif" width="' + W + '" height="' + H + '" border="0">'
}
function ImgMouse (e, s) {
	if (e && e.src.indexOf('_3.') < 0)
		e.src = e.src.replace(/_\d\./, '_' + IfStr('1', s.toString(), e.lowsrc == 'vis') + '.')
}
function LinkMouse (e, s) {
	if (e != null)
		e.className = e.className.replace(/ovr/, '') + IfStr('ovr', '', s > 0)
}
function LinkTable (e, s) {
	if (e) {
		var X = ToInt(e.getAttribute('rowopt', 0), 0)
		if (BitsEnabled(X, foSelectable))
			if (BitsEnabled(X, foSelected))
				e.setAttribute('rowcolor', '#FF9900', 0)
			else e.setAttribute('rowcolor', '', 0)
		if (s > 0) {
			if (!BitsEnabled(X, foSelected)) {
				e.setAttribute('rowcolor', e.style.backgroundColor,0)
				e.style.backgroundColor = '#DDDDDD'
			}
		} else {
			e.style.backgroundColor = e.getAttribute('rowcolor',0)
			e.removeAttribute('rowcolor',0)
		}
	}
}
function RollOver (e, s) {
  if (e != null)
    if (e.tagName == 'IMG') ImgMouse(e, s); else
    if (e.tagName == 'A') LinkMouse(e, s); else
    if (e.tagName == 'TR') LinkTable(e, s); else
    if (e.tagName == 'TD') LinkMouse(e, s);
}

function ImgStr (aImg, aBorder, Id, W, H, sH, sV, aStyle, aAlt, aEvents) {
  return '<img ' + IfStr('id=' + Id, '', (Id)) + ' src="' + aImg + '" border=' + aBorder +
         ' onMouseOver="RollOver(this,1)" onMouseOut="RollOver(this,0)"' +
         IfStr(' alt="' + aAlt + '"', '',(aAlt)) +
         IfStr(' width=' + W, '', (W && W > 0)) +
         IfStr(' height=' + H, '', (H && H > 0)) +
         IfStr(' hspace=' + sH, '', (sH && sH > 0)) +
         IfStr(' vspace=' + sV, '', (sV && sV > 0)) +
         IfStr(' style="' + aStyle + '"', '', (aStyle && aStyle != '')) +
         IfStr(' ' + aEvents, '', (aEvents && aEvents != '')) + '>'
}
function AStr (aId, aClass, aTitle, aText, aHRef, IsOnClick, aEvents) {
  return '<A id="' + aId + '" class="' + aClass + '" onMouseOver="RollOver(this,1)" onMouseOut="RollOver(this,0)" ' +
         'title="' + aTitle + '" href="' + IfStr('#" onClick="' + aHRef + ';return false;', aHRef, IsOnClick) + '" ' +
          aEvents + '>' + aText + '</A>'
}

function FindIdElement (t) {
	var W = self
	while (true) {
		var E = W.document.getElementById(t)
		if (E) return E
		if (W.parent == self)
			return null
		else W = W.parent
	}
}
function FindInheritedTagElement (e, t) {
	var T = t.toUpperCase()
	while (e != null && e.tagName) {
		var ET = e.tagName.toUpperCase()
		if (ET == T)
			return e
		e = (ET != 'BODY') ? e = e.parentNode : null
	}
	return null
}
function FindNodeValue (aDoc, aId) {
  var e = aDoc.getElementById(aId)
  while (e && e.firstChild)
    e = e.firstChild
  return e
}
function GetNodeValue (aDoc, aId) {
  var e = FindNodeValue(aDoc, aId)
  if (e && e.nodeValue)
    return e.nodeValue
  return ''
}
function SetNodeValue (aDoc, aId, aValue) {
  var e = FindNodeValue(aDoc, aId)
  if (e)
    if (e.nodeValue) e.nodeValue = aValue; else
    if (e.tagName != 'INPUT') e.innerHTML = aValue
}
// ------------------------------
// Formulare
// ------------------------------
function GetFromChecks (f, n) {
  var R = 0
  var i = 0
  while (f.elements[n + i]) {
    if (f.elements[n + i].checked)
      R += Math.pow(2, i)
    i++
  }
  return R
}
function SetToChecks (o, f, n) {
  var i = 0
  while (f.elements[n + i]) {
    f.elements[n + i].checked = BitsEnabled(o, Math.pow(2, i))
    i++
  }
}
function CheckAutoFiller (aAuto, aData) {
  var Ln = []
  var L = aAuto.split('<BR>')
  for (var i=0; i<L.length; i++) {
    var p = L[i].split(';')
    var Lx = []
    for (var j=0; j<p.length; j++) {
      var N=p[j].toString()
      if (N!='' && N.charAt(0)=='*') {
        B = true
        N=N.substr(1,N.length)
      } else { B = false }
      var n = aData[N.toUpperCase()]
      if (n)
        n=ChkStr(n)
      else if (B)
        n=' '
      else n=N
      Lx[Lx.length]=n
    }
    Ln[Ln.length] = Lx.join('')
  }
  return Ln.join('\n')
}
function ArrayToForm (aForm, aData, aCh, aOpt) {
  if (aForm && aForm.elements && aData)
    for (var i = 0; i < aForm.elements.length; i++) {
      var e = aForm.elements[i]
      var gso = ToInt(e.getAttribute('gso',0),0)
      var u = ToInt(e.getAttribute('use',0),0)
      if (u!=1) {
        var n = ChkStr(e.name).toUpperCase()
        if (n == '') n = ChkStr(e.id).toUpperCase()
		var p = n.indexOf('_')
		if (p > 0) {
			var Pf = n.substr(0, p)
			if (Pf == 'EMAIL' || Pf == 'DATE' || Pf == 'INT' || Pf == 'PINT' || Pf == 'FLOAT' || Pf == 'E' || Pf == 'LEN')
				n = n.substr(p + 1, n.length)
		}
		if (aCh && aCh != '') n = n.substr(aCh.length, n.length)
	var t = e.type.toUpperCase()
	if (t!='HIDDEN'||!BitsEnabled(ToInt(aOpt,0),oNoHidden)) {
	  var d = ChkStr(aData[n])
	  if (t.indexOf('SELECT') != -1)
	    if (BitsEnabled(gso, 1))
	      SELECTsetvaluesel(e, d)
	    else SELECTsettextsel(e, d)
	  else
		if (t.indexOf('CHECKBOX') != -1) { if (d == e.value) e.checked = true } else
		if (t.indexOf('RADIO') != -1) { if (d == e.value) e.checked = true } else
		{
            if (d == '' || u==2 || u==4) {
              p = ChkStr(e.getAttribute('concat',0))
              if (p != '') d = CheckAutoFiller(p, aData)
              p = ChkStr(e.getAttribute('ifempty',0))
              if (p != '') d = CheckAutoFiller(p, aData)
            }
            e.value = d
          }
        }
      }
    }
}
function FormToArray (aForm, aCh) {
  var r = []
  if (aForm && aForm.elements)
    for (var i = 0; i < aForm.elements.length; i++) {
      var e = aForm.elements[i]
      var gso = ToInt(e.getAttribute('gso',0),0)
      var u = ToInt(e.getAttribute('use',0),0)
      if (u==0) {
	var n = ChkStr(e.name).toUpperCase()
        if (n == '') n = ChkStr(e.id).toUpperCase()
		var p = n.indexOf('_')
		if (p > 0) {
			var Pf = n.substr(0, p)
			if (Pf == 'EMAIL' || Pf == 'DATE' || Pf == 'INT' || Pf == 'PINT' || Pf == 'FLOAT' || Pf == 'E' || Pf == 'LEN')
				n = n.substr(p + 1, n.length)
		}
		if (aCh && aCh != '') n = n.substr(aCh.length, n.length)
		var t = e.type.toUpperCase()
		if (t.indexOf('SELECT') != -1)
		  if (BitsEnabled(gso, 1))
			r[n] = SELECTvalue(e)
		  else r[n] = SELECTtext(e)
		else
		if (t.indexOf('CHECKBOX') != -1) { r[n] = (e.checked) ? e.value : '' } else
		if (t.indexOf('RADIO') != -1) { if (e.checked) r[n] = e.value } else
		  r[n] = e.value
	  }
	}
  return r
}
function PageForms (aDoc, opt) {
  for (var i = 0; i < aDoc.forms.length; i++)
    if (IsStr(aDoc.forms[i].name))
      if (opt == 0)
        top.cForms[aDoc.forms[i].name] = FormToArray(aDoc.forms[i])
      else if (top.cForms[aDoc.forms[i].name])
        ArrayToForm(aDoc.forms[i], top.cForms[aDoc.forms[i].name])
}
function PageFormsSend () {
  var s = ''
  var d = ''
  for (var i in top.cForms)
    if (i.indexOf('INTERN') != 0) {
      s += i + ';'
      d += MakeTag(i, ArrayToTags(top.cForms[i]))
    }
  return MakeTag('FORMPARTS', s.substr(0, s.length - 1)) + d
}
function ArrayToTags (a, noEmpty, asXML) {
  var r = ''
  for (var i in a)
    if (typeof(a[i]) != 'function' && (!noEmpty || ChkStr(a[i]) != ''))
      r += MakeTag(i, ChkStr(a[i]))
  return r
}
function TagsToArray (a, chkE) {
  var r = []
  var i = 0
  do {
    i = a.indexOf('<', i)
    if (i != -1) {
      i++
      var j = a.indexOf('>', i)
      if (j >= i) {
	var t = a.substring(i, j).toUpperCase()
	var k = t.indexOf('/')
	if (k < 0) {
	  var s = ChkStr(GetTag(t, a))
	  i += s.length + (t.length * 2) + 4
	} else {
	  var t = Trim(t.substr(0, k))
	  var s = ''
	  i = j + 1
	}
	if (chkE) s = IfStr(s, ' ', s != '')
	r[t] = s
      }
    }
  } while (i >= 0 && i < a.length)
  return r
}
function FormSendA (aDoc, aFormId, aParam, aTarget) {
  var S = eval('window.BEFORESEND')
  var e = aDoc.forms[aFormId]
  if (e && (!S || S(e))) {
    var c = null
    var p = ''
    var a = new Array('scriptname','sendenan','parameter','template','subject','options')
    var j = a.length
    if (ToInt(aTarget, 0) == aTarget) {
      j -= ToInt(aTarget)
      aTarget = ''
    }
    for (var i = 0; i < j; i++) {
      c = e.elements[a[i]]
      if (c != null) {
	p = GetNodeValue(aDoc, 'I' + a[i].toUpperCase())
	c.value = (p != '') ? p : c.value
      }
    }
    c = e.elements[a[0]]
    if (c != null) p = (c.value == 'AUTO') ? hpCgiProg : c.value
    var t = ChkStr(aTarget)
	if (t == '' && !BitsEnabled(aParam, optWindow) && hpNoFrames == 0 && top.frames['CONTENT'])
	  t = 'CONTENT'
	return FormSend(e, aParam, IfStr(hpCgiProg, p, c == null), t, 'multipart/form-data')
  }
  return false
}
function AJAX_AdrToForm (Form, Prefix, Field) {
	var F = document.forms[Form]
	if (CheckFormularBeforeTransmit(F, Prefix + Field)) {
		new Ajax.Request(hpCgiProg, {
			parameters: DoTwinkle(tw_Sql_GetRecord, ['tablename', 'conditions', 'tag'],
				[tabKunden, Field + ' LIKE "' + F.elements[Prefix + Field].value + '"', 1]),
			onSuccess: function (data) {
				var P = GetTag('NODE', XMLText(XMLRoot(data)))
				if (P == '')
					SKS_InfoShow('Für die [ ' + Field + ' ] = [ ' + F.elements[Prefix + Field].value + ' ] existieren keine Daten!')
				else ArrayToForm(F, TagsToArray(P))
			},
			onFailure: function(data) {
				SKS_InfoShow('Fehler bei Ausführung der Anforderung!')
			}
		});
	}
	return false;
}
// ------------------------------
// ZAHLEN
// ------------------------------
function Pt1000On (aValue, aDec, aParams) {
  aValue=ToFmt(aValue,aDec)
  if (!BitsEnabled(aParams,oTPt)) return aValue
  var A=aValue.split('.');var S='';var K=0;
  for (var i=A[0].length-1;i>=0;i--){S=A[0].charAt(i)+S;K++;if(A[0].charAt(i-1)!='-'&&K<A[0].length&&K%3==0)S='.'+S}
  return S+IfStr(','+A[1],'',A[1])
}
function Pt1000Off (aValue, aDec, aParams) {
  aValue=ChkStr(aValue).toString()
  if (!BitsEnabled(aParams,oTPt)||(aValue.indexOf(',')==-1&&aDec>0)) return aValue
  return ToFmt(aValue.replace(/\./g,''),aDec).replace(/\./,',')
}
function SCIInRename (F,O,Oa,N) {
  var A = (F.elements[O])?O:Oa
  F.elements[A].name=N
//  F.elements[N].id=N
}
function SCIInGet (e) {
  var P = ToInt(e.getAttribute('Params',false),0)
  var D = ToInt(e.getAttribute('Decimals',false),0)
  return ToFloat(Pt1000Off(e.value,D,P),0)
}
function SCIInSet (e, v) {
  var P = ToInt(e.getAttribute('Params',false),0)
  var D = ToInt(e.getAttribute('Decimals',false),0)
  e.value = Pt1000On(v,D,P)
}
function SCIInFocus (e) {
  e.value = Pt1000Off(e.value, ToInt(e.getAttribute('Decimals',false),0), ToInt(e.getAttribute('Params',false),0))
  e.select()
  return true
}
function SCIInBlur (e,i,ChkStart) {
  var P = ToInt(e.getAttribute('Params',false),0)
  var L = ToFloat(e.getAttribute('MinValue',false),0)
  var R = ToFloat(e.getAttribute('MaxValue',false),0)
  var D = ToInt(e.getAttribute('Decimals',false),0)
  var v = ToFloat(Pt1000Off(e.value,D, P))
  var w = ToFloat(e.getAttribute('StartWith',false),0)
  if (v == 0 && ChkStart && w != 0)
    v = w
  else v += ToFloat(i,0)
  if(R != 0) v = Math.min(v,R)
  if(L != 0 || R != 0) v = Math.max(v,L)
  e.value = Pt1000On(v,D,P)
  L = eval('window.BLURELEMENT')
  if (L) L(e,v,D,P)
}
var SCIInElement = null
var SCIInInc = 0
var SCIInTimer = 0
function SCIInMouseDown (e,i) {
  SCIInElement = e
  SCIInInc = i
  SCIInTimerStart(SCIInElement, SCIInInc)
}
function SCIInMouseUp () {
  SCIInElement = null
  SCIInInc = 0
  clearTimeout(SCIInTimer)
  SCIInTimer = 0
}
function SCIInTimerRun (e,i) {
  SCIInBlur(document.getElementById(e.getAttribute('Field', false)), i, true)
  SCIInTimer = setTimeout("SCIInTimerStart()", IfStr(500, 100, SCIInTimer == 0))
}
function SCIInTimerStart () {
  if (SCIInElement && SCIInInc != 0)
    SCIInTimerRun(SCIInElement, SCIInInc)
}
function SCIIn (aName, aMin, aMax, aValue, aParams, aClass, L, T, W, H, Align, aSize, aDec, aInc, aStart) {
  var C = ChkStr(aClass)
  var X = ToInt((ToInt(W,0) - ToInt(IfStr(15,0,BitsEnabled(aParams,oInc)),0)),0)
  var S = IfStr('POSITION:absolute;LEFT:'+L+'px;TOP:'+T+'px;','',L!=0&&T!=0)+
          IfStr('WIDTH:'+X+'px;','',W!=0)+IfStr('HEIGHT:'+H+'px;','',H!=0)+
          IfStr('float:left;','',L==0||T==0)
  S = '<input class="'+IfStr(C,'number',C!='')+'" type="TEXT" id="'+aName+'" name="'+aName+'" Params="'+aParams+'" '+
     'Decimals="'+aDec+'" MinValue="'+aMin+'" MaxValue="'+aMax+'" Value="'+Pt1000On(aValue,aDec,aParams)+'" size="'+
     aSize+'" onFocus="return SCIInFocus(this)" onBlur="SCIInBlur(this,0)" style="'+S+IfStr('border:1px solid #000000;','',
     BitsEnabled(aParams,oFramed))+IfStr('border-right:0px','',BitsEnabled(aParams,oFramed) &&
     BitsEnabled(aParams,oInc))+'" Align="'+IfStr(Align,'L', Align)+'"'+IfStr(' readonly','',aName=="" ||
     BitsEnabled(aParams,oReadOnly))+IfStr(' StartWith="'+ToFloat(aStart,0)+'"','',aStart)+'>'
  if (BitsEnabled(aParams,oInc)) {
    var P = IfStr('POSITION:absolute;LEFT:'+(ToInt(L,0)+X)+'px;TOP:'+T+'px;','',L!=0&&T!=0)
    S += '<table cellpadding="0" cellspacing="0" border="0" style="FLOAT:left; HEIGHT:'+H+'px;'+P+
            IfStr('border:1px solid #000000;','',BitsEnabled(aParams,oFramed))+IfStr('border-left:0px','',
            BitsEnabled(aParams,oFramed))+'">'+
	  '<tr><td><IMG src="../sys/sysbut/arrowsmallu_0.gif" style="cursor:pointer" Field="'+aName+'" '+
        'onMouseDown="SCIInMouseDown(this,'+aInc+')" onMouseUp="SCIInMouseUp()" onMouseOut="SCIInMouseUp()"></td></tr>'+
      '<tr><td><IMG src="../sys/sysbut/arrowsmalld_0.gif" style="cursor:pointer" Field="'+aName+'" '+
        'onMouseDown="SCIInMouseDown(this,-'+aInc+')" onMouseUp="SCIInMouseUp()" onMouseOut="SCIInMouseUp()"></td></tr>'+
      '</table>'
  }
  return S
}

/// DATUM

function DateDigit (d) {
  return (d < 10) ? '0' + d : d
}
function DateToStr (d,o) {
  return IfStr('', DateDigit(d.getDate()) + '.', BitsEnabled(o,oDShort)) +
         DateDigit(d.getMonth() + 1) + '.' + d.getFullYear()
}
function TimeToStr (d) {
  return DateDigit(d.getHours()) + ':' + DateDigit(d.getMinutes()) + ':' + DateDigit(d.getSeconds())
}
function DateToSQLStr (d) {
  return d.getFullYear() + '.' + DateDigit(d.getMonth() + 1) + '.' + DateDigit(d.getDate()) + ' ' + TimeToStr(d)
}
function DateToBDEStr (d) {
  return DateDigit(d.getDate()) + '.' + DateDigit(d.getMonth() + 1) + '.' + d.getFullYear() + ' ' + TimeToStr(d)
}
function StrToDate (d) {
  if (ChkStr(d)=='') return new Date()
  var A = ['','','','','','']
  var B = [0,0,0,0,0,0]
  var j = 0
  for (var i = 0; i < d.length; i++)
    if (d.charAt(i) >= '0' && d.charAt(i) <= '9')
      A[j] += d.charAt(i)
    else j++
  for (var i = 0; i < 3; i++) B[i] = Math.max(1, ToInt(A[i], 0))
  for (var i = 3; i < 6; i++) B[i] = ToInt(A[i], 0)
  if (B[0] > 50)
    return new Date(Math.max(1900, B[0]), B[1] - 1, B[2], B[3], B[4], B[5])
  return new Date(Math.max(1900, B[2]), B[1] - 1, B[0], B[3], B[4], B[5])
}
function FmtDate (d,o) {return DateToStr(StrToDate(d),o)}
function ChkDate (e,o) {
  var L = ChkStr(e.getAttribute('MinValue',false))
  var R = ChkStr(e.getAttribute('MaxValue',false))
  var D = DateToStr(StrToDate(IfStr('01.','',BitsEnabled(o,oDShort)) + e.value))
  if ((L==''||StrToDate(D).getTime()>=StrToDate(L).getTime())&&(R==''||StrToDate(D).getTime()<=StrToDate(R).getTime()))
    e.value = FmtDate(D,o)
  else {
    alert('Datum muss zwischen [ '+L+' ] und [ '+R+' ] liegen!')
    e.focus()
  }
}
function ShowDate (e) {
  document.getElementById(e.getAttribute('Field', false))
}
function SCIDate (aName, aMin, aMax, aValue, aParams, aClass, L, T, W, H, Align) {
  var C = ChkStr(aClass)
  var X = ToInt((ToInt(W,0) - ToInt(IfStr(15,0,BitsEnabled(aParams,oDShort)),0)),0)
  var S = IfStr('POSITION:absolute;LEFT:'+L+'px;TOP:'+T+'px;','',L!=0&&T!=0)+
	  IfStr('WIDTH:'+X+'px;','',W!=0)+IfStr('HEIGHT:'+H+'px;','',H!=0)
  S = '<input class="'+IfStr(C,'dates',C!='')+'" type="TEXT" id="'+aName+'" name="'+aName+'" Params="'+aParams+'" '+
    'MinValue="'+aMin+'" MaxValue="'+aMax+'" Value="'+FmtDate(aValue,aParams)+'" size="'+
	IfStr('7','10',BitsEnabled(aParams,oDShort))+'" '+IfStr('readonly','',BitsEnabled(aParams,oDShow))+' '+
	'onBlur="ChkDate(this,'+aParams+')" style="'+S+IfStr('border:1px solid #000000;','',
	BitsEnabled(aParams,oFramed))+'" Align="'+IfStr(Align,'L',Align)+'"'+
	IfStr(' readonly','',aName==""||BitsEnabled(aParams,oReadOnly))+'>'
  if (BitsEnabled(aParams,oDShow))
	S += '<table cellpadding="0" cellspacing="3" border="0" style="POSITION:absolute;LEFT:'+(ToInt(L,0)+X)+'px;'+
	  'TOP:'+(ToInt(T,0)-2)+'px;HEIGHT:'+H+'px;">'+
	  '<tr><td><IMG width="7" src="../sys/sysbut/arrowsmalld_0.gif" style="cursor:pointer" Field="'+aName+'" '+
	  'onClick="ShowDate(this)"></td></tr></table>'
  return S
}
////////////////////////////////////////////////////////////////////////////////////
function FormSend (F, aParam, aScript, aTarget, aEncoding) {
	var R = true
	if (aParam == optNone)
		F.reset()
	else {
		for (var i = 0; i < F.elements.length; i++) {
			var e = F.elements[i]
			if (e.className == 'dates' || e.className == 'number') {
				e.setAttribute('old', e.value, 0)
				if (e.className == 'dates')
					e.value = DateToSQLStr(StrToDate(e.value))
				else if (e.className == 'number') {
					var P = SCIInGet(e)
					e.value = (P == 0) ? '' : P
				}
			}
		}
		if (BitsEnabled(aParam, optNoCheck) || CheckFormularBeforeTransmit(F)) {
			F.method = 'POST'
			F.action = aScript
			if (BitsEnabled(aParam, optWindow)) {
				var a = aTarget.split(';')
				OpenWindow('../sys/dynamic.htm', 'XYZ', ToInt(a[0],10), ToInt(a[1],10), ToInt(a[2],500), ToInt(a[3],500), '')
				F.target = 'XYZ'
			} else
			if (ChkStr(aTarget) != '')
				F.target = aTarget
			if (aEncoding != '')
				F.encoding = aEncoding
			F.submit()
		} else {
			R = false
			for (var i = 0; i < F.elements.length; i++) {
				var e = F.elements[i]
				if (e.className == 'dates' || e.className == 'number')
					e.value = e.getAttribute('old', 0)
			}
		}
	}
	return R
}
// ------------------------------
// flickern hervorheben
// ------------------------------
feFE = null;
feCnt = 0;
feOpt = 0;
feTO = 0;
feSaveBG = '';

feElem = 1;
feBg = 2;

function XfeFE () {
	feCnt = feCnt - 1;
	if (BitsEnabled(feOpt, feElem))
		feFE.toggle();
	else if (BitsEnabled(feOpt, feBg))
		if (feCnt % 2 > 0)
			feFE.style.backgroundColor = feSaveBG;
		else feFE.style.backgroundColor = '#DDDDDD';
	if (feCnt > 0)
		window.setTimeout('XfeFE()', feTO)
	else {
		if (BitsEnabled(feOpt, feElem))
			feFE.show();
		else if (BitsEnabled(feOpt, feBg)) {
			feFE.style.backgroundColor = feSaveBG;
			feSaveBG = '';
		}
	}
}
function FlickerTag (FE, Cnt, TO, Opt) {
	feFE = FE;
	feCnt = Cnt;
	feTO = TO;
	feOpt = Opt;
	feSaveBG = ChkStr(feFE.style.backgroundColor);
	XfeFE();
}

var CFT = '';
var CFE = '';
var CFC = 0;

function CheckFlicker () {
	(CFC % 2 > 0) ? CFE.addClassName('inerr') : CFE.removeClassName('inerr');
	if (CFC > 1) {
		CFC--;
		window.setTimeout("CheckFlicker()", 40)
	}
}
function _BlurInErr (event) {
	var E = Event.element(event)
	E.stopObserving('blur', _BlurInErr);
	E.removeClassName('inerr');
}
function FlickerElement (E, Title, Info, Msg, TOut) {
	try {
		CFE = ChkStr($(E).readAttribute('bounded'));
		CFE = (CFE == '') ? E : $(CFE);
		CFE = $(CFE);
		CFC = 10;
		var T = ChkStr(CFE.readAttribute('title')) || ChkStr(Title);
		var I = ChkStr(CFE.readAttribute('info')) || ChkStr(Info);
		var M = ChkStr(CFE.readAttribute('msg')) || ChkStr(Msg);
		if (M == '')
			M = 'Bitte einen korrekten Wert engeben!';
		SKS_InfoShow(M.replace(/:title:/g, T).replace(/:info:/g, I),
			Math.max(ToInt(CFE.readAttribute('tout') || ChkStr(TOut), 0), 1) * 1000, iwNoClose);
		try {
			CFE.activate()
			CFE.observe('blur', _BlurInErr)
		} catch(e) {
		}
		CheckFlicker();
	} catch(e) {
	}
}
function CheckFormularBeforeTransmit (aForm, aField) {
	for (var i = 0; i < aForm.elements.length; i++) {
		var e = aForm.elements[i]
		var n = ChkStr(e.name)
		if (n == '')
			n = ChkStr(e.id)
		var v = e.value

		var F = true;
		if (n.indexOf('FUNC_') == 0)
			F = eval('F' + n + '("' + v + '")');

		if (!IsStr(aField) || aField == n) {
			if (	!F ||
				( n.indexOf('EMAIL_') == 0 && !v.match(/^[\w+\.?\-\_]*\w+@\w+[\.?\w+\-\_]*.\w{2,}$/) ) ||
				( n.indexOf('DATE_') == 0 && !ValidDate(v) ) ||
				( n.indexOf('TIME_') == 0 && !ValidTime(v) ) ||
				( n.indexOf('INT_') == 0 && !ValidInt(v) ) ||
				( n.indexOf('PINT_') == 0 && (!ValidInt(v) || ToInt(v, 0) <= 0) ) ||
				( n.indexOf('FLOAT_') == 0 && !ValidFloat(v) ) ||
				( n.indexOf('PFLOAT_') == 0 && (!ValidFloat(v) || ToFloat(v, 0) <= 0) ) ||
				( n.indexOf('E_') == 0 && !v.match(/.+/) )
			) {
				FlickerElement(e);
				return false;
			}
		}
	}
	return true;
}
function ValidDate (d) {
	d = Trim(ChkStr(d))
	if (d.match(/^\d{2}\.\d{2}\.\d{4}$/)) {
		var a = d.split('.')
	for (var i=0; i<a.length; i++)
		a[i] = ToInt(a[i], 0)
	if (a[0] > 0 && a[1] > 0 && a[2] > 0 && a[1] <= 12 && a[0] <= cMonthDays(a[1] - 1, a[2]))
		return true
	}
	return false
}
function ValidTime (d) {
	d = Trim(ChkStr(d))
	if (d.match(/^\d{2}:\d{2}:\d{2}$/)) {
		var a = d.split(':')
		for (var i=0; i<a.length; i++)
			a[i] = ToInt(a[i], -1)
		if (a[0] >= 0 && a[0] < 24 && a[1] >= 0 && a[1] < 60 && a[2] >= 0 && a[2] < 60)
			return true
	}
	return false
}
function ValidDateTime (d) {
	d = Trim(ChkStr(d));
	return (d.length == 19 && ValidDate(d.substr(0, 10)) && ValidTime(d.substr(11, 8)))
}
function ValidInt (d) {
	d = Trim(ChkStr(d));
	return d.match(/^\d+$/)
}
function ValidFloat (d) {
	d = Trim(ChkStr(d));
	return ValidInt(d) || d.match(/^\d*[\.,]\d*$/)
}
// ------------------------------
// Menu
// ------------------------------
var activeButton = null
var activeDoc = null
var activeWin = null

function buttonClick (event, menuId, InitAlways) {
  if (!activeDoc) {
    activeDoc = document
    activeWin = activeDoc.parentWindow
  }
  var button = (isIE) ? activeWin.event.srcElement : event.currentTarget
  if (button.menu == null) {
    button.menu = activeDoc.getElementById(menuId)
    if (button.menu != null && (InitAlways || button.menu.isInitialized == null))
      menuInit(button.menu)
    else return false
  }
  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout
  if (button == activeButton)
    return false
  if (activeButton != null)
    resetButton(activeButton)
  if (button != activeButton) {
    depressButton(button)
    activeButton = button
  } else activeButton = null
  return false
}
// -------------------------------------------------------------
function HideForMenuEx (D, s) {
  var L = D.getElementsByTagName('SELECT')
  for (var i = 0; i < L.length; i++)
    if (s == 'hidden' && L[i].style.visibility != s) {
	  L[i].setAttribute('mks', 1, 0)
      L[i].style.visibility = s
    } else
    if (s == 'visible' && L[i].getAttribute('mks', 0))
      L[i].style.visibility = s
}
function HideForMenu (s) {
  HideForMenuEx(document, s)
  if (document.frames)
    for (var i = 0; i < document.frames.length; i++)
      HideForMenuEx(document.frames[i].document, s)
}
// -------------------------------------------------------------
function OpenPopupMenu(event, menuId, InitAlways) {
//  HideForMenu('hidden')
  if (activeButton == null) {
    buttonClick(event, menuId, InitAlways)
    return
  }
  var button = (isIE) ? activeWin.event.srcElement : event.currentTarget
  if (activeButton != null && activeButton != button)
    buttonClick(event, menuId, InitAlways)
}
function OpenPopupMenuEx(event, P, InitAlways) {
  activeDoc = P.ownerDocument
  activeWin = activeDoc.parentWindow

  OpenPopupMenu(event, P.id, InitAlways)
// -------------------------------------------------------------
  var x = event.clientX
  var y = event.clientY
  var maxX, maxY
  if (isNav) {
    maxX = window.scrollX + window.innerWidth
    maxY = window.scrollY + window.innerHeight
  }
  if (isIE) {
    var E = activeDoc.documentElement
    var B = activeDoc.body
    maxX = Math.max(E.scrollLeft, B.scrollLeft) + (E.clientWidth != 0 ? E.clientWidth : B.clientWidth)
    maxY = Math.max(E.scrollTop, B.scrollTop) + (E.clientHeight != 0 ? E.clientHeight : B.clientHeight)
  }
  maxX -= P.offsetWidth
  maxY -= P.offsetHeight
  if (x > maxX)
    x = Math.max(0, x - P.offsetWidth + 2)
  else x = x - 2
  y = Math.max(0, Math.min(y, maxY) - 2)
  P.style.left = x + 'px'
  P.style.top = y + 'px'
// -------------------------------------------------------------
}
function ClosePopupMenu(event) {
//  HideForMenu('visible')
  buttonOrMenuMouseout(event)
}
function ClosePopupMenuEx () {
//  HideForMenu('visible')
  if (activeButton != null) {
    resetButton(activeButton)
    activeButton = null
  }
}
function depressButton(button) {
  var x, y
  button.className += " menuButtonActive"
  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout
  if (button.menu.onmouseout == null)
    button.menu.onmouseout = buttonOrMenuMouseout
  x = AbsLeft(button)
  y = AbsTop(button) + button.offsetHeight
  if (isIE && button.offsetParent) {
    x += button.offsetParent.clientLeft
    y += button.offsetParent.clientTop
  }
  button.menu.style.left = x + "px"
  button.menu.style.top  = y + "px"
  button.menu.style.zIndex = 1000
  button.menu.style.visibility = "visible"
}
function resetButton(button) {
  removeClassName(button, "menuButtonActive")
  if (button.menu != null) {
    closeSubMenu(button.menu)
    button.menu.style.visibility = "hidden"
    button.menu.style.left = -1000
  }
}
function InitPopupMenu(event) {
  var menu = (isIE) ? getContainerWith(activeWin.event.srcElement, "DIV", "menu") : event.currentTarget
  if (menu.activeItem != null)
    closeSubMenu(menu)
}
function ExpandPopupMenu(event, menuId) {
  var x, y
  var item = (isIE) ? getContainerWith(activeWin.event.srcElement, "A", "menuItem") : event.currentTarget
  var menu = getContainerWith(item, "DIV", "menu")
  if (menu.activeItem != null)
    closeSubMenu(menu)
  menu.activeItem = item
  item.className += " menuItemHighlight"
  if (item.subMenu == null) {
    item.subMenu = activeDoc.getElementById(menuId)
    if (item.subMenu.isInitialized == null)
      menuInit(item.subMenu)
  }
  if (item.subMenu.onmouseout == null)
    item.subMenu.onmouseout = buttonOrMenuMouseout
  x = AbsLeft(item) + item.offsetWidth
  y = AbsTop(item)
  var maxX, maxY
  if (isNav) {
    maxX = window.scrollX + window.innerWidth
    maxY = window.scrollY + window.innerHeight
  }
  if (isIE) {
    maxX = Math.max(activeDoc.documentElement.scrollLeft, activeDoc.body.scrollLeft) + (activeDoc.documentElement.clientWidth != 0 ? activeDoc.documentElement.clientWidth : activeDoc.body.clientWidth)
    maxY = Math.max(activeDoc.documentElement.scrollTop, activeDoc.body.scrollTop) + (activeDoc.documentElement.clientHeight != 0 ? activeDoc.documentElement.clientHeight : activeDoc.body.clientHeight)
  }
  maxX -= item.subMenu.offsetWidth
  maxY -= item.subMenu.offsetHeight
  if (x > maxX)
    x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth + (menu.offsetWidth - item.offsetWidth))
  y = Math.max(0, Math.min(y, maxY))

  item.subMenu.style.left = x + "px"
  item.subMenu.style.top  = y + "px"
  item.subMenu.style.visibility = "visible"
  item.subMenu.style.zIndex = 1000

  if (isIE)
    activeWin.event.cancelBubble = true
  else event.stopPropagation()
}
function closeSubMenu(menu) {
	if (menu == null || menu.activeItem == null)
		return
	if (menu.activeItem.subMenu != null) {
		closeSubMenu(menu.activeItem.subMenu)
		menu.activeItem.subMenu.style.visibility = 'hidden'
		menu.activeItem.subMenu.style.left = -1000
		menu.activeItem.subMenu = null
	}
	removeClassName(menu.activeItem, "menuItemHighlight")
	menu.activeItem = null
}
function buttonOrMenuMouseout(event) {
  if (activeButton == null) return
  var e = (isIE) ? activeWin.event.toElement : event.relatedTarget
  if (!isIE && e && !e.tagName) e = e.parentNode
  if (e && getContainerWith(e, "DIV", "menu") == null) {
    resetButton(activeButton)
    activeButton = null
//    HideForMenu('visible')
  }
}
function menuInit(menu) {
  var L = menu.getElementsByTagName("A")
  if (L.length > 0)
    var w = L[0].offsetWidth
  else return
  for (var i = 0; i < L.length; i++) {
    var sL = L[i].getElementsByTagName("SPAN")
    var tw = null
    var aw = null
    for (var j = 0; j < sL.length; j++) {
      if (hasClassName(sL[j], "menuItemText"))
	tw = sL[j]
      if (hasClassName(sL[j], "menuItemArrow"))
	aw = sL[j]
    }
    if (tw != null && aw != null && tw.style && tw.style.paddingRight && tw.offsetWidth && aw.offsetWidth)
      tw.style.paddingRight = (w - (tw.offsetWidth + aw.offsetWidth)) + "px"
  }
  if (isIE) {
    w = L[0].offsetWidth
    L[0].style.width = w + "px"
    var dw = L[0].offsetWidth - w
    w -= dw
    L[0].style.width = w + "px"
  }
  menu.isInitialized = true
}
function getContainerWith(node, tagName, className) {
  while (node != null) {
    if (node.tagName != null && node.tagName == tagName && hasClassName(node, className))
      return node
    node = node.parentNode
  }
  return node
}
function hasClassName(e, name) {
  var i, list
  list = e.className.split(" ")
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true
  return false
}
function removeClassName(e, name) {
  var i, curList, newList
  if (e.className == null)
    return
  newList = new Array()
  curList = e.className.split(" ")
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name) {
      newList[newList.length] = curList[i]
    }
  e.className = newList.join(" ")
}
function AbsLeft (e) { return $(e).cumulativeOffset()[0] }
function AbsTop (e) { return $(e).cumulativeOffset()[1] }
function SKS_ChkWin (d) {
	if (isIE)
		return (d) ? d.document : document;
	return (d) ? d : window;
}
function SKS_BodyScrollLeft (d) { return (isIE) ? SKS_ChkWin(d).body.scrollLeft : SKS_ChkWin(d).scrollX }
function SKS_BodyScrollTop (d) { return (isIE) ? SKS_ChkWin(d).body.scrollTop : SKS_ChkWin(d).scrollY }
function SKS_BodyWidth (d) { return (isIE) ? SKS_ChkWin(d).body.clientWidth : SKS_ChkWin(d).innerWidth }
function SKS_BodyHeight (d) { return (isIE) ? SKS_ChkWin(d).body.clientHeight : SKS_ChkWin(d).innerHeight }

function SKS_EventOffsetX (event) { if (!event) return 0; return (isIE) ? event.offsetX : event.clientX - AbsLeft(event.currentTarget) }
function SKS_EventOffsetY (event) { if (!event) return 0; return (isIE) ? event.offsetY : event.clientY - AbsTop(event.currentTarget) }
function SKS_EventTarget (event) { return (isIE) ? event.toElement : event.relatedTarget }

function CalcInnerViewLeftTop (P, AddOffs, x, y, d) {
  P.style.left = Math.max(SKS_BodyScrollLeft(d) + AddOffs, Math.min(x, (SKS_BodyScrollLeft(d) + SKS_BodyWidth(d)) - AddOffs - $(P).getWidth())) + 'px'
  P.style.top = Math.max(SKS_BodyScrollTop(d) + AddOffs, Math.min(y, (SKS_BodyScrollTop(d) + SKS_BodyHeight(d)) - AddOffs - $(P).getHeight())) + 'px'
}
// ------------------------------
// Tree.Menu
// ------------------------------
function ExpandTreeMenu(sId, dId) {
  var s = document.getElementById(sId)
  var d = document.getElementById(dId)
  if (d != null) {
    if (d.innerHTML != '')
      d.innerHTML = ''
    else if (s != null)
      d.innerHTML = s.innerHTML
  }
}
// ------------------------------
// Tree
// ------------------------------
toNone = 0
toExpand = 1
toCollapse = 2
toSwapExpand = 3
toFocused = 4
toSelected = 5

toIconClick = 1
toImageClick = 2
toTextClick = 3
toCheckClick = 4

toIcons = 1
toImages = 2
toIndent = 4
toChecks = 8
toWordBreak = 16
toAutoExpand = 32
toCheckDn = 64
toOnlyEnabled = 128
toEffect = 256
toCheckPoints = 512


toChild = 1

toExpandAttr = 'EXP_'
toSelectAttr = 'SEL_'
toCheckAttr = 'CHK_'

function TTree (aId, aOptions, aLevelDist, aVertDist) {
	this.Id = aId
	this.Options = aOptions
	this.DivStyle = ''
	this.Levels = -1
	this.LevelDist = aLevelDist
	this.VertDist = aVertDist
	this.Style = ['tree','treefoc','treesel','treeitm0','treeitm1','treeitm2']
	this.Icons = []
	this.Width = 0
	this.Order = ''
	this.Clip = null
	this.CopyNode = null
	this.CopyType = ''
	this.Popup = null
	this.Focused = null
	this.XObj = null
	this.XDoc = null
	this.XRoot = null

	this.TableName = ''
	this.OnLinkForChildren = null
	this.WithParam = ''
	this.FoundList = null
	this.FoundIndex = 0

	this.ClickElement = null
	this.ClickPart = 0

	this.OnSetFocus = null
	this.OnClick = null
	this.OnClicking = null
	this.OnDblClick = null
	this.OnMove = null
	this.OnDisplayText = null
}
TTree.prototype.Wait = function (W) {
	if (!this.ClickElement)
		return
	with (this.ClickElement) {
		var i = innerHTML.indexOf('waiting.gif')
		if (W && i < 0)
			innerHTML = '<img src="../sys/sysbut/waiting.gif" height="13" border="0"> - ' + innerHTML
		else if (!W && i >= 0)
			innerHTML = innerHTML.substr(innerHTML.indexOf('> - ') + 4, innerHTML.length)
	}
}
TTree.prototype.Container = function () {
	return document.getElementById(this.Id + '_CONTAINER')
}
TTree.prototype.Scroller = function () {
	var S = this.Container();
	return (S.parentElement) ? S.parentElement : S.parentNode;
}
TTree.prototype.ScrollIntoView = function (Id) {
	var E = document.getElementById(this.Id + 'T' + Id)
	if (E) {
		E.scrollIntoView(true)
		this.Scroller().scrollLeft = 0
	}
}
TTree.prototype.UpdateTree = function (Node, Id) {
	if (Node) this.ReloadChildren(Node)
	this.SetFocus(null, Id, true)
}
TTree.prototype.UpdateFocused = function (Id) {
	if (this.Focused) {
		this.ReloadChildren(this.Focused)
                if (ToInt(Id, 0) > 0)
			this.SetFocus(null, ToInt(Id, 0), true)
		else this.SetFocus(null, this.FocusId(), true)
	}
}
TTree.prototype.FocusId = function () {
	return XMLGetAttr(this.Focused, 'TID')
}
TTree.prototype.FocusText = function () {
	return XMLGetAttr(this.Focused, 'TTEXT')
}
TTree.prototype.Expand = function (Node, Exp) {
	if (Node)
		if (Node == this.XRoot)
			this.Container().innerHTML = this.Draw(this.XRoot)
		else {
			var E = Exp
			if (E == toSwapExpand)
				E = (XMLGetAttr(Node, toExpandAttr) == toExpand) ? toCollapse : toExpand
			var P = Node.parentNode
			if (P != this.XRoot && E == toExpand && XMLGetAttr(P, toExpandAttr) != E)
				this.Expand(P, E)
			XMLSetAttr(Node, [toExpandAttr], [E])
			var ID = XMLGetAttr(Node, 'TID')
			P = $(this.Id + 'E' + ID)
			if (P) {
				if (E == toExpand) {
					P.innerHTML = this.Draw(Node)
					if (BitsEnabled(this.Options, toEffect))
						Effect.BlindDown(P.id, {duration:0.4})
				} else { P.innerHTML = '' }
			}
			P = $(this.Id + 'B' + ID)
			if (P)
				P.src = (E == toExpand) ? P.src.replace(/close/,'open') : P.src.replace(/open/,'close')
		}
}
TTree.prototype.EnableChildren = function (Id) {
	if (Id > 0) {
		var Node = this.XRoot.selectSingleNode('//NODE[@TID = "' + Id + '"]')
		if (!Node && this.TableName != '') {
			var Path = AjaxGet(DoTwinkle(tw_Tree_RootPath,
				['tablename', 'conditions', 'tag'], [this.TableName, 'tid=' +
				Id, grAsXML + grXMLAttr]), optRoot).selectNodes('NODE')
			Node = this.XRoot
			for (var i = 0; i < Path.length; i++) {
				var Id = XMLGetAttr(Path[i], 'TID')
				var N = Node.selectSingleNode('NODE[@TID="' + Id + '"]')
				if (!N)
					N = this.GetChildren(XMLClear(Node)).selectSingleNode('NODE[@TID="' + Id + '"]')
				Node = N
			}
		}
		return Node
	}
	return null
}
TTree.prototype.SetFocus = function (Node, Id, Fnull) {
	if (!Node && ToInt(Id, -1) > 0)
		Node = this.EnableChildren(Id)
	if (Node) {
		if (Node != this.Focused || Fnull) {
			this.SetStyle(this.Focused, toNone)
			if (this.Focused && BitsEnabled(this.Options, toAutoExpand)) {
				var P = this.Focused
				while (P != Node.parentNode && P != this.XRoot) {
					this.Expand(P, toCollapse)
					P = P.parentNode
				}
			}
			this.Focused = Node
			this.Expand(Node, toExpand)
			this.SetStyle(Node, toFocused)
//			this.ScrollIntoView(Id)
			if (this.OnSetFocus)
				this.OnSetFocus(XMLGetAttr(Node, 'TID'), Node)
		} else
		if (BitsEnabled(this.Options, toAutoExpand)) {
			if (BitsEnabled(this.Options, toEffect))
				Effect.BlindDown($(this.Id + 'E' + this.FocusId()), {duration:0.4})
			this.Expand(this.Focused, toCollapse)
		}
	}
}
TTree.prototype.ReloadChildren = function (Node) {
	this.Expand(this.GetChildren(XMLClear((Node && Node.parentNode) ? Node.parentNode : this.XRoot)), toExpand)
}
TTree.prototype.LinkForChildren = function (Parent) {
	if (this.OnLinkForChildren)
		var S = this.OnLinkForChildren(Parent)
	else var S = DoCGI(DoTwinkle(tw_Tree_Children, ['tablename', 'tparent', 'spezopt', 'tag', 'fields', 'order'],
		[this.TableName, ToInt(XMLGetAttr(Parent, 'TID'), 0), this.Options, grAsXML + grXMLAttr,
			'tid,tparent,ttext', this.Order]))
	if (this.WithParam != '') {
		S += DoParams(['data'], [this.WithParam])
        	this.WithParam = ''
	}
        return S
}
TTree.prototype.GetChildren = function (Parent) {
	if (Parent && this.TableName != '' && !Parent.selectSingleNode('NODE')) {
		var List = AjaxGet(this.LinkForChildren(Parent), optRoot).selectNodes('NODE')
		for (var i = 0; i < List.length; i++)
			this.AddChild(Parent, List[i])
	}
	return Parent
}
TTree.prototype.FindChildren = function (FindFirst, SearchColumns, SearchValues) {
	if (FindFirst) {
		this.FoundIndex = 0
		if (this.TableName != '') {
			this.WithParam = MakeTag('LIKEFIELDS', SearchColumns.join(';'))
			for (var i = 0; i < SearchColumns.length; i++)
				this.WithParam += MakeTag(SearchColumns[i].toUpperCase(), ChkStr(SearchValues[i]))
			this.FoundList = AjaxGet(this.LinkForChildren(null), optRoot).selectNodes('NODE')
		} else
			this.FoundList = this.XRoot.selectNodes('//NODE[contains(@TID,"' +
				ChkStr(SearchValues[0]) + '") or contains(@TTEXT,"' + ChkStr(SearchValues[0]) + '")]')
	}
	if (this.FoundIndex >= 0 && this.FoundIndex < this.FoundList.length) {
		this.UpdateTree(null, XMLGetAttr(this.FoundList[this.FoundIndex], 'TID'))
		this.FoundIndex++
	}
}
TTree.prototype.SetAutomaticId = function (Node) {
	var Node = (Node) ? Node : this.Focused
	if (this.TableName != '')
		var Id = XMLGetText(AjaxGet(DoTwinkle(tw_Tree_ChangeId, ['tablename', 'tid', 'data'],
			[this.TableName, XMLGetAttr(Node, 'TID'), 0]), optRoot))
	else {
		var Id = 10000
		while (this.XRoot.selectSingleNode('//NODE[@TID=' + Id + ']'))
			Id++
		XMLSetAttr(Node, ['TID'], [Id])
	}
	this.UpdateTree(null, Id)
}
TTree.prototype.SetManuellId = function (Node) {
	var Node = (Node) ? Node : this.Focused
	var OldId = XMLGetAttr(Node, 'TID')
	var Id = ToInt(StdModalResult('dialog_1value_input.htm', EncDlgStr([OldId, 'ID']), ''), 0)
	if (Id > 0) {
		if (this.TableName != '')
			Id = XMLGetText(AjaxGet(DoTwinkle(tw_Tree_ChangeId, ['tablename',
				'tid', 'data'], [this.TableName, OldId, Id]), optRoot))
		else if (Id > 0 && !this.XRoot.selectSingleNode('//NODE[@TID=' + Id + ']'))
			XMLSetAttr(Node, ['TID'], [Id])
		this.UpdateTree(Node.parentNode, Id)
	}
}
TTree.prototype.OpenChildren = function (Id) {
	this.UpdateTree(null, ToInt((Id) ? Id : StdModalResult('dialog_1value_input.htm', EncDlgStr(['', 'Gehe zu Knoten-Id...']), ''), 0))
}
TTree.prototype.CopyChildren = function (Node) {
	this.CopyNode = (Node) ? Node : this.Focused
	this.CopyType = 'COPY'
}
TTree.prototype.PasteChildren = function (Node) {
	var Parent = (Node) ? Node : this.Focused
	if (this.CopyNode && Parent && Parent != this.XRoot && Parent != this.CopyNode && this.CopyType == 'COPY') {
		var Id = XMLGetAttr(Parent, 'TID')
		if (this.TableName != '') {
			Id = ToInt(XMLGetText(AjaxGet(DoTwinkle(tw_Tree_Paste, ['tablename', 'tid', 'tparent'],
				[this.TableName, XMLGetAttr(this.CopyNode, 'TID'), Id]), optRoot)), 0)
			this.UpdateTree(Parent, Id)
		} else {
			Id = this.AddChild(Parent, this.CopyNode.cloneNode(true)).parentNode.getElementsByTagName('NODE')
			for (var i = 0; i < Id.length; i++)
				this.SetAutomaticId(Id[i])
	                this.Expand(Parent, toExpand)
		}
		this.CopyNode = null
		this.CopyType = ''
	}
}
TTree.prototype.MoveChildren = function (Node, Parent, Options) {
	var Ok = true
	if (this.TableName != '')
		Ok = XMLGetText(AjaxGet(DoTwinkle(tw_Tree_Move, ['tablename', 'tid', 'tparent',
			'tag', 'order'], [this.TableName, XMLGetAttr(Node, 'TID'), XMLGetAttr(Parent, 'TID'), Options,
			'torder']), optRoot))
	if (Ok) {
		var NodeParent = Node.parentNode
		if (BitsEnabled(Options, toChild))
			var NewParent = Parent.appendChild(Node)
		else var NewParent = Parent.parentNode.insertBefore(Node, Parent)
		if (Parent.parentNode != NodeParent)
			this.Expand(NodeParent, toExpand)
		this.Expand(Parent.parentNode, toExpand)
		this.SetFocus(NewParent, 0, true)
	}
}
TTree.prototype.DeleteChildren = function (Node) {
	if (Node) {
		var Ok = true
		if (this.TableName != '')
			Ok = XMLGetText(AjaxGet(DoTwinkle(tw_Tree_Delete, ['tablename', 'tid'],
				[this.TableName, XMLGetAttr(Node, 'TID')]), optRoot))
		if (Ok) {
			var P = Node.parentNode
			XMLRemove(Node)
			this.SetFocus(P, 0, true)
		}
		return this.Focused
	}
}
TTree.prototype.Prior = function (Node) {
	if (Node && Node.previousSibling)
		return Node.previousSibling
	return Node.parentNode
}






////////////////////////////




// Nur Übergang
TTree.prototype.Delete = function (e) {
  return this.DeleteChildren(e)
}
// Ende Nur Übergang

TTree.prototype.ExtractId = function (s) {
  return s.substr(this.Id.length + 1, s.length)
}
TTree.prototype.SetXObj = function (D) {
  this.XObj = D
  this.SetRoot(this.XObj)

  if (!IsOnline)
    this.TableName = ''
}
TTree.prototype.SetRoot = function (D, R) {
  this.XDoc = XMLDoc(D)
  this.XRoot = (R) ? R : XMLRoot(this.XDoc)
  XMLSetAttr(this.XRoot, [toExpandAttr], [toExpand])
}
TTree.prototype.SetStyle = function (N, Exp) {
  if (N) {
    P = document.getElementById(this.Id + 'T' + XMLGetAttr(N, 'TID'))
    if (P) {
      P.className = this.GetStyle(N)
      if (Exp == toFocused)
        if (ChkStr(this.Style[1]) == '')
          P.className += 'vis'
        else P.className = this.Style[1]
      else
      if (Exp == toSelected)
        if (ChkStr(this.Style[2]) == '')
          P.className += 'visovr'
        else P.className = this.Style[2]
    }
  }
}
TTree.prototype.GetStyle = function (N) {
  var S = this.Style[3]
  if (N) {
    var l = XMLLevel(N)
    if ((l + 3) >= this.Style.length)
      S = this.Style[this.Style.length - 1]
    else S = this.Style[l + 3]
  }
  return S
}
TTree.prototype.MainParentOf = function (N) {
  while (N && N.parentNode != this.XRoot)
    N = N.parentNode
  return N
}
TTree.prototype.NodePathOf = function (N) {
  var P = ';'
  while (N && N.parentNode != this.XRoot) {
    P += XMLGetAttr(N, 'TID') + ';'
    N = N.parentNode
  }
  return P
}
TTree.prototype.NodeInPathOf = function (N, R) {
  var P = this.NodePathOf(R)
  while (N && N.parentNode != this.XRoot) {
    if (P.indexOf(';' + XMLGetAttr(N, 'TID') + ';') >= 0)
      return true
    N = N.parentNode
  }
  return false
}
TTree.prototype.SetSelect = function (N) {
  XMLSetAttr(N, [toSelectAttr], [IfStr(toSelected, toNone, XMLGetAttr(N, toSelectAttr) != toSelected)])
  this.SetStyle(N, XMLGetAttr(N, toSelectAttr))
}
TTree.prototype.InitFocus = function (Id) {
	this.SetFocus(null, Id, true)
	this.NodeClickXML(this.Focused, toTextClick)
}
TTree.prototype.Redraw = function (N) {
  this.SetFocus(null,0,true)
  this.FullExpand(N.parentNode, toCollapse)
  this.SetFocus(N,0,true)
}
TTree.prototype.CreateChild = function (N, Id, Txt, Opt) {
  var P = null
  if (N) {
    var P = N.ownerDocument.createElement('NODE')
    XMLSetAttr(P, ['TID', 'TTEXT', 'OPTIONS'], [Id, Txt, Opt])
  }
  return P
}
TTree.prototype.AddChild = function (Node, Parent) {
	return XMLImportNode(Node, Parent, true)
}
TTree.prototype.InsChild = function (Node, Parent) {
	return Node.parentNode.insertBefore(Parent, Node)
}
TTree.prototype.NewChild = function (Node, Parent, AsChild) {
	return (AsChild) ? this.AddChild(Node, Parent) : this.InsChild(Node, Parent)
}

TTree.prototype.FullExpand = function (N, Exp) {
  this.Expand(N, Exp)
  if (Exp == toExpand)
    for (var i = 0; i < N.childNodes.length; i++)
      this.FullExpand(N.childNodes[i], Exp)
}
TTree.prototype.Checked = function (N, C, R) {
  if (N) {
    var P = document.getElementById(this.Id + 'X' + XMLGetAttr(N, 'TID'))
    if (P) P.checked = C
    XMLSetAttr(N, [toCheckAttr], [IfStr(toSelected, toNone, C)])
    if (BitsEnabled(this.Options, toCheckDn)) {
      P = XMLFindChild(N,'NODE',[],[])
      while (P) {
        this.Checked(P, C)
        P = P.nextSibling
      }
    }
    if (R)
      while (N && N.parentNode != this.XRoot) {
        N = N.parentNode
        this.Checked(N, C, R)
      }
  }
}
TTree.prototype.NodeClick = function (Event, f) {
	return this.NodeClickEx((isIE) ? Event.srcElement : Event.currentTarget, f)
}
TTree.prototype.NodeClickEx = function (Element, f) {

	if (this.OnClicking)
		this.OnClicking(this.ClickElement, this.FocusId, this.Focused, this.ClickPart)

	this.ClickElement = null
	this.ClickPart = f

	if (Element) {
		this.ClickElement = Element
		if (this.ClickPart == toTextClick)
			this.ClickElement = FindInheritedTagElement(this.ClickElement, 'A')
		var N = this.ClickElement.id.substr(this.Id.length + 1, this.ClickElement.id.length)
		N = this.XRoot.selectSingleNode('//NODE[@TID = ' + N + ']')
		if (N) {
			this.GetChildren(N)
			if (this.ClickPart == toIconClick)
				this.Expand(N, toSwapExpand)
			else if (this.ClickPart == toImageClick)
				this.SetSelect(N)
			else {
				if (this.ClickPart == toTextClick)
					this.SetFocus(N)
				else if (this.ClickPart == toCheckClick)
					this.Checked(N, this.ClickElement.checked)
				if (this.OnClick)
					this.OnClick(this.ClickElement, this.FocusId(), N, this.ClickPart)
			}
		}
		return this.Focused
	}
}
TTree.prototype.NodeClickId = function (Id, f) {
	return this.NodeClickEx(document.getElementById(this.Id + 'T' + Id), IfStr(f, toTextClick, f))
}
TTree.prototype.NodeClickXML = function (Node, f) {
	return this.NodeClickId(XMLGetAttr(Node, 'TID'), f)
}
TTree.prototype.NodeDblClick = function (e, f) {
	e.cancelBubble = true;
	var P = (isIE) ? e.srcElement : e.currentTarget
	if (f == toTextClick) P = FindInheritedTagElement(P, 'A')
	var I = P.id.substr(this.Id.length + 1, P.id.length)
	var N = XMLFindChild(this.XRoot, 'NODE', ['TID'], [I], true)
	if (N) {
/*
		if (this.Clip) {
			this.Clip = this.Clip.parentNode.removeChild(this.Clip)
			N = N.appendChild(this.Clip)
			this.Clip = null
		} else
			this.Clip = N
*/
		if (this.OnDblClick) this.OnDblClick(P, I, N, f)
	}
	return false
}
TTree.prototype.DragStart = function (Event) {
	this.Clip = Event.srcElement.id
}
TTree.prototype.DragEnd = function (Event) {
	var Node = document.elementFromPoint(Event.x, Event.y)
	if (Node) {
		var Parent = this.XRoot.selectSingleNode('//NODE[@TID = "' + this.ExtractId(Node.id) + '"]')
		var Node = this.XRoot.selectSingleNode('//NODE[@TID = "' + this.ExtractId(this.Clip) + '"]')
		if (Node && Parent && Node != Parent)
			this.MoveChildren(Node, Parent, (Event.ctrlKey) ? 1 : 0)
	}
}
TTree.prototype.FirstDraw = function (e) {
	var P = document.getElementById(e)
	if (P) {
		if (this.DivStyle != '')
			P.style.cssText = this.DivStyle
		this.Width = ToInt(P.style.width,0)
	}
	var S = '<span id="' + this.Id + '_CONTAINER" ' +
			'ondragstart="' + this.Id + '.DragStart(event)" ' +
			'ondragend="' + this.Id + '.DragEnd(event)" ' +
			'ondragenter="NoEvent()" ' +
			'ondragover="NoEvent()">' +
			this.Draw(this.XRoot) +
		'</span>'
	if (P)
		P.innerHTML = S
	else return S
}
TTree.prototype.Draw = function (Node) {
	if (!Node) return ''
	var S = '<table border="0" cellpadding="0" cellspacing="0">'
	L = Node.selectNodes('NODE')
	for (var i = 0; i < L.length; i++) {
		XMLSetAttr(L[i], [toExpandAttr, toSelectAttr], [toCollapse, toNone])
		var POpt = ToInt(XMLGetAttr(L[i], 'OPTIONS'), 0)
                if (IsOnline && POpt != 0)
                  continue;
		var PId = XMLGetAttr(L[i], 'TID')
		var PLevel = XMLLevel(L[i])
		var PText = (this.OnDisplayText) ? this.OnDisplayText(this, PId, PLevel, L[i]) : XMLGetAttr(L[i], 'TTEXT')
		var PTitle = (this.OnDisplayText) ? '' : PText
		S += '<tr>'
		if (BitsEnabled(this.Options, toIcons))
			S += '<td valign="top" ' + IfStr('', 'style="background-image:url(../sys/media/tree/tree_verticalline.gif)"', !L[i].nextSibling) + '>' + ImgStr('../sys/media/tree/tree_' + IfStr('last', '', !L[i].nextSibling) + 'node_' + IfStr('close', 'empty', ToInt(XMLGetAttr(L[i], 'CHILDCOUNT'),0) > 0 || L[i].selectSingleNode('NODE')) + '.gif', 0, this.Id + 'B' + PId, 0, 0, 0, 0, '', '', 'onClick="' + this.Id + '.NodeClick(event, toIconClick);return false;"') + '</td>'
		else if (BitsEnabled(this.Options, toIndent) && PLevel > 0)
			S += '<td>' + ImgStr('../sys/media/graphic/dist.gif', 0, '', this.LevelDist, 1, 0, 0, '', '', '') + '</td>'
		if (BitsEnabled(this.Options, toChecks))
			S += '<td valign="top"><INPUT id="' + this.Id + 'X' + PId + '" onClick="' + this.Id + '.NodeClick(event, toCheckClick)" type="checkbox"' + IfStr('checked', '', XMLGetAttr(L[i], toCheckAttr) == toSelected) + '></td>'
		if (BitsEnabled(this.Options, toImages)) {
			var I = XMLGetAttr(L[i], 'ICON')
			I = ((I == '') ? 'ticonstandard' : I) + '_0.gif'
			S += '<td valign=top>' + ImgStr('../sys/media/tree/' + I, 0, this.Id + 'C' + PId, 0, 0, 1, 0, '', '', 'onClick="' + this.Id + '.NodeClick(event, toImageClick)"') + '</td>'
		}
		var I = ''
		if (!isIE && this.Width > 0 && BitsEnabled(this.Options, toIndent))
			I = '" style="width:' + (this.Width - PLevel * this.LevelDist) + 'px;overflow:hidden;'
		I = AStr(this.Id + 'T' + PId, this.GetStyle(L[i]) + I, PTitle, PText, this.Id + '.NodeClick(event, toTextClick);return false;', true, 'onDblClick="return ' + this.Id + '.NodeDblClick(event, toTextClick)"')
		if (!BitsEnabled(this.Options, toWordBreak))
			I = MakeTag('nobr', I)
		S += '<td valign="top" class="dlgtext1" style="padding-bottom:' + this.VertDist + 'px;">' + I + '<span id="' + this.Id + 'E' + PId + '"></span></td></tr>'
	}
	return S + '</table>'
}
// ------------------------------
// TWINKLE
// ------------------------------
dlgTagList = 'A;B;BLOCKQUOTE;BODY;CODE;DIV;DL;DD;DT;EM;FORM;H1;H2;H3;H4;H5;H6;HR;I;INPUT;LI;OL;P;PRE;SMALL;SPAN;STRONG;TABLE;TD;TEXTAREA;TH;TR;UL'

function ModalResult (aUrl, aArgs, aParam) {
	return ChkStr(window.showModalDialog(aUrl, aArgs, 'edge:Raised;center:yes;help:no;resizable:no;status:no;' + IfStr('scroll:no;',aParam,aParam=='')))
}
function StdModalResult (aUrl, aArgs, aParam) {
	return ModalResult(IfStr(hpDomain, '../', IsOnline) + 'twinkle/' + aUrl, aArgs, aParam)
//  return ModalResult(hpDomain + 'twinkle/' + aUrl, aArgs, aParam)
}
function Download (aParams) {
	return StdModalResult('dialog_download.htm', DoCGI(aParams), '')
}
function MRReset (s) { return (s == cReset) }
function MROk (s) { return (s != '' && !MRReset(s)) }
function GetColorOf (e) {
	var c = (e.tagName == 'TD') ? e.bgColor : e.value
	c = ModalResult('../twinkle/dialog_selector_color.htm', c, '')
	if (c != '') {
		c = (c == 'RESET') ? '' : c
		c = (e.tagName == 'TD') ? e.bgColor = c : e.value = c
	}
	return false
}
function GetStyleOf (e, n) {
	var c = ModalResult('../twinkle/dialog_selector_' + n + '.htm', e.value, '')
	if (c != '')
		e.value = (c == 'RESET') ? '' : c
	return false
}
function ExtractNum (s) {
	var r = ''
	if (s)
		for (var i = 0; i < s.length; i++) {
			var c = s.charAt(i)
			if ((c >= '0' && c <= '9') || ((c == '.' || c == ',') && r.length > 0 && r.indexOf(c) < 0))
				r += c
			else
			if (r.length > 0)
				break
		}
	return ToFloat(r, 0)
}
function ExtractInt (s) {
	return ToInt(ExtractNum(s))
}
function EncDlgStr (a) {
	if (a)
		return a.join(cSplitter)
	return ''
}
function DecDlgStr (a) {
	if (a)
		return a.toString().split(cSplitter)
	return []
}
// ------------------------------
// Ajax
//
// Formular mit Ajax senden -> ohne Fensterantwort
// Beispiel siehe ..twinkle/dialog_upload_image.htm
// ------------------------------
AjaxSF = {
	frame: function(c) {
		var n = 'f' + Math.floor(Math.random() * 99999)
		var d = document.createElement('DIV')
		d.innerHTML = '<iframe style="display:none" src="about:blank" id="' + n + '" name="' + n +
			'" onload="AjaxSF.loaded(\'' + n + '\')"></iframe>'
		document.body.appendChild(d)
		var i = document.getElementById(n);
		if (c && typeof(c.onComplete) == 'function')
			i.onComplete = c.onComplete
		return n
	},
	form: function(f, name) {
		f.action = (f.action != '') ? f.action : hpCgiProg;
		f.encoding = 'multipart/form-data'
		f.method = 'post'
		f.target = name
	},
	submit: function(f, c) {
		AjaxSF.form(f, AjaxSF.frame(c))
		if (c && typeof(c.onStart) == 'function')
			return c.onStart(f)
		else return true
	},
	loaded: function(id) {
		var i = $(id)
		if (i.contentDocument)
			var d = i.contentDocument
		else if (i.contentWindow)
			var d = i.contentWindow.document
		else var d = window.frames[id].document
		if (d.location.href == "about:blank")
			return
		if (typeof(i.onComplete) == 'function')
			i.onComplete(EGetV(d.body))
	}
}
function AjaxSendForm (f, onStart, onComplete) {
	return AjaxSF.submit(f, {'onStart':onStart, 'onComplete':onComplete})
}
function AjaxPost (Params, Opt) {
	var Opt = ToInt(Opt, 0);
	var Res = null;
	new Ajax.Request(hpCgiProg, {
		asynchronous: false,
		parameters: Params,
		onSuccess: function(data) {
			Res = XMLLoadData(XMLText(XMLDoc(data), true));
			if (BitsEnabled(Opt, optRoot))
				Res = XMLRoot(Res);
		},
		onFailure: function(data) {
			alert(data.responseText)
		}
	});
	return Res;
}
function AjaxGet (Url, Opt) {
	var Opt = ToInt(Opt, 0);
	var Res = null;
	new Ajax.Request(((IsReadyUrl(Url)) ? Url : DoCGI(Url)), {
		asynchronous: false,
		method: 'get',
		onSuccess: function(data) {
			Res = XMLLoadData(XMLText(XMLDoc(data), true));
			if (BitsEnabled(Opt, optRoot))
				Res = XMLRoot(Res);
		},
		onFailure: function(data) {
			alert(data.responseText)
		}
	});
	return Res;
}
// ------------------------------
// XML
// ------------------------------
var ELEMENT_NODE=1;
var ATTRIBUTE_NODE=2;
var TEXT_NODE=3;
var CDATA_SECTION_NODE=4;
var ENTITY_REFERENCE_NODE=5;
var ENTITY_NODE=6;
var PROCESSING_INSTRUCTION_NODE=7;
var COMMENT_NODE=8;
var DOCUMENT_NODE=9;
var DOCUMENT_TYPE_NODE=10;
var DOCUMENT_FRAGMENT_NODE=11;
var NOTATION_NODE=12;

var cXMLEncoding='ISO-8859-1';
var cUTF8='UTF-8';
var cXMLDocRootTag='DOCUMENTCONTENT';
// ------------------------------
// XML XPath -> Mozilla
// ------------------------------
function SKSclearDOM (D) {
	while (D.hasChildNodes())
		D.removeChild(D.firstChild);
}
function SKScopyDOM (D, F) {
	SKSclearDOM(D);
	var N = F.childNodes;
	for (var i = 0; i < N.length; i++)
		D.appendChild(D.importNode(N[i], true));
};
function SKStransformToFragmentDOM (XML, XSL, R) {
	try {
		var P = new XSLTProcessor();
		if (P.reset) {
			P.importStylesheet(XSL);
			var F = P.transformToFragment(XML, R);
			SKScopyDOM(R, F);
		} else {
			P.transformDocument(XML, XSL, R, null);
		};
	} catch(e) {
	};
};
function SKStransformDOM (XML, XSL) {
	var R = document.implementation.createDocument("", "", null);
	XML.transformNodeToObject(XSL, R);
	return XMLText(R, true);
};
if (document.implementation && document.implementation.createDocument) {
	XMLDocument.prototype.transformNodeToObject = function(XSL, R) {
		SKStransformToFragmentDOM(this, XSL, R);
	}
	XMLDocument.prototype.transformNode = function(XSL) {
		return SKStransformDOM(this, XSL);
	}
	Element.prototype.transformNodeToObject = function(XSL, R) {
		SKStransformToFragmentDOM(this, XSL, R)
	}
	Element.prototype.transformNode = function(XSL) {
		return SKStransformDOM(this, XSL)
	}
	Array.prototype.item = function (I) {
		return this[I];
	}
	Array.prototype.expr = '';
	XMLDocument.prototype.setProperty = function(x,y) {};
	XMLDocument.prototype.selectNodes = function(XPath, Node) {
		var R = this.evaluate(XPath, (Node ? Node : this), this.createNSResolver(this.documentElement), XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
		var L = new Array(R.snapshotLength);
		L.expr = XPath;
		for (i = 0; i < L.length; i++)
			L[i] = R.snapshotItem(i);
		return L;
	}
	Element.prototype.selectNodes = function(XPath) {
		var D = this.ownerDocument;
		if (D.selectNodes) return D.selectNodes(XPath, this);
	}
	XMLDocument.prototype.selectSingleNode = function(XPath, Node) {
		var N = Node ? Node : null;
		XPath += "[1]";
		var L = this.selectNodes(XPath, N);
		if (L.length > 0) return L[0]; else return null;
	}
	Element.prototype.selectSingleNode = function(XPath) {
		var D = this.ownerDocument;
		if (D.selectSingleNode) return D.selectSingleNode(XPath, this);
	}
}
function XMLOpenFile (url, async, readyFunc) {
	var F = Try.these(
		function() {return new ActiveXObject('MSXML2.DOMDocument.6.0')},
		function() {return new ActiveXObject('MSXML2.DOMDocument.5.0')},
		function() {return new ActiveXObject('MSXML2.DOMDocument.4.0')},
		function() {return new ActiveXObject('MSXML2.DOMDocument.3.0')},
		function() {return new ActiveXObject('MSXML2.DOMDocument.2.0')},
		function() {return new ActiveXObject('MSXML2.DOMDocument')},
		function() {return new ActiveXObject('Microsoft.XmlDom')}
	) || false;
	if (F) {
		F.setProperty('SelectionLanguage', 'XPath')
		F.setProperty('AllowDocumentFunction', true);
		F.onreadystatechange = function () { if (this.readyState == 4 && readyFunc) readyFunc() }
	} else
	if (document.implementation && document.implementation.createDocument) {
		F = document.implementation.createDocument('','',null)
		if (readyFunc)
			F.onload = readyFunc
	}
	if (F) {
		F.resolveExternals = true;
		F.async = async
		if (ChkStr(url) != '')
			F.load(url)
	}
	return F
}
function XMLLoadData (data) {
	var F = XMLOpenFile('');
	try {
		F.loadXML(data);
	} catch(e) {
		try {
			P = new DOMParser();
			F = P.parseFromString(data, 'text/xml');
		} catch(e) {
		}
	}
	return F
}
function XMLCreateDoc (url, async, readyFunc, data, Options) {
	if (!isIE || IsOnline) {
		var p = url
		if (!IsReadyUrl(p))
			p = DoPPO('TWINKLE', '', tw_File_Get, 'filename=' + url)
		return AjaxGet(p, Options);
	}
	if (IsReadyUrl(url)) {
		url = url.split('&')
		for (var i = 0; i < url.length; i++) {
			if (url[i].indexOf('tablename=') == 0) {
				url = 'xml/' + url[i].split('=')[1] + '.xml'
				break
			} else
			if (url[i].indexOf('filename=') == 0) {
				url = url[i].split('=')[1]
				break
			}
		}
	}
	return XMLOpenFile(MkUrl(url), false, readyFunc)
}
function XML_DB_RetriveRecords (tablename, conditions, filename, Options) {
	return AjaxGet(DoTwinkle(tw_Sql_GetRecord, ['tablename', 'conditions', 'tag', 'filename'],
			[tablename, conditions, grAsXML + grNoProlog + ToInt(Options, 0), ChkStr(filename)]));
}
function XMLDoc (D) {
	var P = D
	if (P.responseXML)
		P = P.responseXML
	if (isIE)
		P.setProperty('SelectionLanguage', 'XPath')
	return P
}
function XMLRoot (D) {
	var P = XMLDoc(D)
	return P.documentElement
}
function XMLImportNode (N, D, Deep) {
	if (document.implementation && document.implementation.createDocument)
		N.appendChild(N.ownerDocument.importNode(D, Deep))
	else N.appendChild(D.cloneNode(Deep))
	return N
}
function XMLTransformNode (Xml, Xsl, RunOptN, RunOptV) {
	var D = Xml;
	if (!D.documentElement && !D.ownerDocument)
		D = (IsReadyUrl(D) || D.indexOf('../') == 0) ? XMLOpenFile(D) : XMLLoadData(D);
	var E = (D.documentElement) ? XMLRoot(D) : D;
	var S = Xsl;
	if (!S.documentElement && !S.ownerDocument)
		S = (IsReadyUrl(S) || S.indexOf('../') == 0) ? XMLOpenFile(S) : XMLLoadData(S);
	if (RunOptN && RunOptV && RunOptN.length == RunOptV.length) {
		for (var i = 0;  i < RunOptN.length; i++)
			XMLCreateChild(E, RunOptN[i], [], [], RunOptV[i], null, E.firstChild);
	}
	var R = D.transformNode(S);
	if (RunOptN && RunOptV && RunOptN.length == RunOptV.length) {
		for (var i = 0;  i < RunOptN.length; i++)
			XMLRemove(E.selectSingleNode(RunOptN[i]));
	}
	return R;
}
function XMLGetRoot (D, T) {
	return XMLForceChild(XMLRoot(D), T, [], [], '');
}
function XMLProlog (E) {
	return '<?xml version="1.0" encoding="' + IfStr(ChkStr(E), cXMLEncoding, ChkStr(E)!='') + '"?>';
}
function XMLHeader (S, E) {
	return XMLProlog(E) + MakeTag(cXMLDocRootTag, S);
}
function XMLTransferHeader (S, Opt) {
	var P = ToInt(Opt, 0);
	if (BitsEnabled(P, grNoHeader))
		P = GetTag(cXMLDocRootTag, S);
	else P = S;
	return encodeURI(XMLHeader(_scec(P), cUTF8));
}
function XMLResult (S) {
	var R = XMLRoot(S)
	return {Code:ToInt(XMLGetChildText(R, 'RESULTCODE'), 0),
		Info:XMLGetChildText(R, 'RESULTTEXT'),
		Data:XMLGetChildText(R, 'RESULTDATA')
	}
}
function XMLText (N, NoH) {
	var R = '';
	try {
		if (window.XMLSerializer) {
			var S = new XMLSerializer();
			R = S.serializeToString(N);
			if (R.indexOf('<a0:') >= 0)
				R = R.replace(/a0:/g, '');
		} else
			R = N.xml;
		if (!NoH) {
			var E = XMLGetAttr(N.ownerDocument.firstChild, 'encoding');
			R = XMLProlog(IfStr(cXMLEncoding, E, E == '')) + R;
//			R = XMLProlog(IfStr(E, cUTF8, E != '')) + R;
		}
	} catch(e) {
	};
	return _scec(R);
}
function XMLChild (N, T, I) {
	var j = 0
	if (N && N.hasChildNodes)
		for (var i = 0; i < N.childNodes.length; i++)
			if (N.childNodes[i].nodeType == T) {
				if (!I || I == j)
					return N.childNodes[i]
				j++
			}
	return null
}
function XMLIndex (N) {
	var i = -1
	if (N) do {
		i++
		N = N.previousSibling
	} while (N)
	return i
}
function XMLCount (N) {
	if (N)
		return XMLIndex(N.lastChild) + 1
	return 0
}
function XMLLevel (N, R) {
	x = -1
	if (N) {
		var P = (R) ? R : XMLRoot(N.ownerDocument)
		while (N && N != P) {
			N = N.parentNode;
			x++
		}
	}
	return x
}
function XMLRemove (N) {
	if (N)
		N.parentNode.removeChild(N)
	return N
}
function XMLClear (N) {
	while (N && N.hasChildNodes())
		N.removeChild(N.firstChild)
	return N
}
function XMLRemoveAttr (N, a) {
	if (N && N.attributes && N.attributes.getNamedItem(a))
		N.attributes.removeNamedItem(a)
	return true
}
function XMLGetAttr (N, a) {
	if (N && N.attributes) {
		var P = N.attributes.getNamedItem(a)
		if (P)
			return P.nodeValue
	}
	return ''
}
function XMLSetAttr (N, a, av) {
	if (N && N.attributes) {
		for (var i = 0; i < a.length; i++) {
			var P = N.attributes.getNamedItem(a[i]);
			if (!P) {
				P = N.ownerDocument.createAttribute(a[i]);
				N.attributes.setNamedItem(P);
			}
			if (P)
				P.nodeValue = av[i];
			else return false;
		}
		return true;
	}
	return false;
}
function XMLEqAttr (N, a, av) {
	for (var i = 0; i < a.length; i++)
		if (XMLGetAttr(N, a[i]) != av[i])
			return false
	return true
}
function XMLCreateChild (N, T, a, av, V, NT, B) {
	var P = null
	if (N) {
		P = N.ownerDocument.createElement(T)
		if (P) {
			if (B && B.parentNode)
				B.parentNode.insertBefore(P, B);
			else N.appendChild(P);
			XMLSetText(P, V, NT)
			XMLSetAttr(P, a, av)
		}
	}
	return P
}
function XMLForceChild (N, T, a, av, V) {
	var P = XMLFindChild(N, T, a, av, false)
	if (!P)
		P = XMLCreateChild(N, T, a, av, V)
	else {
		XMLSetText(P, V)
		XMLSetAttr(P, a, av)
	}
	return P
}
function XMLFindChild (N, T, a, av, R) {
	var P = null
	if (N && N.hasChildNodes) {
		for (var i = 0; i < N.childNodes.length; i++) {
			if ((T == '' || N.childNodes[i].nodeName == T) && (!a || XMLEqAttr(N.childNodes[i], a, av)))
				P = N.childNodes[i]
			else if (R)
			P = XMLFindChild(N.childNodes[i], T, a, av, R)
			if (P)
				break
		}
	}
	return P
}
function XMLFindText (N, V, R) {
	var P = null
	if (N && N.hasChildNodes) {
		for (var i = 0; i < N.childNodes.length; i++) {
			if (XMLGetText(N.childNodes[i]) == V)
				P = N.childNodes[i]
			else if (R)
			P = XMLFindText(N.childNodes[i], V, R)
			if (P)
				break
		}
	}
	return P
}
function XMLGetText (N, NT) {
	var P = XMLChild(N, IfStr(ChkStr(NT), TEXT_NODE, NT))
	if (P)
		return P.nodeValue
	return ''
}
function XMLGetChildText (N, T, a, av, R) {
	var P = XMLFindChild(N, T, a, av, R)
	return XMLGetText(P) + XMLNodeCDATA(P)
}
function XMLNodeCDATA (N) {
	return XMLGetText(N, CDATA_SECTION_NODE)
}
function XMLRootCDATA (D) {
	return XMLNodeCDATA(XMLRoot(D))
}
function MakeCDATA (S) {
	return '<![CDATA[' + S + ']]>'
}
function XMLSetText (N, V, NT) {
	if (IsStr(V)) {
		var P = XMLChild(N, IfStr(ChkStr(NT), TEXT_NODE, NT))
		if (!P && N)
			if (NT == CDATA_SECTION_NODE)
				P = N.appendChild(N.ownerDocument.createCDATASection(''));
			else P = N.appendChild(N.ownerDocument.createTextNode(''));
		if (P)
			P.nodeValue = V;
		return (P) ? true : false
	}
	return false;
}
function XMLSetChildText (N, T, a, av, V, R) {
	return XMLSetText(XMLFindChild(N, T, a, av, R), V)
}
// ------------------------------
// XML Helfer-Funktionen
// ------------------------------
function XMLChildAttrToList (N, T, a, D) {
  var R = []
  if (N && N.hasChildNodes) {
    D = IfStr(D, '=', D)
    for (var i = 0; i < N.childNodes.length; i++)
      if ((T == '' || N.childNodes[i].nodeName == T) && N.childNodes[i].attributes) {
	var S = ''
	for (var j = 0; j < a.length; j++)
	  S += XMLGetAttr(N.childNodes[i], a[j]) + IfStr(D, '', j < a.length - 1)
	if (S != '')
	  R[R.length] = S
      }
  }
  return R
}
// ------------------------------
// Inputs
// ------------------------------
function SELECTcreate (aName, aMultiple, aSize, aClass, aStyle, aEvents, aOptions, aArr) {
  return '<select' +
	    IfStr(' name="' + aName + '"', '', aName != null) +
	    IfStr(' multiple', '', aMultiple) +
	    IfStr(' size="' + aSize + '"', '', aSize != null) +
	    IfStr(' class="' + aClass + '"', '', aClass != null) +
	    IfStr(' style="' + aStyle + '"', '', aStyle != null) +
	    IfStr(' ' + aEvents, '', aEvents != null) +
	  '>' + IfStr(aOptions, '', aOptions != null) + '</select>'
}
function SELECTadd (e, aIndex, aValue, aText, aStyle) {
  var o = document.createElement('OPTION')
  SELECTassignoption(o, aValue, aText, aStyle)
  if (aIndex != null)
    if (aIndex < 0)
      e.options.add(o, e.selectedIndex)
    else e.options.add(o, aIndex)
  else e.options.add(o)
}
function SELECTaddOptionArray (e, a, c) {
  if (e != null && a != null) {
    if (c)
      SELECTclear(e)
    for (var i = 0; i < a.length; i++)
      SELECTadd(e, null, i, a[i], null)
  }
}
function SELECTaddOptionString (e, a, c) {
  SELECTaddOptionArray(e, a.split(';'), c)
}
function SELECTfind (e, aText) {
  for (var i = 0; i < e.options.length; i++)
    if (e.options[i].text == aText)
      return i
  return -1
}
function SELECTfindValue (e, aValue) {
  for (var i = 0; i < e.options.length; i++)
    if (e.options[i].value == aValue)
      return i
  return -1
}
function SELECTnoduplicates (e) {
  SELECTsort(e)
  var s = ''
  var i = 0
  while (i < e.options.length)
    if (s != SELECTtext(e, i)) {
      s = SELECTtext(e, i)
      i++
    } else SELECTremove(e, i)
}
function SELECTkillmatches (a, i) {
  for (var j = 0; j < a.options.length; j++)
    SELECTremove(i, SELECTfind(i, SELECTtext(a, j)))
}
function SELECTclear (e) {
  if (e)
    e.innerHTML = ''
}
function SELECTselectall (e, t) {
  if (e)
    for (var i = 0; i < e.options.length; i++)
      e.options[i].selected = t
}
function swapOptions (e, i, j) {
  if (e != null) {
    var o = e.options
    var i_s = o[i].selected
    var j_s = o[j].selected
    var t1 = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected)
    var t2 = new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected)
    o[i] = t2
    o[j] = t1
    o[i].selected = j_s
    o[j].selected = i_s
  }
}
function SELECTmoveupdown (e, ud) {
  if (e != null)
    if (ud) {
      for (i = 0; i < e.options.length; i++)
	if (e.options[i].selected)
	  if (i != 0 && !e.options[i - 1].selected) {
	    swapOptions(e, i, i - 1)
	    e.options[i - 1].selected = true
	  }
    } else {
      for (i = e.options.length - 1; i >= 0; i--)
	if (e.options[i].selected)
	  if (i != (e.options.length - 1) && !e.options[i + 1].selected) {
	    swapOptions(e, i, i + 1)
	    e.options[i + 1].selected = true
	  }
    }
}
function SELECTmovefromto (f, t) {
  if (f != null && t != null) {
    var fs = f.selectedIndex
    for (var i = 0; i < f.options.length; i++) {
      var o = f.options[i]
      if (o.selected)
	t.options[t.options.length] = new Option(o.text, o.value, false, false)
    }
    for (var i = (f.options.length - 1); i >= 0; i--) {
      var o = f.options[i]
      if (o.selected)
	f.options[i] = null
    }
    if (f.options.length > 0)
      f.selectedIndex = Math.min(f.options.length - 1, Math.max(0, fs));
  }
}
function SELECTcopyfromto (f, t) {
  if (f != null && t != null) {
    var fs = f.selectedIndex
    var os = new Object()
    for (var i = 0; i < t.options.length; i++)
      os[t.options[i].value] = t.options[i].text
    for (var i = 0; i < f.options.length; i++) {
      var o = f.options[i]
      if (o.selected)
	if (os[o.value] == null || os[o.value] == "undefined" || os[o.value]!=o.text)
	  t.options[t.options.length] = new Option(o.text, o.value, false, false)
    }
    if (f.options.length > 0)
      f.selectedIndex = Math.min(f.options.length - 1, Math.max(0, fs));
  }
}
function SELECTassignoption (o, aValue, aText, aStyle) {
  if (o != null) {
    o.value = aValue
    o.text = aText
    o.style.cssText = aStyle
  }
}
function SELECTassignoptionO (o, O) {
  if (o != null && O != null)
    SELECTassignoption(o, O.value, O.text, O.style.cssText)
}
function SELECTassign (f, t, d) {
  if (f != null && t != null) {
    SELECTclear(t)
    for (var i = 0; i < f.options.length; i++) {
      var o = d.createElement('OPTION')
      SELECTassignoptionO(o, f.options[i])
      t.options.add(o)
    }
  }
}
function SELECTremove (e, i) {
	if (e != null) {
		var fs = e.selectedIndex
		if (i != null && i >= 0 && i < e.options.length)
			e.removeChild(e.options[i])
		else
		if (i != -1)
			for (var i = (e.options.length - 1); i >= 0; i--)
				if (e.options[i].selected)
					e.removeChild(e.options[i])
		if (e.options.length > 0)
			if (i == -1)
				e.selectedIndex = 0;
			else e.selectedIndex = Math.min(e.options.length - 1, Math.max(0, fs));
	}
	return false
}
function SELECTsort (e) {
  var o = new Array()
  if (e.options == null)
    return
  for (var i = 0; i < e.options.length; i++)
    o[o.length] = new Option(e.options[i].text, e.options[i].value, e.options[i].defaultSelected, e.options[i].selected)
  if (o.length == 0)
    return
  o = o.sort(
    function(a,b) {
      if ((a.text+"") < (b.text+"")) return -1
      if ((a.text+"") > (b.text+"")) return 1
      return 0
    }
  )
  for (var i = 0; i < o.length; i++)
    e.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected)
}
function SELECTmatch (e, r, which, only) {
  if (window.RegExp) {
    if (which == "select") {
      var selected1=true
      var selected2=false
    } else
    if (which == "unselect") {
      var selected1=false
      var selected2=true
    } else
      return
    var re = new RegExp(r)
    for (var i = 0; i < e.options.length; i++) {
      if (re.test(e.options[i].text))
	e.options[i].selected = selected1
      else if (only == true)
	e.options[i].selected = selected2
    }
  }
}
function selectMatchingOptions (e, r) { SELECTmatch(e, r, "select", false) }
function selectOnlyMatchingOptions (e, r) { SELECTmatch(e, r, "select", true) }
function unSelectMatchingOptions (e, r) { SELECTmatch(e, r, "unselect", false) }
function SELECTsettextsel (e, aText) {
  for (var i = 0; i < e.options.length; i++)
    if (SELECTtext(e, i) == aText) {
      e.selectedIndex = i
      return true
    }
  return false
}
function SELECTsetvaluesel (e, v) {
  for (var i = 0; i < e.options.length; i++)
    if (SELECTvalue(e, i) == v) {
      e.selectedIndex = i
      return true
    }
  return false
}
function SELECTgetall (e, Ch, v) {
	var R = []
	for (var i = 0; i < e.options.length; i++)
		if (v)
			R[R.length] = ChkStr(e.options[i].value)
		else R[R.length] = ChkStr(e.options[i].text)
	return R.join(Ch)
}
function SELECTgetselected (e, Ch) {
  var R = []
  for (var i = 0; i < e.options.length; i++)
    if (e.options[i].selected)
      R[R.length] = e.options[i].text
  return R.join(Ch)
}
function SELECTsetindexsel (e, aIndex) {
  if (aIndex >= 0 && aIndex < e.options.length) {
    e.selectedIndex = aIndex
    return true
  }
  return false
}
function SELECTvalue (e, aIndex) {
  if (aIndex == null) aIndex = e.selectedIndex
  if (aIndex >= 0 && aIndex < e.options.length) return e.options[aIndex].value; else return ''
}
function SELECTtext (e, aIndex) {
  if (aIndex == null) aIndex = e.selectedIndex
  if (aIndex >= 0 && aIndex < e.options.length) return e.options[aIndex].text; else return ''
}
function SELECTstyle (e, aIndex) {
  if (aIndex == null) aIndex = e.selectedIndex
  if (aIndex >= 0 && aIndex < e.options.length) return e.options[aIndex].style.cssText; else return ''
}
function SELECTsettext (e, t, aIndex) {
  if (aIndex == null) aIndex = e.selectedIndex
  if (aIndex >= 0 && aIndex < e.options.length) e.options[aIndex].text = t
}
// ------------------------------
// Checkbox-Group
// ------------------------------
function CHECKBOXGROUPgetdata (n, x, f) {
	if (f)
		var a = f.elements
	else if (typeof(n) == 'string')
		var a = document.getElementsByName(n)
	else var a = document.getElementsByName(n.id + '0')
	var v = 0
	for (var i = 0; i < a.length; i++)
		if (!f || a[i].name == n)
			if (x)
				v = (a[i].checked) ? (v | ToInt(a[i].value, 0)) : v
			else v = (a[i].checked) ? (v | Math.pow(2, i)) : v
	return v
}
function CHECKBOXGROUPsetdata (n, v, x, f) {
	if (f)
		var a = f.elements
	else if (typeof(n) == 'string')
		var a = document.getElementsByName(n)
	else var a = document.getElementsByName(n.id + '0')
	for (var i = 0; i < a.length; i++)
		if (!f || a[i].name == n)
			if (x)
				a[i].checked = BitsEnabled(v, ToInt(a[i].value))
			else a[i].checked = BitsEnabled(v, Math.pow(2, i))
}
// ------------------------------
// Radiobox-Group
// ------------------------------
function RADIOBOXGROUPgetdata (n, x) {
	var a = document.getElementsByName(n.id + '0')
	for (var i = 0; i < a.length; i++)
		if (a[i].checked)
			if (x)
				return a[i].value
			else return i
	return null
}
function RADIOBOXGROUPsetdata (n, v, x) {
	var a = document.getElementsByName(n.id + '0')
	for (var i = 0; i < a.length; i++)
		if (x)
			a[i].checked = ToInt(a[i].value) == v
		else a[i].checked = i == v
}
// ------------------------------
// Elements
// ------------------------------
function Element_Create (T, P, Before) {
	var E = null
	if (P.ownerDocument.createElementNS)
		E = P.ownerDocument.createElementNS('http://www.w3.org/1999/xhtml', T)
	else E = P.ownerDocument.createElement(T)
	if (typeof(P) != 'undefined')
		if (Before && P.parentNode)
			P.parentNode.insertBefore(E, P)
		else P.appendChild(E)
	return $(E)
}
function Element_Remove (E) {
	if (E) E.parentNode.removeChild(E)
}
function EGetV (E, Q) {
	var E = $(E)
	E = (E && E.firstChild) ? E.firstChild.nodeValue : ''
	if (Q) return E.replace(/"/g,'&quot;')
	return E
}
function ESetV (E, T) {
	var E = $(E)
	if (E) {
		E.innerHTML = ''
		E.appendChild(document.createTextNode(T))
	}
}
// ------------------------------
// Events
// ------------------------------
MousePt = [0,0];
MouseDn = false;
MouseDE = null;
MouseFU = null;
MouseOPT = '';

function _DocMouseDown (event, Func, Option, ClipE) {
	MouseDE = Event.element(event);
	if (MouseDE) {
		MouseDn = true;
		MouseFU = Func;
		MouseOPT = Option;
		MouseEG = [0,0,0,0];
		if (ChkStr(ClipE) != '') {
			var E = $(ChkStr(ClipE));
			var W = Math.abs((MouseDE.getWidth() - 1) / 2);
			MouseEG = [0 - W, 0 - W, E.getWidth() - W - 1, E.getHeight() - W - 1];
		}
		MousePt = [Event.pointerX(event), Event.pointerY(event)];
		Event.stop(event);
		Event.observe(document, 'mousemove', _DocMouseMove);
		Event.observe(document, 'mouseup', _DocMouseUp);
		EnableSelection(false);
	} else
		MouseDE = null;
}
function _DocMouseUp (event) {
	MouseDn = false
	MouseDE = null;
	MouseFU = null;
	MouseOPT = '';
	Event.stop(event);
	Event.stopObserving(document, 'mousemove', _DocMouseMove);
	Event.stopObserving(document, 'mouseup', _DocMouseUp);
	EnableSelection(true);
}
function _DocMouseMove (event) {
	if (MouseDn) {
		var X = (Event.pointerX(event) - MousePt[0]);
		var Y = (Event.pointerY(event) - MousePt[1]);
		Event.stop(event);
		if (MouseOPT == 'move') {
			X = ToInt(MouseDE.style.left, 0) + X;
			Y = ToInt(MouseDE.style.top, 0) + Y;
			MouseDE.style.left = Math.min(MouseEG[2], Math.max(MouseEG[0], X)) + 'px';
			MouseDE.style.top = Math.min(MouseEG[3], Math.max(MouseEG[1], Y)) + 'px';
		}
		if (MouseFU)
			MouseFU(event, X, Y)
		MousePt = [Event.pointerX(event), Event.pointerY(event)];
	}
}
function Drag_Start (event, DE) {
	if (!document.DETmp) {
		document.DETmp = (DE) ? DE : Event.element(event)
		document.DETmp.ondragstart = NoEvent
		document.DETmp.xOffs = Event.pointerX(event) - AbsLeft(document.DETmp)
		document.DETmp.yOffs = Event.pointerY(event) - AbsTop(document.DETmp)
		document.DETmp.wOffs = $(document.DETmp).getWidth() - ((isIE)?0:2)
		document.DETmp.hOffs = $(document.DETmp).getHeight() - ((isIE)?0:2)
		Event.observe(document, 'mousemove', Drag_Begin)
		Event.observe(document, 'mouseup', Drag_End)
		Event.stop(event)
	}
}
function Drag_Begin (event) {
	if (document.DETmp) {
		document.DETmp.style.left = (Event.pointerX(event) - document.DETmp.xOffs) + 'px'
		document.DETmp.style.top = (Event.pointerY(event) - document.DETmp.yOffs) + 'px'
		document.DETmp.style.width = document.DETmp.wOffs + 'px'
		document.DETmp.style.height = document.DETmp.hOffs + 'px'
	}
}
function Drag_End (event) {
	if (document.DETmp) {
		document.DETmp = null
		Event.stopObserving(document, 'mousemove', Drag_Begin)
		Event.stopObserving(document, 'mouseup', Drag_End)
	}
}
// ------------------------------
// Infodiv
// ------------------------------
iwWait = 1;
iwNoClose = 2;
iwFixed = 4;
iwCursor = 8;

function SKS_InfoShow (Text, TimeOut, Opt, Win) {
	SKS_InfoHide();
	var Opt = ToInt(Opt, 0);
	top.iwWin = (Win) ? Win : window;
	var P = Element_Create('div', top.iwWin.document.body);
	P.setStyle({position:'absolute', zIndex:'10001', padding:'0px', border:'1px solid #000000',
		left:(SKS_BodyScrollLeft(top.iwWin) + SKS_BodyWidth(top.iwWin)/2 - 200) + 'px',
		top:(SKS_BodyScrollTop(top.iwWin) + 10) + 'px', width:'400px', backgroundColor:'#FFFFFF', overflow:'hidden'})
	P.innerHTML =	'<table id="_SKS_INFOWIN_" width="100%" cellpadding="5" cellspacing="0" border="0" class="text1">'+
				'<tr>' +
					IfStr('', '<td valign="top"><img src="../sys/sysbut/buttons/cancel_0.gif" height="15" width="15" onclick="SKS_InfoHide()" /></td>', BitsEnabled(Opt, iwNoClose)) +
					'<td valign="middle" align="center"><p><b>' + Text + IfStr('&nbsp;&nbsp;&nbsp;<img src="../sys/sysbut/waiting.gif" height="15">', '', BitsEnabled(Opt, iwWait)) + '</b></p></td>' +
				'</tr>' +
			'</table>';
	top.iwWin._sks_InfoWin_ = P;
	var W = ToInt(TimeOut, 0);
	if (W >= 0)
		top.iwWinTO = top.iwWin.setTimeout('SKS_InfoHide()', (W > 0) ? W : 1000);
	else Event.observe(document, 'mousedown', SKS_InfoCheckClose);
	if (BitsEnabled(Opt, iwFixed))
		top.iwWin.onscroll = SKS_InfoFixed;
}
function SKS_InfoHide () {
	if (top.iwWin) {
		Event.stopObserving(document, 'mousedown', SKS_InfoCheckClose)
		if (top.iwWin._sks_InfoWin_)
			Element_Remove(top.iwWin._sks_InfoWin_)
		if (top.iwWinTO)
			top.iwWin.clearTimeout(top.iwWinTO);
		top.iwWinTO = null;
		top.iwWin.onscroll = null;
		top.iwWin._sks_InfoWin_ = null
		top.iwWin = null;
	}
}
function SKS_InfoCheckClose (event) {
	var E = Event.element(event)
	if (top.iwWin && top.iwWin._sks_InfoWin_ && (!E || !(ChkStr(E.tagName).toUpperCase() == 'SCROLLBAR' || E.descendantOf(top.iwWin._sks_InfoWin_) ||
			E == top.iwWin._sks_InfoWin_ )))
		SKS_InfoHide()
}
function SKS_InfoFixed () {
	if (top.iwWin._sks_InfoWin_)
		CalcInnerViewLeftTop(top.iwWin._sks_InfoWin_, 20, 0, 0, top.iwWin);
}
// ------------------------------
// Bildlupe mit Infodiv
// ------------------------------
_liW = 0;
_liH = 0;
_liRef = null;

function SKS_ShowImgLoup (event, Url, W, H, Opt, Win) {
	if (!top.iwWin || !top.iwWin.document.getElementById('_LOUPIMG_')) {
		if (event)
			_liRef = Event.element(event);
		else _liRef = null;
		SKS_InfoShow('<img id="_LOUPIMG_" src="' + Url + '" border="0">' + IfStr('<img id="_DOT_" ' +
			'style="position:absolute;" src="../sys/sysbut/cur_default.gif" border="0">', '',
			BitsEnabled(Opt, iwCursor)), -1, Opt, Win);
		P = top.iwWin.document.getElementById('_LOUPIMG_');
		_liW = $(P).getWidth();
		_liH = $(P).getHeight();
		var W = ToInt(W, 0);
		if (W <= 0)
			W = Math.min(_liW + (BitsEnabled(Opt, iwNoClose) ? 0 : 50), SKS_BodyWidth(top.iwWin));
		var H = ToInt(H, 0);
		if (H <= 0)
			H = Math.min(_liH + (BitsEnabled(Opt, iwNoClose) ? 0 : 10), SKS_BodyHeight(top.iwWin));
		top.iwWin._sks_InfoWin_.setStyle({width:W + 'px', height:H + 'px'});
		SKS_InfoFixed();
	}
}
function SKS_MoveImgLoup (event) {
	var E = Event.element(event)
	if ((E == _liRef || E.tagName == 'AREA') && top.iwWin && top.iwWin._sks_InfoWin_) {
		var L = Math.ceil(_liW * SKS_EventOffsetX(event) / _liRef.getWidth()) - 100;
		var T = Math.ceil(_liH * SKS_EventOffsetY(event) / _liRef.getHeight()) - 100;
		top.iwWin._sks_InfoWin_.scrollLeft = L;
		top.iwWin._sks_InfoWin_.scrollTop = T;
		var P = top.iwWin.document.getElementById('_DOT_');
		if (P) {
			P.style.left = (L + 100 + 4) + 'px';
			P.style.top = (T + 100 + 4) + 'px';
		}
	}
}
function SKS_CloseImgLoup (event) {
	_liRef.cumulativeOffset();
	Element.getDimensions(_liRef);
	if (!Position.within(_liRef, event.clientX, event.clientY) || !Position.within(_liRef, event.clientX + 3, event.clientY + 3)) {
		SKS_InfoHide();
		return true;
	}
	return false;
}
// ------------------------------
// Popup
// ------------------------------
/*
Params:	x
	y
	Caption
	ShowAtElement
	AdjustOffset
	GetData
*/
function SKS_PopupWinClose (CloseInfo) {
	if (window._sks_DocWin_)
		window._sks_DocWin_.Hide()
	SKS_InfoHide()
	if (window.SKS_PopupWinClosed)
		window.SKS_PopupWinClosed(CloseInfo)
}
function SKS_PopupWin (event, Params) {
	window._sks_DocWin_ = this
	EnableSelection(false)
	this.Params = Params
	this.Container = Element_Create('div', document.body)
	this.Container.style.position = 'absolute'
	this.Container.style.zIndex = '10000'
	this.Container.className = 'skspopup'

	Event.observe(document, 'mousedown', this._MouseDown)
	Event.observe(document, 'mouseup', this._MouseUp)

	this.Table = Element_Create('table', this.Container)
		this.Table.border = '0'
		this.Table.cellSpacing = '0'
		this.Table.cellPadding = '1'

	this.Body = Element_Create('tbody', this.Table)
		var tr = Element_Create('tr', this.Body)
			var td = Element_Create('td', tr)
				td.id = '_sks_Help'
				td.className = 'sksbutton'
				td.setStyle({width:'20px', height:'18px'})
				td.innerHTML = '?'
				td.observe('mousedown', this._ButtonMouseDown)
				td.observe('mouseover', this._ButtonMouseOver)
				td.observe('mouseout', this._ButtonMouseOut)
				td.observe('click', this._ButtonClick)
			this.Caption = Element_Create('td', tr)
				this.Caption.id = '_sks_Select'
				this.Caption.className = 'skscaption'
				this.Caption.innerHTML = this.Params.Caption || ' '
				this.Caption.setStyle({height:'18px'})
				this.Caption.observe('mousedown', this._ButtonMouseDown)
			td = Element_Create('td', tr)
				td.id = '_sks_Close'
				td.className = 'sksbutton'
				td.setStyle({width:'20px', height:'18px'})
				td.innerHTML = '&#x00d7;'
				td.observe('mousedown', this._ButtonMouseDown)
				td.observe('mouseover', this._ButtonMouseOver)
				td.observe('mouseout', this._ButtonMouseOut)
				td.observe('click', this._ButtonClick)
	this.Body = Element_Create('div', this.Container)
	if (this.Params.Waiter)
		this._SetBodyHTML(Waiter())
	return this
}
SKS_PopupWin.prototype._SetAdjustments = function (event) {
	this.Table.setStyle({width:(this.Body.getWidth()) + 'px'})
	this.Container.setStyle({width:(this.Table.getWidth()) + 'px'})
	if (this.Params.x && this.Params.y) {
		var X = ToInt(this.Params.x, 0)
		var Y = ToInt(this.Params.y, 0)
	} else
	if (this.Params.ShowAtElement) {
		var E = $(this.Params.ShowAtElement)
		var X = AbsLeft(E)
		var Y = AbsTop(E) + E.clientHeight
	} else
	if (event) {
		var X = Event.pointerX(event)
		var Y = Event.pointerY(event)
	} else {
		var X = AbsLeft(this.Container)
		var Y = AbsTop(this.Container)
	}
	CalcInnerViewLeftTop(this.Container, this.Params.AdjustOffset || 20, X, Y)
}
SKS_PopupWin.prototype._SetBodyHTML = function (T, Params) {
	if (Params) {
		this.Body.setStyle({overflow:'auto'})
		if (Params.Width)
			this.Body.setStyle({width:ToInt(Params.Width, 200) + 'px'})
		if (Params.Height)
			this.Body.setStyle({height:ToInt(Params.Height, 200) + 'px'})
	}
	this.Body.innerHTML = T
	this._SetAdjustments()
}
SKS_PopupWin.prototype._SetActiveElement = function (E) {
	if (document.activeButton) {
		document.activeButton.removeClassName('skshilite')
		document.activeButton.removeClassName('sksactive')
	}
	document.activeButton = E
}
SKS_PopupWin.prototype._MouseDown = function (event) {
	var E = Event.element(event);
	if (!E || !(ChkStr(E.tagName).toUpperCase() == 'SCROLLBAR' || E.descendantOf(_sks_DocWin_.Container) || E == _sks_DocWin_.Container))
		window._sks_DocWin_.Hide()
}
SKS_PopupWin.prototype._MouseMove = function (event) {
	if (document.DETmp)
		return false
}
SKS_PopupWin.prototype._MouseUp = function (event) {
	window._sks_DocWin_._SetActiveElement(null)
}
SKS_PopupWin.prototype._ButtonMouseDown = function (event) {
	var E = Event.element(event)
	if (E.id == '_sks_Select')
		Drag_Start(event, window._sks_DocWin_.Container)
	else {
		E.addClassName('sksactive')
		window._sks_DocWin_._SetActiveElement(E)
	}
}
SKS_PopupWin.prototype._ButtonMouseOver = function (event) {
	var E = Event.element(event)
	if (!document.activeButton || document.activeButton == E)
		E.addClassName('skshilite')
	if (document.activeButton && document.activeButton == E)
		E.addClassName('sksactive')
}
SKS_PopupWin.prototype._ButtonMouseOut = function (event) {
	var E = Event.element(event)
	E.removeClassName('skshilite')
	if (document.activeButton && document.activeButton == E)
		E.removeClassName('sksactive')
}
SKS_PopupWin.prototype._ButtonClick = function (event) {
	var E = Event.element(event)
	E.removeClassName('sksactive')
	window._sks_DocWin_._SetActiveElement(null)
	if (E.id == '_sks_Close')
		SKS_PopupWinClose()
//		window._sks_DocWin_.Hide()
	else if (E.id == '_sks_Help')
		window._sks_DocWin_.Help()
	else
		return false
	Event.stop(event)
}
SKS_PopupWin.prototype.Hide = function () {
	Event.stopObserving(document, 'mousedown', this._MouseDown)
	Event.stopObserving(document, 'mouseup', this._MouseUp)
	Element_Remove(this.Container)
	window._sks_DocWin_ = null
	EnableSelection(true)
}
SKS_PopupWin.prototype.Help = function () {
/*
	if (this.HelpDiv) {
		Element_Remove(this.HelpDiv)
		this.HelpDiv = null
	} else {
		this.HelpDiv = Element_Create('div', this.Container)
		this.HelpDiv.setStyle({position:'absolute',left:this.Body.offsetLeft+'px',top:this.Body.offsetTop+'px',
			width:this.Body.clientWidth+'px', height:this.Body.clientHeight+'px',overflow:'auto'})
		Waiter(this.HelpDiv)
	}
*/
}
