// some utils; IE- and Mozilla-Firefox-compatible

// start TCPIP; should be called only in 'offline'-mode
function xDKIStartTCPIP(aWindow,aAdditionalFieldName1,aAdditionalFieldValue1,aAdditionalFieldName2,aAdditionalFieldValue2) {
  try { return aWindow.external.xDKIStartTCPIP(aAdditionalFieldName1,aAdditionalFieldValue1,aAdditionalFieldName2,aAdditionalFieldValue2); } catch(e) { }
}


// http <--> https
function makeSecure_Unsecure(aAction,aURL,s1,s2) {
  var r1,d;

  r1 = new RegExp(s1,'i');
  if (!aAction) 
     return aURL.replace(r1,s2);
  else if (aAction.substr(0,s1.length).toLowerCase() == s1.toLowerCase()) 
     return aAction.replace(r1,s2);
  else if (aAction.substr(0,s2.length).toLowerCase() != s2.toLowerCase()) {
     d = aURL.replace(r1,s2);
     if (d.substr(d.length-aAction.length,aAction.length).toLowerCase() == aAction.toLowerCase()) 
        return d;
     else {
        if ((d.length > 0) && (d.charAt(d.length-1) != '/') && (aAction.charAt(0) != '/')) d+='/';
        return d+aAction;
     }   
  }   
  else 
     return aAction; 
}
function makeSecure(aAction,aURL) {
  return makeSecure_Unsecure(aAction,aURL,'http:','https:');
}
function makeUnsecure(aAction,aURL) {
  return makeSecure_Unsecure(aAction,aURL,'https:','http:');
}


// service call with new page: submit
function xDKIGoto(aApp) {
  with (document.forms[0]) {
       elements['xDKI_Receiver'].value = aApp;
       submit();
  }
  return true;
}
function xDKIGotoSecure(aApp) {
  document.forms[0].action = makeSecure(document.forms[0].action,document.URL);
  return xDKIGoto(aApp);
}
function xDKIGotoUnsecure(aApp) {
  document.forms[0].action = makeUnsecure(document.forms[0].action,document.URL);
  return xDKIGoto(aApp);
}
function xDKIGotoEvent(aEvent,aApp) {
  xDKIStopPropagation(aEvent);

  for (var i=2; i<arguments.length; i+=2) if (arguments[i]) setField(arguments[i],arguments[i+1]);
  return xDKIGoto(aApp);
}
function xDKIGotoField1(aApp) {
  for (var i=1; i<arguments.length; i+=2) if (arguments[i]) setField(arguments[i],arguments[i+1]);
  return xDKIGoto(aApp);
}
function xDKIGotoField1Secure(aApp) {
  document.forms[0].action = makeSecure(document.forms[0].action,document.URL);
  for (var i=1; i<arguments.length; i+=2) if (arguments[i]) setField(arguments[i],arguments[i+1]);
  return xDKIGoto(aApp);
}
function xDKIGotoField1Unsecure(aApp) {
  document.forms[0].action = makeUnsecure(document.forms[0].action,document.URL);
  for (var i=1; i<arguments.length; i+=2) if (arguments[i]) setField(arguments[i],arguments[i+1]);
  return xDKIGoto(aApp);
}
function xDKISubmitField1() {
  for (var i=0; i<arguments.length; i+=2) if (arguments[i]) setField(arguments[i],arguments[i+1]);
  return xDKIGoto(document.forms[0].elements['xDKI_Receiver'].value);
}
function xDKIGoto_Form(aForm,aApp) {
  with (document.forms[aForm]) {
       elements['xDKI_Receiver'].value = aApp;
       submit();
  }
  return true;
}
function xDKIGotoEvent_Form(aForm,aEvent,aApp) {
  xDKIStopPropagation(aEvent);

  for (var i=3; i<arguments.length; i+=2) if (arguments[i]) setField_Form(aForm,arguments[i],arguments[i+1]);
  return xDKIGoto_Form(aForm,aApp);
}
function xDKIGotoField1_Form(aForm,aApp) {
  for (var i=2; i<arguments.length; i+=2) if (arguments[i]) setField_Form(aForm,arguments[i],arguments[i+1]);
  return xDKIGoto_Form(aForm,aApp);
}
function xDKISubmitField1_Form(aForm) {
  for (var i=1; i<arguments.length; i+=2) if (arguments[i]) setField_Form(aForm,arguments[i],arguments[i+1]);
  return xDKIGoto_Form(aForm,document.forms[aForm].elements['xDKI_Receiver'].value);
}
function xDKIGoto_URL(aURL,aMethod) {
  with (document.forms[0]) {
       action = aURL;
       method = aMethod;
       submit();
  }
  return true;
}


// service call within same page: remote procedure call with IFrame; the IFrame will be created from scratch; Variable number of arguments
function xDKICall(aID,aURL,aReceiver,aSessionID,aLanguage) { 
  var i,aOldIFrame,aTempIFrame,aIFrameObj,aIFrameDoc,aIFrameForm,aOldIDiv,aTempIDiv,aIDivObj,aHTML1,aHTML2,
      aURL1,aRegExp,aSrc;

  if (!document.createElement) { return true };

  if (aURL.substr(0,6).toLowerCase() == 'https:') {
     aURL1 = xDKIParseQuery(true,aURL); 
     aRegExp = new RegExp(xDKIParseURL(aURL1).file,'i')
     aSrc = aURL1.replace(aRegExp,'empty.html');
    }   
  else 
     aSrc = '';
  
  // MS-IE (bug for unicode in IE 6 prohibits the else branch below)
  if (xDKIBrowser_IE()) {
     aOldIDiv = xDKIElemId('Div'+aID);
     if (aOldIDiv) document.body.removeChild(aOldIDiv);

     aTempIDiv = document.createElement('div');
     aTempIDiv.id = 'Div'+aID;
     aTempIDiv.style.display = "none";
     aHTML1 = '<iframe src="'+aSrc+'" id="'+aID+'" name="'+aID+'" frameBorder="0px" '+
              ' style="border:0px; background-color:white; position:absolute; left:0; top:0; width:0; height:0;">'+
              '</iframe>';
     aTempIDiv.innerHTML = aHTML1;
     aIDivObj = document.body.appendChild(aTempIDiv);
     aHTML2  = '<html>'+
               '<head><meta http-equiv="content-type" content="text/html; charset=UTF-8" /></head>'+
               '<body><form id="form'+aID+'" method="post" action="'+xDKIParseQuery(true,aURL)+'"><div>'+
               '<input type="hidden" name="xDKI_Receiver" value="'+aReceiver+'" />'+
               '<input type="hidden" name="xDKI_SessionID" value="'+aSessionID+'" />'+
               '<input type="hidden" name="xDKI_Language" value="'+aLanguage+'" />';
     if ((arguments.length == 6) && (typeof(arguments[5]) == 'object') && (arguments[5].constructor.toString().search('Array') != -1)) {
        for (i=0; i<arguments[5].length; i=i+2)
            if ((arguments[5][i]!='xDKI_Receiver')&&(arguments[5][i]!='xDKI_SessionID')&&(arguments[5][i]!='xDKI_Language'))
               aHTML2 += '<input type="hidden" name="'+arguments[5][i]+'" value="'+_quot(arguments[5][i+1])+'" />';
     }
     else {
        for (i=5; i<arguments.length; i+=2) 
            aHTML2 += '<input type="hidden" name="'+arguments[i]+'" value="'+_quot(arguments[i+1])+'" />';
     }
     aHTML2 += '</div></form></body></html>';
     with (document.frames[document.frames.length-1].document) {
          open();
          write(aHTML2);
          close();
          getElementById('form'+aID).submit();
     }
     return true;
  }
  // other browser
  else {
     // create IFrame always from scratch to avoid errors when calling multiple times with different fields
     aOldIFrame = xDKIElemId(aID);
     if (aOldIFrame) document.body.removeChild(aOldIFrame);

     aTempIFrame = document.createElement('iframe');
     with (aTempIFrame) {src = aSrc; id = aID; name = aID; frameBorder = "0px";
                        with (style) { border = "0px"; backgroundColor = "white"; position = "absolute";
                                       left = 0; top = 0; width = 0; height = 0;  }
     }
     aIFrameObj = document.body.appendChild(aTempIFrame);
     aIFrameDoc = xDKIFrameDoc(aIFrameObj,aID);
     if (!aIFrameDoc) return true;

     // form to post Receiver, SessionID, Language and Arguments
     aIFrameForm = aIFrameDoc.createElement("form");
     if (!aIFrameDoc.body) aIFrameDoc.appendChild(aIFrameDoc.createElement("body"));
     aIFrameDoc.body.appendChild(aIFrameForm);
     createHiddenFieldInDoc(aIFrameDoc,aIFrameForm,'xDKI_Receiver',aReceiver);
     createHiddenFieldInDoc(aIFrameDoc,aIFrameForm,'xDKI_SessionID',aSessionID);
     createHiddenFieldInDoc(aIFrameDoc,aIFrameForm,'xDKI_Language',aLanguage);

     if ((arguments.length == 6) && (typeof(arguments[5]) == 'object') && (arguments[5].constructor.toString().search('Array') != -1)) {
        for (i=0; i<arguments[5].length; i=i+2)
            if ((arguments[5][i]!='xDKI_Receiver')&&(arguments[5][i]!='xDKI_SessionID')&&(arguments[5][i]!='xDKI_Language'))
               createHiddenFieldInDoc(aIFrameDoc,aIFrameForm,arguments[5][i],arguments[5][i+1]);
     }
     else {
        for (i=5; i<arguments.length; i+=2) createHiddenFieldInDoc(aIFrameDoc,aIFrameForm,arguments[i],arguments[i+1]);
     }
     aIFrameForm.method="post";
     aIFrameForm.action=xDKIParseQuery(true,aURL);
     aIFrameForm.submit();
     return true;
  }
}
function xDKIFrameDoc(aIFrameObj,aName) {
  if (aIFrameObj.contentDocument)         return aIFrameObj.contentDocument;        // for NS6
  else if (aIFrameObj.contentWindow)      return aIFrameObj.contentWindow.document; // for IE
  else return '';
}


// external call via 'GET' via hidden IFrame; the IFrame will be created from scratch
function xDKIExternalGET(aID,aURL,aLoadedEvent) {
  var aDiv;

  xDKIExternalGETClose(aID);

  aDiv = document.createElement('div');
  aDiv.id = 'Div'+aID;
  aDiv.style.display = "none";
  aDiv.innerHTML = '<iframe src="'+aURL+'" id="'+aID+'" name="'+aID+'" frameBorder="0px"'+
                   ' onload="'+aLoadedEvent+'" onreadystatechange="'+aLoadedEvent+'" ' +
                   ' style="border:0px none transparent; background-color:transparent; position:absolute; left:0px; top:0px; width:0px; height:0px;">'+
                   '</iframe>';
  document.body.appendChild(aDiv);
}
function xDKIExternalGETClose(aID) {
  var aDiv;

  aDiv = elemById('Div'+aID);
  if (aDiv) document.body.removeChild(aDiv);
}


// service call with empty new window as "POST"
function xDKINewWindow(aWindow,aURL,aReceiver,aSessionID,aLanguage) {
  var aDoc,aForm,aHTML2;

  if (!aWindow) aWindow=window.open('');

  // MS-IE (bug for unicode in IE 6 prohibits the else branch below)
  if (xDKIBrowser_IE()) {
     aHTML2 = '<html>'+
              '<head><meta http-equiv="content-type" content="text/html; charset=UTF-8" /></head>'+
              '<body><form name="Form-A1" id="Form-A1" method="post" action="'+xDKIParseQuery(true,aURL)+'">'+
              '<input type="hidden" name="xDKI_Receiver" value="'+aReceiver+'" />'+
              '<input type="hidden" name="xDKI_SessionID" value="'+aSessionID+'" />'+
              '<input type="hidden" name="xDKI_Language" value="'+aLanguage+'" />';
     if ((arguments.length == 6) && (typeof(arguments[5]) == 'object') && (arguments[5].constructor.toString().search('Array') != -1)) {
        for (i=0; i<arguments[5].length; i=i+2)
            if ((arguments[5][i]!='xDKI_Receiver')&&(arguments[5][i]!='xDKI_SessionID')&&(arguments[5][i]!='xDKI_Language'))
               aHTML2 += '<input type="hidden" name="'+arguments[5][i]+'" value="'+_quot(arguments[5][i+1])+'" />';
     }
     else {
        for (i=5; i<arguments.length; i+=2)
            aHTML2 += '<input type="hidden" name="'+arguments[i]+'" value="'+arguments[i+1]+'" />';
     }
     aHTML2 += '</form></body></html>';
     try { aDoc = aWindow.document; } catch(E) { aWindow=window.open(''); aDoc = aWindow.document; }
     with (aDoc) {
          open();
          write(aHTML2);
          close();
          getElementById('Form-A1').submit();
     }
  }
  // other browser
  else {
     try { aDoc = aWindow.document; } catch(E) { aWindow=window.open(''); aDoc = aWindow.document; }
     if (!aDoc.createElement) { return true };

     aForm = aDoc.createElement("form");
     if (!xDKIBrowser_IE5()) {
        if (!aDoc.body) aDoc.appendChild(aDoc.createElement("body"));
        aDoc.body.appendChild(aForm);
     }
     createHiddenFieldInDoc(aDoc,aForm,'xDKI_Receiver',aReceiver);
     createHiddenFieldInDoc(aDoc,aForm,'xDKI_SessionID',aSessionID);
     createHiddenFieldInDoc(aDoc,aForm,'xDKI_Language',aLanguage);
     if ((arguments.length == 6) && (typeof(arguments[5]) == 'object') && (arguments[5].constructor.toString().search('Array') != -1)) {
        for (i=0; i<arguments[5].length; i=i+2)
            if ((arguments[5][i]!='xDKI_Receiver')&&(arguments[5][i]!='xDKI_SessionID')&&(arguments[5][i]!='xDKI_Language'))
               createHiddenFieldInDoc(aDoc,aForm,arguments[5][i],arguments[5][i+1]);
     }
     else {
        for (i=5; i<arguments.length; i+=2) createHiddenFieldInDoc(aDoc,aForm,arguments[i],arguments[i+1]);
     }
     aForm.method="post";
     aForm.action=xDKIParseQuery(true,aURL);
     aForm.submit();
  }
}
function xDKINewWindow_OptionalStream(aWindow,aURL,asStream,aURLAppReplaced,aReceiver,aSessionID,aLanguage) {
  var aHTML2,aTarget;
  if (xDKIBrowser_IE() && (asStream != '')) aTarget = xDKIRandomString(7); 
  if (xDKIBrowser_IE() && (aURLAppReplaced != '')) aURL = aURL.replace(/xDKI\.asp/i,aURLAppReplaced); 
  aHTML2 = '<html>'+
           '<head><meta http-equiv="content-type" content="text/html; charset=UTF-8" />' +
           '<script type="text/javascript">function MyLoad() { document.forms["Form-A1"].submit(); }</script>' +
           '</head><body onload="MyLoad()" style="margin:0px;padding:0px;overflow:hidden">';
  if (xDKIBrowser_IE() && (asStream != ''))
     aHTML2 += '<iframe src="empty.html" name="'+aTarget+'" width="100%" height="100%" border="0px" style="frameBorder:0px"></iframe>';
  aHTML2 += '<form name="Form-A1" method="post"';
  if (xDKIBrowser_IE() && (asStream != ''))
     aHTML2 += ' target="'+aTarget+'"';
  aHTML2 += ' action="'+xDKIParseQuery(true,aURL)+'">'+
           '<input type="hidden" name="xDKI_Receiver" value="'+aReceiver+'" />'+
           '<input type="hidden" name="xDKI_SessionID" value="'+aSessionID+'" />'+
           '<input type="hidden" name="xDKI_Language" value="'+aLanguage+'" />';
  if ((arguments.length == 8) && (typeof(arguments[7]) == 'object') && (arguments[7].constructor.toString().search('Array') != -1)) {
     for (i=0; i<arguments[7].length; i=i+2)
         if ((arguments[7][i]!='xDKI_Receiver')&&(arguments[7][i]!='xDKI_SessionID')&&(arguments[7][i]!='xDKI_Language'))
            aHTML2 += '<input type="hidden" name="'+arguments[7][i]+'" value="'+_quot(arguments[7][i+1])+'" />';
  }
  else {
     for (i=7; i<arguments.length; i+=2)
         aHTML2 += '<input type="hidden" name="'+arguments[i]+'" value="'+arguments[i+1]+'" />';
  }
  aHTML2 += '</form></body></html>';

  with (aWindow.document) {
       open();
       write(aHTML2);
       close();
  }
}


