/**
* Sammeldatei für nachträglich nötig gewordene Funktionen
* Derzeitiger Inhalt:
* - Kontrollfunktion für Formularfelder
* - (veränderte!) Anleihen aus dhtml.js
* - Korrekturfunktion für Höhe d. rechten Spalte
* - onLoad-Funktion "doOnPageReady()"
*/
var EA, undefined, tmpObj, tmpStr, tmpArr;

var ENV = {
  app : new Object()
}

var MPOT = {
  Cache : {
    LastCss : null,
    LayoutHor : {
      doFit : true,
      to : '',
      is : 'center',
      ml : new Array()
    }
  },
  documentStarted : false,
  documentInitialized : false,
  onDocStart : new Array(),
  onBeforeInit : new Array(),
  onInitDone : new Array(),
  RootPath : document.location.protocol+'//'+document.location.host
}

function noop() {;}

function notUndef(obj) {
  return typeof obj != "undefined";
}

// MPOT.solveOptions = function(str) {
//   var q, k, erg, arr, ar2;
//   erg = new Object();
//   if(typeof str == "string") {
//     arr = str.split(",");
//     for(q=0; q<qrr.length; q++) {
//       ar2 = arr[q].split("=");
//       k = ar2[0].trim();
//       if(k) {
//         if(k.charAt(0)=="!" || k.charAt(0)=="-" || k.charAt(0)=="+") {
//           k = k.slice(1);
//           if(k.length) {
//             if(k.charAt(0)=="+") erg[k] = "true";
//             else erg[k] = "false";
//           }
//         }
//         erg[k] = ar2.slice(1).join("=");
//         if(erg[k].toLowerCase()=="true") erg[k] = true;
//         if(erg[k].toLowerCase()=="false") erg[k] = false;
//       }
//     }
//   }
//   return erg;
// }
MPOT.solveOptions = function(str) {
  // loest kommaseparierte Optionsstrings zu einem Objekt (im Weiteren "L") auf:
  // 'x,+x,x=true' : L.x ist boolesch "true"
  // '!x,-x,x=false' : L.x ist boolesch "false"
  // 'x=-1.2e+3' : L.x ist eine Fliesskommawert
  // 'x=Erna Mittelkoetter' L.x ist ein String
  var q, k, erg, arr, ar2, c0;
  erg = new Object();
  if(typeof str == "string") {
    arr = str.split(",");
    for(q=0; q<arr.length; q++) {
      ar2 = arr[q].split("=");
      k = ar2[0].trim();
      if(k && k.length) {
        c0 = k.charAt(0);
        if( ("!-+").indexOf(c0) != -1) {
          k = k.slice(1);
          if(k.length) {
            if(c0=="+") erg[k] = "true";
            else erg[k] = "false";
          }
          else continue;
        }
        else if(typeof ar2[1] == 'undefined') erg[k] = "true";
        else erg[k] = ar2.slice(1).join("=").trim();
        if (erg[k].search(/^[\-\+]?\d+(\.\d+(e[\-\+]?\d+)?)?$/) == 0) {
          if (str.indexOf(".")+1) erg[k] = parseFloat(erg[k]);
          else erg[k] = parseInt(erg[k]);
          continue;
        }
        if(erg[k].charAt(0)=="$") erg[k] = document.getElementById(erg[k].slice(1).trim());
        else {
          c0 = erg[k].toLowerCase();
          erg[k] = c0=="true" ? true : (c0=="false" ? false : (c0=="null" ? null : erg[k] ));
        }
      }
    }
  }
  return erg;
}


MPOT.announce = function (mainText, subText, closeText) {
  // Buttons als weitere Argumente, Form: ['Text','Anweisung','Optionen'], [T,A] ,...
  // automatischen Schliessknopf ausblenden: closeText = null
  // braucht Klasse .MPOT_announcer
  var DIV, i, txt='', arr, OPT;
  function getBtn(arr) {
    var BO = MPOT.solveOptions(arr[2]);
    return '<a href="javascript: ;" style="'+(BO.style||'')+'" onclick="'
      +( BO.noclose ? '' : "this.parentNode.style.display='none';" )
      +(arr[1]||'')+'">&nbsp;'+(arr[0]||arr)+'&nbsp;<\/a><br><br>';
  }
  function isOff () {
    return this.style.display == 'none';
  }

  if(typeof closeText == 'undefined' || closeText==='') closeText = 'OK';

  if(document.body && document.createElement) {
    DIV = document.createElement('div');
    DIV.className = 'MPOT_announcer';
    DIV = document.body.appendChild(DIV);
    fixPos(DIV, getWindowWidth()/2, 150, isOff);

    if(mainText) txt += '<span class="mainText">'+mainText+'<\/span><br><br>'
    if(subText) txt += '<span class="subText">'+subText+'<\/span><br><br>'

    for (i=3; i<arguments.length; i++) txt += getBtn(arguments[i]);
    if(closeText !== null) txt += getBtn([closeText,'']);

    DIV.innerHTML = txt;

  }

  else alert('Eine Benachrichtigung oder Auswahlbox konnte auf Ihrem\n'
    + 'Computer nicht erzeugt werden. Ihr Textinhalt lautete:\n\n'
    + (mainText ? mainText+'\n\n' : '') + (subText ? subText : '')
  );

}

MPOT.pseudoUid = function(length) {
  var uid = "", num, qq;
  for(qq=0; qq<=length; qq++) {
    num = Math.random();
    num = Math.floor(num*61.999)+48;
    if(num>57) num+=7;
    if(num>90) num+=6;
    uid += String.fromCharCode(num);
  }
  return uid;
}

if(!document.getElementById && document.all){
  document.getElementById = function(id){
    return document.all[id];
  }
}

function isWhitespaceOnly(html) {
  var text = html||"";
  text = text.replace(/\x3C[^\x3C\x3E]*\x3E/g,' '); // Tags entfernen
  text = text.replace(/\&nbsp\;/g,' '); // &nbsp; entfernen
  return text.search(/\S/) == -1;
}