// service call with empty new window as "GET"
function xDKINewWindowGET(aURL,aReceiver,aSessionID,aLanguage) {
  var aFinalURL;
  aFinalURL = xDKIParseQuery(true,aURL)+'?xR='+aReceiver+'&xS='+aSessionID+'&xL='+aLanguage;
  if ((arguments.length == 5) && (typeof(arguments[4]) == 'object') && (arguments[4].constructor.toString().search('Array') != -1)) {
     for (i=0; i<arguments[4].length; i=i+2)
         if ((arguments[4][i]!='xDKI_Receiver')&&(arguments[4][i]!='xDKI_SessionID')&&(arguments[4][i]!='xDKI_Language'))
            aFinalURL += '&'+arguments[4][i]+'='+arguments[4][i+1];
  }
  else {
     for (i=4; i<arguments.length; i+=2)
         aFinalURL += '&'+arguments[i]+'='+arguments[i+1];
  }
  window.open(aFinalURL);
}


// XML HTTP
var XMLHttpFactories = [
    function () {return new XMLHttpRequest()},
    function () {return new ActiveXObject("Msxml2.XMLHTTP")},
    function () {return new ActiveXObject("Msxml3.XMLHTTP")},
    function () {return new ActiveXObject("Microsoft.XMLHTTP")} ];
function xDKIXMLHTTP(aURL,aPostData) { // from www.quirksmode.org (modified)
  var aXMLHTTP,i;

  aXMLHTTP = false;
  for (i=0;i < XMLHttpFactories.length;i++) {
      try { aXMLHTTP = XMLHttpFactories[i]();	}	catch (e) { continue;	}
      break;
  }
  if (aXMLHTTP) {
     with (aXMLHTTP) {
          open(aPostData ? "POST" : "GET",aURL,false);
          setRequestHeader('User-Agent','XMLHTTP/1.0');
          if (aPostData) { setRequestHeader('Content-type','application/x-www-form-urlencoded'); send(aPostData); }
          else send(null);
          return responseText;
     }
  }
  return '';
}
function xDKIXMLHTTP2(aURL,aPostData) {
  var aXMLHTTP,i;

  aXMLHTTP = false;
  for (i=0;i < XMLHttpFactories.length;i++) {
      try { aXMLHTTP = XMLHttpFactories[i]();	}	catch (e) { continue;	}
      break;
  }
  if (aXMLHTTP) {
     with (aXMLHTTP) {
          open(aPostData ? "POST" : "GET",aURL,false);
          setRequestHeader('User-Agent','XMLHTTP/1.0');
          if (aPostData) { setRequestHeader('Content-type','application/x-www-form-urlencoded'); send(aPostData); }
          else send(null);
          return [responseText,responseXML];
     }
  }
  return '';
}