popUpWindow.IDRegistry = new Object();
popUpWindow.byNumber = new Array();
popUpWindow.HandBack = null;
function popUpWindow(url, opts) {
  // benoetigte Funktionen: MPOT.solveOptions
  // Option rc (recycle): Fenster bei gleicher Skriptadresse (ohne Query) wiederverwenden (Standard: ja)
  // Optionen w h l t r b: Breite / Hoehe / von Links / von Oben / von Rechts / von Unten
  // Option resize: User kann Groesse aendern (Standard: nein)
  // Option scroll: Fenster hat Scrollbars (Standard: ja)
  // Option keep : Bei Oeffnen auf Vorgabe-Werte zuruecksetzen (interessant bei Wiederaufruf)
  // Optionen id name: setzt das Namensattribut des Fensters auf einen festen (den uebergebenen) Wert
  // Option recover: offenes, namentlich bekanntes Fenster in neuer Seite wieder aufgreifen
  // Optionen übergeben (Beispiel): '!rc,h=-1,r=0' - Fenster nicht recyclen, maximale Hoehe, rechtsbuenndig
  // siehe auch MPOT.solveOptions
  var OPT = MPOT.solveOptions(opts);
  var REG = popUpWindow.IDRegistry, urlID, WIN=null, winName, err, O, firstTime=true, LNK, DIV, arr;
  var w = OPT.w || 720, h = OPT.h || screen.availHeight-100;
  var l = 0, t = 0, resize, scroll;

  resize = OPT.resize ? 'yes' : 'no';
  scroll = (typeof OPT.scroll == 'boolean' && !OPT.scroll) ? 'no' : 'yes';
  if(typeof OPT.rc == 'undefined') OPT.rc = true;
  if(typeof OPT.keep == 'undefined') OPT.keep = false;

  try{
    if(url && url.length) {

      if(url=='blank') url = '/jsinc/dummyWithReadyMarker.html';

      url = url.trim();
      urlID = url.split('?')[0].replace(new RegExp('^'+MPOT.RootPath, 'i'), '').replace(/\W/g,'_');

      if(w<0) {
        w = screen.availWidth;
        l = 0;
      } else {
        if(typeof OPT.l == 'number') l = OPT.l; // links
        if(typeof OPT.r == 'number') l = screen.availWidth - w - OPT.r; // rechts
        else l = (screen.availWidth - w) / 2; // hor'mittig
      }
      if(h<0) {
        h = screen.availHeight;
        t = 0;
      } else {
        if(typeof OPT.t == 'number') t = OPT.t; // oben
        if(typeof OPT.b == 'number') t = screen.availHeight - h - OPT.b; // unten
        else t = (screen.availHeight - h) / 2; // vertikal mittig
      }

      if(OPT.internal_trickBlocker) { // falls der Popupblocker zuschlaegt ...
        MPOT.announce('Ein Popup konnte nicht ge&ouml;ffnet werden', null, 'Hinweis ausblenden',
          ['Popup &ouml;ffnen',"popUpWindow('"+url+"','"+opts.replace(/\,internal_trickBlocker/,'')+"');"]
        );
        return null;
      }
      else if(OPT.rc && REG[urlID] && !REG[urlID].closed) { // Fenster recyclen ...
        WIN = REG[urlID];
        WIN.location.href = url;
        winName = WIN.name;
      }
      else { // neues Fenster oder in offenem Fenster Seite wieder aufgreifen bzw. laden ...
        winName = OPT.id || OPT.name || 'MPOTWIN'+MPOT.pseudoUid(9);
        WIN = REG[urlID] = window.open(OPT.recover ? '' : url, winName,
              'width='+(w-8)+',height='+(h-50)+',left=0,top=0,location=no,menubar=no,resizable='+resize+',scrollbars='+scroll+',toolbar=no');
        if(WIN && OPT.recover && compareSrc(WIN.location.href, url) == 'unequal') WIN.location.href = url;
      }

      if(WIN) {
        try { // Position korrigieren ...
          WIN.eval("if(opener) opener.popUpWindow.HandBack = self.originalPopUpVals || '';");
          if(popUpWindow.HandBack) {
            O = MPOT.solveOptions(popUpWindow.HandBack);
            if(O.w) w = O.w; h = O.h; l = O.l; t = O.t;
            firstTime = false;
          }
          popUpWindow.HandBack = null;
        } catch (err) {
          if(top.TRACER) top.TRACER.announce(err.message, ':Error in meltingpot.js \n in function popUpWindow - Marker 2');
        }

        if(firstTime || OPT.keep) {
          WIN.resizeTo(w,h);
          WIN.moveTo(l,t);
        }

        WIN.popUpWindowNumber = popUpWindow.byNumber.length;
        popUpWindow.byNumber.push(WIN);
      }

      setTimeout(function() {
        if(WIN) {
          WIN.focus();
          WIN.setInterval('if (!opener || opener.closed) self.close();', 333);
          WIN.setTimeout("self.originalPopUpVals = 'w="+w+",h="+h+",l="+l+",t="+t+"';",1500);
        } else if(!OPT.internal_trickBlocker) {
          if(!opts) opts = '';
          opts += ',internal_trickBlocker';
          popUpWindow(url, opts);
        }
      }, 333);

      return WIN;

    }
  } catch (err) {
    if(top.TRACER) top.TRACER.announce(err.message, ':Error in meltingpot.js \n in function popUpWindow - Marker 1');
    return null;
  }
}


// Browsererkennung ...

EA = ENV.app;

EA.ie4 = document.all ? true : false;
EA.nn4 = document.layers ? true : false;

EA.w3c = (document.getElementById && document.documentElement) ? true : false;
EA.w3cL2 = (EA.w3c && document.createRange && document.addEventListener) ? true : false;

EA.gecko  = navigator.product ? navigator.product.search("Gecko") >= 0 : false;
EA.gecko14comp = (EA.w3cL2 && notUndef(document.designMode) && document.execCommand) ? true : false;
EA.gecko14 = EA.gecko && EA.gecko14comp;

// AppleWebKit:
EA.safari = navigator.userAgent.indexOf("AppleWebKit") >= 0;
EA.safariNative = navigator.userAgent.indexOf("Safari") >= 0;

// KHTML-Engines:
EA.konqNative = navigator.appName == "Konqueror";
EA.konq = EA.konqNative || EA.safari;
EA.khtml = !EA.gecko && (navigator.product ? navigator.product.search("khtml") >= 0 : EA.konq);

EA.opera = navigator.userAgent.indexOf("Opera") >= 0;

// Gecko-Engines:
EA.moz = !EA.konq && !EA.opera && EA.w3c && EA.gecko; // auch Netsc. 6+ und Epiphany
EA.moz14 = EA.moz && EA.gecko14; // auch Netsc. 7.1 +
EA.kecko = EA.konq && EA.gecko14; // Stand Okt. 04: in Planung -> korrekt?
EA.ffx = EA.gecko14 && navigator.userAgent.indexOf("Firefox") >= 0; // dann auch EA.moz!

if(EA.gecko || EA.khtml || EA.opera) EA.ie4 = false;
else if (EA.ie4) EA.w3c = false;

EA.msie = EA.ie4;

EA.verNum = 0;
EA.revNum = -1;

EA.ie5=false; EA.ie5mac=false; EA.ie52mac=false; // Korrektur im OS-Block
EA.ie55=false; EA.ie6=false; EA.sim_msie=false;
if (EA.ie4) {
  if (document.getElementById) EA.ie5 = true;
  tmpStr = navigator.userAgent || navigator.appVersion;
  tmpArr = tmpStr.match(/\; *MSIE *([\d\.]+) *\;/);
  if (tmpArr.length>1) EA.verNum = parseFloat(tmpArr[1]);
  else EA.verNum = EA.ie5 ? 5.0 : 4.0;
  if(EA.verNum>5.499) EA.ie55 = true;
  if(EA.verNum>5.999) {
    EA.ie6 = true;
    if(document.addEventListener) {
      EA.ie4=EA.ie5=false;
      EA.w3c=EA.w3cL2=true;
    }
  }
}else{
  EA.sim_msie = navigator.appName.indexOf("Internet Explorer") >= 0;
  tmpArr = navigator.userAgent.match(/[ \;]+rv: ?([\d\.]*)/i);
  // EA.revNum
  if(tmpArr && tmpArr[1]) EA.revNum = parseFloat(tmpArr[1].replace(/(\.\d*)\./g,"$1"));
  if(tmpArr && tmpArr[1] && !EA.ffx) EA.verNum = EA.revNum;
  else {
    tmpStr = EA.konqNative?"Konqueror":(EA.safariNative?"Safari":(EA.safari?"AppleWebKit":(EA.ffx?"Firefox":(EA.opera?"Opera":"DUMMY"))));
    tmpRXp = new RegExp(tmpStr+"[\\ \\/]?([\\d\\.]+)","i");
    tmpArr = navigator.userAgent.match(tmpRXp);
    if(tmpArr && tmpArr[1]) {
      EA.verNum = parseFloat(tmpArr[1]);
      if(EA.safari && EA.verNum>45) {
        EA.revNum = EA.verNum;
        switch (Math.floor((EA.verNum-1)/100)) {
          case 0: EA.verNum = EA.verNum>=85 ? 1.0 : 0.8; break;
          case 1: case 2: EA.verNum = EA.verNum<125 ? 1.1 : 1.2; break;
          case 3: EA.verNum = 1.3; break;
          default: EA.verNum = (Math.floor((EA.verNum)/10)-21)/10; // grobe Schaetzung Feb 2006 (aktuell: Safari/417.8) [BNY]
        }
      }
    }
  }
  if(!EA.verNum) EA.verNum = parseFloat(navigator.appVersion);
}

EA.engineType = EA.gecko?"gecko":(EA.msie?"msie":(EA.khtml?"khtml":(EA.opera?"opera":(EA.w3c?"w3c":(EA.nn4?"nn4":"unknown")))));

String.prototype.trim = function() {
  return this.replace(/^\s*/,"").replace(/\s*$/,"");
}