// parse 'abc?def=123&xyz=456' in either ['abc'] or ['def','123','xyz','456']
function xDKIParseQuery(aFirstPart,aQuery) {
  var aUrl,nameValuePair,aResult,i,j;

  if (aQuery == '') return aQuery;

  if (aFirstPart) {
     aUrl = aQuery.split('?');
     return aUrl?(aUrl[0]):'';
  }
  else {
     aResult = new Array();
     aUrl = /\?.+/.exec(aQuery);
     aUrl = aUrl?(aUrl[0].substring(1).split('&')):[];
     for (i=0,j=0;i<aUrl.length;i++,j+=2){
         nameValuePair = aUrl[i].split('=');
         aResult[j] = nameValuePair[0];
         aResult[j+1] = unescape(nameValuePair[1]);
     }
     return aResult;
  }
}
// parse aURL in parts; modified from http://lawrence.ecorp.net
function xDKIParseURL(aURL) { 
  if (aURL.match(/^((http|https):\/)?\/?([^:\/\s]+)((\/\w+)*\/)([\w\-\.]+\.[^#?\s]+)(#[\w\-]+)?$/)) 
     return {url:RegExp['$&'],protocol:RegExp.$2,host:RegExp.$3,path:RegExp.$4,file:RegExp.$6,hash:RegExp.$7};
  else 
     return {url:"",protocol:"",host:"",path:"",file:"",hash:""};
}


// get / replaces a switch; delete / add a URL-Parameter
// alert(xDKIGetSwitch('... -s1="v1" ...' , '-s1')); //--> v1
// alert(xDKIGetSwitch('... s1="v1" ...' , 's1')); //--> v1
// alert(xDKIGetSwitch("... -s1='v1' ..." , '-s1')); //--> v1
// alert(xDKIGetSwitch('... -s1="v\'1" ...' , '-s1')); //--> v1'
// alert(xDKIGetSwitch("... -s1='v\"1' ..." , '-s1')); //--> v1"
// alert(xDKIGetSwitch('... -s1=v1 ...' , '-s1')); //--> v1
// alert(xDKIGetSwitch('... -s1="" ...' , '-s1')); //--> 
// alert(xDKIGetSwitch('... -s1= ...' , '-s1')); //--> 
// alert(xDKIGetSwitch('...' , '-s1')); //--> 
function xDKIGetSwitch(sIn,aSwitch) {
  var p,aResult;

  if (!sIn) return sIn;
  p = new RegExp("([.\n\r]*"+aSwitch+"=\")([^\"]*)(\"[.\n\r]*)","i");
  aResult = sIn.match(p);
  if (aResult != null) return aResult[2];

  p = new RegExp("([.\n\r]*"+aSwitch+"=')([^']*)('[.\n\r]*)","i");
  aResult = sIn.match(p);
  if (aResult != null) return aResult[2];

  p = new RegExp("([.\n\r]*"+aSwitch+"=)([\\S]*)([.\n\r]*)","i");
  aResult = sIn.match(p);
  if (aResult != null) return aResult[2];

  return '';
}
// alert(xDKIReplaceSwitch('-s1="v1" -s2="v2" -s3=' , '-s1' , 'v1new')); //--> -s1="v1new" -s2="v2" -s3=
// alert(xDKIReplaceSwitch('s1="v1" -s2="v2" -s3=' , 's1' , 'v1new')); //--> s1="v1new" -s2="v2" -s3=
// alert(xDKIReplaceSwitch("-s1='v1' -s2='v2' -s3=" , '-s1' , 'v1new')); //--> -s1='v1new' -s2='v2' -s3=
// alert(xDKIReplaceSwitch('-s1="v\'1" -s2="v2" -s3=' , '-s1' , 'v1new')); //--> -s1="v1new" -s2="v2" -s3=
// alert(xDKIReplaceSwitch("-s1='v\"1' -s2='v2' -s3=" , '-s1' , 'v1new')); //--> -s1='v1new' -s2='v2' -s3=
// alert(xDKIReplaceSwitch('-s1=v1 -s2="v2" -s3=' , '-s1' , 'v1new')); //--> -s1="v1new" -s2="v2" -s3=
// alert(xDKIReplaceSwitch('-s1=v1 -s2="v2" -s3=' , '-s1' , '')); //--> -s1="" -s2="v2" -s3=
// alert(xDKIReplaceSwitch('-s1="" -s2="v2" -s3=' , '-s1' , 'v1new')); //--> -s1="v1new" -s2="v2" -s3=
// alert(xDKIReplaceSwitch('-s1= -s2="v2" -s3=' , '-s1' , 'v1new')); //--> -s1="v1new" -s2="v2" -s3=
// alert(xDKIReplaceSwitch('-s2="v2" -s3=' , '-s1' , 'v1new')); //--> -s2="v2" -s3= -s1="v1new"
// alert(xDKIReplaceSwitch('-s2="v2" -s3=' , '-s1' , '')); //--> -s2="v2" -s3= -s1=""
function xDKIReplaceSwitch(sIn,aSwitch,aNewValue) {
  var p;

  if (!sIn) return aSwitch+'="'+aNewValue+'"';
  p = new RegExp("([.\n\r]*"+aSwitch+"=\")[^\"]*(\"[.\n\r]*)","i");
  if (p.test(sIn)) return sIn.replace(p,'$1'+aNewValue+'$2');

  p = new RegExp("([.\n\r]*"+aSwitch+"=')[^']*('[.\n\r]*)","i");
  if (p.test(sIn)) return sIn.replace(p,'$1'+aNewValue+'$2');

  p = new RegExp("([.\n\r]*"+aSwitch+"=)[\\S]*([.\n\r]*)","gi");
  if (p.test(sIn)) return sIn.replace(p,'$1"'+aNewValue+'"$2');
  
  return sIn+' '+aSwitch+'="'+aNewValue+'"';
}
// alert(xDKIDeleteURLParameter('http://...?s1=v1&s2=v2&s3=v3' , ['s1','s2'])); //--> http://...?s3=v3
// alert(xDKIDeleteURLParameter('http://...?s1=v1&s2=v2' , ['s1','s2'])); //--> http://...
// alert(xDKIDeleteURLParameter('http://...?s1=v1&s2=v2' , ['s1'])); //--> http://...?s2=v2
// alert(xDKIDeleteURLParameter('http://...?s1=v1&s2=v2&s3=v3' , ['s2'])); //--> http://...?s1=v1&s3=v3
function xDKIDeleteURLParameter(sIn,aParameterList) {
  var i,s,p;
  
  if (!sIn) return sIn; 
  s = sIn;
  for (i=0;i < aParameterList.length;i++) {
      p = new RegExp("([.]*)(\\?|&)"+aParameterList[i]+"=[^&$]*(.*)","i");
      if (p.test(s)) s = s.replace(p,'$1$2$3').replace(/&&/gi,'&').replace(/\?&/gi,'?').replace(/&$/gi,'').replace(/\?$/gi,'');
  }    
  
  return s;
}
// alert(xDKIAddURLParameter('' , 's1=v1')); //--> ?s1=v1
// alert(xDKIAddURLParameter('http://...' , 's1=v1')); //--> http://...?s1=v1
// alert(xDKIAddURLParameter('http://...?' , 's1=v1')); //--> http://...?s1=v1
// alert(xDKIAddURLParameter('http://...?s1=v1' , 's2=v2')); //--> http://...?s1=v1&s2=v2
function xDKIAddURLParameter(sIn,aParameterValue) {
  if (!sIn) return '?'+aParameterValue;  
  if (sIn.search(/\?/) < 0) return sIn+'?'+aParameterValue; 
  if (sIn.search(/\?./) < 0) return sIn+aParameterValue; 
  return sIn+'&'+aParameterValue;
}


// tab on enter, focus etc.
function xDKIDefaultFocus(aDoc) {
  var fieldFound,form,e;
  fieldFound = false;
  form = aDoc.forms[0];
  for (e=0; e<form.elements.length; e++) {
    if (xDKIVisibleFormElement(form.elements[e])) {
       fieldFound = true;
       break;
    }
  }
  if (fieldFound) form.elements[e].focus();
  return fieldFound;
}
function xDKIGetNextElement(field) {
  var fieldFound,form,e;
  if (!field) return field;
  fieldFound = false;
  form = field.form;
  if (!form || !form.elements) form = document.forms[0];
  for (e=0;e<form.elements.length;e++) {
      if (fieldFound && xDKIVisibleFormElement(form.elements[e])) break;
      if (field == form.elements[e]) fieldFound = true;
  }
  return form.elements[e % form.elements.length];
}
function xDKIGetNextElementId(aId) {
  return xDKIGetNextElement(xDKIElemId(aId));
}
function xDKIPressed(evt,keys) {
  var keyCode,i;

  if (!evt) evt = window.event;
  keyCode = document.layers ? evt.which : evt.keyCode;
  for (i = 0; i<keys.length;i++) if (keyCode == keys[i]) return true;
  return false;
}
function xDKIDigitPressed(evt) {
  if (!evt) evt = window.event;
  return xDKIPressed(evt,[48,49,50,51,52,53,54,55,56,57,58,59,96,97,98,99,100,101,102,103,104,105])
}
function xDKIAlphaNumericPressed(evt) {
  var keyCode,key;

  if (!evt) evt = window.event;
  keyCode = document.layers ? evt.which : evt.keyCode;
  key = String.fromCharCode(keyCode).toLowerCase();
  return ("abcdefghijklmnopqrstuvwxyz0123456789").indexOf(key) >= 0;
}
function xDKIBlankPressed(evt) {
  if (!evt) evt = window.event;

  return xDKIPressed(evt,[32])
}
function xDKINewLinePressed(evt) {
  if (!evt) evt = window.event;

  return xDKIPressed(evt,[13])
}
function xDKIExecPressed(evt) {
  if (!evt) evt = window.event;

  if (xDKIBrowser_IE()) {
     if (evt.type == 'keypress') return (xDKIBlankPressed(evt) || xDKINewLinePressed(evt));
     else return false;
  }
  else {
     if (evt.type == 'keyup') return (xDKIBlankPressed(evt) || xDKINewLinePressed(evt));
     else return false;
  }
}
function xDKICtrlPressed(e,keys) {
  var pressedKey,i;

  if (!e) e = window.event;
  if (!e.ctrlKey ) return false;
  pressedKey = String.fromCharCode(e.keyCode).toUpperCase();
  for (i = 0;i<keys.length;i++) if (pressedKey == keys[i]) return true;
  return false;
}
function xDKIShiftPressed(e,keys) {
  var i;

  if (!e) e = window.event;
  if (!e.shiftKey ) return false;
  for (i = 0;i<keys.length;i++) if (e.keyCode == keys[i]) return true;
  return false;
}
function xDKITabOnEnter(field,evt,aCounter) {
  var aNextElem,i;
  if (!evt) evt = window.event;
  if (xDKINewLinePressed(evt)) {
     if (aCounter) {
        aNextElem = field; 
        for (i=1;i<=aCounter;i++) aNextElem = xDKIGetNextElement(aNextElem);
     }   
     else aNextElem = xDKIGetNextElement(field);
     if (aNextElem) { aNextElem.focus(); if (typeof(aNextElem["select"]) == 'function') aNextElem.select(); }
     return false;
  }
  return true;
}
function xDKITabOnEnterId(aId,evt,aCounter) {
  var aNextElem;
  if (aCounter) return xDKITabOnEnter(elemById(aId),evt,aCounter);
  if (!evt) evt = window.event;
  if (xDKINewLinePressed(evt)) {
     aNextElem = xDKIGetNextElementId(aId);
     if (aNextElem) aNextElem.focus(); if (typeof(aNextElem["select"]) == 'function') aNextElem.select();
     return false;
  }
  return true;
}


// not undef
function xDKINotUndef(obj) {
  return typeof obj != "undefined";
}


// functionstack for AddEvent / RemoveEvent
// should be used insted of "new Function(aFunctionVars,aFunctionLiteral)" to get always the same function(-pointer)
var xDKIFunctionStack = '';
function xDKIGetFunction(aFunctionVars,aFunctionLiteral) {
  var i,aFunction;

  if (!xDKIFunctionStack) xDKIFunctionStack = [];
  for (i = 0; i <= xDKIFunctionStack.length-1;i++)
      if ((xDKIFunctionStack[i][0] == aFunctionVars) && (xDKIFunctionStack[i][1] == aFunctionLiteral))
         return xDKIFunctionStack[i][2];
  aFunction = new Function(aFunctionVars,aFunctionLiteral);
  xDKIFunctionStack[xDKIFunctionStack.length] = [aFunctionVars,aFunctionLiteral,aFunction];
  return aFunction;
}


// events
function xDKIStopPropagation(aEvent) {
  if (aEvent) {
     if (xDKINotUndef(aEvent.cancelBubble) && !aEvent.preventDefault) {
        aEvent.cancelBubble = true;
        aEvent.returnValue = false;
     }
     else if (xDKINotUndef(aEvent.preventDefault)) {
        aEvent.preventDefault();
        aEvent.stopPropagation();
     }
     if (xDKINotUndef(aEvent.returnValue))
        aEvent.returnValue = false;
  }
}
function xDKIAddEvent(aObject,aEvent,aFunction,aFlag) {
  if (aObject.addEventListener) {
     aObject.addEventListener(aEvent,aFunction,aFlag);
     return true;
  }
  else if (aObject.attachEvent) {
     aObject["e"+aEvent+aFunction] = aFunction;
     aObject[aEvent+aFunction] = function() { aObject["e"+aEvent+aFunction](window.event); }
     return aObject.attachEvent("on"+aEvent,aObject[aEvent+aFunction]);
  }
  else
     return false;
}
function xDKIRemoveEvent(aObject,aEvent,aFunction,aFlag) {
  var aResult;

  if (aObject.removeEventListener) {
     aObject.removeEventListener(aEvent,aFunction,aFlag);
     return true;
  }
  else if (aObject.detachEvent) {
     if (xDKINotUndef(aObject[aEvent+aFunction])) {
        aResult = aObject.detachEvent("on"+aEvent,aObject[aEvent+aFunction]);
        aObject[aEvent+aFunction] = null;
        aObject["e"+aEvent+aFunction] = null;
        return aResult;
     }
     else
        return false;
  }
  else
     return false;
}
function xDKIAddLoadEvent(aFunc) {
  var aOldFunc;
  
  if (typeof window.onload != 'function') window.onload = aFunc;
  else {
     aOldFunc = window.onload;
     window.onload = function() { aOldFunc(); aFunc();}
  }   
}
function xDKIAddUnLoadEvent(aFunc) {
  var aOldFunc;
  
  if (typeof window.onunload != 'function') window.onunload = aFunc;
  else {
     aOldFunc = window.onunload;
     window.onunload = function() { aOldFunc(); aFunc();}
  }   
}


// selection in a radiobutton-group / in a checkbox
function xDKISelectRBEx(aId,aClassPrefix,aActIdPostfix,aNoOfRadios) {
  window.status = '';
  for (var i=1; i<=aNoOfRadios; i++)
      if (i != aActIdPostfix) xDKIChangeClassNameId(aId+i,aClassPrefix+'_on',aClassPrefix+'_off');
  xDKIChangeClassNameId(aId+aActIdPostfix,aClassPrefix+'_off',aClassPrefix+'_on');
  elemById(aId).value = aActIdPostfix;
}
function xDKISelectCBEx(aId,aClassPrefix) {
  window.status = '';
  if (valueById('CB'+aId)) {
     xDKIChangeClassNameId('A'+aId,aClassPrefix+'_on',aClassPrefix+'_off');
     elemById('CB'+aId).value = '';
  }
  else {
     xDKIChangeClassNameId('A'+aId,aClassPrefix+'_off',aClassPrefix+'_on');
     elemById('CB'+aId).value = '1';
  }
}
function xDKISelectRB(aImgId,aSelClass,aUnSelclass,aRBID) {
  elemById(aRBID).checked = true;
  elemById(aRBID).focus();
  elemById(aRBID+aImgId).className = aSelClass;
  for (var i=4; i<arguments.length; i++) {
      elemById(arguments[i]).checked = false;
      elemById(arguments[i]+aImgId).className = aUnSelclass;
  }
  return true;
}
function xDKISelectCB1(aImgId,aSelClass,aUnSelclass,aCBID,aValue) {
  if (aValue) {
     elemById(aCBID).checked=true;
     elemById(aCBID).setAttribute("value","on");
     elemById(aCBID+aImgId).className = aSelClass;
  }
  else {
     elemById(aCBID).checked=false;
     elemById(aCBID).setAttribute("value","");
     elemById(aCBID+aImgId).className = aUnSelclass;
  }
}
function xDKISelectCB(aImgId,aSelClass,aUnSelclass,aCBID,aValue) {
  if (aValue) xDKISelectCB1(aImgId,aSelClass,aUnSelclass,aCBID,aValue == '1');
  else {
     xDKISelectCB1(aImgId,aSelClass,aUnSelclass,aCBID,!valueById(aCBID));
     elemById(aCBID).focus();
  }
  return true;
}
function xDKISelectCB1_NoImg(aImgId,aCBID,aValue) {
  if (aValue) {
     elemById(aCBID).checked=true;
     elemById(aCBID).setAttribute("value","on");
  }
  else {
     elemById(aCBID).checked=false;
     elemById(aCBID).setAttribute("value","");
  }
}
function xDKISelectCB_NoImg(aImgId,aCBID,aValue) {
  if (aValue) xDKISelectCB1_NoImg(aImgId,aCBID,aValue == '1');
  else {
     xDKISelectCB1_NoImg(aImgId,aCBID,!valueById(aCBID));
     elemById(aCBID).focus();
  }
  return true;
}
function xDKISequence_SpecialFirstElem(aLen,aFirstElem) { // xDKISequence_SpecialFirstElem(7,6) --> 6,1,2,3,4,5,7
  var i,j,a1,a2;

  a1 = new Array(aLen);
  for (i = 1;i <= aLen;i++) a1[i-1] = i;

  a2 = new Array(aLen);
  a2[0] = aFirstElem;
  j = 1;
  for (i = 0;i < a1.length;i++) {
      if (a1[i] == aFirstElem) continue;
      a2[j++] = a1[i];
  }
  return a2.toString();
}

// disable / enable a set of elements
function xDKIDisableId(aId) {
  for (var i=1; i<arguments.length; i++)
    try
    {
      if (arguments[i]) elemById(aId+arguments[i]).disabled = true;
    }catch(e){}
}
function xDKIEnableId(aId) {
  for (var i=1; i<arguments.length; i++)
    try
    {
      if (arguments[i]) elemById(aId+arguments[i]).disabled = false;
    }catch(e){}
}


// elem / exist / show / hide / focus by Id
function xDKIElemId(aID,aWindow) {
  var w;
  if (!aWindow) w = self;
  else          w = aWindow;
  with (w)
       if (document.getElementById) return document.getElementById(aID);
       else if (document.layers) return document.layers[aID];
       else if (document.all) return document.all[aID];
}
function xDKIExistId(aID,aWindow) {
  return xDKIElemId(aID,aWindow);
}
function xDKIShowId(aID,aWindow) {
  var w;
  if (!aWindow) w = self;
  else          w = aWindow;
  with (w)
       if (document.getElementById) document.getElementById(aID).style.visibility = "visible";
       else if (document.layers) document.layers[aID].visibility = "show";
       else if (document.all) document.all[aID].style.visibility = "visible";
}
function xDKIShowIdAt(aID,x,y,aWindow) {
  var w;
  if (!aWindow) w = self;
  else          w = aWindow;
  with (w)
       if (document.getElementById) {
          with (document.getElementById(aID).style) { visibility = "visible";
               if (navigator.appName.indexOf("Microsoft")!=-1) { posLeft = x; posTop = y; } else { left = x; top = y; } }
       }
       else if (document.layers) {
          with (document.layers[aID]) { visibility = "show"; style.Left = x; style.Top = y; }
       }
       else if (document.all) {
          with (document.all[aID].style) { visibility = "visible"; posLeft = x; posTop = y; }
       }
}
function xDKIShowIdEx(aID,aWindow) {
  var w;
  if (!aWindow) w = self;
  else          w = aWindow;
  with (w)
       if (document.getElementById) {
          with (document.getElementById(aID).style) { visibility = "visible"; display = "block"; }
       }
       else if (document.layers) {
          with (document.layers[aID]) { visibility = "show"; display = "block"; }
       }
       else if (document.all) {
          with (document.all[aID].style) { visibility = "visible"; display = "block"; }
       }
}
function xDKIHideId(aID,aWindow) {
  var w;
  if (!aWindow) w = self;
  else          w = aWindow;
  with (w)
       if (document.getElementById) { if (document.getElementById(aID)) document.getElementById(aID).style.visibility = "hidden"; }
       else if (document.layers) document.layers[aID].visibility = "hide";
       else if (document.all) document.all[aID].style.visibility = "hidden";
}
function xDKIHideIdEx(aID,aWindow) {
  var w;
  if (!aWindow) w = self;
  else          w = aWindow;
  with (w)
       if (document.getElementById) {
          if (document.getElementById(aID))
             with (document.getElementById(aID).style) { visibility = "hidden"; display = "none"; }
       }
       else if (document.layers) {
          with (document.layers[aID]) { visibility = "hide"; display = "none"; }
       }
       else if (document.all) {
          with (document.all[aID].style) { visibility = "hidden"; display = "none"; }
       }
}
function xDKIVisible(aElem) {
  if (xDKIExist(aElem)) {
     if (document.getElementById) { return (aElem.style.visibility != "hidden") && (aElem.style.display != "none"); }
     else if (document.layers) return aElem.visibility != "hide";
     else return (aElem.style.visibility != "hidden") && (aElem.style.display != "none");
  }
  else return false;
}
function xDKIVisibleId(aID,aWindow) {
  var w;
  if (!aWindow) w = self;
  else          w = aWindow;
  return xDKIVisible(xDKIElemId(aID,w));
}
function xDKIVisibleEx(aElem) {
  if (xDKIExist(aElem))
     return (aElem.style.visibility && (aElem.style.visibility != "hidden")) &&
            (aElem.style.display && (aElem.style.display != "none"));
  else return false;
}
function xDKIVisibleIdEx(aID,aWindow) {
  var w;
  if (!aWindow) w = self;
  else          w = aWindow;
  return xDKIVisibleEx(xDKIElemId(aID,w));
}
function xDKIVisibleFormElement(aElem) {
  if ((aElem.type == 'hidden') || (aElem.style.visibility == "hidden") || (aElem.style.display == "none")) return false;
  while (aElem = aElem.parentNode)
        if (aElem.style && ((aElem.style.visibility == "hidden") || (aElem.style.display == "none"))) return false; 
  return true;
}
function xDKIVisibleFormElementId(aID,aWindow) {
  var w;
  if (!aWindow) w = self;
  else          w = aWindow;
  return xDKIVisibleFormElement(xDKIElemId(aID,w));
}
function xDKIFocusId(aID,aWindow) {
  var e;
  e = xDKIElemId(aID,aWindow);
  if (e) e.focus();
}


// exist / show / hide / focus by elem
function xDKIExist(aElem) {
  return aElem;
}
function xDKIShow(aElem) {
  if (xDKIExist(aElem)) {
     if (document.getElementById) aElem.style.visibility = "visible";
     else if (document.layers) aElem.visibility = "show";
     else if (document.all) aElem.style.visibility = "visible";
  }
}
function xDKIShowEx(aElem) {
  if (xDKIExist(aElem)) {
     if (document.getElementById) { aElem.style.visibility = "visible"; display = "block"; }
     else if (document.layers) { aElem.visibility = "show"; display = "block"; }
     else if (document.all) { aElem.style.visibility = "visible"; display = "block"; }
  }
}
function xDKIHide(aElem) {
  if (xDKIExist(aElem)) {
     if (document.getElementById) aElem.style.visibility = "hidden";
     else if (document.layers) aElem.visibility = "hide";
     else if (document.all) aElem.visibility = "hidden";
  }
}
function xDKIHideEx(aElem) {
  if (xDKIExist(aElem)) {
     if (document.getElementById) with (aElem.style) { visibility = "hidden"; display = "none"; }
     else if (document.layers) with (aElem) { visibility = "hide"; display = "none"; }
     else if (document.all) with (aElem) { visibility = "hidden"; display = "none"; }
  }
}
function xDKIFocus(aElem) {
  if (xDKIExist(aElem))
     eElem.focus();
}
function xDKIIsRow(aElem) {
  return aElem.nodeName.toUpperCase() == 'TR'
}


// ranges: is an Element in a range?
function xDKIIsInRange(aRange,anElement,aDelim) {
  if (!aRange) return false;
  return xDKIIsIn(aRange.split(aDelim),anElement);
}
// ranges: make a new range form range1 with no elements from range2
function xDKINewRange1NoIntersect2(aRange1,aRange2,aDelim) {
  var anArray1,anArray2,aResult,i,j,anElement,aFound;

  if (!aRange2) return aRange1;
  if (!aRange1) return '';
  aResult = '';
  anArray1 = aRange1.split(aDelim);
  anArray2 = aRange2.split(aDelim);
  for (i = 0; i < anArray1.length; i++) {
      anElement = anArray1[i];
      aFound = false;
      for (j = 0; j < anArray2.length; j++) if (anElement == anArray2[j]) { aFound = true; break; }
      if (!aFound) aResult += anElement + aDelim;
  }
  return aResult;
}


// childNodes
function _childNodes(aNode,aIndex) {
  var aCounter,aChildNode,l;

  if (aNode) {
     aCounter = -1;
     l = aNode.childNodes.length;
     for (var i = 0;i < l;i++) {
         aChildNode = aNode.childNodes[i];
         // remove empty whitespace-textnodes for IE-comptibility
         if ((aChildNode.nodeType == 1) ||
             ((aChildNode.nodeType == 3) && ((/\S/g).test(aChildNode.nodeValue)))) {
            aCounter++;
            if (aCounter == aIndex) return aNode.childNodes[i];
         }
     }
  }
  return null;
}
function _childNodes_length(aNode) {
  var aCounter,aChildNode,l;

  aCounter = 0;
  if (aNode) {
     l = aNode.childNodes.length;
     for (var i = 0;i < l;i++) {
         aChildNode = aNode.childNodes[i];
         if ( (aChildNode.nodeType == 1) ||
             ((aChildNode.nodeType == 3) && ((/\S/g).test(aChildNode.nodeValue)))) {
            aCounter++;
         }
     }
  }
  return aCounter;
}


// shortcut for document.getElementById(aID) resp. document.getElementById(aID).value
function elemById(aId) {
  if (aId) return document.getElementById(aId);
  else return '';
}
function valueById(aId) {
  return elemById(aId).value;
}
function sonElemById(aId,aParent) {
  var i,aChildElements,anElement;

  if (aParent.id == aId) return aParent;
  aChildElements = aParent.childNodes;
  for (i = 0; i < aChildElements.length; i++) {
      anElement = sonElemById(aId,aChildElements[i]);
      if (anElement) return anElement;
  }
  return null;
}


// shortcut for document.createTextNode
function makeTextNode(aNode,aText) {
  return aNode.appendChild(document.createTextNode(aText));
}


// position
function xDKIPositionId(aId) {
  return xDKIPosition(elemById(aId))
}
function xDKIPosition(aObject) { // from www.quirksmode.org (modified)
  var l,t;

  l = t = 0;
  if (aObject.offsetParent) 
     do { l += aObject.offsetLeft;
           t += aObject.offsetTop;
     } while (aObject = aObject.offsetParent); 
  return [l,t];
     }
function xDKIPositionEx(aObject) { // compatible to xDKIMousePosition(), when scolling within a parent element has occurred
  var l,t;

  l = t = 0;
  if (aObject.offsetParent) 
     do { l += aObject.offsetLeft-aObject.scrollLeft;
          t += aObject.offsetTop-aObject.scrollTop; 
     } while (aObject = aObject.offsetParent); 
  return [l,t];
}


// pt in rect
function PTInRect(x,y,l,t,r,b) {
  return (l <= x) && (t <= y) && (r >= x) && (b >= y)
}


// mouse-position
function xDKIMousePosition(e) { // from www.quirksmode.org (modified)
	 if (!e) e = window.event;
	 if (e.pageX || e.pageY) return [e.pageX,e.pageY];
	 else if (e.clientX || e.clientY) return [e.clientX + document.body.scrollLeft	+ document.documentElement.scrollLeft,
		                                         e.clientY + document.body.scrollTop		+ document.documentElement.scrollTop];
  else return [0,0];
}


// int to pixel
function px(i) {
  return i+'px';
}


// remove whitespace
function removeWhitespace(aNode) {
  var regex = /\S/,nodes = aNode.childNodes;
  for (var i = 0; i < nodes.length; i++)
      if ((nodes[i].nodeType == 3) && (!regex.test(nodes[i].nodeValue))) aNode.removeChild(nodes[i--]);
      else if (nodes[i].nodeType == 1) removeWhitespace(nodes[i]);
}


// xDKIEncode2 / xDKIDecode2: 'A$ % = BB L &A%=BBL??/(' --> 'A$ %1 %8 BB L %6A%1%8BBL??/('
// changes only %'"<>&;,= to %1,%2,...,%8,%9
function xDKIEncode2(s,amps) {
  var aResult,c,i;

  if (!s) return '';

  if (amps) {
     s = s.replace(/&#39;/gi,"'");
     s = s.replace(/&quot;/gi,'"');
     s = s.replace(/&lt;/gi,'<');
     s = s.replace(/&gt;/gi,'>');
     s = s.replace(/&amp;/gi,'&');
  }
  aResult = '';
  for (i = 0; i < s.length; i++) {
      c = s.charAt(i);
      switch (c) {
        case '%': { aResult += '%1'; break; }
        case "'": { aResult += '%2'; break; }
        case '"': { aResult += '%3'; break; }
        case '<': { aResult += '%4'; break; }
        case '>': { aResult += '%5'; break; }
        case '&': { aResult += '%6'; break; }
        case ';': { aResult += '%7'; break; }
        case '=': { aResult += '%8'; break; }
        case ',': { aResult += '%9'; break; }
        default: aResult += c;
      }
  }
  return aResult;
}
function xDKIDecode2(s,amps) {
  var aResult,c,i;

  if (!s) return '';

  aResult = '';
  i = 0;
  while (i < s.length) {
        c = s.charAt(i);
        if (c == '%') {
           i++;
           switch (s.charAt(i)) {
             case '1': { aResult += '%'; break; }
             case '2': { if (amps) aResult += '&#39;';  else aResult += "'"; break; }
             case '3': { if (amps) aResult += '&quot;'; else aResult += '"'; break; }
             case '4': { if (amps) aResult += '&lt;';   else aResult += '<'; break; }
             case '5': { if (amps) aResult += '&gt;';   else aResult += '>'; break; }
             case '6': { if (amps) aResult += '&amp;';  else aResult += '&'; break; }
             case '7': { aResult += ';'; break; }
             case '8': { aResult += '='; break; }
             case '9': { aResult += ','; break; }
           }
        }
        else aResult += c;
        i++;
  }
  return aResult;
}


// URLEncode
function xDKIURLEncode(s) {
  return escape(s.replace(/\+/g,"_*13523*_").replace(/ /g,"+")).replace(/_\*13523\*_/g,"%2B");
}


// " --> &quot;
function _quot(s) { 
  return s.toString().replace(/"/g,'&quot;'); 
}


// unicode to hex and vice versa
function xDKIUnicodeToHex(s) {
  var aResult,s1,i;
  if (s.length <= 0) return '';
  aResult = '$';

  for (i = 0; i < s.length; i++) {
      s1 = Number(s.charCodeAt(i)).toString(16).toUpperCase();
      while (s1.length < 4) s1 = '0'+s1;
      aResult += s1;
  }
  return aResult;
}
function xDKIHexToUnicode(s) {
  var aResult,i;
  aResult = '';
  if (s.length > 4) 
     for (i = 1; i < s.length; i+=4) 
         aResult += String.fromCharCode(parseInt(s.substr(i,4),16));
  return aResult;
}


// browser-check
var _isie = 0;
var _isie5 = 0;
var _isie6 = 0;
var _isie7 = 0;
var _isie8 = 0;
var _isie6up = 0;
var _isie8up = 0;
var _isxDKIBrowser = 0;
var _isChrome = 0;
function xDKIBrowser_IE() {
  if (_isie == 0) _isie = (window.navigator.userAgent.toLowerCase().indexOf('msie') >= 0) ? 1 : -1;
  return _isie == 1;
}
function xDKIBrowser_IE5() {
  if (_isie5 == 0) _isie5 = (window.navigator.userAgent.toLowerCase().indexOf('msie 5') >= 0) ? 1 : -1;
  return _isie5 == 1;
}
function xDKIBrowser_IE6() {
  if (_isie6 == 0) _isie6 = (window.navigator.userAgent.toLowerCase().indexOf('msie 6') >= 0) ? 1 : -1;
  return _isie6 == 1;
}
function xDKIBrowser_IE7() {
  if (_isie7 == 0) _isie7 = (window.navigator.userAgent.toLowerCase().indexOf('msie 7') >= 0) ? 1 : -1;
  return _isie7 == 1;
}
function xDKIBrowser_IE8() {
  if (_isie8 == 0) _isie8 = (window.navigator.userAgent.toLowerCase().indexOf('msie 8') >= 0) ? 1 : -1;
  return _isie8 == 1;
}
function xDKIBrowser_IE6Up() {
  if (_isie6up == 0) {
     if (xDKIBrowser_IE() && (6 <= parseInt(window.navigator.userAgent.substr(window.navigator.userAgent.toLowerCase().indexOf('msie ')+5))))
        _isie6up = 1;
     else
        _isie6up = -1;
  }
  return _isie6up == 1;
}
function xDKIBrowser_IE8Up() {
  if (_isie8up == 0) {
     if (xDKIBrowser_IE() && (8 <= parseInt(window.navigator.userAgent.substr(window.navigator.userAgent.toLowerCase().indexOf('msie ')+5))))
        _isie8up = 1;
     else
        _isie8up = -1;
  }
  return _isie8up == 1;
}
function xDKIBrowser_IENUp(N) {
  if (xDKIBrowser_IE() && (N <= parseInt(window.navigator.userAgent.substr(window.navigator.userAgent.toLowerCase().indexOf('msie ')+5))))
     return true;
  else
     return false;
}
function xDKIBrowser_Chrome() {
  if (_isChrome == 0) _isChrome = (window.navigator.userAgent.toLowerCase().indexOf('chrome') >= 0) ? 1 : -1;
  return _isChrome == 1;
}
function xDKIBrowser() {
  if (_isxDKIBrowser == 0) try { if (window.external.xDKIBrowser() == 'xDKIBrowser') _isxDKIBrowser = 1 } catch(e) { _isxDKIBrowser = -1 } // running below xDKIBrowser
  return _isxDKIBrowser == 1;
}
function xDKIBrowser_SetBrowserForm(aFieldName) {
  if (xDKIBrowser()) elemById(aFieldName).value = window.external.xDKIBrowserForm(); 
}
function xDKIBrowser_Loaded() {
  if (xDKIBrowser()) window.external.xDKILoaded(); 
}
function xDKIBrowser_Loading() {
  return xDKIBrowser() && window.external.xDKIBrowserLoading()
}
function xDKIBrowser_SpecialPosition() {
  return xDKIBrowser() && window.external.xDKIBrowserSpecialPosition()
}


// set and create hidden field
function setField(aName,aValue) {
   with (document.forms[0]) {
        if (!elements[aName]) createHiddenField(aName,aValue);
        else elements[aName].value = aValue;
   }
}
function setField_Form(aForm,aName,aValue) {
   with (document.forms[aForm]) {
        if (!elements[aName]) createHiddenFieldInDoc(document,document.forms[aForm],aName,aValue);
        else elements[aName].value = aValue;
   }
}
function createHiddenField(aName,aValue,aRefNodeToInsertBefore) {
  var aNode;

  aNode = document.createElement("input");
  with (aNode) { type = 'hidden'; name = aName; value = aValue; }
  if (aRefNodeToInsertBefore) document.forms[0].insertBefore(aNode,aRefNodeToInsertBefore);
  else document.forms[0].appendChild(aNode);
}
function createHiddenFieldEx(aName,aValue,aRefNodeToInsertBefore) {
  var aNode;
  
  aNode = elemById(aName);
  if (!aNode) {
     aNode = document.createElement("input");
     with (aNode) { type = 'hidden'; name = aName; id = aName; value = aValue; }
     if (aRefNodeToInsertBefore) document.forms[0].insertBefore(aNode,aRefNodeToInsertBefore);
     else document.forms[0].appendChild(aNode);
  }   
  else aNode.value = aValue;
}
function createHiddenFieldInDoc(aDoc,aForm,aName,aValue,aRefNodeToInsertBefore) {
  var aNode;
  
  aNode = aDoc.createElement("input");
  with (aNode) { type = 'hidden'; id = aName; name = aName; value = aValue; }
  if (aRefNodeToInsertBefore) aForm.insertBefore(aNode,aRefNodeToInsertBefore);
  else aForm.appendChild(aNode);
}


// width / height
var _ScrollBarWidth = -1;
function xDKIWindowWidth(w,aDefaultWidth) {
  if (!w) w = window;
  if (w.document.compatMode && (w.document.compatMode != "BackCompat"))
     return w.document.documentElement.clientWidth;
  else if (w.document.body && (typeof(w.document.body.clientWidth) == 'number') && (w.document.body.clientWidth != 0))
     return w.document.body.clientWidth;
  else if (!xDKIBrowser_Chrome() && w.document.documentElement && (typeof(w.document.documentElement.clientWidth) == 'number') && (w.document.documentElement.clientWidth != 0))
     return w.document.documentElement.clientWidth;
  else if (typeof(w.innerWidth) == 'number')
     return w.innerWidth;
  else if (aDefaultWidth)
     return aDefaultWidth;
  else
     return 300;
}
function xDKIWindowWidthInclScrollbar(w) {
  return xDKIWindowWidth(w)+xDKIScrollBarWidth();
}
function xDKIWindowHeight(w,aDefaultHight) {
  if (!w) w = window;
  if (w.document.compatMode && (w.document.compatMode != "BackCompat"))
     return w.document.documentElement.clientHeight;
  else if (w.document.body && (typeof(w.document.body.clientHeight) == 'number') && (w.document.body.clientHeight != 0))
     return w.document.body.clientHeight;
  else if (!xDKIBrowser_Chrome() && w.document.documentElement && (typeof(w.document.documentElement.clientHeight) == 'number') && (w.document.documentElement.clientHeight != 0))
     return w.document.documentElement.clientHeight;
  else if (typeof(w.innerHeight) == 'number')
     return w.innerHeight;
  else if (aDefaultHight)
     return aDefaultHight;
  else
     return 300;
}
function xDKIWindowHeightInclScrollbar(w) {
  return xDKIWindowHeight(w)+xDKIScrollBarWidth();
}
function xDKIGetWindowSize(w) {
  return [xDKIWindowWidth(w),xDKIWindowHeight(w)];
}
function xDKIWindowScrollLeft(w) {
  if (!w) w = window;
  if (w.document.compatMode && w.document.compatMode != "BackCompat")
     return document.documentElement.scrollLeft;
  else
     return document.body.scrollLeft;
}
function xDKIWindowScrollTop(w) {
  if (!w) w = window;
  if (w.document.compatMode && w.document.compatMode != "BackCompat")
     return w.document.documentElement.scrollTop;
  else
     return w.document.body.scrollTop;
}
function xDKIGetWindowScroll(w) {
  return [xDKIWindowScrollLeft(w),xDKIWindowScrollTop(w)];
}
function xDKIWindowSetScrollLeft(w,sl) {
  if (!w) w = window;
  if (w.document.compatMode && w.document.compatMode != "BackCompat")
     document.documentElement.scrollLeft = sl;
  else
     document.body.scrollLeft = sl;
}
function xDKIWindowSetScrollTop(w,st) {
  if (!w) w = window;
  if (w.document.compatMode && w.document.compatMode != "BackCompat")
     w.document.documentElement.scrollTop = st;
  else
     w.document.body.scrollTop = st;
}
function xDKIScrollBarWidth() {
  var d1,d2;

  if (_ScrollBarWidth < 0) {
     d1 = document.createElement('div');
     with (d1.style) {
          overflow = 'scroll';
          width = '200px';
          height = '200px';
          visibility = "hidden";
     }
     d2 = document.createElement('div');
     with (d2.style) {
          overflow = 'scroll';
          width = '2000px';
          height = '2000px';
          visibility = "hidden";
     }
     d1.appendChild(d2);
     document.body.appendChild(d1);
     _ScrollBarWidth = d1.offsetWidth-d1.clientWidth;
     document.body.removeChild(d1);
  }
  return _ScrollBarWidth;
}
function xDKIScrollBarHeight() {
  return xDKIScrollBarWidth() // ok!
}


// show wait and wait
function xDKIWaitCursor() {
  document.body.className = 'wait';
 }
function xDKINormalCursor() {
  document.body.className = '';
}
function xDKIWait(x,y,aMaxMSecs,aTimeOutMsg) {
  var aWait,aImage;

  xDKIUnWait();

  aWait = document.createElement('div');
  with (aWait) { id = "xDKIWaiting"; align = "center";
                 with (style) { border = "0px"; backgroundColor = "white"; position = "absolute"; padding = "40px";
                                left = x; top = y; width = 220; height = 70; zIndex = 10; } }
  aImage = document.createElement('img');
  aImage.src="images/wait_mov.gif";
  aWait.appendChild(aImage);
  document.body.appendChild(aWait);

  return setTimeout("xDKIWaitTimedOut('"+aTimeOutMsg+"')",aMaxMSecs);
}
function xDKIWaitSilent_Image(x,y,p,w,h,z,aMaxMSecs,aTimeOutFunction) {
  var aWait,aImage;

  xDKIUnWait();

  aWait = document.createElement('div');
  with (aWait) { id = "xDKIWaiting"; align = "center";
                 with (style) { border = "1px solid gray"; backgroundColor = "#f6f6f6"; position = "absolute"; padding = px(p);
                                left = px(x); top = px(y); width = px(w); height = px(h); zIndex = z } }
  aImage = document.createElement('img');
  aImage.src="images/wait_mov.gif";
  aWait.appendChild(aImage);
  document.body.appendChild(aWait); 
  
  if (aTimeOutFunction) return setTimeout(aTimeOutFunction,aMaxMSecs);
  else return 0;
}

function xDKIWaitSilent(aMaxMSecs,aTimeOutFunction) {
  var aWait;

  xDKIUnWait();

  aWait = document.createElement('div');
  with (aWait) { id = "xDKIWaiting"; align = "center";
       with (style) { display = "none"; visibility = "hidden"; position = "absolute";
                      left = '0px'; top = '0px'; width = '1px'; height = '1px'; } }
  document.body.appendChild(aWait);

  if (aTimeOutFunction) return setTimeout(aTimeOutFunction,aMaxMSecs);
  else return 0;
}
function xDKIWaitTimedOut(aMsg) {
  xDKIUnWait();
  alert(aMsg);
}
function xDKIIsWaiting() {
  return xDKIExistId('xDKIWaiting');
}
function xDKIUnWait(aTimeOutIDToClear) {
  if (aTimeOutIDToClear) clearTimeout(aTimeOutIDToClear);
  if (xDKIIsWaiting()) document.body.removeChild(elemById('xDKIWaiting'));
}


// get time
function xDKIGetTime() {
  var s1,s2,s3,s4;
  with (new Date()) {
       s1 = getHours().toString();
       if (s1.length == 1) s1 = '0'+s1;
       s2 = getMinutes().toString();
       if (s2.length == 1) s2 = '0'+s2;
       s3 = getSeconds().toString();
       if (s3.length == 1) s3 = '0'+s3;
       s4 = getMilliseconds().toString();
       if (s4.length == 1) s4 = s4+'00'
       else if (s4.length == 2) s4 = s4+'0';
  }
  return s1+'.'+s2+'.'+s3+':'+s4;
}


// is c a control character?
function xDKIControlChar(c) {
  return  !( (c == 32) ||                  // space
             ((c >= 48) && (c <= 57))   || // numeric
             ((c >= 65) && (c <= 90))   || // a-z, also A-Z
             ((c >= 96) && (c <= 107))  || // numeric keypad
             ((c >= 109) && (c <= 111)) || // -./
             ((c >= 186) && (c <= 192)) || // ;=,-./`
             ((c >= 219) && (c <= 222)) )  // (\)'
}


// random string
function xDKIRandomIntervall(a,b) {
  return Math.floor(a+Math.random()*(b-a+1));
}
function xDKIRandomString(aLen) {
  var aResult,i;

  aResult = '';
  for (i = 0;i < aLen;i++) aResult += String.fromCharCode(xDKIRandomIntervall(65,90));
  return aResult;
}


// search for a string: w= "wordonly"  i="insensitive"
// returns found position or -1
// example: xDKISearch('abcd','abc','w') --> -1
function xDKISearch(aString,aStringToSearchFor,aFlags) {
  var aSwitch,aRegModifier;

  if (aFlags.indexOf('i') >= 0) aSwitch = 'i';else aSwitch = '';
  if (aFlags.indexOf('w') >= 0) aRegModifier = '\\b';else aRegModifier = '';
  return aString.search(new RegExp(aRegModifier+aStringToSearchFor+aRegModifier,aSwitch));
}


// is a elem in an array
function xDKIIsIn(anArray,anElement) {
  var i;
  for (i = 0; i < anArray.length; i++) if (anElement == anArray[i]) return true;
  return false;
}
function xDKIIsIn_Index(anArray,anElement) {
  var i;
  for (i = 0; i < anArray.length; i++) if (anElement == anArray[i]) return i;
  return -1;
}


// conditional 'scroll into view' (without IE-error)
function xDKIScrollIntoViewIfNotInView(aParent,anElem,aUseScrollIntoView) {
  var aParentUsed,aPositionParent,aParentIsBody,s,sl,st,o,ow,oh,ch,cv;

  if (!anElem) return false;
  if (!aParent) aParentUsed = anElem.parentNode; else aParentUsed = aParent;

  aPositionParent = xDKIPosition(aParentUsed);
  aPosition = xDKIPosition(anElem);
  aParentIsBody = aParentUsed.nodeName.toLowerCase() == 'body';
  if (aParentIsBody) {
     s = xDKIGetWindowScroll(window); sl = s[0]; st = s[1];
     o = xDKIGetWindowSize(window);   ow = o[0]; oh = o[1];
  }
  else {
     sl = aParentUsed.scrollLeft;     st = aParentUsed.scrollTop;
     ow = aParentUsed.offsetWidth;    oh = aParentUsed.offsetHeight;
  }
  ch = (aPosition[0]-sl < aPositionParent[0]) || (aPosition[0]-sl > aPositionParent[0]+ow-20);
  cv = (aPosition[1]-st < aPositionParent[1]) || (aPosition[1]-st > aPositionParent[1]+oh-20);
  if (aUseScrollIntoView && (ch || cv)) anElem.scrollIntoView();
  else {
     if (aParentIsBody) {
        if (ch) xDKIWindowSetScrollLeft(window,anElem.offsetLeft-2*xDKIScrollBarWidth());
        if (cv) xDKIWindowSetScrollTop(window,anElem.offsetTop-2*xDKIScrollBarWidth());
     }
     else {
        if (ch) aParentUsed.scrollLeft = anElem.offsetLeft-2*xDKIScrollBarWidth();
        if (cv) aParentUsed.scrollTop = anElem.offsetTop-2*xDKIScrollBarWidth();
     }
  }
}


// hasAttribute for IE
function xDKIHasAttribute(elem,aAttribute) {
  if (typeof elem.hasAttribute == 'function') return elem.hasAttribute('href');
  else return xDKINotUndef(elem.attributes[aAttribute]);
}


// dynamic line
function xDKIMakeOrGetALine(aId,z,aParent) {
  var e;

  e = elemById(aId);
  if (!e) {
     e = document.createElement('img');
     with (e) {
          className = 'line';
          src = 'images/1x1_black.gif';
          alt = '';
          id = aId;
          with (style) {
               zIndex = z;
               display = 'none';
          }
     }
     if (aParent) aParent.appendChild(e); else document.body.appendChild(e);
  }
  return e;
}
function xDKILine(aParent,l,t,w,h,z) {
  var e;

  e = document.createElement('img');
  with (e) {
       className = 'line';
       src = 'images/1x1_black.gif';
       alt = '';
       with (style) {
            left = px(l);
            top  = px(t);
            width = px(w);
            height = px(h);
            zIndex = z;
            display = 'inline';
       }
  }
  aParent.appendChild(e);
  return e;
}


// refresh a image (if still "loading" (IE-Error))
function xDKIRefreshImage(aImgId,aDelta) {
  var aImg,srcNew,aPos;

  aImg = elemById(aImgId);
  if (aImg) {
     srcNew = aImg.src;
     aPos = srcNew.indexOf('?');
     if (aPos >= 0) srcNew = srcNew.substr(0,aPos);
     setTimeout('elemById("'+aImgId+'").src = "'+srcNew+'?'+(new Date()).getTime()+'"',aDelta);
  }
}
function xDKIRefreshALoadingImage(aImgId,aDelta) {
  var aImg;

  aImg = elemById(aImgId);
  if (aImg) {
     if (aImg.readyState) {
        if (aImg.readyState == 'loading') xDKIRefreshImage(aImgId,aDelta);
     }
     else xDKIRefreshImage(aImgId,aDelta);
  }
}


// get all child elements of an element
function xDKIGetAllElements(aParent) {
  var x;

  if (!aParent) return [];
  if (xDKIBrowser_IE5()) return aParent.all;
  return aParent.getElementsByTagName('*');
}


// returns, whether an element has a special classname, even in case there is more then one class assigned to it
function xDKIHasClassNameId(aId,aClass) {
  return xDKIHasClassName(elemById(aId),aClass);
}
function xDKIHasClassName(elem,aClass) {
  if (elem) return xDKISearch(elem.className,aClass,'wi') >= 0;
  else return false;
}


// changes the class of an element, even in case there is more then one class assigned to it
function xDKIChangeClassNameId(aId,aClassIn,aClassOut) {
  return xDKIChangeClassName(elemById(aId),aClassIn,aClassOut);
}
function xDKIChangeClassName(elem,aClassIn,aClassOut) {
  var aNew,aResult;
  if (!elem) return;
  if (elem.className.search(aClassIn) >= 0) {
     aNew = elem.className.replace(new RegExp('\\b'+aClassIn+'\\b','g'),aClassOut);
     aResult = elem.className != aNew;
     elem.className = aNew;
     return aResult;
  }
  else
     return false;
}


// cursor
function xDKICursorPointer(anElem) {
  if (!anElem) return;
  if (xDKIBrowser_IE5()) anElem.style.cursor = 'hand'; else anElem.style.cursor = 'pointer';
}


// xDKISelectBox
// DKI3.css is needed
// interface:
// - xDKISelectBox_Create
var xDKISelectBox_Show_NextProhibited = false;
function xDKISelectBox_Create(aMenuParentId,aLabel,aInitialContent,
                              aSelectBoxWidth,aSelectBoxHeight,anArrowWidth,aPaddingTop,aPaddingRight,z,
                              aBackgroundColor,aBackgroundColorSelected,
                              aBorderWidth,aBorderStyle,aBorderColor,anArrowBackgroundColor,
                              aArrowDownClass,aFontSize,aTextAlign,aUserSelectFunction,aHiddenFieldName,
                              aDisplacementIE,aFocusEvent) {
  var aMainParent,aLabelElement,aSelectBoxParent,aParent,aParentId,
      anArrowParent,anArrow,anArrowId,aHiddenField,aShowFunction,i;

  aMainParent = document.createElement('div');
  aMainParent.style.fontSize = aFontSize;

  if (aLabel) {
     aLabelElement = document.createElement('div');
     with (aLabelElement.style) {
          cssFloat = 'left';
          styleFloat = 'left';
          paddingTop = '3px';
          paddingRight = '7px';
     }
     aLabelElement.appendChild(document.createTextNode(aLabel));
     aMainParent.appendChild(aLabelElement);
  }

  aSelectBoxParent = document.createElement('div');
  with (aSelectBoxParent.style) {
       cssFloat = 'left';
       styleFloat = 'left';
       width = px(parseInt(aSelectBoxWidth)+parseInt(aPaddingRight));
       backgroundColor = aBackgroundColor;
       borderWidth = aBorderWidth;
       borderStyle = aBorderStyle;
       borderColor = aBorderColor;
  }
  aMainParent.appendChild(aSelectBoxParent);

  aParent = document.createElement('div');
  aParentId = 'xDKISelectBox_'+xDKIRandomString(20);
  aParent.id = aParentId;
  with (aParent.style) {
       cssFloat = 'left';
       styleFloat = 'left';
       width = px(parseInt(aSelectBoxWidth)-parseInt(anArrowWidth)-1 - ((aTextAlign == 'left') ? 5 : 0));
       height = px(parseInt(aSelectBoxHeight)-parseInt(aPaddingTop));
       backgroundColor = aBackgroundColor;
       textAlign = aTextAlign;
       paddingTop = px(parseInt(aPaddingTop));
       paddingRight = px(parseInt(aPaddingRight));
       if (aTextAlign == 'left') paddingLeft = px(5);
  }
  aParent.appendChild(document.createTextNode(aInitialContent));
  aSelectBoxParent.appendChild(aParent);

  anArrowParent = document.createElement('div');
  with (anArrowParent.style) {
       cssFloat = 'right';
       styleFloat = 'right';
  }

  anArrow = document.createElement('a');
  anArrowId  = 'xDKISelectBox_'+xDKIRandomString(20);
  anArrow.id = anArrowId;
  anArrow.className = 'nohint '+aArrowDownClass;
  anArrow.href = 'javascript:void(0)';
  with (anArrow.style) {
       width = px(parseInt(anArrowWidth));
       height = aSelectBoxHeight;
       display = 'block';
       backgroundColor = anArrowBackgroundColor;
       borderLeftWidth = aBorderWidth;
       borderLeftStyle = aBorderStyle;
       borderLeftColor = aBorderColor;
  }
  aShowFunction =
    'xDKISelectBox_Show("'+aParentId+'","'+aHiddenFieldName+'","'+anArrowId+'","'+aPaddingRight+'",'+z+',"'+
                           aBackgroundColor+'","'+aBackgroundColorSelected+'","'+aBorderColor+'","'+
                           aUserSelectFunction+'(elemById(\''+aParentId+'\').innerHTML)","'+
                           aDisplacementIE+'","'+aTextAlign+'"';
  if (typeof(arguments[22]) == 'object')
     for (i=0; i<arguments[22].length; i++) aShowFunction += ',"'+arguments[22][i]+'"';
  else 
     for (i=22; i<arguments.length; i++) aShowFunction += ',"'+arguments[i]+'"';
  aShowFunction += ')';
  xDKIAddEvent(aParent,'mousedown',new Function('','elemById("'+anArrowId+'").focus();'+aShowFunction));
  xDKIAddEvent(anArrow,'mousedown',new Function('',aShowFunction));
  xDKIAddEvent(anArrow,'keydown',new Function('e','if (xDKIPressed(e,[13,32,38,40])) xDKIStopPropagation(e)'));
  xDKIAddEvent(anArrow,'keypress',new Function('e','if (xDKIPressed(e,[13,32,38,40])) xDKIStopPropagation(e)'));
  xDKIAddEvent(anArrow,'keyup',new Function('e','if (!xDKISelectBox_IsOpen("'+aParentId+'") && xDKIPressed(e,[13,32,38,40])) '+aShowFunction));
  if (aFocusEvent) xDKIAddEvent(anArrow,'focus',new Function('e',aFocusEvent));
  anArrowParent.appendChild(anArrow);

  aSelectBoxParent.appendChild(anArrowParent);

  elemById(aMenuParentId).appendChild(aMainParent);

  if (!xDKIExistId(aHiddenFieldName)) {
     aHiddenField = document.createElement('input');
     aHiddenField.type = 'hidden';
     aHiddenField.id = aHiddenFieldName;
     aHiddenField.name = aHiddenFieldName;
     aHiddenField.value = '';
     elemById(aMenuParentId).appendChild(aHiddenField);
  }
  return [aParentId,anArrow];
}
// show select box values
function xDKISelectBox_Show(aParentId,aHiddenFieldId,anArrowId,aPaddingRight,z,
                            aBackgroundColor,aBackgroundColorSelected,aBorderColor,aSelectFunction,
                            aDisplacementIE,aTextAlign) {
  var aParent,anArrow,aPos,w,h,i,d;

  if (xDKISelectBox_Show_NextProhibited) { xDKISelectBox_Show_NextProhibited = false; return false; } 
  
  aParent = elemById(aParentId);

  if (xDKISelectBox_GetProp(aParent,'IgnoreNext')) {
     xDKISelectBox_SetProp(aParent,'IgnoreNext','');
     return;
  }
  if (xDKISelectBox_CloseAllMenuItems(aParentId)) return;

  anArrow = elemById(anArrowId);
  xDKISelectBox_SetProp(aParent,'SelectedId','');
  xDKISelectBox_SetProp(aParent,'IgnoreNext','');
  xDKISelectBox_SetProp(aParent,'Function',aSelectFunction);
  xDKISelectBox_SetProp(aParent,'BackgroundColor',aBackgroundColor);
  xDKISelectBox_SetProp(aParent,'BackgroundColorSelected',aBackgroundColorSelected);
  xDKISelectBox_SetProp(aParent,'ArrowId',anArrowId);
  xDKISelectBox_SetProp(aParent,'HiddenFieldId',aHiddenFieldId);
  xDKISelectBox_SetProp(aParent,'LastOpened',new Date().getTime());
  xDKISelectBox_SetProp(anArrow,'ParentId',aParentId);

  aPos = xDKIPosition(aParent);
  d = 0;
  if (!xDKIBrowser_IE()) aPos[0] += -1; 
  else { 
     aPos[0] += aDisplacementIE*1; 
     d = 1+aDisplacementIE*1; 
  }
  w = aParent.offsetWidth + anArrow.offsetWidth;
  h = aParent.offsetHeight;
  for (i=11; i<arguments.length; i++)
      xDKISelectBox_CreateMenuItem(xDKISelectBox_MakeId(aParentId,i-11),i-11,aParentId,
                                   aPos[0],aPos[1]+2+((h-1)*(i-10))+d,w,h-1,aPaddingRight,
                                   z,i==arguments.length-1,
                                   aBackgroundColor,aBackgroundColorSelected,aBorderColor,aTextAlign,arguments[i]);
  xDKIAddEvent(anArrow,'keydown',xDKISelectBox_KeyMenuItem);
  xDKIAddEvent(anArrow,'blur',xDKIGetFunction('e','xDKISelectBox_CloseAllMenuItems("'+aParentId+'");'));
  if (7 < arguments.length) xDKISelectBox_SelectMenuElement(elemById(xDKISelectBox_MakeId(aParentId,0)));
}
// create menu-item
function xDKISelectBox_CreateMenuItem(anId,anIndex,aParentId,l,t,w,h,aPaddingRight,z,aLastElement,
                                      aBackgroundColor,aBackgroundColorSelected,aBorderColor,aTextAlign,aContent) {
  var aDiv,aDiv1,aDiv2;
  aDiv = document.createElement('div');
  aDiv.id = anId;
  with (aDiv.style) {
       position = 'absolute';
       left = px(l);
       top = px(t);
       width = px(w-parseInt(aPaddingRight) - ((aTextAlign == 'left') ? 5 : 0));
       height = px(h);
       zIndex = z;
       if (aLastElement) borderWidth = '0px 1px 1px 1px';
       else borderWidth = '0px 1px';
       borderStyle = 'solid';
       borderColor = aBorderColor;
       backgroundColor = aBackgroundColor;
       paddingRight = px(parseInt(aPaddingRight));
       if (aTextAlign == 'left') paddingLeft = px(5);
  }
  xDKISelectBox_SetProp(aDiv,'ParentId',aParentId);
  xDKISelectBox_SetPropElement(aDiv,'Value',aContent);
  aDiv1 = document.createElement('div');
  aDiv1.className = 'hspacer2';
  aDiv.appendChild(aDiv1);
  aDiv2 = document.createElement('div');
  aDiv2.innerHTML = aContent;
  aDiv.appendChild(aDiv2);
  aDiv.onmouseover = xDKISelectBox_SelectMenuItem;
  aDiv.onmouseout = xDKISelectBox_UnselectMenuItem;
  aDiv.onmousedown = xDKISelectBox_MouseDownMenuItem;
  elemById(aParentId).appendChild(aDiv);
}
// close all menu-items
function xDKISelectBox_CloseAllMenuItems(aParentId) {
  var aTimeNow,aTimeLast,aResult,i,aParent,anArrow,anElement;

  aParent = elemById(aParentId);
  aTimeNow = new Date().getTime();
  aTimeLast = xDKISelectBox_GetProp(aParent,'LastOpened');
  if ((aTimeNow-aTimeLast) < 100) return xDKIExistId(xDKISelectBox_MakeId(aParentId,0));

  aResult = false;
  i = 0;
  while (true) {
        anElement = elemById(xDKISelectBox_MakeId(aParentId,i));
        if (!anElement) break;
        aResult = true;
        aParent.removeChild(anElement);
        i = i + 1;
  }

  anArrow = elemById(xDKISelectBox_GetProp(aParent,'ArrowId'));
  if (anArrow) {
     xDKIRemoveEvent(anArrow,'keydown',xDKISelectBox_KeyMenuItem);
     xDKIRemoveEvent(anArrow,'blur',xDKIGetFunction('e','xDKISelectBox_CloseAllMenuItems("'+aParentId+'");'));
  }

  return aResult;
}
// is open
function xDKISelectBox_IsOpen(aParentId) {
  return xDKIExistId(xDKISelectBox_MakeId(aParentId,0))
}
// id-functions
function xDKISelectBox_GetIndex(anElement) {
  return anElement.id.substr(anElement.id.indexOf('xDKISB_Id')+9)
}
function xDKISelectBox_ExchangeId(anElement,anId) {
  return anElement.id.substring(0,anElement.id.indexOf('xDKISB_Id')+9)+anId
}
function xDKISelectBox_MakeId(aParentId,anIndex) {
  return aParentId+'xDKISB_Id'+anIndex
}
function xDKISelectBox_IsId(anId) {
  return anId.indexOf('xDKISB_Id') > 0
}
// get selected
function xDKISelectBox_GetSelectedValue(anElement) {
  var aSelectedId,aSelectedElement;

  aSelectedId = xDKISelectBox_GetSelectedIdElement(anElement);
  if (!aSelectedId) return null;
  aSelectedElement = elemById(xDKISelectBox_ExchangeId(anElement,aSelectedId));
  if (!aSelectedElement) return null;
  return xDKISelectBox_GetPropElement(aSelectedElement,'Value');
}
function xDKISelectBox_GetSelectedIdElement(anElement) {
  return xDKISelectBox_GetPropElement(anElement,'SelectedId',true);
}
function xDKISelectBox_GetSelectedIdParent(aParent) {
  return xDKISelectBox_GetProp(aParent,'SelectedId');
}
// select a menu-item
function xDKISelectBox_SelectMenuItem(e) {
  xDKISelectBox_SelectMenuElement(this);
}
function xDKISelectBox_SelectMenuElement(anElement) {
  var aSelectedId,aSelectedElement,aParentId;

  if (!anElement) return;

  aSelectedId = xDKISelectBox_GetSelectedIdElement(anElement);
  if (aSelectedId) {
     aParentId = xDKISelectBox_GetPropElement(anElement,'ParentId')
     aSelectedElement = elemById(xDKISelectBox_MakeId(aParentId,aSelectedId));
     if (aSelectedElement) xDKISelectBox_UnselectMenuElement(aSelectedElement);
  }

  xDKISelectBox_SetPropElement(anElement,'SelectedId',xDKISelectBox_GetIndex(anElement),true);
  anElement.style.backgroundColor = xDKISelectBox_GetPropElement(anElement,'BackgroundColorSelected',true);
}
// un-select a menu-item
function xDKISelectBox_UnselectMenuItem(e) {
  xDKISelectBox_UnselectMenuElement(this);
}
function xDKISelectBox_UnselectMenuElement(anElement) {
  if (!anElement) return;

  xDKISelectBox_SetPropElement(anElement,'SelectedId','',true);
  anElement.style.backgroundColor = xDKISelectBox_GetPropElement(anElement,'BackgroundColor',true);
}
// select next / previous menuitem
function xDKISelectBox_SelectNextOrPreviousMenuItem(aParentId,aDelta) {
  var aSelectedId,aSelectedElement,aNextSelectedId,aNextSelectedElement;

  aSelectedId = xDKISelectBox_GetSelectedIdParent(elemById(aParentId));
  if (aSelectedId) aNextSelectedId = aDelta+parseInt(aSelectedId);
  else aNextSelectedId = 0;

  if (aSelectedId) aSelectedElement = elemById(xDKISelectBox_MakeId(aParentId,aSelectedId));
  else aSelectedElement = null;
  aNextSelectedElement = elemById(xDKISelectBox_MakeId(aParentId,aNextSelectedId));

  if (!aNextSelectedElement) return;
  if (aSelectedId == aNextSelectedId) return;

  xDKISelectBox_UnselectMenuElement(aSelectedElement);
  xDKISelectBox_SelectMenuElement(aNextSelectedElement);
}
// key-event
function xDKISelectBox_KeyMenuItem(e) {
  var anId,aParentId;

  e = (e) ? e : ((event) ? event : null);
  if (e && ((e.keyCode == 38) || (e.keyCode == 40) || (e.keyCode == 13) || (e.keyCode == 27/*Escape*/))) {
     anId = (this.id) ? this.id : e.srcElement.id;
     aParentId = xDKISelectBox_GetProp(elemById(anId),'ParentId');
     if (e.keyCode == 38) {
        xDKISelectBox_SelectNextOrPreviousMenuItem(aParentId,-1);
        xDKIStopPropagation(e);
     }
     else if (e.keyCode == 40) {
        xDKISelectBox_SelectNextOrPreviousMenuItem(aParentId,1);
        xDKIStopPropagation(e);
     }
     else if (e.keyCode == 13) {
        xDKISelectBox_ClickMenuActualElement(aParentId);
        xDKIStopPropagation(e);
     }
     else xDKISelectBox_CloseAllMenuItems(aParentId);
  }
}
// click-event
function xDKISelectBox_ClickMenuActualElement(aParentId) {
  var aSelectedId,aSelectedElement;

  aSelectedId = xDKISelectBox_GetSelectedIdParent(elemById(aParentId));
  if (aSelectedId) aSelectedElement = elemById(xDKISelectBox_MakeId(aParentId,aSelectedId));
  xDKISelectBox_ClickMenuElement(aSelectedElement,true);
}
function xDKISelectBox_MouseDownMenuItem(e) {
  xDKISelectBox_ClickMenuElement(this);
}
function xDKISelectBox_ClickMenuElement(anElement,aFromNewLine) {
  var aValue,aFunction;

  if (!anElement) return;
  aValue = xDKISelectBox_GetSelectedValue(anElement);
  if (aValue) {
     elemById(xDKISelectBox_GetPropElement(anElement,'ParentId')).innerHTML = aValue;
     anElem = elemById(xDKISelectBox_GetPropElement(anElement,'HiddenFieldId',true));
     if (anElem) anElem.value = aValue;
     aFunction = xDKISelectBox_GetPropElement(anElement,'Function',true);
     eval(aFunction);
  }
  if (!aFromNewLine) xDKISelectBox_CloseAllMenuItems(xDKISelectBox_GetProp(anElement,'ParentId'));
  else xDKISelectBox_SetPropElement(anElement,'IgnoreNext','true',true);
}
// properties
function xDKISelectBox_GetProp(anElement,aProperty) {
  return anElement.getAttribute('xDKISB_'+aProperty);
}
function xDKISelectBox_SetProp(anElement,aProperty,aValue) {
  anElement.setAttribute('xDKISB_'+aProperty,aValue);
}
function xDKISelectBox_GetPropElement(anElement,aProperty,aGlobal) {
  if (aGlobal) anElement = elemById(anElement.getAttribute('xDKISB_ParentId'));
  return xDKISelectBox_GetProp(anElement,aProperty);
}
function xDKISelectBox_SetPropElement(anElement,aProperty,aValue,aGlobal) {
  if (aGlobal) anElement = elemById(anElement.getAttribute('xDKISB_ParentId'));
  xDKISelectBox_SetProp(anElement,aProperty,aValue);
}


// custom controls
// interface: - xDKIInitCustomControls
//            - xDKIRefreshCustomControls
// show via DKI3.css: checkbox_on, checkbox_off, radio_on, ...
// enabled/disable via xDKIChangeClassNameId: xDKIChangeClassNameId('MyId','enabled',disabled');  xDKIRefreshCustomControls()
// use a hidden field to hold the value
// example for a checkbox:
//      <input type="hidden" id="CBMyId" name="CBMyId" value="<%$Text(CBMyId/@Value)%>" />
//      <a id="AMyId" class="nohint checkbox_<%if $Defined(CBMyId) then%>on<%else%>off<%end%>" href="#"
//           onclick="xDKISelectCBEx('MyId','checkbox');return false">My Text</a>
function xDKIInitCustomControls() {
  xDKINoHintsForNoHintAnchors();
  xDKIDisableDisabledAnchors();
  xDKIRefreshCustomControls();
}
function xDKINoHintsForNoHintAnchors() { // no hints for <a>
  var x,i;

  x = document.getElementsByTagName('a');
  for (i=0; i<x.length; i++)
      if (xDKISearch(x[i].className,'nohint','w') >= 0) {
         xDKIAddEvent(x[i],'mouseover',new Function ('e', 'window.status = ""; return true;'));
         xDKIAddEvent(x[i],'mousemove',new Function ('e', 'window.status = ""; return true;'));
         xDKIAddEvent(x[i],'mousedown',new Function ('e', 'window.status = ""; return true;'));
         xDKIAddEvent(x[i],'mouseup',new Function ('et', 'window.status = ""; return true;'));
         xDKIAddEvent(x[i],'focus',new Function ('e', 'window.status = ""; return true;'));
      }
}
function xDKIDisableDisabledAnchors() { // disable disabled <a>
  var x,i;

  x = document.getElementsByTagName('a');
  for (i=0; i<x.length; i++)
      if (xDKISearch(x[i].className,'disabled','w') >= 0)
         xDKIDisableAnchor(x[i]);
}
function xDKIEnableAnchor(elem,aHRef) {
  if (elem) elem.setAttribute('href',aHRef);
}
function xDKIEnableAnchorId(aId,aHRef) {
  xDKIEnableAnchor(elemById(aId),aHRef)
}
function xDKIDisableAnchor(elem) {
  if (elem && xDKIHasAttribute(elem,'href')) elem.removeAttribute('href');
}
function xDKIDisableAnchorId(aId) {
  xDKIDisableAnchor(elemById(aId))
}
function xDKIRefreshCustomControls() { // correct bitmaps for disabled custom controls
  var x,i;

  x = xDKIGetAllElements(document);
  for (i=0; i<x.length; i++) {
      if (xDKISearch(x[i].className,'disabled','w') >= 0) {
         xDKIChangeClassName(x[i],'radio_on','radio_on_dis');
         xDKIChangeClassName(x[i],'radio_off','radio_off_dis');
         xDKIChangeClassName(x[i],'checkbox_on','checkbox_on_dis');
         xDKIChangeClassName(x[i],'checkbox_off','checkbox_off_dis');
         xDKIChangeClassName(x[i],'arrow2left_layoutleft','arrow2left_layoutleft_dis');
         xDKIChangeClassName(x[i],'arrow2left_layoutright','arrow2left_layoutright_dis');
         xDKIChangeClassName(x[i],'arrow2right_layoutleft','arrow2right_layoutleft_dis');
         xDKIChangeClassName(x[i],'arrow2right_layoutright','arrow2right_layoutright_dis');
         xDKIChangeClassName(x[i],'arrow1left_layoutleft','arrow1left_layoutleft_dis');
         xDKIChangeClassName(x[i],'arrow1left_layoutright','arrow1left_layoutright_dis');
         xDKIChangeClassName(x[i],'arrow1right_layoutleft','arrow1right_layoutleft_dis');
         xDKIChangeClassName(x[i],'arrow1right_layoutright','arrow1right_layoutright_dis');
      }
      if (xDKISearch(x[i].className,'enabled','w') >= 0) {
         xDKIChangeClassName(x[i],'radio_on_dis','radio_on');
         xDKIChangeClassName(x[i],'radio_off_dis','radio_off');
         xDKIChangeClassName(x[i],'checkbox_on_dis','checkbox_on');
         xDKIChangeClassName(x[i],'checkbox_off_dis','checkbox_off');
         xDKIChangeClassName(x[i],'arrow2left_layoutleft_dis','arrow2left_layoutleft');
         xDKIChangeClassName(x[i],'arrow2left_layoutright_dis','arrow2left_layoutright');
         xDKIChangeClassName(x[i],'arrow2right_layoutleft_dis','arrow2right_layoutleft');
         xDKIChangeClassName(x[i],'arrow2right_layoutright_dis','arrow2right_layoutright');
         xDKIChangeClassName(x[i],'arrow1left_layoutleft_dis','arrow1left_layoutleft');
         xDKIChangeClassName(x[i],'arrow1left_layoutright_dis','arrow1left_layoutright');
         xDKIChangeClassName(x[i],'arrow1right_layoutleft_dis','arrow1right_layoutleft');
         xDKIChangeClassName(x[i],'arrow1right_layoutright_dis','arrow1right_layoutright');
      }
  }
}


// animated opener / closer
// interface:
// - xDKIOpener_Open
// - xDKIOpener_CloseInit
// - xDKIOpener_Close
var xDKIOpener_NumberOfOpeners, xDKIOpener_CloseProc;
function xDKIOpener_Open(aOriginalId,aOpenerId,aIndexName,aBkColor,aDelta,z,aTimeOut) {
  var eOriginal,eOpener,aPosOriginal,aWasCreated;

  eOriginal = elemById(aOriginalId);
  if (!eOriginal) return;
  aPosOriginal = xDKIPosition(eOriginal);
  aWasCreated = false;
  eOpener = elemById(aOpenerId);
  if (!eOpener) {
     eOpener = document.createElement('div');
     eOpener.id = aOpenerId;
     aWasCreated = true;
     with (eOpener.style) {
          visibility = 'hidden';
          position = 'absolute';
          zIndex = z;
     }
  }
  with (eOpener.style) {
       left = aPosOriginal[0]+'px';
       top = aPosOriginal[1]+'px';
       width = eOriginal.offsetWidth+'px';
       height = eOriginal.offsetHeight+'px';
       backgroundColor = aBkColor;
  }
  if (aWasCreated) document.body.appendChild(eOpener);
  xDKIShowId(aOpenerId);
  s = aIndexName + "=1";
  eval(s);
  setTimeout("xDKIOpener_OpenIt('"+aOpenerId+"',"+aPosOriginal[0]+","+eOriginal.offsetWidth+",'"+aIndexName+"',"+aDelta+","+aTimeOut+")",aTimeOut);
}
function xDKIOpener_CloseInit(aNumberOfOpeners,aCloseProc) {
  xDKIOpener_NumberOfOpeners = aNumberOfOpeners;
  xDKIOpener_CloseProc = aCloseProc;
}
function xDKIOpener_Close(aOriginalId,aOpenerId,aIndexName,aBkColor,aDelta,z,aTimeOut) {
  var eOriginal,eOpener,aPosOriginal,aWasCreated;

  eOriginal = elemById(aOriginalId);
  if (!eOriginal) return;
  aPosOriginal = xDKIPosition(eOriginal);
  aWasCreated = false;
  eOpener = elemById(aOpenerId);
  if (!eOpener) {
     eOpener = document.createElement('div');
     eOpener.id = aOpenerId;
     aWasCreated = true;
     with (eOpener.style) {
          visibility = 'hidden';
          position = 'absolute';
          zIndex = z
     }
  }
  with (eOpener.style) {
       left = (aPosOriginal[0]+eOriginal.offsetWidth)+'px';
       top = aPosOriginal[1]+'px';
       width = '0px';
       height = eOriginal.offsetHeight+'px';
       backgroundColor = aBkColor;
  }
  if (aWasCreated) document.body.appendChild(eOpener);
  xDKIShowId(aOpenerId);
  s = aIndexName + "=" + eOriginal.offsetWidth;
  eval(s);
  setTimeout("xDKIOpener_CloseIt('"+aOpenerId+"',"+aPosOriginal[0]+","+eOriginal.offsetWidth+",'"+aIndexName+"',"+aDelta+","+aTimeOut+")",aTimeOut);
}
function xDKIOpener_OpenIt(aOpenerId,aStartPos,aWidth,aIndexName,aDelta,aTimeOut) {
  var e,i,s;

  e = elemById(aOpenerId);
  i = eval(aIndexName);
  e.style.left = (aStartPos+i)+'px';
  if (aWidth-i > 0) e.style.width = (aWidth-i)+'px';
  i = i+aDelta;
  s = aIndexName + "=" + i;
  eval(s);
  if (i <= aWidth) setTimeout("xDKIOpener_OpenIt('"+aOpenerId+"',"+aStartPos+","+aWidth+",'"+aIndexName+"',"+aDelta+","+aTimeOut+")",aTimeOut);
  else {
     xDKIHideId(aOpenerId);
     document.body.removeChild(e);
  }
}
function xDKIOpener_CloseIt(aOpenerId,aStartPos,aWidth,aIndexName,aDelta,aTimeOut) {
  var e,i,s;

  e = elemById(aOpenerId);
  i = eval(aIndexName);
  e.style.left = (aStartPos+i)+'px';
  if (aWidth-i > 0) e.style.width = (aWidth-i)+'px';
  i = i-aDelta;
  s = aIndexName + "=" + i;
  eval(s);
  if (i > 0) setTimeout("xDKIOpener_CloseIt('"+aOpenerId+"',"+aStartPos+","+aWidth+",'"+aIndexName+"',"+aDelta+","+aTimeOut+")",aTimeOut);
  else {
    e.style.left = aStartPos+'px';
    e.style.width = aWidth+'px';
    if (--xDKIOpener_NumberOfOpeners == 0) eval(xDKIOpener_CloseProc);
  }
}


// slider
// interface:
// - xDKISlideIt
function xDKISlideIt(aId,aWidth,aHeight,aSlideType,aStart,aDelta,aTimeOut) {
  var e;
  e = elemById(aId);
  if (!e) return;
  if (aSlideType == 0) {
     if (aStart >= aHeight) return;
     aStart += aDelta;
     e.style.clip = 'rect(0px '+aWidth+'px '+aStart+'px 0px)';
  }
  else if (aSlideType == 1) {
     if (aStart >= aWidth) return;
     aStart += aDelta;
     e.style.clip = 'rect(0px '+aStart+'px '+aHeight+'px 0px)';
  }
  setTimeout("xDKISlideIt('"+aId+"',"+aWidth+","+aHeight+","+aSlideType+","+aStart+","+aDelta+","+aTimeOut+")",aTimeOut);
}



// moveable, closeable windows
// interface:
// - xDKIDynamicMoveableWindow_Show
// - xDKIDynamicMoveableWindow_Close (normally not needed)
// - xDKIDynamicMoveableWindow_CloseAll
var xDKIDMW_Flag,xDKIDMW_Window,xDKIDMW_Windows,xDKIDMW_InitialEventPos,xDKIDMW_InitialWindowPos;
var _DynamicMoveableWindow_BorderWidth   = 3;
    _DynamicMoveableWindow_CaptionHeight = 17;
    _DynamicMoveableWindow_PaddingTop    =  2;
function xDKIDynamicMoveableWindow_Show(aUniqueWindowId,aContentElem,aIdCalledFromForFocus,aCaption,
                                        aLeft,aTop,aWidth,aHeight,z,aZIndexFunction,
                                        aOnClickClose/*optional*/,aWithoutBorder/*optional*/,
                                        aBackgroundColor/*optional*/,
                                        aCustomCloseFunction/*optional*/,
                                        aCustomMoveFunction/*optional*/,
                                        aUrgent/*optional*/,
                                        aUrgentBorderColor/*optional*/,
                                        aWithCloseButton/*optional*/,
                                        aWithSliding/*optional*/) {
  var aMainDiv,aSubDiv,aCloseFunction,aCloseFunctionBody,aWindowTop,aWindowHeight,l,aNoCaptionBar,d;

  if (xDKIExistId(aUniqueWindowId)) return null;

  // init
  if (!xDKIDMW_Windows) {
     xDKIDMW_Windows = [];
     xDKIAddEvent(document,'keyup',xDKIDynamicMoveableWindow_KeyUp);
  }
  xDKIDMW_Windows[xDKIDMW_Windows.length] = aUniqueWindowId;

  // close
  if (aCustomCloseFunction)
     aCloseFunctionBody = aCustomCloseFunction+"();xDKIDynamicMoveableWindow_Close('"+aUniqueWindowId+"');";
  else
     aCloseFunctionBody = "xDKIDynamicMoveableWindow_Close('"+aUniqueWindowId+"');";
  aCloseFunction = new Function ("",aCloseFunctionBody);

  // elements
  aMainDiv = document.createElement('div');
  aMainDiv.setAttribute('IdCalledFromForFocus',aIdCalledFromForFocus);
  aMainDiv.setAttribute('CloseFunc',aCloseFunctionBody);
  aMainDiv.setAttribute('MoveFunc',aCustomMoveFunction);
  with (aMainDiv.style) {
       position = 'absolute';
       left = px(aLeft);
       top = px(aTop);
       if (aWidth > 0) width = px(aWidth);
       if (aHeight > 0) {
          aWindowTop = xDKIWindowScrollTop();
          aWindowHeight = xDKIWindowHeight();
          if ((aTop+aHeight) > (aWindowTop+aWindowHeight)) aTop = aWindowTop+aWindowHeight-(parseInt(aHeight)+30);
          if (aTop < aWindowTop) aTop = aWindowTop+10;
          height = px(aHeight);
          minHeight = px(aHeight);
       }
       zIndex = z;
       if (aBackgroundColor) backgroundColor = aBackgroundColor; else backgroundColor = '#ffffff';
       if (!aWithoutBorder) {
          if (aUrgent) {
             if (aUrgentBorderColor) border = _DynamicMoveableWindow_BorderWidth+'px solid '+aUrgentBorderColor;
             else border = _DynamicMoveableWindow_BorderWidth+'px solid #ff4242';
          }
          else border = _DynamicMoveableWindow_BorderWidth+'px solid #cac9cd';
       }
       borderTopWidth = '0px';
  }
  aMainDiv.setAttribute('ZIndexFunction',aZIndexFunction)
  aMainDiv.id = aUniqueWindowId;

  aNoCaptionBar = aUrgent && (aCaption =='');
  aSubDiv = document.createElement('div');
  with (aSubDiv.style) {
       if (aWidth > 0) width = px(aWidth);
       if (aNoCaptionBar) height = px(_DynamicMoveableWindow_BorderWidth);
       else height = px(_DynamicMoveableWindow_CaptionHeight);
       backgroundColor = '#ffffff';
       if (aUrgent) {
          if (aUrgentBorderColor) borderTop = _DynamicMoveableWindow_BorderWidth+'px solid '+aUrgentBorderColor;
          else borderTop = _DynamicMoveableWindow_BorderWidth+'px solid #ff4242';
       }
       else
          backgroundImage = 'url(images/moveablewindow_upper_middle.gif)';
       backgroundRepeat = 'repeat-x';
       if (aNoCaptionBar) {
          fontWeight = 'normal';
          fontSize = '0.15em';
       }
       else {
          fontWeight = 'bold';
          fontSize = '11px'; // non-resizeable
       }
       paddingTop = _DynamicMoveableWindow_PaddingTop+'px';
       whiteSpace = 'nowrap';
       zIndex = z;
       cursor = 'default';
  }
  if (!aNoCaptionBar) {
     aSubDiv.innerHTML = '&nbsp;'+aCaption;
     aSubDiv.onmousedown = xDKIDynamicMoveableWindow_MouseDown;
  }
  aMainDiv.appendChild(aSubDiv);

  if (!aUrgent || aWithCloseButton) {
     aSubDiv = document.createElement('div');
     with (aSubDiv.style) {
          position = 'absolute';
          if (aWidth > 0) {
             l = aWidth-_DynamicMoveableWindow_CaptionHeight;
             if (aUrgent) l += 3;
             left = px(l);
          }
          else left = '0px';
          if (aUrgent) top = px(4);
          else top = px(2);
          width = px(13);
          height = px(13);
          if (aUrgent) backgroundImage = 'url(images/moveablewindow_close1.gif)';
          else backgroundImage = 'url(images/moveablewindow_close.gif)';
          backgroundRepeat = 'no-repeat';
          zIndex = z;
     }
     aSubDiv.onclick = aCloseFunction;
     aMainDiv.appendChild(aSubDiv);
  }

  with (aContentElem.style) {
       if (aWidth > 0) width = px(aWidth);
       zIndex = z;
       if (display = 'none') display = 'block';
       visibility = 'visible';
  }
  if (aOnClickClose) aContentElem.onclick = aCloseFunction;
  aMainDiv.appendChild(aContentElem);

  document.body.appendChild(aMainDiv);

  if (!aNoCaptionBar && (aContentElem.offsetHeight+20 >= aMainDiv.offsetHeight)) {
     if (xDKIBrowser_IE()) d = 35; else d = 50;
     aMainDiv.style.height = px(aContentElem.offsetHeight+d);
  }

  xDKIDMW_Window = aUniqueWindowId;

  xDKIScrollIntoViewIfNotInView('',aMainDiv);

  if (aWithSliding) {
     if (aWithSliding[0] == 0) aMainDiv.style.clip = 'rect(0px '+aMainDiv.offsetWidth+'px '+aWithSliding[1]+'px 0px)';
     else if (aWithSliding[0] == 1) aMainDiv.style.clip = 'rect(0px '+aWithSliding[1]+'px '+aMainDiv.offsetHeight+'px 0px)';
     setTimeout("xDKISlideIt('"+aUniqueWindowId+"',"+aMainDiv.offsetWidth+","+aMainDiv.offsetHeight+","+aWithSliding[0]+","+aWithSliding[1]+","+aWithSliding[1]+","+aWithSliding[2]+")",aWithSliding[2]);
  }

  return aMainDiv;
}
function xDKIDynamicMoveableWindow_Close(aUniqueWindowId) {
  var aIdCalledFromForFocus;

  xDKIDynamicMoveableWindow_RemoveWindowId(aUniqueWindowId);
  if (xDKIExist(elemById(aUniqueWindowId))) {
     aIdCalledFromForFocus = elemById(aUniqueWindowId).getAttribute("IdCalledFromForFocus");
     document.body.removeChild(elemById(aUniqueWindowId));
     if ((aIdCalledFromForFocus) && (aIdCalledFromForFocus != '') && (aIdCalledFromForFocus != 'null')) elemById(aIdCalledFromForFocus).focus();
  }
}
function xDKIDynamicMoveableWindow_CloseAll() {
  var i;

  if (!xDKIDMW_Windows) return;
  for (i = 0; i < xDKIDMW_Windows.length;i++)
      if (xDKIExist(elemById(xDKIDMW_Windows[i])))
         document.body.removeChild(elemById(xDKIDMW_Windows[i]));
  xDKIDMW_Windows = [];
}
function xDKIDynamicMoveableWindow_DefProps(e,l,t,w,h,z,bi,br) {
  with (e.style) {
       if (l >=0) {
          position = 'absolute';
          left = px(l);
          top = px(t);
       }
       width = px(w);
       if (h > 0) height = px(h);
       if (bi) backgroundImage = bi;
       if (br) backgroundRepeat = br;
       zIndex = z;
  }
}
function xDKIDynamicMoveableWindow_MouseDown(e) {
  var aFunc;
  if (!e) e = window.event;

  xDKIDMW_Window = this.parentNode;
  xDKIDMW_InitialEventPos = [e.clientX,e.clientY];
  xDKIDMW_InitialWindowPos = [xDKIDMW_Window.offsetLeft,xDKIDMW_Window.offsetTop];

  aFunc = this.parentNode.getAttribute('ZIndexFunction');
  if (aFunc) this.parentNode.style.zIndex = eval(aFunc);

  if (xDKIDMW_Flag != '1') {
     xDKIAddEvent(xDKIDMW_Window,'mousemove',xDKIDynamicMoveableWindow_MouseMove);
     xDKIAddEvent(document,'mousemove',xDKIDynamicMoveableWindow_MouseMove);
     xDKIAddEvent(document,'mouseup',xDKIDynamicMoveableWindow_MouseUp);
     xDKIStopPropagation(e);
  }
  xDKIDMW_Flag = '1';
}
function xDKIDynamicMoveableWindow_MouseMove(e) {
  var aFunc;
  if (!e) e = window.event;

  if (xDKIDMW_Flag == '1') {
     xDKIDMW_Window.style.left = xDKIDMW_InitialWindowPos[0] + e.clientX - xDKIDMW_InitialEventPos[0] + 'px';
     xDKIDMW_Window.style.top = xDKIDMW_InitialWindowPos[1] + e.clientY - xDKIDMW_InitialEventPos[1] + 'px';
     if (document.selection) document.selection.clear();
     xDKIStopPropagation(e);
     aFunc = xDKIDMW_Window.getAttribute('MoveFunc');
     if (aFunc) eval(aFunc);
  }	
}
function xDKIDynamicMoveableWindow_MouseUp(e) {
  if (!e) e = window.event;

  xDKIDMW_Flag = '';
  xDKIRemoveEvent(xDKIDMW_Window,'mousemove',xDKIDynamicMoveableWindow_MouseMove);
  xDKIRemoveEvent(document,'mousemove',xDKIDynamicMoveableWindow_MouseMove);
  xDKIRemoveEvent(document,'mouseup',xDKIDynamicMoveableWindow_MouseUp);
  if (document.selection) document.selection.clear();
  xDKIStopPropagation(e);
}
function xDKIDynamicMoveableWindow_KeyUp(e) {
  var aWindowId,aCloseFunc;
  e = (e) ? e : ((event) ? event : null);

  if (e && (e.keyCode == 27/*Escape*/)) {
     aWindowId = xDKIDynamicMoveableWindow_GetTopMostWindowId();
     if (aWindowId) {
        aCloseFunc = elemById(aWindowId).getAttribute("CloseFunc");
        eval(aCloseFunc);
     }
  }
}
function xDKIDynamicMoveableWindow_RemoveWindowId(aUniqueWindowId) {
  var i,j,k,anArray;

  if (!xDKIDMW_Windows) return;
  for (i = 0; i < xDKIDMW_Windows.length;i++)
      if (xDKIDMW_Windows[i] == aUniqueWindowId) {
         anArray = new Array(xDKIDMW_Windows.length-1);
         k = 0;
         for (j = 0; j < xDKIDMW_Windows.length;j++) if (i != j) anArray[k++] = xDKIDMW_Windows[j];
         xDKIDMW_Windows = anArray;
         return;
      }
}
function xDKIDynamicMoveableWindow_GetTopMostWindowId() {
  var i,elem,aZElem;

  aZElem = null;
  for (i = 0; i < xDKIDMW_Windows.length; i++) {
      elem = elemById(xDKIDMW_Windows[i]);
      if (elem && (!aZElem || (elem.style.zIndex > aZElem.style.zIndex))) aZElem = elem;
  }
  if (aZElem) return aZElem.id;
  else return null;
}


// is left button-down
function xDKIIsLeftButtonDown(e) {
 	if (!e) e = window.event;

	 if (xDKIBrowser_IE()) return e.button == 1;
	 else return e.button == 0;
}


// splitter
var xDKISplitter_Flag,xDKISplitter_Window,xDKISplitter_InitialEventPos,xDKISplitter_InitialWindowPos,
    xDKISplitter_BodyMouseMove,xDKISplitter_BodyMouseUp;
function xDKISplitter_MouseDown(e,aObj) {
  var aMouseFunc;

 	if (!e) e = window.event;
  xDKIStopPropagation(e);

  xDKISplitter_Window = aObj;
  if (!xDKISplitter_Window) return;
  xDKISplitter_InitialEventPos = e.clientY;
  xDKISplitter_InitialWindowPos = xDKISplitter_Window.offsetTop;

  if (xDKISplitter_Flag != '1') {
     xDKIAddEvent(document,'mousemove',xDKISplitter_MouseMove,true);
     xDKIAddEvent(document,'mouseup',xDKISplitter_MouseUp,true);
     aMouseFunc = xDKISplitter_Window.getAttribute("xDKISplitter_CustomMouseDown")
     if (aMouseFunc) eval(aMouseFunc);
  }
  xDKISplitter_Flag = '1';
}
function xDKISplitter_MouseMove(e) {
  var aMouseFunc,NewTopPosition;

 	if (!e) e = window.event;
  xDKIStopPropagation(e);
  if (!xDKIIsLeftButtonDown(e)) { xDKISplitter_MouseUp(e); return; }

  if ((xDKISplitter_Flag == '1') && xDKISplitter_Window) {
     NewTopPosition = xDKISplitter_InitialWindowPos + e.clientY - xDKISplitter_InitialEventPos;
     aMouseFunc = xDKISplitter_Window.getAttribute("xDKISplitter_CustomMouseMove")
     if (aMouseFunc) NewTopPosition = eval(aMouseFunc);
     xDKISplitter_Window.style.top = NewTopPosition+'px'
  }
}
function xDKISplitter_MouseUp(e) {
  var aMouseFunc;

 	if (!e) e = window.event;
  xDKIStopPropagation(e);

  xDKISplitter_Flag = '';
  xDKIRemoveEvent(document,'mousemove',xDKISplitter_MouseMove,true);
  xDKIRemoveEvent(document,'mouseup',xDKISplitter_MouseUp,true);
  aMouseFunc = xDKISplitter_Window.getAttribute("xDKISplitter_CustomMouseUp")
  if (aMouseFunc) eval(aMouseFunc)
}


// photo / pic
function xDKIIsPic(aURL) {
  return aURL && (aURL.toLowerCase().indexOf('no_file') < 0);
}
function xDKIShowPhoto(aURL,aId,aIdCalledFromForFocus,aCaption,z,aZIndexFunction,dx,dy,w,h) {
  var aPos,aPhoto,aLeft,aTop;

  if (xDKIExistId('DynamicWindow'+aId)) {
     xDKIDynamicMoveableWindow_Close('DynamicWindow'+aId);
     return false;
  }
  if (!xDKIIsPic(aURL)) return;

  if (!dx) dx = 30;
  if (!dy) dy = 0;

	 aPhoto = document.createElement('img');
	 aPhoto.style.backgroundColor = '#ffffff';
	 aPhoto.src = aURL;
  if (!w) { if (aPhoto.width > 0) w = aPhoto.width; else w = 350; }
  if (!h) { if (aPhoto.height > 0) h = aPhoto.height; else h = 250; }
  h = h+20;
  aPos = xDKIPosition(elemById(aId));
  aLeft = aPos[0]+dx;
  aTop = aPos[1]+dy;
  xDKIDynamicMoveableWindow_Show('DynamicWindow'+aId,aPhoto,aIdCalledFromForFocus,aCaption,
                                 aLeft,aTop,w,h,z,aZIndexFunction,true);
}


// messagebox
function xDKIMessageBox(aCaption,aMessage,aOk,
                        aLeft/* optional */,
                        aTop/* optional */,
                        aWidth,aHeight,z,aZIndexFunction,
                        aCustomCloseFunction) {
  xDKIMessageBox1(aCaption,aMessage,'','',aOk,aLeft,aTop,aWidth,aHeight,z,aZIndexFunction,aCustomCloseFunction,
                  false,'',false,false);
}
function xDKIMessageBoxUrgent(aCaption,aMessage,aOk,
                              aLeft/* optional */,
                              aTop/* optional */,
                              aWidth,aHeight,z,aZIndexFunction,
                              aCustomCloseFunction,aUrgentBorderColor,aWithCloseButton,aWithSliding) {
  xDKIMessageBox1(aCaption,aMessage,'','',aOk,aLeft,aTop,aWidth,aHeight,z,aZIndexFunction,aCustomCloseFunction,
                  true,aUrgentBorderColor,aWithCloseButton,aWithSliding);
}
function xDKIMessageBox1(aCaption,aMessage,aLinkTxt,aLink,aOk,
                        aLeft/* optional */,
                        aTop/* optional */,
                        aWidth,aHeight,z,aZIndexFunction,aCustomCloseFunction,
                        aUrgent,aUrgentBorderColor,aWithCloseButton,aWithSliding) {
  var D,D1,D2,E,M,S,A,w;

  D = elemById('xDKIMessageBoxInternal');
  if (!D) {
     D = TheDoc().createElement('div');
     D.id = 'xDKIMessageBoxInternal';
     D.style.visibility = 'hidden';

     E = TheDoc().createElement('div');
     E.className = 'hspacer5';
     D.appendChild(E);

     M = TheDoc().createElement('div');
     M.innerHTML = aMessage;
     with (M.style) {
          marginLeft = '20px';
          if ((aCaption == '') && aUrgent && aWithCloseButton) marginRight = '20px';
          fontSize = '0.85em';
          fontWeight = 'bold';
     }
     M.id = 'xDKIMessageBoxInternal_Text';
     D.appendChild(M);

     E = TheDoc().createElement('div');
     E.className = 'spaceabove10';
     D.appendChild(E);

     if (aLink) {
        D1 = TheDoc().createElement('div');
        with (D1.style) {
             styleFloat = 'left';
             cssFloat = 'left';
             width = px(aWidth);
        }
        E.appendChild(D1);

        // 1
        D2 = TheDoc().createElement('div');
        with (D2.style) {
             styleFloat = 'left';
             cssFloat = 'left';
             width = '16px';
             height = '20px';
        }
        D1.appendChild(D2);

        // 2
        D2 = TheDoc().createElement('div');
        with (D2.style) {
             styleFloat = 'left';
             cssFloat = 'left';
             width = '150px';
             height = '20px';
        }
        D1.appendChild(D2);
        A = TheDoc().createElement('a');
        with (A) {
             className = 'left nohint arrow2right_layoutleft link';
             href = aLink;
        }
        D2.appendChild(A);
        S = TheDoc().createElement('span');
        S.innerHTML = aLinkTxt;
        A.appendChild(S);

        // 3
        D2 = TheDoc().createElement('div');
        with (D2.style) {
             styleFloat = 'left';
             cssFloat = 'left';
             width = '50px';
             height = '20px';
        }
        D1.appendChild(D2);

        // 4
        D2 = TheDoc().createElement('div');
        with (D2.style) {
             styleFloat = 'left';
             cssFloat = 'left';
             width = '50px';
             height = '20px';
        }
        D1.appendChild(D2);
        if (aOk) {
           A = TheDoc().createElement('a');
           with (A) {
                id = 'xDKIMessageBoxInternal_Ok';
                className = 'left nohint arrow2right_layoutleft link';
                href = 'javascript:'+(aCustomCloseFunction?aCustomCloseFunction+'();':'')+'xDKIDynamicMoveableWindow_Close("xDKIMessageBox")';
           }
           D2.appendChild(A);
           S = TheDoc().createElement('span');
           S.innerHTML = aOk;
           S.id = 'xDKIMessageBoxInternal_TextOk';
           A.appendChild(S);
        }
     }
     else if (aOk) {
        D1 = TheDoc().createElement('div');
        with (D1.style) {
             styleFloat = 'left';
             cssFloat = 'left';
             width = px(aWidth-50);
             fontSize = '2px';
             height = '20px';
        }
        E.appendChild(D1);
        A = TheDoc().createElement('a');
        with (A) {
             id = 'xDKIMessageBoxInternal_Ok';
             className = 'left nohint arrow2right_layoutleft link';
             href = 'javascript:'+(aCustomCloseFunction?aCustomCloseFunction+'();':'')+'xDKIDynamicMoveableWindow_Close("xDKIMessageBox")';
        }
        E.appendChild(A);
        S = TheDoc().createElement('span');
        S.innerHTML = aOk;
        S.id = 'xDKIMessageBoxInternal_TextOk';
        A.appendChild(S);
     }

     E = TheDoc().createElement('div');
     E.className = 'hspacer5';
     D.appendChild(E);
  }
  else {
     elemById('xDKIMessageBoxInternal_Text').innerHTML = aMessage;
     elemById('xDKIMessageBoxInternal_TextOk').innerHTML = aOk;
  }

  // show
  w = xDKIDynamicMoveableWindow_Show('xDKIMessageBox',D,null,aCaption,aLeft,aTop,aWidth,aHeight,
                                     z,aZIndexFunction,'','','',aCustomCloseFunction,'',
                                     aUrgent,aUrgentBorderColor,aWithCloseButton,aWithSliding);
  if (aOk) elemById('xDKIMessageBoxInternal_Ok').focus();
}
function xDKIMessageBoxPosition(aInnerWidth) {
  return (xDKIWindowWidth()-xDKIScrollBarWidth()-(_DynamicMoveableWindow_BorderWidth*2+aInnerWidth)) / 2;
}


// upper-right-icons
function xDKIIconUpperRight_Make(aId1,aId2,aId2Small,aShow) {
  var elem;

  // special positioning for IE 5
  if (xDKIBrowser_IE5()) {
     elem = elemById(aId1);
     elem.className = aId2Small;
     with (elem.style) {
          position = 'absolute';
          width = '20px';
          height = '20px';
     }
     elemById(aId2).className = '';
  }

  // special for xDKIBrowser
  if (aShow || !xDKIBrowser()) xDKIShowIdEx(aId1);
}
function xDKIIconUpperRight_Resize(aId,l1,l2,aWindowScrollLeft,aMaxOffset,aMaxOffsetW) {
  var w,l;

  if (aMaxOffset) w = aMaxOffsetW+aMaxOffset;
  with (elemById(aId).style) {
       l = (aWindowScrollLeft+xDKIWindowWidth()-l1);
       if (aMaxOffset && (l < w)) l = w;
       left = l+"px"; // After this the width can change (scrollbar!)
       if (xDKIWindowScrollLeft() != aWindowScrollLeft) left = (parseInt(left)-l2)+"px"
  }
}
function xDKIIconUpperRight_ResizeArray(aIdArray,l1Array,l2Array,aWindowScrollLeft,aMaxOffset,aMaxOffsetWArray) {
  var i,k;

  k = -1;
  for (i = 0;i <= aIdArray.length-1; i++)
      if (xDKIVisibleIdEx(aIdArray[i])) {
         k++;
         xDKIIconUpperRight_Resize(aIdArray[i],l1Array[k],l2Array[k],aWindowScrollLeft,aMaxOffset,
                                   aMaxOffsetWArray[k]);
      }
}


// call a function with arguments
function xDKICallFunction(aName,anArgsArr) {
  var s,i;
  s = aName+'(';
  for (i = 0; i <= anArgsArr.length-1; i++) {
      if (i != 0) s+=',';
      if (typeof anArgsArr[i] == 'string') s+='"'+anArgsArr[i]+'"'; else s+=anArgsArr[i];
  }
  s+= ')';
  return eval(s);
}


// dynamic script load
function xDKILoadJavaScriptModule(aFilename) {
  var aScript;

  aScript = document.createElement('script');
  aScript.setAttribute('type','application/javascript');
  aScript.setAttribute('src',aFilename);
  document.getElementsByTagName('head')[0].appendChild(aScript);
}


// add a rule to a CSS (will work also in IE5.5)
// example: xDKIAddCSSRule('css/SPCDetail.css','.spc_detail_td_header','font-size:0.7em');
function xDKIAddCSSRule(ahref,aName,aRule) {
	 var i;

  if (!document.styleSheets) return false;

	 for (i = 0; i<= document.styleSheets.length-1; i++)
      if (document.styleSheets[i].href.toLowerCase() == ahref.toLowerCase()) {
          document.styleSheets[i].addRule(aName,aRule);
          return true;
      }
}


// offline check
function xDKIOffline() {
  return xDKINotUndef(navigator.onLine) && !navigator.onLine
}

function isAChild(parentObject,ChildObject)
{
	var ChildrenList,i,result;
	result=false;
	for (i=0;i<parentObject.childNodes.length;i++)
	{
		if (parentObject.childNodes[i]==ChildObject) result=true;
	}
  return result;	
}