function testFormOnSubmit(form,MfStr,umlOK) {
  // MF steht für Mandatory-Fields-Objekt
  // Beispiel:
  //   MfStr = 'email:Im Feld XY muss eine Mailadresse stehen!:@email|name:Geben Sie einen Namen ein|...'
  // -> Empfehlung: Meldungstext = escape(Meldungstext);
  var arr, arr2, str, flg, RX, erg=true, ergTotal=true, MF, qq, k, outStr="";
  arr = MfStr.split("|");
  MF = new Object();
  for(qq=0; qq<arr.length; qq++){
    arr2 = arr[qq].split(":");
    MF[arr2[0].trim()] = arr2.slice(1).join(':');
  }
  for(k in MF){
    if(typeof form[k]!='undefined'){
      arr = MF[k].split(':');
      if(!arr[1]) arr[1] = "@@string";

      if(form[k].type && (form[k].type=="text"||form[k].type=="textarea")){
        switch(arr[1]){
          case "@@string": RX = /\S+/; break;
          case "@@confirm": RX = /^\s*(JA|J|NEIN|N|YES|Y|NO|N|OUI|O|NON|SI|S)\s*$/i; break;
          case "@@ok": RX = /^\s(JA|J|OK|YES|Y|OUI|O|SI|S)\s$/i; break;
          case "@@email":
            RX = /^[\w\.\-äöüßáéíóúàèìòùâêîôû]+@\w([\w\-äöüßáéíóúàèìòùâêîôû]+\.)+\w{2,5}$/i;
            break;
          case "@@integer": RX = /^[\-\+]?\d+$/; break;
          case "@@number": RX = /^[\-\+]?\d+(\.\d+([Ee][\-\+]?\d+)?)?$/; break;
          case "@@plz": RX = /^\d{5}$/; break;
          case "@@adr": RX = /^\S{2,} .*\d{1,4}\w?$|^(q.{0,7} )?\w\d{1,2}[\,\ ]{0,3}[\d\-]{0,5}$/i; break;
          case "@@zahl": RX = /^[\-\+]?\d+(\,\d+([Ee][\-\+]?\d+)?)?$/; break;
          case "@@menge": RX = /^\d{1,8}$/; break;
          case "@@telefon": RX = /^(\S{1,3}[ \-]{1,3})?[\d\+\-\(\)\[\]\/\ ]*\d{3,}[\d\-\/\ ]*$/; break;
          default:
            str = arr.slice(1).join(':').replace(/^\s*|\s*$/g,"");
            if(str.search(/^\/.+\/[gim]{0,3}$/)!=-1) {
              flg = str.replace(/^\/.+\/([gim]{0,3})$/,"$1");
              str = str.replace(/^\//,"").replace(/\/[gim]{0,3}$/,"");
            } else flg = "i";
            RX = new RegExp(str,flg);
        }
        erg = form[k].value.search(RX)!=-1;
      }

      if(form[k].type && form[k].type=="Checkbox") erg = form[k].checked;

      if(!erg){ // wenn Ergebnis negativ ...
        ergTotal = false;
        outStr += unescape(arr[0]).replace(/\r\n|\n|\r/g,"\\n").replace(/"/g,"''")+"\\n";
      }
    }
  }
  if(!ergTotal){ // wenn Ergebnis negativ ...
    setTimeout('alert("'+outStr+'");',1);
  }
  return ergTotal;
}

function canScroll(win) {
  if(!win) win = window;
  if(win.scrollbars && (typeof win.scrollbars.visible != 'undefined'))
    return win.scrollbars.visible;
  // bezieht sich auf seitlichen Scrollbar ...
  if(document.body) {
    if(typeof document.body.scroll == "string" && document.body.scroll.length)
      return (("yes,auto").indexOf(win.document.body.scroll) > -1);
    if(document.body.offsetWidth && document.body.clientWidth)
      return (Math.abs(win.document.body.offsetWidth - win.document.body.clientWidth) > 6);
    if(win.innerWidth && document.body.clientWidth)
      return (Math.abs(win.innerWidth - win.document.body.clientWidth) > 6);
  }
  return true; // : im "Zweifelsfall"
}

function getWindowWidth(win) {
  var doc;
  if(!win) win = window;
  doc = win.document;
  if (doc.documentElement && doc.documentElement.clientWidth) return doc.documentElement.clientWidth;
  if (win.innerWidth) {
    if(canScroll(win))
      return (bodyClientSize() && doc.body.clientWidth!=win.innerWidth) ?
        doc.body.clientWidth : win.innerWidth-16;
    return win.innerWidth;
  }
  if (doc.body.clientWidth) return doc.body.clientWidth;
  if (doc.body.offsetWidth)
    return doc.body.offsetWidth - (win.canScroll()?16:0);
  return -1; // = nicht gefunden
}

function getSize(node) {
  if(typeof node == "string") node = document.getElementById(node);
  if(node) {
    if (document.layers) {
      if(node.clip) return [ node.clip.width , node.clip.height ];
      if(node.width) return [ node.width , node.height ];
      return [0,0];
    }
    else return [ parseInt(node.offsetWidth.toString()) , parseInt(node.offsetHeight.toString()) ];
  } else return [0,0];
}

function setSize(node,w,h) {
  if(typeof node == "string") node = document.getElementById(node);
  if(node) {
    if(typeof w == "number") {
      if(document.layers) node.clip.width = w;
      else node.style.width = w.toString()+"px";}
    if(typeof h == "number") {
      if(document.layers) node.clip.height = h;
      else node.style.height = h.toString()+"px";}
  }
}

function getPos(node){
  var vati,x=0,y=0;
  if(typeof node == "string") node = document.getElementById(node);
  if(node){
    if(document.layers) {
      if(typeof node.pageX == 'number') return [ node.pageX , node.pageY , node.zIndex ];
      if(typeof node.x == 'number') return [ node.x , node.y , 0 ];
      return [0,0,0];
    }
    else {
      vati = node;
      while (vati) {
        x += vati.offsetLeft; y += vati.offsetTop;
        vati = vati.offsetParent;
      }
      return [ x, y, (node.style && node.style.zIndex) ? node.style.zIndex : 0 ];
    }
  } else return [0,0,0];
}

function setPos(node,X,Y,Z) {
  if(typeof node == "string") node = document.getElementById(node);
  if (typeof X == "number") node.style.left = X.toString()+"px";
  if (typeof Y == "number") node.style.top = Y.toString()+"px";
  if (typeof Z == "number") node.style.zIndex = Z;
}

findLastCss = function () {
  var C = MPOT.Cache, doc, arr, win = window;
  if(!C.LastCss){
   doc = win.document;
   arr = doc.styleSheets || doc.styleSheet;
   if(arr && arr.length) C.LastCss = arr[arr.length-1];
  }
}

function addCssRule(sel,rule) {
  var C = MPOT.Cache, CSS;
  findLastCss();
  CSS = C.LastCss;
  if(CSS) {
    if (CSS.addRule) CSS.addRule(sel,rule);
    else CSS.insertRule(sel+"{"+rule+"}",CSS.cssRules.length);
  }
}

function openPopup(type,url) {
   var breit, hoch, X0, Y0, str, Korrektur=25;
   switch(type) {
     case "100px":
       breit = hoch = 100; X0 = Y0 = 10;
       break;
     case "full":
       breit = screen.availWidth-10; hoch = screen.availHeight-Korrektur;
       X0 = Math.round((screen.availWidth-breit)/2)-10; if (X0<0) X0=0;
       Y0 = Math.round((screen.availHeight-hoch-Korrektur)/2)-15; if (Y0<0) Y0=0;
       break;
     default:
       breit = 400; hoch = 300;
       X0 = Math.round((screen.availWidth-breit)/2)-10; if (X0<0) X0=0;
       Y0 = Math.round((screen.availHeight-hoch-Korrektur)/2)-15; if (Y0<0) Y0=0;
   }
   str = "menubar=no,location=no,directories=no,resizable=yes,scrollbars=yes,toolbar=no,status=yes,";
   str += 'width='+breit+',height='+hoch+',';
   if (document.layers) str += 'screenX='+X0+',screenY='+Y0+',';
   else str += 'left='+X0+',top='+Y0;
   return window.open(url,"YellowMarkerPopup",str,false);
}

MPOT.getSelectedText = function (win) {
  var W = window || win, D, S = null;
  D = W.document;
  if (typeof W.getSelection == 'function') {
    S = W.getSelection();
    if (S && S.toString) return S.toString();
  }
  else if (typeof D.selection != "undefined") {
    S = D.selection;
    if (S && S.createRange) return S.createRange().text || '';
  }
  return '';
}

MPOT.evalWithSelectionText = function (str, inWin) {
  // Als zweites Argument kann ein Bezugsfenster uebergeben werden
  var arr, txt, win = self, host;
  if (inWin && inWin.setTimeout && win.eval) win = inWin;
  host = win.location.protocol+'//'+win.location.host+'/';
  txt = MPOT.getSelectedText (win);
  if (typeof str == 'string') {
    txt = txt.replace(/\s+/g, ' ').replace(/("|')/g, '\\$1');
    // %SEL% wird durch den Selektionstext ersetzt
    // %QSELQ% wird durch den Selektionstext in Anfuehrungszeichen ersetzt ...
    win.eval(str.replace(/%SEL%/g, txt).replace(/%QSELQ%/g, '"'+txt+'"')
      .replace(/%HOST%/g, host).replace(/%SELQUERY%/g, encodeURIComponent(txt)));
  }
}

function doOnPageReady(){
  var node, y, y1, y2, h1, h2, dy, hSoll, get;
  if(get = document.getElementById){
    node = get("LinkeSpalte");
    y1 = getPos(node)[1]+getSize(node)[1];
    node = get("MittlereSpalte");
    y2 = getPos(node)[1]+getSize(node)[1];
    node = get("RechteSpalte");
    hSoll = Math.max(y1,y2) - getPos(node)[1];
    if(hSoll > getSize(node)[1]) node.style.height = hSoll+"px";
  }
}

MPOT.startDocument = function(options) {
  var qq, OPT = MPOT.solveOptions(options);
  if(!MPOT.documentStarted) {
    MPOT.documentStarted = true;
    for(qq=0; qq<MPOT.onDocStart.length; qq++) MPOT.onDocStart[qq]();
  }
}

MPOT.init = function(options) {
  var qq, OPT = MPOT.solveOptions(options);
  if(!MPOT.documentInitialized) {
    if(!MPOT.documentStarted) MPOT.startDocument();
    MPOT.documentInitialized = true;
    for(qq=0; qq<MPOT.onBeforeInit.length; qq++) MPOT.onBeforeInit[qq]();
    // hier ggf. spaetere Initialisierungsfunktionen einfuegen ...
    for(qq=0; qq<MPOT.onInitDone.length; qq++) MPOT.onInitDone[qq]();
  }
}

if(typeof initConfig == "undefined") window.initConfig = MPOT.init;


function fitLayoutToWinSize () {
  var w100p = getWindowWidth();
  var div, LH = MPOT.Cache.LayoutHor;

  function fitHPos(name) {
    var S, x;
    div = document.getElementById(name);
    if ( div && ( S = div.style ) ) {
      if ( typeof LH.ml[name] == 'undefined' ) LH.ml[name] = getStyle(div, 'marginLeft');
      if ( LH.to == 'center' ) {
        S.left = '50%';
        S.marginLeft = LH.ml[name];
      } else { // demnach LH.to == 'left'
        x = 478 + parseInt( LH.ml[name] ); // 487
        S.left = x+'px';
        S.marginLeft = '0px';
      }
    }
  }

  if(LH.doFit) {
    if ( w100p > 0 && w100p < 1000) { // wenn User Fenster kleiner 1000px macht ...
      LH.to = 'left';
      if(LH.is != LH.to) {
        fitHPos('StructureTop');
        fitHPos('OuterStructMainLeftBottom');
        // fitHPos('DummyPageHeight');
        LH.is = LH.to;
      }
    } else { // wenn User Fenster wieder groesser 1000px macht ...
      LH.to = 'center';
      if(LH.is != LH.to) {
        fitHPos('StructureTop');
        fitHPos('OuterStructMainLeftBottom');
        // fitHPos('DummyPageHeight');
        LH.is = LH.to;
      }
    }
  }

}

/**
* Nachfolgend Sondermodul "Textcounter/-längenbegrenzer" für Stadt MH ...
*/


function InputLengthGuard(node) { // Laengenwaechter-Klasse
  var arr, str, osub, CLA = InputLengthGuard, form = node.form, _fn;
  var i = CLA.inst.length;
  var my = CLA.inst[i] = this;
  arr = node.className.match(/\bLenMinMax_(\d+)_(\d+)_?(\w+)?\-?(\S+)?\b/i);
  this.node = node;
  this.form = form;
  this.cnum = i;
  this.min = parseInt(arr[1]);
  this.max = parseInt(arr[2]);
  if(this.max<1) this.max = 1E+10;
  this.mode = arr[3] || "0";
  this.dispName = arr[4] || null;
  this.disp = null;
  if(this.dispName && document.getElementById) this.disp = document.getElementById(this.dispName);
  this.lastContent = node.value.toString();

  this.loopID = setInterval("InputLengthGuard.inst["+i+"].checkMaxAndCount();", 50);

  // nachfolgend wird der Mindestlaengencheck fuer d. einzeln. Felder an d. Formularsubmit gehaengt
  osub = form.onsubmit;
  _fn = form.onsubmit = function(EVT) {
    var OK = my.checkMin(), args = null, osubRtn = true;
    if(typeof arguments != "undefined") args = arguments;
    else if(_fn.arguments) args = _fn.arguments
    if(typeof osub == "function") osubRtn = osub.apply(form, args);
    return OK && ( typeof osubRtn != "undefined" ? osubRtn : true ); // ERST TESTEN
  }
  // else form.onsubmit = my.checkMin;

}

InputLengthGuard.inst = new Array(); // Sammler für die Instanzen

InputLengthGuard.prototype.checkMaxAndCount = function() {
  var node = this.node, dsp = this.disp, str, num;
  var len = node.value.length;
  if(dsp && typeof dsp.innerHTML != "undefined") {
    switch(this.mode.toLowerCase()) {
      case "max":
          str = (this.max - len).toString();
          if(this.max < 1E+9 && dsp.innerHTML != str) dsp.innerHTML = str;
        break;
      case "min":
          num = this.min - len;
          if(num<0) num = 0;
          str = num.toString();
          if(dsp.innerHTML != str) dsp.innerHTML = str;
        break;
      default:
        str = len.toString();
        if(dsp.innerHTML != str) dsp.innerHTML = str;
    }
  }
  if(len > this.max) {
    node.value = this.lastContent;
  }
  this.lastContent = node.value.toString();
}

InputLengthGuard.prototype.checkMin = function() {
  var node = this.node, title="", arr, i, id;
  id = node.id;
  if(!id) id = "";
  if(node.value.length < this.min) {
    if(document.getElementsByTagName) {
      arr = document.getElementsByTagName('label');
      for(i=0; i<arr.length; i++) if(arr[i].htmlFor && arr[i].htmlFor==id) {
        title = '"'+arr[i].innerHTML.replace(/\x3C[^\x3C\x3E]*\x3E/g,' ')+'"';
        break;
      }
    }
    if(title=='' && node.title) title = '"'+node.title+'"';
    if(title=='') title = node.id ? '"'+node.id+'"' : '[ohne Titel]';
    setTimeout("alert('Eingabefeld "+title+" enthält zu wenige Zeichen!');", 10);
    return false;
  } else {
    return true;
  }
}

function startInputLengthGuard() {
  var I, i, G, str="";
  I = new Array();

  I = document.getElementsByTagName('input');
  for(i=0; i<I.length; i++) {
    if(I[i].type.indexOf('text') == 0 &&
       I[i].className.search(/\bLenMinMax_\d+_\d+/i) != -1) G = new InputLengthGuard(I[i]);
  }
  I = document.getElementsByTagName('textarea');
  for(i=0; i<I.length; i++) {
    if(I[i].className.search(/\bLenMinMax_\d+_\d+/i) != -1) G = new InputLengthGuard(I[i]);
  }

}

MPOT.onBeforeInit[MPOT.onBeforeInit.length] = startInputLengthGuard;

function showBmTitle(BmName) {
    BmDiv = document.getElementById('bookmark_service');
    switch (BmName) {
        case 'delicious':
            BmDiv.innerHTML = "Del.icio.us";
        break;
        case 'google':
            BmDiv.innerHTML = "Google";
        break;
        case 'misterwong':
            BmDiv.innerHTML = "Mister Wong";
        break;
        default:
            object_test(BmName);
        break;
    }
}

function hideBmTitle() {
    document.getElementById('bookmark_service').innerHTML = "";
}

function toggle_verteiler_anschrift(check) {
    str = document.getElementById('zeile_strasse');
    ort = document.getElementById('zeile_ort');
    if (check.checked === true) {
        if (EA.msie) {
            str.style.display = "block";
            ort.style.display = "block";
        } else {
            str.style.display = "table-row";
            ort.style.display = "table-row";
        }
    } else {
        str.style.display = "none";
        ort.style.display = "none";
    }
    return;
}

function toggle_verteiler_mail(check) {
    mail = str = document.getElementById('zeile_email');
    if (check.checked === true) {
        if (EA.msie) {
            mail.style.display = "block";
        } else {
            mail.style.display = "table-row";
        }
    } else {
        mail.style.display = "none";
    }
    return;
}

function setColorNamesForClickTracker(color, ParamText) {
    if (color == "amg") {
        newColor = "Rot";
    } else if (color == "wirt") {
        newColor = "Gruen";
    } else if (color == "tech") {
        newColor = "Blau";
    } else if (color == "std") {
        newColor = "Portal";
    } else {
        return false;
    }

    //alert(newColor+ParamText);
    clickTracker(newColor+ParamText);
    return false;
}
