

/*
XMLHttpRequest-Properties:
open
onreadystatechange
send
readyState
channel
responseXML
responseText
status
statusText
abort
getAllResponseHeaders
getResponseHeader
setRequestHeader
overrideMimeType
multipart
onload
onerror
onprogress
addEventListener
removeEventListener
dispatchEvent
getInterface
*/

var undefined;

function Ajax(id) {
  this.id;
  this.req = undefined;
  this.url = '';
  this.asynchron = true;
  this.parameter = {};
  this.parameterLength = [];
  this.mimeType = 'text/xml';
  this.requestHeader = 'application/x-www-form-urlencoded';
  this.callBackFunction = undefined;
  this.method = 'POST';

  this._setID(id);
}

Ajax.prototype._setID = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Ajax->_setID: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Ajax->_setID: Argument str ist nicht vom Typ String!");
  }
  this.id = str;
}

Ajax.prototype.createRequest = function () {
  var req;
  if (window.ActiveXObject) {
    try {
      req = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    }
  } else if (typeof XMLHttpRequest != undefined) {
    req = new XMLHttpRequest();
    /*
    if (this.mimeType){
      req.overrideMimeType(this.mimeType);
    }*/
  } else {
    focus();
    throw new Error("Ajax->createRequest: Der Browser unterstützt die Methode nicht!");
  }
  return req;
}

Ajax.prototype.addParameter = function (strKey, strValue) {
  if (arguments.length != 2) {
    focus();
    throw new Error("Ajax->addParameter: Falsche Anzahl von Argumenten!");
  }
  if (typeof strKey != "string") {
    focus();
    throw new Error("Ajax->addParameter: Argument strKey ist nicht vom Typ String!");
  }
  if (typeof strValue != "string") {
    focus();
    throw new Error("Ajax->addParameter: Argument strValue ist nicht vom Typ String!");
  }
  this.parameter[strKey] = strValue;
  this.parameterLength.push(strKey);
}

Ajax.prototype.setRequestHeader = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Ajax->setRequestHeader: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Ajax->setRequestHeader: Argument str ist nicht vom Typ String!");
  }
  this.requestHeader = str;
}

Ajax.prototype.setAsynchron = function (b) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Ajax->setAsynchron: Falsche Anzahl von Argumenten!");
  }
  if (typeof b != "boolean") {
    focus();
    throw new Error("Ajax->setAsynchron: Argument str ist nicht vom Typ Boolean!");
  }
  this.asynchron = b;
}

Ajax.prototype.setMethod = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Ajax->setMethod: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Ajax->setMethod: Argument str ist nicht vom Typ String!");
  }
  if (str!='GET' && str!='POST' && str!='HEAD'){
    focus();
    throw new Error("Ajax->setMethod: Argument str muss Wert GET oder POST oder HEAD haben!");
  }
  this.method = str;
}

Ajax.prototype.setURL = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Ajax->setURL: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Ajax->setURL: Argument str ist nicht vom Typ String!");
  }
  this.url = str;
}

Ajax.prototype.setCallBackFunction = function (func) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Ajax->setCallBackFunction: Falsche Anzahl von Argumenten!");
  }
  if (typeof func != "function") {
    focus();
    throw new Error("Ajax->setCallBackFunction: Argument func ist nicht vom Typ Function!");
  }
  this.callBackFunction = func;
}

Ajax.prototype.open = function () {
  this.req = this.createRequest();
  if (this.method == 'POST'){
    if (! this.requestHeader){
      focus();
      throw new Error("Ajax->open: Mehtod=POST requires requestHeader !");
    }
  }
  try {
    this.req.open(this.method, this.url, this.asynchron);
    if (this.callBackFunction){
      this.req.onreadystatechange = this.callBackFunction;
    }
  } catch(e){
    Ajax._getNavigatorPrivilege(this);
  }
}

Ajax.prototype.sendAll = function () {
  var _req = '';
  for (var i in this.parameter){
    if (Ajax.getCharset() == 'utf-8' || Ajax.getCharset() == 'utf-16'){
      _req += '&' + i + '=' + encodeURIComponent(this.parameter[i]);
    } else {
      _req += '&' + i + '=' + escape(this.parameter[i]);
    }
  }
  _req = _req.replace(/^\&/,'');
  this.req.send(_req);
}

Ajax.prototype.sendNull = function () {
  this.req.send(null);
}

Ajax.prototype.send = function (strKey, strValue) {
  if (arguments.length != 2) {
    focus();
    throw new Error("Ajax->send: Falsche Anzahl von Argumenten!");
  }
  if (typeof strKey != "string") {
    focus();
    throw new Error("Ajax->send: Argument strKey ist nicht vom Typ String!");
  }
  if (typeof strValue != "string") {
    focus();
    throw new Error("Ajax->send: Argument strValue ist nicht vom Typ String!");
  }
  if (Ajax.getCharset() == 'utf-8' || Ajax.getCharset() == 'utf-16'){
    this.req.send(strKey + '=' + encodeURIComponent(strValue));
  } else {
    this.req.send(strKey + '=' + escape(strValue));
  }
}

Ajax.prototype.getReadyState = function () {
  if (this.req.readyState == undefined){
    return undefined;
  }
  return this.req.readyState;
}

Ajax.prototype.getStatus = function () {
  if (this.req.status == undefined){
    return undefined;
  }
  return this.req.status;
}

Ajax.prototype.getResponseXML = function () {
  return this.req.responseXML;
}

Ajax.prototype.getResponseText = function () {
  return this.req.responseText;
}

Ajax.prototype.getXML = function (str) {
  str = Ajax.stripSpace(str);
  if (arguments.length != 1) {
    focus();
    throw new Error("Ajax->getXML: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Ajax->send: Argument str ist nicht vom Typ String!");
  }
  var xml = '';
  if (window.DOMParser){
    var parser = new DOMParser();
    xml = parser.parseFromString(str, "text/xml");
  } else {
    xml = new ActiveXObject("Microsoft.XMLDOM");
    xml.async="false";
    xml.loadXML(str);
  }
  return xml;
}

Ajax.prototype.getReadableXMLNode = function () {
  if (! this.req.responseXML){
    focus();
    throw new Error("Ajax->getReadableXMLNode: INVALID XML, SERVER-REQUEST-STATUS: " + this.getStatus());
    return undefined;
  }
  return this.req.responseXML.documentElement;
}

Ajax.prototype.getSingleNodeValue = function (name) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Ajax->getSingleNodeValue: Falsche Anzahl von Argumenten!");
  }
  if (typeof name != "string") {
    focus();
    throw new Error("Ajax->getSingleNodeValue: Argument name ist nicht vom Typ String!");
  }
  var xml = this.getReadableXMLNode();
  if (! xml){
    return undefined;
  }
  for (var i=0; i<xml.childNodes.length; i++) {
    var node = xml.childNodes[i];
    if (node.nodeType != 1){
      continue;
    }
    if (node.nodeName.toLowerCase() != name){
      continue;
    }
    return this.getValueFromXMLNode(node);
  }
  return undefined;
}

Ajax.prototype.getValueFromXMLNode = function (node) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Ajax->getValueFromXMLNode: Falsche Anzahl von Argumenten!");
  }
  return node.firstChild.nodeValue;
}

Ajax.prototype.getIdenticalNodeArray = function (name) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Ajax->getIdenticalNodeArray: Falsche Anzahl von Argumenten!");
  }
  if (typeof name != "string") {
    focus();
    throw new Error("Ajax->getIdenticalNodeArray: Argument name ist nicht vom Typ String!");
  }
  var xml = this.getReadableXMLNode();
  if (! xml){
    return undefined;
  }
  return xml.getElementsByTagName(name);
}

Ajax._increment = [];
Ajax._registerInstance = {};
Ajax._registerInstanceLength = [];

Ajax._getNavigatorPrivilege = function (obj) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Ajax._getNavigatorPrivilege: Falsche Anzahl von Argumenten!");
  }
  if (! (obj instanceof Ajax)) {
    focus();
    throw new Error("Ajax._getNavigatorPrivilege: Argument obj ist keine Instance von Ajax!");
  }
  if (obj.req) {
    if (typeof netscape != 'undefined' && typeof netscape.security != 'undefined' && typeof netscape.security.PrivilegeManager != 'undefined') {
      netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
      obj.open();
    } else {
      focus();
      throw new Error("Ajax._getNavigatorPrivilege: Das Ajax-Progamm läuft in diesem Kontext nicht. bitte wenden Sie sich an Ihren Administrator!");
    }
  }
}

Ajax.stripSpace = function(attr){
  var result = '';
  if (attr){
    attr = new String(attr);
    result = attr.replace(/^\s+/,'');
    result = result.replace(/\s+$/,'');
  }
  if (result.match(/^\s+/) || result.match(/\s+$/)){
    return Ajax.stripSpace(result);
  }
  return result;
}

Ajax.getInstance = function(id) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (! (Ajax._registerInstance[id])){
    focus();
    throw new Error("Es ist keine Ajax.Instance mit id=" + id + " registriert!");
  }
  return Ajax._registerInstance[id];
}

Ajax.createInstance = function(id) {
  if (!arguments.length) {
    id = 'Ajax' + Ajax._increment.length;
    Ajax._increment.push(1);
  }
  if (! (Ajax._registerInstance[id])){
    Ajax._registerInstance[id] = new Ajax(id);
    Ajax._registerInstanceLength.push(id);
  } else {
    focus();
    throw new Error("Ajax.createInstance: id schon vorhanden!");
  }
  return Ajax.getInstance(id);
}

Ajax.cursorWait = function () {
  if (! document.getElementsByTagName('body').length){
    return;
  }
  document.getElementsByTagName('body')[0].style.cursor = 'wait';
}

Ajax.cursorFinished = function () {
  if (! document.getElementsByTagName('body').length){
    return;
  }
  document.getElementsByTagName('body')[0].style.cursor = 'auto';
}

Ajax.getCharset = function () {
  if (document.charset){
    return document.charset.toLowerCase();
  } else if (document.characterSet) {
    return document.characterSet.toLowerCase();
  } else {
    return undefined;
  }
}






function Tools() {
}







Tools.openMicrosite = function(htmlElement, properties) {
  if (!arguments.length) {
    return false;
  }
  var url = '';
  var docSource = '';
  var tagName = htmlElement['tagName'];
  tagName = tagName.toLowerCase();
  if (tagName == 'form'){
    var nameValuePeer = [];
    for (var i=0; i<htmlElement.elements.length; i++){
      nameValuePeer[i] = {};
      if (htmlElement.elements[i].name.length){
        if (htmlElement.elements[i].type == 'select-one'){
            nameValuePeer[i]['name'] = htmlElement.elements[i].name;
            nameValuePeer[i]['value'] = htmlElement.elements[i].options[htmlElement.elements[i].selectedIndex].value;
        } else if (htmlElement.elements[i].type == 'select-multiple'){
          nameValuePeer[i]['name'] = htmlElement.elements[i].name;
          nameValuePeer[i]['value'] = [];
          for (var ii=0; ii<htmlElement.elements[i].options.length; ii++){
            if (htmlElement.elements[i].options[ii].selected){
              nameValuePeer[i]['value'][ii] = htmlElement.elements[i].options[ii].value;
            }
          }
        } else if (htmlElement.elements[i].type == 'radio'){
          nameValuePeer[i]['name'] = htmlElement.elements[i].name;
          if (htmlElement.elements[i].length){
            nameValuePeer[i]['value'] = [];
            for (var ii=0; ii<htmlElement.elements[i].length; ii++){
              if (htmlElement.elements[i][ii].checked){
                nameValuePeer[i]['value'][ii] = htmlElement.elements[i][ii].value;
              }
            }
          } else {
            if (htmlElement.elements[i].checked){
              nameValuePeer[i]['value'] = htmlElement.elements[i].value;
            }
          }
        } else if (htmlElement.elements[i].type == 'checkbox'){
          nameValuePeer[i]['name'] = htmlElement.elements[i].name;
          if (htmlElement.elements[i].length){
            nameValuePeer[i]['value'] = [];
            for (var ii=0; ii<htmlElement.elements[i].length; ii++){
              if (htmlElement.elements[i][ii].checked){
                nameValuePeer[i]['value'][ii] = htmlElement.elements[i][ii].value;
              }
            }
          } else {
            if (htmlElement.elements[i].checked){
              nameValuePeer[i]['value'] = htmlElement.elements[i].value;
            }
          }
        } else {
          nameValuePeer[i]['name'] = htmlElement.elements[i].name;
          nameValuePeer[i]['value'] = htmlElement.elements[i].value;
        }
      }
    }
    if (!htmlElement.method || htmlElement.method.toLowerCase() != 'post'){
      url += htmlElement.action + '?';
      for (var f=0; f<nameValuePeer.length; f++){
        if (typeof nameValuePeer[f]['value'] == 'object'){
          for (var ff=0; ff<nameValuePeer[f]['value'].length; ff++){
            if (nameValuePeer[f]['value'][ff]){
              url += '&' + encodeURIComponent(nameValuePeer[f]['name']);
              url += '=' + encodeURIComponent(nameValuePeer[f]['value'][ff]);
            }
          }
        } else {
          if (nameValuePeer[f]['value']){
            url += '&' + encodeURIComponent(nameValuePeer[f]['name']);
            url += '=' + encodeURIComponent(nameValuePeer[f]['value']);
          }
        }
      }
    } else {
      var charsetting = 'ISO-8859-1';
      if (document.charset){
        if (document.charset != charsetting){
          charsetting = document.charset;
        }
      } else if (document.characterSet){
        if (document.characterSet != charsetting){
          charsetting = document.characterSet;
        }
      }
      docSource += '<html>\n<head><title></title><meta http-equiv="content-type" content="text/html; charset='+ charsetting +'"/></head>\n<body background-color="#ffffff" onload="document.forms[\'myform\'].submit();"><div style="display: none;">\n';
      docSource += '<form name="myform" action="'+ htmlElement.action +'" method="post">\n';
      for (var f=0; f<nameValuePeer.length; f++){
        if (typeof nameValuePeer[f]['value'] == 'object'){
          for (var ff=0; ff<nameValuePeer[f]['value'].length; ff++){
            if (nameValuePeer[f]['value'][ff]){
              docSource += '<input type="checkbox" name="'+ nameValuePeer[f]['name'] +'" value="'+ nameValuePeer[f]['value'][ff] +'" checked="checked"/>\n';
            }
          }
        } else {
          if (nameValuePeer[f]['value']){
            docSource += '<input type="checkbox" name="'+ nameValuePeer[f]['name'] +'" value="'+ nameValuePeer[f]['value'] +'" checked="checked"/>\n';
          }
        }
      }
      docSource += '</form>\n</div></body>\n</html>';
    }
    try {
      htmlElement.reset();
    } catch(e){
    }
  } else if (tagName == 'a' || tagName == 'area'){
    url += htmlElement.href;
  }
  var windowProps = '';
  if (arguments[1]){
    windowProps = properties;
  } else {
    windowProps = 'width=800,height=600,scrollbars=yes,locationbar=no,menubar=no';
  }
  var fenster = window.open(url, 'Micorsite', windowProps);
  if (docSource.length){
    var doc = fenster.document;
    doc.open();
    doc.write(docSource);
    doc.close();
  }
  fenster.focus();
  return false;
}

Tools.getCookieValue = function(cookieName){
  var cookieValue = '';
  if (! navigator.cookieEnabled){
    alert('Ihr Browser erlaubt keine Cookies!');
    return cookieValue;
  }
  if (! cookieName){
    return cookieValue;
  }
  var allCookies = document.cookie;
  var allCookiesArr = allCookies.split(/\;/);
  var regExp = new RegExp('^' + cookieName + '=');
  for (var i=0; i<allCookiesArr.length; i++){
    var _val = Tools.stripSpace(allCookiesArr[i]);
    if (! _val.match(regExp)){
      continue;
    }
    cookieValue = _val.replace(regExp,'');
  }
  if (cookieValue.match(/^"/) && cookieValue.match(/"$/)){
    cookieValue = cookieValue.replace(/^"/,'');
    cookieValue = cookieValue.replace(/"$/,'');
  }
  cookieValue = cookieValue.replace(/###/,';');
  return cookieValue;
}

Tools.setCookieValue = function(cookieValue, cookieName, expiresDate, path, version, valueType){
  if (! navigator.cookieEnabled){
    alert('Ihr Browser erlaubt keine Cookies!');
    return false;
  }
  if (! cookieValue.length){
  }
  if(! cookieName){
    cookieName = 'myCookie';
  }
  var expDate = Tools.DateToGMTStringCookie(expiresDate);
  if (cookieValue.length >= 4000){
    alert('Das Cookie kann nicht gespeichert werden.\nDie Datenmenge übersteigt die maximal zu speichernde Datenmenge eines Cookies.\nBitte überprüfen Sie Ihre Daten.');
    return false;
  }
  cookieValue = cookieValue.replace(/;/,'###');
  var cookieStr = '';
  if (valueType == 'int'){
    cookieStr = cookieName +'=' + cookieValue +';';
  } else {
    cookieStr = cookieName +'="' + cookieValue +'";';
  }
  if (expDate){
    cookieStr += ' expires='+ expDate +';';
  }
  if (path){
    cookieStr += ' path='+ path + ';';
  }
  version = 3;
  if (version && version.toString().length){
    cookieStr += ' version="'+ version + '";';
  }
  document.cookie = cookieStr;
}

Tools.DateToGMTStringCookie = function(date){
  if (! date){
    return false;
  }
  var str = '';
  var gtm = '';
  var gtmJS = date.toGMTString();
  var gtmArr = gtmJS.split(/ /);
  for (var i=0; i<gtmArr.length; i++){
    if (i>1 && i<4){
      gtm += '-';
    } else if (i > 0){
      gtm += ' ';
    }
    gtm += gtmArr[i];
  }
  return gtm;
}

Tools.confirmURL = function(url){
  if (! url){
    return false;
  }
  var conf = confirm('Möchten Sie den Datensatz wirklich löschen?');
  if (conf) {
    return url;
  }
}

Tools.checkRequiredData = function(htmlElement) {
  if (!arguments.length) {
    return false;
  }
  var _dataType = new RegExp(' \\[datatype\\=');
  var _required = new RegExp(' \\[required');
  var _requiredOn = new RegExp(' \\[requiredOn\\]');
  var _requiredOr = new RegExp(' \\[requiredOr\\]');
  var tagName = htmlElement['tagName'];
  tagName = tagName.toLowerCase();
  if (tagName == 'form'){
    for (var i=0; i<htmlElement.elements.length; i++){
      var idRequiredOn = undefined;
      var elemRequiredOn = undefined;
      var idRequiredOr = undefined;
      var elemRequiredOr = undefined;
      var mulitple = undefined;
      if(htmlElement.elements[i].nodeName.toLowerCase() == 'fieldset'){
        continue;
      }
      if (!htmlElement.elements[i].name.length || (!htmlElement.elements[i].className.length || (!htmlElement.elements[i].className.toString().match(_required) && !htmlElement.elements[i].className.toString().match(_dataType))) ){
        continue;
      }
      var requiredElemHasValue = false;
      var dataTypeElemHasDataTypeValue = true;
      if (htmlElement.elements[i].className.toString().match(_dataType)){
        if (! Tools.checkDataTypeElement(htmlElement.elements[i])) {
          dataTypeElemHasDataTypeValue = false;
        }
      }
      if (htmlElement.elements[i].className.toString().match(_requiredOn)){
        idRequiredOn = htmlElement.elements[i].className.toString().split(_requiredOn)[1].toString().replace(/[\[\]]/gi,'');
        elemRequiredOn = document.getElementById(idRequiredOn);
        if (Tools.checkRequiredElement(elemRequiredOn)){
          requiredElemHasValue = Tools.checkRequiredElement(htmlElement.elements[i]);
        } else {
          requiredElemHasValue = true;
        }
      } else if (htmlElement.elements[i].className.toString().match(_requiredOr)){
        idRequiredOr = htmlElement.elements[i].className.toString().split(_requiredOr)[1].toString().replace(/[\[\]]/gi,'');
        elemRequiredOr = document.getElementById(idRequiredOr);
        if (Tools.checkRequiredElement(elemRequiredOr)){
          requiredElemHasValue = true;
        } else {
          requiredElemHasValue = Tools.checkRequiredElement(htmlElement.elements[i]);
        }
      } else {
        requiredElemHasValue = Tools.checkRequiredElement(htmlElement.elements[i]);
      }
      if (!requiredElemHasValue){
        var shownElemName = htmlElement.elements[i].name;
        if (htmlElement.elements[i].title){
          shownElemName = htmlElement.elements[i].title;
        }
        if (elemRequiredOr != undefined){
          var shownElemNameOr = elemRequiredOr.name;
          if (elemRequiredOr.title){
            shownElemNameOr = elemRequiredOr.title;
          }
          alert('Bitte füllen Sie das Feld >>'+ shownElemName +'<< oder >>'+ shownElemNameOr +'<< aus!');
        } else {
          alert('Bitte füllen Sie das Feld >>'+ shownElemName +'<< aus!');
        }
        if (htmlElement.elements[i].type != 'hidden') {
          htmlElement.elements[i].focus();
        }
        return false;
      }
      if (!dataTypeElemHasDataTypeValue){
        var shownElemName = htmlElement.elements[i].name;
        if (htmlElement.elements[i].title){
          shownElemName = htmlElement.elements[i].title;
        }
        if (htmlElement.elements[i].type != 'hidden') {
          htmlElement.elements[i].focus();
        }
        return false;
      }
    }
    return true;
  }
}

Tools.checkRequiredDataFormFragment = function(htmlElement, elem) {
  if (arguments.length != 2) {
    return false;
  }
  var _dataType = new RegExp(' \\[datatype\\=');
  var _required = new RegExp(' \\[required');
  var _requiredOn = new RegExp(' \\[requiredOn\\]');
  var _requiredOr = new RegExp(' \\[requiredOr\\]');
  var tagName = htmlElement['tagName'];
  tagName = tagName.toLowerCase();
  if (tagName == 'form'){
    for (var i=0; i<htmlElement.elements.length; i++){
      var idRequiredOn = undefined;
      var elemRequiredOn = undefined;
      var idRequiredOr = undefined;
      var elemRequiredOr = undefined;
      if(htmlElement.elements[i].nodeName.toLowerCase() == 'fieldset'){
        continue;
      }
      if (!htmlElement.elements[i].name.length || (!htmlElement.elements[i].className.length || (!htmlElement.elements[i].className.toString().match(_required) && !htmlElement.elements[i].className.toString().match(_dataType))) ){
        continue;
      }
      if (! Tools.isChildOfElement(elem, htmlElement.elements[i])) {
        continue;
      }
      var requiredElemHasValue = false;
      var dataTypeElemHasDataTypeValue = true;
      if (htmlElement.elements[i].className.toString().match(_dataType)){
        if (! Tools.checkDataTypeElement(htmlElement.elements[i])) {
          dataTypeElemHasDataTypeValue = false;
        }
      }
      if (htmlElement.elements[i].className.toString().match(_requiredOn)){
        var idRequiredOn = htmlElement.elements[i].className.toString().split(_requiredOn)[1].toString().replace(/[\[\]]/gi,'');
        var elemRequiredOn = document.getElementById(idRequiredOn);
        if (Tools.checkRequiredElement(elemRequiredOn)){
          requiredElemHasValue = Tools.checkRequiredElement(htmlElement.elements[i]);
        } else {
          requiredElemHasValue = true;
        }
      } else if (htmlElement.elements[i].className.toString().match(_requiredOr)){
        var idRequiredOr = htmlElement.elements[i].className.toString().split(_requiredOr)[1].toString().replace(/[\[\]]/gi,'');
        var elemRequiredOr = document.getElementById(idRequiredOr);
        if (Tools.checkRequiredElement(elemRequiredOr)){
          requiredElemHasValue = true;
        } else {
          requiredElemHasValue = Tools.checkRequiredElement(htmlElement.elements[i]);
        }
      } else {
        requiredElemHasValue = Tools.checkRequiredElement(htmlElement.elements[i]);
      }
      if (!requiredElemHasValue){
        var shownElemName = htmlElement.elements[i].name;
        if (htmlElement.elements[i].title){
          shownElemName = htmlElement.elements[i].title;
        }
        if (elemRequiredOr != undefined){
          var shownElemNameOr = elemRequiredOr.name;
          if (elemRequiredOr.title){
            shownElemNameOr = elemRequiredOr.title;
          }
          alert('Bitte füllen Sie das Feld >>'+ shownElemName +'<< oder >>'+ shownElemNameOr +'<< aus!');
        } else {
          alert('Bitte füllen Sie das Feld >>'+ shownElemName +'<< aus!');
        }
        if (htmlElement.elements[i].type != 'hidden') {
          htmlElement.elements[i].focus();
        }
        return false;
      }
      if (!dataTypeElemHasDataTypeValue){
        var shownElemName = htmlElement.elements[i].name;
        if (htmlElement.elements[i].title){
          shownElemName = htmlElement.elements[i].title;
        }
        if (htmlElement.elements[i].type != 'hidden') {
          htmlElement.elements[i].focus();
        }
        return false;
      }
    }
    return true;
  }
}

Tools.isChildOfElement = function(parentElem, childElem) {
  if (arguments.length != 2) {
    return false;
  }
  var nextElem = childElem;
  while (nextElem && nextElem.nodeName.toLowerCase() != 'body'){
    if (nextElem == parentElem){
      return true;
    }
    nextElem = nextElem.parentNode;
  }
  return false;
}

Tools.checkDataTypeElement = function(elem) {
  if (!arguments.length) {
    return false;
  }
  if (elem == undefined){
    return false;
  }
  var _dataTypeDE = new RegExp(' \\[datatype\\=Date\\_DE\\]');
  var _dataTypeCMS = new RegExp(' \\[datatype\\=Date\\_CMS\\]');
  var _dataTypeMail = new RegExp(' \\[datatype\\=Mail\\]');
  var _dataTypeAge = new RegExp(' \\[datatype\\=Age\\]');
  var _dataTypeLedgerNr = new RegExp(' \\[datatype\\=LedgerNr\\]');
  var _dataTypeInteger = new RegExp(' \\[datatype\\=Integer\\]');
  var _value = '';
  if (elem.type == 'select-one'){
    if (elem.selectedIndex < 0){
      return false;
    }
    _value = Tools.stripSpace(elem.options[elem.selectedIndex].value);
  } else if (elem.type == 'select-multiple'){
    for (var ii=0; ii<elem.options.length; ii++){
      if (elem.options[ii].selected){
        _value += Tools.stripSpace(elem.options[ii].value);
      }
    }
  } else if (elem.type == 'radio'){
    if (elem.length){
      for (var ii=0; ii<elem.length; ii++){
        if (elem[ii].checked){
          _value += Tools.stripSpace(elem[ii].value);
        }
      }
    } else {
      if (elem.checked){
        _value = Tools.stripSpace(elem.value);
      }
    }
  } else if (elem.type == 'checkbox'){
    if (elem.length){
      for (var ii=0; ii<elem.length; ii++){
        if (elem[ii].checked){
          _value += Tools.stripSpace(elem[ii].value);
        }
      }
    } else {
      if (elem.checked){
        _value = Tools.stripSpace(elem.value);
      }
    }
  } else {
    _value = Tools.stripSpace(elem.value);
  }
  if (! _value.length){
    return true;
  }
  if (elem.className.toString().match(_dataTypeDE)){
    return Tools.validateDateFormat(_value, 'DE');
  }
  if (elem.className.toString().match(_dataTypeCMS)){
    return Tools.validateDateFormat(_value, 'CMS');
  }
  if (elem.className.toString().match(_dataTypeMail)){
    return Tools.validateMailFormat(_value);
  }
  if (elem.className.toString().match(_dataTypeLedgerNr)){
    return Tools.validateLedgerNumber(_value);
  }
  if (elem.className.toString().match(_dataTypeAge)){
    return Tools.validateAge(_value);
  }
  if (elem.className.toString().match(_dataTypeInteger)){
    return Tools.validateInteger(_value);
  }
  return true;
}

Tools.getDataValue = function(elem) {
  if (!arguments.length) {
    return false;
  }
  if (elem == undefined){
    return false;
  }
  var _value = '';
  if (elem.type == 'select-one'){
    if (elem.selectedIndex < 0){
      return false;
    }
    _value = Tools.stripSpace(elem.options[elem.selectedIndex].value);
  } else if (elem.type == 'select-multiple'){
    for (var ii=0; ii<elem.options.length; ii++){
      if (elem.options[ii].selected){
        _value += Tools.stripSpace(elem.options[ii].value);
      }
    }
  } else if (elem.type == 'radio'){
      if (elem.checked){
        _value = Tools.stripSpace(elem.value);
      }
  } else if (elem.type == 'checkbox'){
      if (elem.checked){
        _value = Tools.stripSpace(elem.value);
      }
  } else if (elem.length) {
      for (var ii=0; ii<elem.length; ii++){
        if (elem[ii].checked){
          _value += Tools.stripSpace(elem[ii].value);
        }
      }
  } else {
    _value = Tools.stripSpace(elem.value);
  }
  return _value;
}

Tools.setDataValue = function(elem, value) {
  if (!arguments.length) {
    return false;
  }
  if (elem == undefined){
    return false;
  }
  var _value = '';
  if (elem.type == 'select-one'){
    for (var ii=0; ii<elem.options.length; ii++){
      if (elem.options[ii].value == value){
        elem.options[ii].selected = 'selected';
      }
    }
  } else if (elem.type == 'select-multiple'){
    for (var ii=0; ii<elem.options.length; ii++){
      if (elem.options[ii].value == value){
        elem.options[ii].selected = 'selected';
      }
    }
  } else if (elem.type == 'radio'){
      if (elem.value == value){
        elem.checked = 'checked';
      }
  } else if (elem.type == 'checkbox'){
      if (elem.value == value){
        elem.checked = 'checked';
      }
  } else if (elem.length){
      for (var ii=0; ii<elem.length; ii++){
        if (elem[ii].value == value){
          elem[ii].checked = 'checked';
        }
      }
  } else {
    elem.value = value;
  }
  return true;
}

Tools.getCheckedElements = function(elem) {
  if (!arguments.length) {
    return false;
  }
  if (elem == undefined){
    return false;
  }
  var arr = [];
  if (elem.type == 'radio'){
      if (elem.checked){
        arr.push(elem);
      }
  } else if (elem.type == 'checkbox'){
      if (elem.checked){
        arr.push(elem);
      }
  } else if (elem.length) {
      for (var ii=0; ii<elem.length; ii++){
        if (elem[ii].checked){
          arr.push(elem[ii]);
        }
      }
  }
  return arr;
}

Tools.validateInteger = function(value) {
  if (! arguments.length) {
    return;
  }
  if (! value.match(/^[+-]?\d\d*$/)) {
    alert('Bitte geben Sie nur ganze Zahlen ein!');
    return false;
  }
  return true;
}

Tools.validateAge = function(value) {
  if (! arguments.length) {
    return;
  }
  if (! Tools.validateInteger(value)) {
    return false;
  }
  if (! (parseInt(value) > 0 && parseInt(value) < 130)) {
    var str = '';
    if (parseInt(value) > 120){
      str += 'Herzlichen Glückwunsch zu Ihrem sehr hohen Alter!!\n'
    } else {
      str += 'Sie sind leider noch nicht geboren!!\n';
    }
    str += 'Bitte geben Sie eine Zahl zwischen 1 und 130 ein!'
    alert(str);
    return false;
  }
  return true;
}

Tools.validateLedgerNumber = function(value) {
  if (! arguments.length) {
    return;
  }
  if (! value.match(/^(\d\d?\d?\d?\d?\d?\d?\d?\d?\d?)$/)) {
    alert('Bitte geben Sie eine Zahl mit 1 - 10 Stellen ein!');
    return false;
  }
  return true;
}

Tools.validateDateFormat = function(value, variant) {
  if (! arguments.length) {
    return;
  }
  if (variant == 'CMS'){
    if (! value.match(/^(\d\d\d\d)\-(\d\d)\-(\d\d)$/)) {
      alert('Bitte geben Sie das Datum im Format jjjj-mm-dd an!');
      return false;
    }
  } else {
    if (! value.match(/^(\d\d?)\.(\d\d?)\.(\d\d\d\d)$/)) {
      alert('Bitte geben Sie das Datum im Format tt.mm.jjjj an!');
      return false;
    }
  }
  return true;
}

Tools.validateMailFormat = function(value) {
  if (!arguments.length) {
    return false;
  }
  var regEx = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)(\\@)([a-zA-Z0-9\\-\\.]+)(\\.)([a-zA-Z]{2,4})$');
  if (! value.match(regEx)){
    alert('Bitte geben Sie eine gültige E-Mail-Adresse an!');
    return false;
  }
  return true;
}

Tools.checkRequiredElement = function(elem) {
  if (!arguments.length) {
    return false;
  }
  if (elem == undefined){
    return false;
  }
  var _multipleRegEx = new RegExp(' \\[multiple\\]');
  var _multiple = false;
  if(elem.className.toString().match(_multipleRegEx)){
    _multiple = true;
  }
  if (_multiple){
    return Tools.checkRequiredElementMultiple(elem);
  }
  return Tools.checkRequiredElementSingle(elem);
}

Tools.checkRequiredElementMultiple = function(elem) {
  if (!arguments.length) {
    return false;
  }
  if (elem == undefined){
    return false;
  }
  var requiredValue = '';
  var arr = document.getElementsByName(elem.name);
  for (var i=0; i<arr.length; i++) {
    var multipleElem = arr[i];
    if (! Tools.checkRequiredElementSingle(multipleElem)){
      continue;
    }
    return true;
  }
  return false;
}

Tools.checkRequiredElementSingle = function(elem) {
  if (!arguments.length) {
    return false;
  }
  if (elem == undefined){
    return false;
  }
  var requiredValue = '';
  if (elem.type == 'select-one'){
    if (elem.selectedIndex < 0){
      return false;
    }
    requiredValue = Tools.stripSpace(elem.options[elem.selectedIndex].value);
  } else if (elem.type == 'select-multiple'){
    for (var ii=0; ii<elem.options.length; ii++){
      if (elem.options[ii].selected){
        requiredValue += Tools.stripSpace(elem.options[ii].value);
      }
    }
  } else if (elem.type == 'radio'){
    if (elem.length){
      for (var ii=0; ii<elem.length; ii++){
        if (elem[ii].checked){
          requiredValue += Tools.stripSpace(elem[ii].value);
        }
      }
    } else {
      if (elem.checked){
        requiredValue = Tools.stripSpace(elem.value);
      }
    }
  } else if (elem.type == 'checkbox'){
    if (elem.length){
      for (var ii=0; ii<elem.length; ii++){
        if (elem[ii].checked){
          requiredValue += Tools.stripSpace(elem[ii].value);
        }
      }
    } else {
      if (elem.checked){
        requiredValue = Tools.stripSpace(elem.value);
      }
    }
  } else {
    requiredValue = Tools.stripSpace(elem.value);
  }
  if (!requiredValue.length){
    return false;
  }
  return true;
}

Tools.resetForm = function(elem) {
  if (!arguments.length) {
    return false;
  }
  if (elem == undefined){
    return false;
  }
  if (! elem.elements) {
    return false;
  }
  for (var i=0; i<elem.elements.length; i++){
    Tools.resetFormElement(elem.elements[i]);
  } 
  return true;
}

Tools.resetFormElement = function(elem) {
  if (!arguments.length) {
    return false;
  }
  if (elem == undefined){
    return false;
  }
  if (elem.type == 'submit') {
    return false;
  }
  var requiredValue = '';
  if (elem.type == 'select-one'){
    elem.options[0].selected = 'selected';
  } else if (elem.type == 'select-multiple'){
    elem.options[0].selected = 'selected';
  } else if (elem.type == 'radio'){
    if (elem.length){
      for (var ii=0; ii<elem.length; ii++){
        elem[ii].checked = false;
      }
    } else {
      elem.checked = false;
    }
  } else if (elem.type == 'checkbox'){
    if (elem.length){
      for (var ii=0; ii<elem.length; ii++){
        elem[ii].checked = false;
      }
    } else {
      elem.checked = false;
    }
  } else {
    elem.value = '';
  }
  return true;
}

Tools.stripSpace = function(attr){
  var result = '';
  if (attr){
    attr = new String(attr);
    result = attr.replace(/^\s+/,'');
    result = result.replace(/\s+$/,'');
  }
  return result;
}

Tools.checkDataSize = function(elem, size) {
  if (!arguments.length) {
    return false;
  }
  var _type = elem.type.toLowerCase();
  var _value = Tools.stripSpace(elem.value);
    if (_value.length > size){
      elem.value = _value.substring(0, size);
      alert('Sie dürfen maximal ' + size + ' Zeichen eingeben.');
    }
}

Tools.validateEmail = function(elem) {
  if (!arguments.length) {
    return false;
  }
  var _value = Tools.stripSpace(elem.value);
  var regEx = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)(\\@)([a-zA-Z0-9\\-\\.]+)(\\.)([a-zA-Z]{2,4})$');
  if (! _value.match(regEx)){
    alert('Bitte geben Sie eine gültige E-Mail-Adresse an!');
    elem.focus();
  }
}

Tools.validateURL = function(elem) {
  if (!arguments.length) {
    return false;
  }
  var _value = Tools.stripSpace(elem.value);
  var regEx = new RegExp('^(http:\/\/|https:\/\/|mailto:\/\/|ftp:\/\/|\/)');
  if (! _value.match(regEx)){
    alert('Bitte geben Sie eine gültige URL an!\nEine gültige URL muß mit http://, https://, etc. anfangen');
    elem.focus();
  }
}

Tools.openLinkinOpener = function(url) {
  if (!arguments.length) {
    return false;
  }
  var root;
  if (window.opener){
    root = window.opener;
  }
  if (parent.opener){
    root = parent.opener;
  }
  if (parent.top.opener){
    root = parent.top.opener;
  }
  if (! root){
    return true;
  }
  root.location = url;
  root.focus();
  return false;
}

Tools.submitQuichsearch = function(htmlElement) {
  if (!arguments.length) {
    return false;
  }
  var tagName = htmlElement['tagName'];
  tagName = tagName.toLowerCase();
  if (tagName == 'form'){
    var regExp = new RegExp('Stichwort|Stichwort eingeben|Suchwort|Suchwort eingeben|Suchbegriff|Suchbegriff eingeben');
    for (var i=0; i<htmlElement.elements.length; i++){
      var _value = Tools.stripSpace(htmlElement.elements[i].value);
      if(! _value.match(regExp)){
        continue;
      }
      htmlElement.elements[i].value = '';
    }
    return true;
  }
}

Tools.formatCashFloat = function(n){
  cash_float = parseFloat(new String(n).replace(/\,/,'.'));
  cash_float = parseFloat(cash_float * 100);
  cash_float = parseFloat(Math.round(cash_float) / 100);
  cash_float = new String(cash_float);
  if (!cash_float.match(/\./)){
    cash_float = cash_float + '.00';
  }
  if (cash_float.split(/\./)[1].length == 1){
    cash_float = cash_float + '0';
  }
  cash_float = cash_float.replace(/\./,',');
  return cash_float;
}


Tools.addEvent = function(oneEvent, obj, handler, bol, ieWindow){
  if (arguments.length < 3) {
    focus();
    throw new Error('Tools.addEvent: Falsche Anzahl von Argumenten!');
  }
  if(window.addEventListener){
    obj.addEventListener(oneEvent, handler, bol);
  } else if(obj.attachEvent){
    var win = window;
    if (ieWindow) {
      win = ieWindow;
    }
    obj['e' + oneEvent + handler] = handler;
    obj[oneEvent + handler] = function() { obj['e' + oneEvent + handler] ( win.event ); win.event.cancelBubble = true;};
    obj.attachEvent('on' + oneEvent, obj[oneEvent + handler]);
  }
  return true;
}


Tools.removeEvent = function(oneEvent, obj, handler, bol){
  if (arguments.length < 3) {
    focus();
    throw new Error('Tools.removeEvent: Falsche Anzahl von Argumenten!');
  }
  if(window.removeEventListener){
    obj.removeEventListener(oneEvent, handler, bol);
  } else if(obj.detachEvent){
    obj.detachEvent( "on"+ oneEvent, obj[oneEvent + handler] );
    obj[oneEvent + handler] = undefined;
    obj["e" + oneEvent + handler] = undefined;
  }
  return true;
}


Tools.eventStopPropagation = function(event){
  if (arguments.length!=1){
    focus();
    throw new Error("Tools:eventStopPropagation: Falsche Anzahl von Argumenten!");
  }
  if (event.stopPropagation){
    event.stopPropagation();
  } else {
    event.cancelBubble = true;
  }
}


Tools.eventPreventDefault = function(event){
  if (arguments.length!=1){
    focus();
    throw new Error("Tools:eventPreventDefault: Falsche Anzahl von Argumenten!");
  }
  if (event.preventDefault){
    event.preventDefault();
  } else {
    event.returnValue = false;
  }
}


Tools.jumpForwardInput = function(e, elem){
 if (arguments.length != 2) {
   focus();
   throw new Error('Tools.jumpForwardInput: Falsche Anzahl von Argumenten!');
 }
 if (! elem){
   return;
 }
 Tools.eventPreventDefault(e);
 if (! window.addEventListener)  {
  e = window.event;
  key = e.keyCode;
 } else {
   key = e.which;
 }
 if (key != 8 && key < 48 || key > 122){
   return;
 }
 var idPostfix = elem.id.toString().replace(/_token/,'');
 if (key == 8){
   var nextIdx = '_token' + parseFloat(parseFloat(idPostfix) - 1);
   var nextElem = document.getElementById(nextIdx);
   if (elem.value){
     elem.value = '';
     return;
   }
 } else {
   var nextIdx = '_token' + parseFloat(parseFloat(idPostfix) + 1);
   var nextElem = document.getElementById(nextIdx);
   elem.value = String.fromCharCode(key);
 }
 if (nextElem){
   nextElem.focus();
   return;
 }
 var submitBut = document.getElementById('submit-form');
 if (submitBut && parseFloat(idPostfix) >= 4){
   submitBut.focus();
 }
 return;
}


Tools.reloadCounter = 0;

Tools.reloadCodeField = function(url){
  if (arguments.length != 1) {
    return;
  }
  Ajax.cursorWait();
  Tools.reloadCounter++;
  url += '&__RC=' + Tools.reloadCounter;
  var img = new Image();
  img.className = "form-code-validate-secure";
  img.onload = function () {Tools.drawCodeField(this);}
  img.src = url;
  return false;
}


Tools.drawCodeField = function(img){
  if (arguments.length != 1) {
    return;
  }
  img.onload = '';
  var elem = document.getElementById('_sicherheitscode_');
  elem.innerHTML = '';
  elem.appendChild(img);
  /*
  var str = '<img src="'+ img.src +'" border="0" class="form-code-validate-secure" /><br />';
  elem.innerHTML = str;
  */
  Ajax.cursorFinished();
  return false;
}

Tools.setBank = function(elem, url){
  if (arguments.length != 2) {
    return;
  }
  var reqUrl = url + elem.value;
  Ajax.cursorWait();
  var myAjax = Ajax.createInstance();
  myAjax.setAsynchron(false);
  myAjax.setMethod('GET');
  myAjax.setURL(reqUrl);
  myAjax.open();
  myAjax.sendNull();
  var setBank = Tools._setBank(myAjax, elem);
  Ajax.cursorFinished();
}

Tools._setBank = function(ajax, elem){
  if (arguments.length != 2) {
    return;
  }
  if (ajax.getReadyState() != 4){
    return Ajax.cursorWait();
  }
  if (ajax.getReadyState() == 4){
    Ajax.cursorFinished();
    var xml = ajax.getReadableXMLNode();
    if (! xml){
      alert('Es ist ein Fehler aufgetreten!');
      return;
    }
    var bankAnzeigeElem = document.getElementById('_Kreditinstitut_');
    var bankCGIElem = document.getElementById('konto_bank');
    var code = ajax.getSingleNodeValue('code');
    if (code == 'fail'){
      alert('Die Bankleitzahl konnte nicht ermittelt werden.\nBitte überprüfen Sie Ihre Angaben');
      bankAnzeigeElem.innerHTML = 'wird automatisch eingefügt';
      bankCGIElem.value = '';
      elem.value = '';
      elem.focus();
      return false;
    }
    var bankName = ajax.getSingleNodeValue('bank');
    bankCGIElem.value = bankName;
    if (bankAnzeigeElem) {
      bankAnzeigeElem.innerHTML = bankName;
    }
  }
  return true;
}


Tools.getElementDocumentPositionTop = function(elem){
  var pos = 0;
  if (elem.nodeName.toLowerCase() == 'area'){
    elem = elem.parentNode;
  }
  if (elem.nodeName.toLowerCase() == 'map'){
    elem = elem.parentNode;
  }
  var nextElem = elem;
  pos += nextElem.offsetTop;
  while (nextElem.offsetParent) {
    pos += nextElem.offsetParent.offsetTop;
    nextElem = nextElem.offsetParent;
  }
  return parseFloat(pos);
}


Tools.getElementDocumentPositionLeft = function(elem){
  var pos = 0;
  if (elem.nodeName.toLowerCase() == 'area'){
    elem = elem.parentNode;
  }
  if (elem.nodeName.toLowerCase() == 'map'){
    elem = elem.parentNode;
  }
  var nextElem = elem;
  pos += nextElem.offsetLeft;
  while (nextElem.offsetParent) {
    pos += nextElem.offsetParent.offsetLeft;
    nextElem = nextElem.offsetParent;
  }
  return parseFloat(pos);
}


Tools.getElementDocumentPositionRight = function(elem){
  var pos = 0;
  pos += Tools.getElementDocumentPositionLeft(elem) + elem.offsetWidth;
  return parseFloat(pos);
}


Tools.getElementDocumentPositionBottom = function(elem){
  var pos = 0;
  pos += Tools.getElementDocumentPositionTop(elem) + elem.offsetHeight;
  return parseFloat(pos);
}

  
Tools.getScreenHeight = function() {
  var height = 0;
  if (document.documentElement != undefined && document.documentElement.clientHeight != undefined) {
     height = parseFloat(document.documentElement.clientHeight);
  } else {
     height = parseFloat(window.innerHeight);
  }
  return height;
}   


Tools.getScreenWidth = function() {
  var width = 0;
  if (document.documentElement != undefined && document.documentElement.clientWidth != undefined) {
     width = parseFloat(document.documentElement.clientWidth);
  } else {
     width = parseFloat(window.innerWidth);
  }
  return width;
}


Tools.getScrollPositionTop = function() {
  var pos = 0;
  if (document.documentElement != undefined && document.documentElement.scrollTop != undefined) {
     pos = parseFloat(document.documentElement.scrollTop);
  } else {
     pos = parseFloat(window.pageYOffset);
  }
  return pos;
}

  
Tools.getElementWidth = function(elem) {
  width = 0;
  if (!elem){
    return width;
  }
   width = parseFloat(elem.offsetWidth); 
   return width;
}    

  
Tools.getElementHeight = function(elem) {
  height = 0;
  if (!elem){
    return height;
  }
   height = parseFloat(elem.offsetHeight); 
   return height;
}


var undefined;



var popupSettings = {};

popupSettings['default'] = '';

popupSettings['Artikel versenden'] = 'width=566,height=600';
popupSettings['Fotogalerie'] = 'width=569,height=600';
popupSettings['Formular'] = 'width=810,height=573';
popupSettings['Formular2'] = 'width=810,height=590';

function openPopup(url,windowName,settingsID) {

  var settings;
  var newWindow;

  if (popupSettings[settingsID]) {
    settings = popupSettings[settingsID];
  } else {
    settings = popupSettings['default'];
  }

  newWindow = window.open(url,windowName,settings);
  newWindow.focus();

}



var zaehler = 1;

function tausche_bilder() {

	var richtung = tausche_bilder.arguments[0];
	var bildid = tausche_bilder.arguments[1];
	var pfadname = tausche_bilder.arguments[2];
	var maximum = tausche_bilder.arguments[3];
	var pfad = new String();

	if (richtung == 'vor') {

		zaehler += 1;

	} else {

		zaehler -= 1;

	}

	if (zaehler == 0) {

		zaehler = maximum;

	}

	if (zaehler > maximum) {

		zaehler = 1;

	}

	pfad = String(pfadname + zaehler + '.jpg');

	document.images[bildid].src = pfad;

}


function unsetFocusBorder() {
 var arr = document.getElementsByTagName('a');
 if (arr){
   for (var i=0; i<arr.length; i++) {
     arr[i].onfocus = arr[i].blur;
   }
 }
} 

var undefined;





function Navigation(id) {
  if (arguments.length>1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  this._id = undefined;
  this._setID(id);
  this._navigationAllowedStatus = undefined;
  this._direction = 'horizontal';
  this._dependVertical = 'top';
  this._dependHorizontal = 'right';
  this._highlightActiveRoot = 'no';
  this._highlightActiveClassPostfix = undefined;
  this._rootLeft = 0;
  this._rootTop = 0;
  this._differenceVertical = 0;
  this._differenceHorizontal = 0;
  this._navigationStructure = {};
  this._registerStructureItem = {};
  this._chacheRoot = '';
  this._chacheRootHTMLString = undefined;
  this._activeMenu = {};
  this._menuInUse = false;
  this._containerIDPrefix = this.id() + '_Nav';
  this._itemIDPrefix = this.id() + '_Item';
  this._timeout = undefined;
  this._delay = undefined;
  this._getNavigationStructureHTMLRoot = true;
  
  this.setDelay(1000);
}

Navigation.prototype.toString = function() {
  return "\n[Navigation - id: " + this + "]\n";
}


Navigation.prototype.id = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("Argument ist nicht vom Typ String!");
    }
    this._id = str;
  }
  return this._id;
}

Navigation.prototype.navigationStructure = function(obj) {
  if (arguments.length) {
    if (typeof obj != "object") {
      focus();
      throw new Error("Argument ist nicht vom Typ Object!");
    }
    this._navigationStructure = obj;
  }
  return this._navigationStructure;
}

Navigation.prototype.registerStructureItem = function(obj) {
  if (arguments.length) {
    if (typeof obj != "object") {
      focus();
      throw new Error("Argument ist nicht vom Typ Object!");
    }
    this._registerStructureItem = obj;
  }
  return this._registerStructureItem;
}

Navigation.prototype._direction = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this._direction = str;
  return this._direction;
}


Navigation.prototype._setID = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.id(str);
}

Navigation.prototype._setRegisterStructureItem = function(obj) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof obj != "object") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.registerStructureItem(obj);
}

Navigation.prototype._setRootPosition = function() {
  var id = this._containerIDPrefix + 'root';
  if (document.getElementById(id)){
    var elem = document.getElementById(id);
    if (elem.offsetParent){
      elem = elem.offsetParent;
    }
    this._rootLeft = elem.offsetLeft;
    this._rootTop = elem.offsetTop;
  }
}

Navigation.prototype._getNavigationStructureHTML = function(structure, html, id, loopPosition) {
  var containerClassName = '';
  var first = undefined;
  if (loopPosition == 1){
    first = true;
  }
  var containerStyle = 'display: none;';
  if (this._getNavigationStructureHTMLRoot){
    containerStyle = 'display: block;';    
  }
  if (NavigationItem.hasInstance(id) && NavigationItem.getInstance(id).style()){
    containerStyle += NavigationItem.getInstance(id).style();
  }
  if (NavigationItem.hasInstance(id) && NavigationItem.getInstance(id).className()){
    containerClassName = 'class="'+ NavigationItem.getInstance(id).className() +'"';
  }
  this._getNavigationStructureHTMLRoot = false;
  if (this._direction == 'vertical'){
    if (loopPosition > 1 &&  loopPosition <= 2){
      html += '<div id="'+ id +'"  '+ containerClassName +' style="'+ containerStyle +' position: absolute;">';
    } else  if (loopPosition > 2){
      html += '<div id="'+ id +'"  '+ containerClassName +' style="'+ containerStyle +' position: static;">';
    } else {
      html += '<div id="'+ id +'" '+ containerClassName +' style="'+ containerStyle +' position: absolute;">';
    }
    for (var i in structure){
      var id = this._containerIDPrefix + i;
      var cssStyle = '';
      var cssClassName = '';
      var href = 'href="javascript:void(0);"';
      var target = '';
      var onclick = '';
      var label = this.registerStructureItem()[id].label();
      var title = '';
      if (this.registerStructureItem()[id].style()){
        cssStyle = 'style="' + this.registerStructureItem()[id].style() + '" ';
      }
      if (this.registerStructureItem()[id].className()){
        cssClassName = 'class="' + this.registerStructureItem()[id].className() + '" ';
      }
      if (this.registerStructureItem()[id].href()){
        href = 'href="' + this.registerStructureItem()[id].href() + '" ';
      }
      if (this.registerStructureItem()[id].target()){
        target = 'target="' + this.registerStructureItem()[id].target() + '" ';
      }
      if (this.registerStructureItem()[id].onclick()){
        onclick = 'onclick="' + this.registerStructureItem()[id].onclick();
      } else {
      }
      if (this.registerStructureItem()[id].title()){
        title = 'title="' + this.registerStructureItem()[id].title() + '" ';
      }
      if (first){
        html += '<div id="'+ this._itemIDPrefix + this.registerStructureItem()[id].id() +'" style="position: static; float: left;">\n';
      } else {
        html += '<div id="'+ this._itemIDPrefix + this.registerStructureItem()[id].id() +'" style="position: static;">\n';
      }
      if (this._dependVertical == 'top'){
        if (typeof structure[i] == 'object'){
          html += this._getNavigationStructureHTML(structure[i], '', id, loopPosition+1);
        } 
      }
      if (this.registerStructureItem()[id].type() == 0){
        if (this.registerStructureItem()[id].subClassName()){
          cssClassName = 'class="' + this.registerStructureItem()[id].subClassName() + '" ';
        }
        if (this.registerStructureItem()[id].subStyle()){
          cssStyle = 'style="' + this.registerStructureItem()[id].subStyle() + ' display: block;" ';
        }
        if (first){
          html += '<a id="button_'+ this.registerStructureItem()[id].id() +'" '+ href +' '+ cssStyle +' '+ cssClassName +' '+ target +' '+ onclick +' onmouseout="Navigation.getInstance(\''+ this.id() +'\').collapseMenu();" onmouseover="Navigation.getInstance(\''+ this.id() +'\').displaySubmenu(\''+ this.registerStructureItem()[id].id() +'\');" '+ title +'>' + label +'</a>\n';
        } else {
          html += '<a id="button_'+ this.registerStructureItem()[id].id() +'" '+ cssStyle +' '+ cssClassName +' '+ target +' '+ onclick +' onmouseout="Navigation.getInstance(\''+ this.id() +'\').collapseMenu();" '+ title +'>' + label +'</a>\n';
        }
      } else {
        html += '<a id="button_'+ this.registerStructureItem()[id].id() +'" '+ href +' '+ cssStyle +' '+ cssClassName +' '+ target +' '+ onclick +' onmouseout="Navigation.getInstance(\''+ this.id() +'\').collapseMenu();" onmouseover="Navigation.getInstance(\''+ this.id() +'\').displaySubmenu(\''+ this.registerStructureItem()[id].id() +'\');" '+ title +'>' + label +'</a>\n';
      }
      if (this._dependVertical != 'top'){
        if (typeof structure[i] == 'object'){
          html += this._getNavigationStructureHTML(structure[i], '', id, loopPosition+1);
        } 
      } 
      html += '</div>\n'; 
    }
    html += '</div>';
  } else {
    html += '<div id="'+ id +'"  '+ containerClassName +' style="'+ containerStyle +' position: absolute;">\n';
    for (var i in structure){
      var id = this._containerIDPrefix + i;
      var cssStyle = '';
      var cssClassName = '';
      var href = 'href="javascript:void(0);"';
      var target = '';
      var onclick = '';
      var label = this.registerStructureItem()[id].label();
      var title = '';
      if (this.registerStructureItem()[id].style()){
        cssStyle = 'style="' + this.registerStructureItem()[id].style() + '" ';
      }
      if (this.registerStructureItem()[id].className()){
        cssClassName = 'class="' + this.registerStructureItem()[id].className() + '" ';
      }
      if (this.registerStructureItem()[id].href()){
        href = 'href="' + this.registerStructureItem()[id].href() + '" ';
      }
      if (this.registerStructureItem()[id].target()){
        target = 'target="' + this.registerStructureItem()[id].target() + '" ';
      }
      if (this.registerStructureItem()[id].onclick()){
        if(document.all && !navigator.userAgent.match(/Opera/)){
          onclick += 'onclick="new ' + this.registerStructureItem()[id].onclick() + '; return false;" ';
        } else {
          onclick += 'onclick="' + this.registerStructureItem()[id].onclick() + '" ';
        }
      }
      if (this.registerStructureItem()[id].title()){
        title = 'title="' + this.registerStructureItem()[id].title() + '" ';
      }
      if (first){
        html += '<div id="'+ this._itemIDPrefix + this.registerStructureItem()[id].id() +'" style="float: left;">\n';
      } else {
        html += '<div id="'+ this._itemIDPrefix + this.registerStructureItem()[id].id() +'" style="">\n';
      }
      if (this.registerStructureItem()[id].type() == 0){
        if (this.registerStructureItem()[id].subClassName()){
          cssClassName = 'class="' + this.registerStructureItem()[id].subClassName() + '" ';
        }
        if (this.registerStructureItem()[id].subStyle()){
          cssStyle = 'style="display: block; ' + this.registerStructureItem()[id].subStyle() + '" ';
        }
        html += '<a id="button_'+ this.registerStructureItem()[id].id() +'" '+ href +' '+ cssStyle +' '+ cssClassName +' '+ target +' '+ onclick +' onmouseout="'+ this._chacheRoot +'Navigation.getInstance(\''+ this.id() +'\').collapseMenu();" onmouseover="'+ this._chacheRoot +'Navigation.getInstance(\''+ this.id() +'\').displaySubmenu(\''+ this.registerStructureItem()[id].id() +'\');" '+ title +'>' + label +'</a>\n';
      } else {
        html += '<a id="button_'+ this.registerStructureItem()[id].id() +'" '+ href +' '+ cssStyle +' '+ cssClassName +' '+ target +' '+ onclick +' onmouseout="'+ this._chacheRoot +'Navigation.getInstance(\''+ this.id() +'\').collapseMenu();" onmouseover="'+ this._chacheRoot +'Navigation.getInstance(\''+ this.id() +'\').displaySubmenu(\''+ this.registerStructureItem()[id].id() +'\');" '+ title +'>' + label +'</a>\n';
      }
      html += '</div>\n';
    } 
    if (first){
      html += '<div class="float-aufheben"><br /></div>\n';
    }
    html += '</div>\n';
    loopPosition++;
    for (var i in structure){
      var id = this._containerIDPrefix + '' + i;
      if (typeof structure[i] == 'object'){
        html += this._getNavigationStructureHTML(structure[i], '', id, loopPosition);
      } 
    }
  }
  return html;
}

Navigation.prototype._setHighlightedItems = function(id) {
  var items = [];
  var activeItem = NavigationItem.getInstance(id);
  items.push(activeItem);
  for (var i=0; i<items.length; i++){
    var elem = document.getElementById('button_' + items[i].id());
    if (elem){
      var className = items[i].subClassName() + this._highlightActiveClassPostfix;
      elem.className = className;
    }  
  }
}

Navigation.prototype._setOffHighlightedItems = function(id) {
  var items = [];
  var activeItem = NavigationItem.getInstance(id);
  items.push(activeItem);
  for (var i=0; i<items.length; i++){
    var elem = document.getElementById('button_' + items[i].id());
    if (elem){
      var className = items[i].subClassName();
      elem.className = className;
    }  
  }
}



Navigation.prototype.setDirection = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this._direction = str;
}

Navigation.prototype.setChacheRoot = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this._chacheRoot = str;
}

Navigation.prototype.setChacheRootHTMLString = function(obj) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof obj != "object") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this._chacheRootHTMLString = obj;
}

Navigation.prototype.getNavigationAllowedStatus = function() {
  if (document.getElementById){
    this._navigationAllowedStatus = true;
  }
  return this._navigationAllowedStatus;
}

Navigation.prototype.setDelay = function(n) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (!NavigationTools.checkNumber(n)) {
    focus();
    throw new Error("Argument ist nicht vom Typ Number!");
  }
  if (document.all){
    if (n < 1200){
      n = n + (n/5);
    }
  }
  this._delay = n;
}

Navigation.prototype.setHighlightActiveRoot = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this._highlightActiveRoot = str;
}

Navigation.prototype.setHighlightActiveClassPostfix = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this._highlightActiveClassPostfix = str;
}

Navigation.prototype.setDependHorizontal = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this._dependHorizontal = str;
}

Navigation.prototype.setDependVertical = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this._dependVertical = str;
}

Navigation.prototype.setDifferenceVertical = function(n) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (!NavigationTools.checkNumber(n)) {
    focus();
    throw new Error("Argument ist nicht vom Typ Number!");
  }
  this._differenceVertical = n;
}

Navigation.prototype.setDifferenceHorizontal = function(n) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (!NavigationTools.checkNumber(n)) {
    focus();
    throw new Error("Argument ist nicht vom Typ Number!");
  }
  this._differenceHorizontal = n;
}

Navigation.prototype.setNavigationStructure = function(obj) {
  if(!this.getNavigationAllowedStatus()){
    return;
  }
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof obj != "object") {
    focus();
    throw new Error("Argument ist nicht vom Typ HMTL-Object!");
  }
  var structure = {};
  structure = Navigation._getNavigationStructureByNode(obj, structure, '', 0, this._containerIDPrefix);
  this.navigationStructure(structure);
  this._setRegisterStructureItem(NavigationItem._registerInstance);
}

Navigation.prototype.drawNavigationStructure = function(html) {
  if(!this.getNavigationAllowedStatus()){
    return;
  }
  if(!document.getElementById(this.id())){
    return;
  }
  var html = '';
  html += this._getNavigationStructureHTML(Navigation._getFirstItem(this.navigationStructure()), '', this._containerIDPrefix + 'root', 1);
  /*
  var win = window.open('','test');
  var doc = win.document;
  doc.open();
  doc.write(html);
  doc.close();
  */
  document.getElementById(this.id()).innerHTML = html;
  this._setRootPosition();
}

Navigation.prototype.hideVisitedNavigation = function(id) {
  var item = NavigationItem.getInstance(id);
  for (var i in this._activeMenu){
    var rootPos = i.split(this._containerIDPrefix)[1];
    if (item.rootObj()[rootPos] == undefined){
      if (this._activeMenu[i]['elem']){
        this._activeMenu[i]['elem'].style.display = 'none';
        this._setOffHighlightedItems(this._activeMenu[i]['item'].id());
      }
      delete this._activeMenu[i];
    }
  }
}

Navigation.prototype.showActiveNavigation = function(id) {
  var elem = document.getElementById(id);
  if (elem){
    this.setElementPosition(id);
    if (elem.style.display == 'block'){
      elem.display = 'none';
    } else {
      elem.style.display = 'block';
    } 
    if (this._highlightActiveRoot == 'yes'){
      if (this._highlightActiveClassPostfix){
        this._setHighlightedItems(id);
      }
    }
  }
}

Navigation.prototype.setElementPosition = function(id) {
  var item = NavigationItem.getInstance(id);
  var rootPos = id.split(this._containerIDPrefix)[1];
  var activeItem = NavigationItem.createInstance(this._itemIDPrefix +''+ id, '');
  if (this._direction == 'vertical'){
    if (document.getElementById(id)){
      if (this._dependHorizontal=='left'){
        document.getElementById(id).style.marginRight =  this._differenceHorizontal + 'px';
      } else {
        document.getElementById(id).style.marginLeft =  this._differenceHorizontal + 'px';
      }
      document.getElementById(id).style.marginTop = this._differenceVertical + 'px';
    }
  } else {  
    var _top;
    var _left;
    if (item.rootObj()[rootPos]){
      var idxR = parseFloat(item.rootObj()[rootPos] -1);
      if (item.rootArr()[idxR]){
        var rootItem = NavigationItem.getInstance(this._containerIDPrefix +''+ item.rootArr()[idxR]);
        if (this._dependHorizontal == 'left'){
          if (rootItem.properties().getLeft() != undefined){
            _left = parseFloat(rootItem.properties().getLeft() - item.properties().getWidth());
          } else {
            if (document.getElementById(this._itemIDPrefix +''+ id)){
            _left = parseFloat(activeItem.properties().getLeft() - item.properties().getWidth());
            }
          }
        } else {
          if (rootItem.properties().getRight() != undefined){
            _left = rootItem.properties().getRight();
          } else {
            if (document.getElementById(this._itemIDPrefix +''+ id)){
            _left = activeItem.properties().getRight();
            }
          }
        }
        if (this._dependVertical=='middle'){
          if (document.getElementById(this._itemIDPrefix +''+ id)){
            _top = parseFloat(activeItem.properties().getTop() + parseFloat(activeItem.properties().getHeight() / 2));
          }
        } else if (this._dependVertical=='bottom'){
          if (document.getElementById(this._itemIDPrefix +''+ id)){
            _top = activeItem.properties().getBottom();
          } 
        } else {
          if (document.getElementById(this._itemIDPrefix +''+ id)){
            _top = activeItem.properties().getTop();
          } 
        }
      }
    }
    if (document.getElementById(id)){
      if (_top != undefined){
        if (idxR > 0){
          document.getElementById(id).style.top = parseFloat(parseFloat(_top + this._differenceVertical) - this._rootTop) + 'px';
        } else {
          document.getElementById(id).style.top = parseFloat(parseFloat(_top + 42) - this._rootTop) + 'px';
        }  
      }
      if (navigator.userAgent.match(/Opera/)){
        document.getElementById(id).style.position = 'absolute';
      }
      if (_left != undefined){   
        if (idxR > 0){  
          document.getElementById(id).style.left = parseFloat(parseFloat(_left + this._differenceHorizontal) - this._rootLeft) + 'px';
        } else {  
          if (document.all) {  
            document.getElementById(id).style.left = parseFloat(parseFloat((_left - activeItem.properties().getWidth())+ this._differenceHorizontal) - this._rootLeft - 10) + 'px';
          } else {
            document.getElementById(id).style.left = parseFloat(parseFloat(_left - activeItem.properties().getWidth()) - this._rootLeft - 10) + 'px';
          }
        }
      }
      if (navigator.userAgent.match(/Opera/)){
        document.getElementById(id).style.position = 'absolute';
      }
    }
  }
}

Navigation.prototype.displaySubmenu = function(id) {
  this._menuInUse = true;
  var item = NavigationItem.getInstance(id);
  var elem = undefined;
  if (document.getElementById(id)){
    elem = document.getElementById(id);
  }
  this.hideVisitedNavigation(id);
  this.showActiveNavigation(id);
  if (this._direction == 'vertical'){
    if (this._activeMenu[id] || item.type() == 1){
      this._menuInUse = false;
      this.hideAll();
      return;
    }
  }
  this._activeMenu[id] = {};
  if (document.getElementById(id)){
    this._activeMenu[id]['elem'] = document.getElementById(id);
  }
  this._activeMenu[id]['item'] = item;
}

Navigation.prototype.collapseMenu = function() {
  this._menuInUse = false;
  if (this._timeout){
    window.clearTimeout(this._timeout);
  }
  var funcStr = 'Navigation.getInstance(\''+ this.id() +'\').hideAll()';
  this._timeout = window.setTimeout(funcStr, this._delay);
}

Navigation.prototype.hideAll = function() {
  if (this._timeout){
    window.clearTimeout(this._timeout);
  }
  if (!this._menuInUse){
    for (var i in this._activeMenu){
      if (this._activeMenu[i]['elem']){
        this._activeMenu[i]['elem'].style.display = 'none';
        this._setOffHighlightedItems(this._activeMenu[i]['item'].id());
      }
      delete this._activeMenu[i];
    }
  }
}


Navigation._defaultID = [];

Navigation._registerInstance = {};

Navigation._getNavigationStructureHTMLRoot = true;

Navigation._attributesToIE = {};
Navigation._attributesToIE['src'] = 'src';
Navigation._attributesToIE['style'] = 'style';
Navigation._attributesToIE['align'] = 'align';
Navigation._attributesToIE['title'] = 'title';
Navigation._attributesToIE['alt'] = 'alt';
Navigation._attributesToIE['valign'] = 'valign';
Navigation._attributesToIE['vspace'] = 'vspace';
Navigation._attributesToIE['hspace'] = 'hspace';
Navigation._attributesToIE['class'] = 'className';
Navigation._attributesToIE['border'] = 'border';
Navigation._attributesToIE['cellspacing'] = 'cellspacing';
Navigation._attributesToIE['cellpadding'] = 'cellpadding';
Navigation._attributesToIE['data'] = 'data';
Navigation._attributesToIE['marginwidth'] = 'marginwidth';
Navigation._attributesToIE['marginheight'] = 'marginheight';
Navigation._attributesToIE['margintop'] = 'margintop';
Navigation._attributesToIE['marginleft'] = 'marginleft';
Navigation._attributesToIE['frameborder'] = 'frameborder';
Navigation._attributesToIE['dataformatas'] = 'dataformatas';
Navigation._attributesToIE['type'] = 'type';
Navigation._attributesToIE['width'] = 'width';
Navigation._attributesToIE['height'] = 'height';
Navigation._attributesToIE['onmouseover'] = 'onMouseover';
Navigation._attributesToIE['onmouseout'] = 'onMouseout';
Navigation._attributesToIE['onclick'] = 'onClick';
Navigation._attributesToIE['onfocus'] = 'onFocus';
Navigation._attributesToIE['onblur'] = 'onBlur';
Navigation._attributesToIE['onload'] = 'onLoad';
Navigation._attributesToIE['onchange'] = 'onChange';
Navigation._attributesToIE['onsubmit'] = 'onSubmit';
Navigation._attributesToIE['name'] = 'name';
Navigation._attributesToIE['value'] = 'value';
Navigation._attributesToIE['id'] = 'id';
Navigation._attributesToIE['href'] = 'href';
Navigation._attributesToIE['target'] = 'target';


Navigation._attributesIE = {};
Navigation._attributesIE['src'] = 'src';
Navigation._attributesIE['style'] = 'style';
Navigation._attributesIE['align'] = 'align';
Navigation._attributesIE['title'] = 'title';
Navigation._attributesIE['alt'] = 'alt';
Navigation._attributesIE['valign'] = 'valign';
Navigation._attributesIE['vspace'] = 'vspace';
Navigation._attributesIE['hspace'] = 'hspace';
Navigation._attributesIE['className'] = 'class';
Navigation._attributesIE['border'] = 'border';
Navigation._attributesIE['cellspacing'] = 'cellspacing';
Navigation._attributesIE['cellpadding'] = 'cellpadding';
Navigation._attributesIE['data'] = 'data';
Navigation._attributesIE['marginwidth'] = 'marginwidth';
Navigation._attributesIE['marginheight'] = 'marginheight';
Navigation._attributesIE['margintop'] = 'margintop';
Navigation._attributesIE['marginleft'] = 'marginleft';
Navigation._attributesIE['frameborder'] = 'frameborder';
Navigation._attributesIE['dataformatas'] = 'dataformatas';
Navigation._attributesIE['type'] = 'type';
Navigation._attributesIE['width'] = 'width';
Navigation._attributesIE['height'] = 'height';
Navigation._attributesIE['onMouseover'] = 'onmouseover';
Navigation._attributesIE['onMouseout'] = 'onmouseout';
Navigation._attributesIE['onClick'] = 'onclick';
Navigation._attributesIE['onFocus'] = 'onfocus';
Navigation._attributesIE['onBlur'] = 'onblur';
Navigation._attributesIE['onLoad'] = 'onload';
Navigation._attributesIE['onChange'] = 'onchange';
Navigation._attributesIE['onSubmit'] = 'onsubmit';
Navigation._attributesIE['name'] = 'name';
Navigation._attributesIE['value'] = 'value';
Navigation._attributesIE['id'] = 'id';
Navigation._attributesIE['href'] = 'href';
Navigation._attributesIE['target'] = 'target';

Navigation._styleAttributesIE = {};
Navigation._styleAttributesIE['width'] = 'width';
Navigation._styleAttributesIE['height'] = 'height';
Navigation._styleAttributesIE['top'] = 'top';
Navigation._styleAttributesIE['left'] = 'left';
Navigation._styleAttributesIE['display'] = 'display';
Navigation._styleAttributesIE['position'] = 'position';
Navigation._styleAttributesIE['textAlign'] = 'text-align';
Navigation._styleAttributesIE['textDecoration'] = 'text-decoration';
Navigation._styleAttributesIE['padding'] = 'padding';
Navigation._styleAttributesIE['paddingTop'] = 'padding-top';
Navigation._styleAttributesIE['paddingRight'] = 'padding-right';
Navigation._styleAttributesIE['paddingBottom'] = 'padding-bottom';
Navigation._styleAttributesIE['paddingLeft'] = 'padding-left';
Navigation._styleAttributesIE['margin'] = 'margin';
Navigation._styleAttributesIE['marginTop'] = 'margin-top';
Navigation._styleAttributesIE['marginRight'] = 'margin-right';
Navigation._styleAttributesIE['marginBottom'] = 'margin-bottom';
Navigation._styleAttributesIE['marginLeft'] = 'margin-left';
Navigation._styleAttributesIE['border'] = 'border';
Navigation._styleAttributesIE['borderLeft'] = 'border-left';
Navigation._styleAttributesIE['borderRight'] = 'border-right';
Navigation._styleAttributesIE['borderTop'] = 'border-top';
Navigation._styleAttributesIE['borderBottom'] = 'border-bottom';
Navigation._styleAttributesIE['borderColor'] = 'border-color';
Navigation._styleAttributesIE['borderStyle'] = 'border-style';
Navigation._styleAttributesIE['borderWidth'] = 'border-width';
Navigation._styleAttributesIE['borderCollapse'] = 'border-collapse';
Navigation._styleAttributesIE['fontSize'] = 'font-size';
Navigation._styleAttributesIE['fontWeight'] = 'font-weight';
Navigation._styleAttributesIE['fontStyle'] = 'font-style';
Navigation._styleAttributesIE['fontFace'] = 'font-face';
Navigation._styleAttributesIE['color'] = 'color';
Navigation._styleAttributesIE['backgroundColor'] = 'background-color';
Navigation._styleAttributesIE['backgroundImage'] = 'background-image';
Navigation._styleAttributesIE['backgroundPosition'] = 'background-position';
Navigation._styleAttributesIE['backgroundRepeat'] = 'background-repeat';
Navigation._styleAttributesIE['zIndex'] = 'z-index'; 


Navigation._getNavigationStructureByNode = function(node, structure, path, countx, containerPrefix) {
  if (arguments.length!=5) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (!node){
    return structure;
  }
  var arr = structure;
  for (var i=0; i<node.childNodes.length; i++){
    var child = node.childNodes[i];
    if (child.nodeType == 1){
      if (child.nodeName.toLowerCase() == 'a'){
        if (path.length){
          path += '-';
        }
        arr[path +''+ countx] = 1;
        var item = NavigationItem.createInstance(containerPrefix + path +''+ countx);
        item.setType('1');
        item.setRoot(path +''+ countx);
        if (Navigation.hasAttributes(child, 'class')){
          item.setClassName(Navigation.getAttributesFromElement(child, 'class'));
        }
        if (Navigation.hasAttributes(child, 'style')){
          item.setStyle(Navigation.getAttributesFromElement(child, 'style'));
        }
        if (Navigation.hasAttributes(child, 'href')){
          item.setHref(Navigation.getAttributesFromElement(child, 'href'));
        }
        if (Navigation.hasAttributes(child, 'target')){
          item.setTarget(Navigation.getAttributesFromElement(child, 'target'));
        }
        if (Navigation.hasAttributes(child, 'onclick')){
          item.setOnClick(Navigation.getAttributesFromElement(child, 'onclick'));
        }
        if (Navigation.hasAttributes(child, 'title')){
          item.setTitle(Navigation.getAttributesFromElement(child, 'title'));
        }
        var label = Navigation.getTextNodeValue(child);
        item.setLabel(label);
      }
      if (child.nodeName.toLowerCase() == 'li'){
        countx++;
      }
      if (child.nodeName.toLowerCase() == 'ul'){
        path += countx;
        countx = 0;
        structure[path] = {};
        arr = structure[path];
        var item = NavigationItem.createInstance(containerPrefix + path);
        item.setType('0');
        item.setRoot(path);
        if (Navigation.hasAttributes(child, 'class')){
          item.setClassName(Navigation.getAttributesFromElement(child, 'class'));
        }
        if (Navigation.hasAttributes(child, 'style')){
          item.setStyle(Navigation.getAttributesFromElement(child, 'style'));
        }
        var subChild = undefined;
        if(child.previousSibling){
          if (child.previousSibling && child.previousSibling.nodeName.toLowerCase() == 'a'){
            subChild = child.previousSibling;
          } else if (child.previousSibling.previousSibling && child.previousSibling.previousSibling.nodeName.toLowerCase() == 'a'){
            subChild = child.previousSibling.previousSibling;
          }
        }
        if (subChild){
          if (Navigation.hasAttributes(subChild, 'class')){
            item.setSubClassName(Navigation.getAttributesFromElement(subChild, 'class'));
          }
          if (Navigation.hasAttributes(subChild, 'style')){
            item.setSubStyle(Navigation.getAttributesFromElement(subChild, 'style'));
          }
          if (Navigation.hasAttributes(subChild, 'href')){
            item.setHref(Navigation.getAttributesFromElement(subChild, 'href'));
          }
          if (Navigation.hasAttributes(subChild, 'target')){
            item.setTarget(Navigation.getAttributesFromElement(subChild, 'target'));
          }
          if (Navigation.hasAttributes(subChild, 'onclick')){
            item.setOnClick(Navigation.getAttributesFromElement(subChild, 'onclick'));
          }
          if (Navigation.hasAttributes(subChild, 'title')){
            item.setTitle(Navigation.getAttributesFromElement(subChild, 'title'));
          }
          var label = Navigation.getTextNodeValue(subChild);
          item.setLabel(label);
        }
      }
      Navigation._getNavigationStructureByNode(child, arr, path, countx, containerPrefix);
    }
  }
  return structure;
}

Navigation._getNavigationStructuretoString = function(nodeList, str, x) {
  if (arguments.length!=3) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  for (var i in nodeList){
    var count = x;
    while (count > 0){
      str += '. .';
      count--;
    }
    str += i + ' = ' + nodeList[i] + '\n';
    if (typeof nodeList[i] == 'object'){
      str += Navigation._getNavigationStructuretoString(nodeList[i], '', x+1);
    }
  }
  return str;
}


Navigation._getFirstItem = function(obj) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  var count = 0;
  for (var i in obj){
    if (count == 0){
      return obj[i];
    }
  }
  return obj;
}



Navigation.getTextNodeValue = function(node) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  var str = '';
  for (var i=0; i<node.childNodes.length; i++){
    var child = node.childNodes[i];
    if (child.nodeType == 3){
      str += child.nodeValue;
    }
  }  
  return str;
}

Navigation.hasAttributes = function(elem, attrName) {
  var str = '';
  if (document.all){
    if (Navigation._attributesToIE[attrName]){
      attrName = Navigation._attributesToIE[attrName];
    }
    if (attrName == 'className'){
      if (elem.getAttribute('class')){
        attrName = 'class';
      }
    }
  }
  if (elem.getAttribute(attrName)){
    return true;
  }
  return false;
}

Navigation.getAttributesFromElement = function(elem, attrName) {
  var str = '';
  if (document.all){
    str = Navigation._getAttributesFromElementIE(elem, attrName);
  } else {
    str = Navigation._getAttributesFromElementDOM(elem, attrName);
  }
  return str;
}

Navigation._getAttributesFromElementIE = function(elem, attrName) { 
  var str = '';
  if (Navigation._attributesToIE[attrName]){
    var attr = Navigation._attributesToIE[attrName];
    if (attr == 'className'){
      if (elem.getAttribute('class')){
        attr = 'class';
      }
    }
    var attrValue = elem.getAttribute(attr);
    if (attrValue){
      if (typeof attrValue == 'object'){
        for (var a in Navigation._styleAttributesIE){
          if (attrValue[a] && attrValue[a].length){
            str += Navigation._styleAttributesIE[a]+': '+attrValue[a]+'; ';
          }
        }
      } else {
        str += attrValue;
      }
    }
  }
  return str;
}

Navigation._getAttributesFromElementIELoop = function(elem, attrName) { 
  var str = '';
  for (var i in Navigation._attributesIE){
    var attr = i;
    if (attr == 'className'){
      if (elem.getAttribute('class')){
        attr = 'class';
      }
    }
    if (elem.getAttribute(attr)){
      var name = Navigation._attributesIE[i];
      if (name == attrName){
        var attrValue = elem.getAttribute(attr);
        if (attrValue){
          if (typeof attrValue == 'object'){
            for (var a in Navigation._styleAttributesIE){
              if (attrValue[a] && attrValue[a].length){
                str += Navigation._styleAttributesIE[a]+': '+attrValue[a]+'; ';
              }
            }
          } else {
            str += attrValue;
          }
        }
      } 
    }  
  }
  return str;
}

Navigation._getAttributesFromElementDOM = function(elem, attrName) {
  var attributes = elem.attributes;
  var str = '';
  if (attributes.length){
    if (elem.getAttribute(attrName)){
      str += elem.getAttribute(attrName);
    }
  }
  return str;
}


Navigation._getAttributesFromElementDOMLoop = function(elem, attrName) {
  var attributes = elem.attributes;
  var str = '';
  var output = '';
  if (attributes.length){
    for (var i=0; i<attributes.length; i++){
      var attr = attributes.item(i);
      if (attr && attr.value && attr.value.length){
        var name = attr.name;
        if (attrName == name){
          var attrValue = attr.value;
          str += attrValue;
        }  
      }
    }
  }
  return str;
}

Navigation.getInstance = function(id) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (! (Navigation._registerInstance[id])){
    focus();
    throw new Error("Es ist keine Navigation.Instance mit id=" + id + " registriert!");
  } 
  return Navigation._registerInstance[id];
}

Navigation.createInstance = function(id) {
  if (!arguments.length) {
    id = 'navigation' + Navigation._defaultID.length;
    Navigation._defaultID.push(1);
  }
  if (! (Navigation._registerInstance[id])){
    Navigation._registerInstance[id] = new Navigation(id);
  } 
  return Navigation.getInstance(id);
}





function NavigationItem(id) {
  if (arguments.length>1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  this._id = undefined;
  this._rootArr = [];
  this._rootObj = {};
  this._type = undefined;
  this._href = undefined;
  this._label = undefined;
  this._style = undefined;
  this._target = undefined;
  this._onclick = undefined;
  this._className = undefined;
  this._title = undefined;
  this._subStyle = undefined;
  this._subClassName = undefined;
  this._setID(id);
  this._properties = NavigationItemProperties.createNavigationItemProperties(this.id(), this._getParentElement());
}

NavigationItem.prototype.toString = function() {
  return "\n[Navigation - id: " + this.id + "]\n";
}


NavigationItem.prototype.id = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("Argument ist nicht vom Typ String!");
    }
    this._id = str;
  }
  return this._id;
}

NavigationItem.prototype.type = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("Argument ist nicht vom Typ String!");
    }
    this._type = str;
  }
  return this._type;
}

NavigationItem.prototype.label = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("Argument ist nicht vom Typ String!");
    }
    this._label = str;
  }
  return this._label;
}

NavigationItem.prototype.href = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("Argument ist nicht vom Typ String!");
    }
    this._href = str;
  }
  return this._href;
}

NavigationItem.prototype.title = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("Argument ist nicht vom Typ String!");
    }
    this._title = str;
  }
  return this._title;
}

NavigationItem.prototype.target = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("Argument ist nicht vom Typ String!");
    }
    this._target = str;
  }
  return this._target;
}

NavigationItem.prototype.onclick = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("Argument ist nicht vom Typ String!");
    }
    this._onclick = str;
  }
  return this._onclick;
}

NavigationItem.prototype.style = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("Argument ist nicht vom Typ String!");
    }
    this._style = str;
  }
  return this._style;
}

NavigationItem.prototype.className = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("Argument ist nicht vom Typ String!");
    }
    this._className = str;
  }
  return this._className;
}

NavigationItem.prototype.subStyle = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("Argument ist nicht vom Typ String!");
    }
    this._subStyle = str;
  }
  return this._subStyle;
}

NavigationItem.prototype.subClassName = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("Argument ist nicht vom Typ String!");
    }
    this._subClassName = str;
  }
  return this._subClassName;
}

NavigationItem.prototype.rootArr = function(arr) {
  if (arguments.length) {
    if (typeof arr != "object") {
      focus();
      throw new Error("Argument ist nicht vom Typ Object!");
    }
    this._rootArr = arr;
  }
  return this._rootArr;
}

NavigationItem.prototype.rootObj = function(obj) {
  if (arguments.length) {
    if (typeof obj != "object") {
      focus();
      throw new Error("Argument ist nicht vom Typ Object!");
    }
    this._rootObj = obj;
  }
  return this._rootObj;
}

NavigationItem.prototype.properties = function(obj) {
  if (arguments.length) {
    if (typeof obj != "object") {
      focus();
      throw new Error("Argument ist nicht vom Typ Object!");
    }
    this._properties = obj;
  }
  return this._properties;
}


NavigationItem.prototype._setID = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.id(str);
}

NavigationItem.prototype._getParentElement = function() {
  var elem = document.getElementById(this.id());
  var parentElem = '';
  if (elem){
    if (document.all){
      parentElem = elem.parentElement.id;
    } else {
      parentElem = elem.parentNode.id;
    }  
  }  
  return parentElem;
}




NavigationItem.prototype.setType = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.type(str);
}

NavigationItem.prototype.setLabel = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.label(str);
}

NavigationItem.prototype.setHref = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.href(str);
}

NavigationItem.prototype.setTitle = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.title(str);
}

NavigationItem.prototype.setTarget = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.target(str);
}

NavigationItem.prototype.setOnClick = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.onclick(str);
}

NavigationItem.prototype.setStyle = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.style(str);
}

NavigationItem.prototype.setClassName = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.className(str);
}

NavigationItem.prototype.setSubStyle = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.subStyle(str);
}

NavigationItem.prototype.setSubClassName = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  this.subClassName(str);
}

NavigationItem.prototype.setRoot = function(str) {
  if (arguments.length!=1) {
    focus();
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Argument ist nicht vom Typ String!");
  }
  var arr = str.split(/-/);
  var _str = '';
  var rootListArr = [];
  var rootListObj = {};
  for (var i=0; i<arr.length; i++){
    if (i>0){
      _str += '-';
    }
    _str += arr[i];
    rootListObj[_str] = i;
    rootListArr[i] = _str;
  }
  this.rootArr(rootListArr);
  this.rootObj(rootListObj);
}


NavigationItem._defaultID = [];

NavigationItem._registerInstance = {};

NavigationItem._isRoot = false;




NavigationItem.getInstance = function(id) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (! (NavigationItem._registerInstance[id])){
    focus();
    throw new Error("Es ist keine NavigationItem.Instance mit id=" + id + " registriert!");
  } 
  return NavigationItem._registerInstance[id];
}

NavigationItem.hasInstance = function(id) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (! (NavigationItem._registerInstance[id])){
    return false;
  } 
  return true;
}

NavigationItem.createInstance = function(id) {
  if (!arguments.length) {
    id = 'navigation' + NavigationItem._defaultID.length;
    NavigationItem._defaultID.push(1);
  }
  if (! (NavigationItem._registerInstance[id])){
    NavigationItem._registerInstance[id] = new NavigationItem(id);
  } 
  return NavigationItem.getInstance(id);
}






function NavigationItemProperties(id, idParentElement) {  
  this._id = undefined;
  this._idParentElement = 'body';
  this.id(id);
  this.idParentElement(idParentElement);
}



NavigationItemProperties.prototype.id = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("ArgumentError:noString!");
    }
    this._id = str;
  }
  return this._id;
}


NavigationItemProperties.prototype.idParentElement = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("ArgumentError:noString!");
    }  
    this._idParentElement = str.toLowerCase();
  }
  return this._idParentElement;
}



NavigationItemProperties.prototype.getTop = function() {  
  if (this._existsElement(this.id())){
    var parentDiv = document.getElementById(this.id());
    var topPosition = 0;
    if (this._existsElement(this.idParentElement())){
      while (parentDiv && parentDiv.id != this.idParentElement()){
        if (parentDiv.nodeType == 1){
          topPosition += parseFloat(parentDiv.offsetTop);
        }
        parentDiv = parentDiv.offsetParent;
      }
    }
    else{
      while (parentDiv){
        if (parentDiv.nodeType == 1){
          topPosition += parseFloat(parentDiv.offsetTop);
        }
        parentDiv = parentDiv.offsetParent;
      }
    }
    return parseFloat(topPosition);
  }
  return undefined;
}


NavigationItemProperties.prototype.getLeft = function() {  
  if (this._existsElement(this.id())){
    var parentDiv = document.getElementById(this.id());
    var leftPosition = 0;
    if (this._existsElement(this.idParentElement())){
      while (parentDiv && parentDiv.id != this.idParentElement()){
        if (parentDiv.nodeType == 1){
          leftPosition += parseFloat(parentDiv.offsetLeft);
        }
        parentDiv = parentDiv.offsetParent;
      }
    }
    else{
      while (parentDiv){
        if (parentDiv.nodeType == 1){
          leftPosition += parseFloat(parentDiv.offsetLeft);
        }
        parentDiv = parentDiv.offsetParent;
      }
    }
    return parseFloat(leftPosition);
  }
  return undefined;
}


NavigationItemProperties.prototype.getBottom = function() {
  if (this._existsElement(this.id())){
    var bottomPosition = parseFloat(this.getTop() +  this.getHeight());
    return parseFloat(bottomPosition);
  }
  return undefined;
}


NavigationItemProperties.prototype.getRight = function() {  
  if (this._existsElement(this.id())){
    var rightPosition = parseFloat(this.getLeft() + this.getWidth());
    return parseFloat(rightPosition);
  }
  return undefined;
}


NavigationItemProperties.prototype.getWidth = function() {
  if (this._existsElement(this.id())){
    var width = parseFloat(document.getElementById(this.id()).offsetWidth);
    return parseFloat(width);
  }
  return undefined;
}


NavigationItemProperties.prototype.getHeight = function() {
  if (this._existsElement(this.id())){
    var height = parseFloat(document.getElementById(this.id()).offsetHeight);
    return parseFloat(height);
  }
  return undefined;
}


NavigationItemProperties.prototype._existsElement = function(id) {
  if (document.getElementById(id) != undefined){
    return true;
  }
  return false;
}



NavigationItemProperties.createNavigationItemProperties = function(id, idParentElement) { 
  return new NavigationItemProperties(id, idParentElement);
}


NavigationItemProperties.prototype.toString = function() {
  return Object.prototype.toString.apply(this);
}





function NavigationTools() {
}








NavigationTools.checkNumber = function(n){
  if (!arguments.length){
    return false;
  }
  if (n == undefined){
    return false;
  }
  n = n.toString();
  if (n == '0'){
    return n;
  }
  if (!n.length){
    return false;
  }
  n = n.replace(/,/g,'.');
  if (isNaN(n)){
    return false;
  }
  if (!isFinite(n)) {
    return false;
  }
  n = parseFloat(n);
  return n;
}


NavigationTools.checkWertInArrayVorhanden = function(){
  var str = arguments[0];
  var arr = new Array();
  arr = arguments[1];
  for (var i in arr){
    if (arr[i] == str){
      return true;
    } 
  }
  return false;
}



NavigationTools.prototype.toString = function() {
  return Object.prototype.toString.apply(this);
}

function getLayoutPic(){
  
  var jetzt = new Date();
  var TagInWoche = jetzt.getDay();
  
  if (TagInWoche == 0) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/schmuckbild_sonntag.jpg" style="width: 978px; height: 142px;" alt="" title="" \/><br \/>');
  }
  
  if (TagInWoche == 1) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/schmuckbild_montag.jpg" style="width: 978px; height: 142px;" alt="" title="" \/><br \/>');
  }
  
  if (TagInWoche == 2) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/schmuckbild_dienstag.jpg" style="width: 978px; height: 142px;" alt="" title="" \/><br \/>');
  }
  
  if (TagInWoche == 3) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/schmuckbild_mittwoch.jpg" style="width: 978px; height: 142px;" alt="" title="" \/><br \/>');
  }
  
  if (TagInWoche == 4) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/schmuckbild_donnerstag.jpg" style="width: 978px; height: 142px;" alt="" title="" \/><br \/>');
  }
  
  if (TagInWoche == 5) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/schmuckbild_freitag.jpg" style="width: 978px; height: 142px;" alt="" title="" \/><br \/>');
  }
  
  if (TagInWoche == 6) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/schmuckbild_samstag.jpg" style="width: 978px; height: 142px;" alt="" title="" \/><br \/>');
  }

}


function getArticlePic(){
  
  var jetzt = new Date();
  var TagInWoche = jetzt.getDay();
  
  if (TagInWoche == 0) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/artikelbild_sonntag.jpg" style="width: 538px; height: 91px;" alt="" title="" \/><br \/>');
  }
  
  if (TagInWoche == 1) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/artikelbild_montag.jpg" style="width: 538px; height: 91px;" alt="" title="" \/><br \/>');
  }
  
  if (TagInWoche == 2) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/artikelbild_dienstag.jpg" style="width: 538px; height: 91px;" alt="" title="" \/><br \/>');
  }
  
  if (TagInWoche == 3) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/artikelbild_mittwoch.jpg" style="width: 538px; height: 91px;" alt="" title="" \/><br \/>');
  }
  
  if (TagInWoche == 4) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/artikelbild_donnerstag.jpg" style="width: 538px; height: 91px;" alt="" title="" \/><br \/>');
  }
  
  if (TagInWoche == 5) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/artikelbild_freitag.jpg" style="width: 538px; height: 91px;" alt="" title="" \/><br \/>');
  }
  
  if (TagInWoche == 6) {
    document.write('<img src="http://www.neumannxxl.de/kiosk/bilder/artikelbild_samstag.jpg" style="width: 538px; height: 91px;" alt="" title="" \/><br \/>');
  }

}


var undefined;


function Gallery(id) {
  this.id = undefined;
  this.config = GalleryConfig.createInstance();
  this.itemList = [];
  this.activeItemList = [];
  this.itemViewLength = 3;
  this.timeout = undefined;
  this.rotationBreak = false;
  this._detailIDX = undefined;
  
  this._baseElem = undefined;
  this._displayElem = undefined;
  this._itemListElem = undefined;
  this._navigationListElem = undefined;
  this._buttonDesc = undefined;
  this._buttonAsc = undefined;
  
  this._setID(id);
  this._setBaseElem();
  this._setDisplayElem();
  this._setItemListElem();
  this._setNavigation();
}


Gallery.prototype._setID = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('Gallery->_setID: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('Gallery->_setID: Argument str ist nicht vom Typ String!');
  }
  this.id = str;
} 


Gallery.prototype._setNavigation = function () {
  if (! this._baseElem) {
    focus();
    throw new Error('Gallery->_setDrawElem: Es existiert kein Base-HTML-Element!');
  }
  var buttonDesc  = document.createElement('a');
  buttonDesc.href = 'javascript:void(0);';
  buttonDesc.className = 'GALLERY_NAVIGATION_BACKBUTTON';
  var id = this.id;
  var backw = new Function ('','Gallery.getInstance(\'' + id + '\').backward();'); 
  GalleryTools.addEvent('click', buttonDesc, backw);
  var buttonAsc  = document.createElement('a');
  buttonAsc.href = 'javascript:void(0);';
  buttonAsc.className = 'GALLERY_NAVIGATION_FORWARDBUTTON';
  var forw = new Function ('','Gallery.getInstance(\'' + id + '\').forward();'); 
  GalleryTools.addEvent('click', buttonAsc, forw);
  var elem = document.createElement('div');
  elem.className = 'GALLERY_NAVIGATION_LIST';
  if (this.itemList.length <= this.config.activeItemLength) {
      elem.style.display = 'none';
  }
  this._baseElem.appendChild(elem);
  elem.appendChild(buttonDesc);
  elem.appendChild(buttonAsc);
  this._buttonAsc = buttonAsc;
  this._buttonDesc = buttonDesc;
  this._navigationListElem = elem;
} 


Gallery.prototype.backward = function () {
  this.config.setDirection('descending');
  this.rotationBreak = false;
  this.rotate();
} 


Gallery.prototype.forward = function () {
  this.config.setDirection('ascending');
  this.rotationBreak = false;
  this.rotate();
} 


Gallery.prototype._setItemListElem = function () {
  if (! this._displayElem) {
    focus();
    throw new Error('Gallery->_setItemListElem: Es existiert kein Display-HTML-Element!');
  }
  var elem = document.createElement('div');
  elem.className = 'GALLERY_ITEM_LIST';
  this._displayElem.appendChild(elem);
  this._itemListElem = elem;
} 


Gallery.prototype._setDisplayElem = function () {
  if (! this._baseElem) {
    focus();
    throw new Error('Gallery->_setDisplayElem: Es existiert kein Base-HTML-Element!');
  }
  var elem = document.createElement('div');
  elem.className = 'GALLERY_BOX_DISPLAY';
  this._baseElem.appendChild(elem);
  this._displayElem = elem;
} 


Gallery.prototype._setBaseElem = function () {
  var elem = document.getElementById(this.id);
  if (! elem) {
    focus();
    throw new Error('Gallery->_setBaseElem: Es existiert kein HTML-Element mit id = '+ this.id +'!');
  }
  this._baseElem = elem;
} 


Gallery.prototype.setItemViewLength = function (n) {
  if (arguments.length!=1) {
    throw new Error("Gallery->setItemViewLength: Falsche Anzahl von Argumenten!");
  }
  if (typeof n != "number") {
    throw new Error("Gallery->setItemViewLength: Argument ist nicht vom Typ number!");
  }
  this.itemViewLength = n;
} 


Gallery.prototype.addItemList = function (obj) {
  if (arguments.length != 1) {
    focus();
    throw new Error('Gallery->addItemList: Falsche Anzahl von Argumenten!');
  }
  if (! (obj instanceof GalleryItem)) {
    focus();
    throw new Error('Gallery->addItemList: Argument obj ist keine Instance GalleryItem!');
  }
  obj._setListPosition(this.itemList.length);
  this.itemList.push(obj);
  if (this.config.activeItemLength >= (this.activeItemList.length-1)) {
    this.activeItemList.push(obj);
  }
} 


Gallery.prototype._cloneItems = function () {
  var length = this.itemList.length;
  for (var i=0; i<length; i++) {
    var item = this.itemList[i];
    var newitem = GalleryItem.createInstance();
    if (item.srcPreview) {
      newitem.setSrcPreview(item.srcPreview);
    }
    if (item.srcStandard) {
      newitem.setSrcStandard(item.srcStandard);
    }
    if (item.title) {
      newitem.setTitle(item.title);
    }
    if (item.subtitle) {
      newitem.setSubtitle(item.subtitle);
    }
    if (item.description) {
      newitem.setDescription(item.description);
    }
    if (item.linkURL) {
      newitem.setLinkURL(item.linkURL);
    }
    this.addItemList(newitem);
  }
}  


Gallery.prototype._closeDetail = function () {
  var body = document.getElementsByTagName('body')[0];
  var gallery_detail = document.getElementById('GALLERY_DETAIL');
  if (gallery_detail) {
    body.removeChild(gallery_detail);
  }
}  


Gallery.prototype.detailBackward = function () {
  if (this._detailIDX == undefined) {
    return;
  }
  this._detailIDX--;
  if (this._detailIDX < 0) {
    this._detailIDX = this.itemList.length -1;
  }
  var next = this.itemList[this._detailIDX];
  this._rotateDetail(next);
}


Gallery.prototype.detailForward = function () {
  if (this._detailIDX == undefined) {
    return;
  }
  this._detailIDX++;
  if (this._detailIDX >= this.itemList.length) {
    this._detailIDX = 0;
  }
  var next = this.itemList[this._detailIDX];
  this._rotateDetail(next);
}


Gallery.prototype._rotateDetail = function (next) {
  if (this.timeout) {
    window.clearTimeout(this.timeout);
  }
  var clone = document.getElementById('GALLERY_DETAIL_DISPLAY_IMG_CLONE');
  var old = document.getElementById('GALLERY_DETAIL_DISPLAY_IMG');
  var id = this.id;
  if (next) {
    if (! clone) {
      clone = old.cloneNode(true);
      clone.className = 'GALLERY_DETAIL_DISPLAY_IMG_CLONE';
      var parent = old.parentNode;
      parent.insertBefore(clone, old);
    }
    var alt = 'Bild ' + parseFloat(next.listPosition + 1) ;
    if (next.title) {
      alt += ' - ' + title;
    }
    clone.src = next.standard.src;
    clone.alt = alt;
    clone.title = alt;
    clone.id = 'GALLERY_DETAIL_DISPLAY_IMG_CLONE';
    var nrElem = document.getElementById('GALLERY_DETAIL_INFO_NUMBER');
    nrElem.innerHTML = 'Bild ' + parseFloat(next.listPosition + 1) ;
    var title = '';
    if (next.title) {
      title = next.title
    }
    var titleElem = document.getElementById('GALLERY_DETAIL_INFO_TITLE');
    titleElem.innerHTML = title;
    var description = '';
    if (next.description) {
      description = next.description
    }
    var textElem = document.getElementById('GALLERY_DETAIL_INFO_TEXT');
    textElem.innerHTML = description;
    if (! clone.complete) {
      var func = function() {
        Gallery.getInstance(id)._rotateDetail(next);
      }
      clone.onload = func;
      return;
    }
  }
  if (clone.height < old.height) {
    var posh = parseFloat(old.height - clone.height) / 2;
    clone.style.top = GalleryTools.getCssUnit(posh);
  } else {
  }
  if (clone.width < old.width) {
    var posw = parseFloat(old.width - clone.width) / 2;
    clone.style.left = GalleryTools.getCssUnit(posw);
  } else {
  }
  var opac;
  if (clone.filters != undefined){
    opac = parseFloat(clone.filters['Alpha']['opacity']);
  } else {
    opac = parseFloat(clone.style.opacity);
  }
  if (! opac) {
    opac = 0;
  }
  var opac_reached = false;
  if (clone.filters != undefined){
    if (opac >= 100) {
        opac_reached = true;
    }
  } else {
    if (opac >= 1) {
        opac_reached = true;
    }
  }
  if (opac_reached) {
    var o_par = old.parentNode;
    clone.id = old.id;
    clone.className = old.className;
    clone.removeAttribute('style');
    o_par.removeChild(old);
    this._updateDetailBox(clone);
    return;
  }
  if (clone.filters != undefined){
    opac += 5;
    clone.filters['Alpha']['opacity'] = opac;
    clone.filters['Alpha']['finishopacity'] = opac;
  } else {
    opac += 0.05;
    clone.style.opacity = opac;
  }
  var func2 = function() {
    if (IE6) {
      Gallery.getInstance(id)._rotateDetail(next);
    } else {
      Gallery.getInstance(id)._rotateDetail();
    }
  }
  this.timeout = window.setTimeout(func2, 50);
}
  

Gallery.prototype._updateDetailBox = function (img) {
  var display = document.getElementById('GALLERY_DETAIL_DISPLAY');    
  var info = document.getElementById('GALLERY_DETAIL_INFO');        
  var width = img.width; 
  var height = img.height;
  display.style.width = GalleryTools.getCssUnit(width);
  display.style.height = GalleryTools.getCssUnit(parseFloat(height + parseFloat(info.offsetHeight)));
  var backw = document.getElementById('GALLERY_DETAIL_BACKWARD');
  backw.style.width = GalleryTools.getCssUnit(parseFloat(img.width / 2)); 
  backw.style.height = GalleryTools.getCssUnit(parseFloat(img.height)); 
  var forw = document.getElementById('GALLERY_DETAIL_FORWARD');
  forw.style.width = GalleryTools.getCssUnit(parseFloat(img.width / 2)); 
  forw.style.height = GalleryTools.getCssUnit(img.height); 
  forw.style.left = GalleryTools.getCssUnit(parseFloat(img.width / 2)); 
}
  

Gallery.prototype.detailButtonAction = function () {
}
  

Gallery.prototype._showDetail = function (idx) {
  var body = document.getElementsByTagName('body')[0];
  var gallery_detail = document.getElementById('GALLERY_DETAIL');
  var display = document.getElementById('GALLERY_DETAIL_DISPLAY');
  var item = GalleryItem.getInstance(idx);
  this._detailIDX = item.listPosition;
  var id = this.id;
  if (! gallery_detail) {
    var display_img = item.standard;
    if (! display_img.complete) {
      var func = function () {
        Gallery.getInstance(id)._showDetail(idx);
      }
      display_img.onload = func;
      return;
    }
    gallery_detail = document.createElement('div');
    gallery_detail.style.visibility = 'hidden';
    gallery_detail.id = 'GALLERY_DETAIL';
    gallery_detail.className = 'GALLERY_DETAIL';
    gallery_detail.style.zIndex = '900000000';
    body.insertBefore(gallery_detail, body.firstChild);
    
    curtain = document.createElement('div');
    curtain.id = 'GALLERY_DETAIL_CURTAIN';
    curtain.className = 'GALLERY_DETAIL_CURTAIN';
    curtain.style.zIndex = '1';
    gallery_detail.appendChild(curtain);
    
    display = document.createElement('div');
    display.id = 'GALLERY_DETAIL_DISPLAY'; 
    display.className = 'GALLERY_DETAIL_DISPLAY';
    display.style.zIndex = '2';
    gallery_detail.appendChild(display);
    
    var display_inner = document.createElement('div');
    display_inner.id = 'GALLERY_DETAIL_DISPLAY_INNER'; 
    display_inner.className = 'GALLERY_DETAIL_DISPLAY_INNER';
    display_inner.style.zIndex = '2';
    display_inner.style.visibility = 'hidden';
    display.appendChild(display_inner);
    
    var display_img_container = document.createElement('div');
    display_img_container.id = 'GALLERY_DETAIL_DISPLAY_IMG_CONTAINER'; 
    display_img_container.className = 'GALLERY_DETAIL_DISPLAY_IMG_CONTAINER';
    display_img_container.style.zIndex = '2';
    display_inner.appendChild(display_img_container);
    
    display_img.className = 'GALLERY_DETAIL_DISPLAY_IMG';
    display_img.id = 'GALLERY_DETAIL_DISPLAY_IMG';
    var alt = 'Bild ' + parseFloat(item.listPosition + 1) ;
    if (item.title) {
      alt += ' - ' + item.title;
    }
    display_img.alt = alt;
    if (item.title) {
      display_img.title = item.title;
    }
    display_img_container.appendChild(display_img);
    
    var back = document.createElement('a');
    back.href = 'javascript:void(0);';
    var id = this.id;
    back.onclick = function() {
      Gallery.getInstance(id).detailBackward();
    };
    back.title = 'Vorheriges Bild anzeigen';
    back.className = 'GALLERY_DETAIL_BACKWARD';
    back.id = 'GALLERY_DETAIL_BACKWARD';
    display_img_container.insertBefore(back, display_img);
    back.style.width = GalleryTools.getCssUnit(parseFloat(display_img.width / 2));
    back.style.height = GalleryTools.getCssUnit(parseFloat(display_img.height));
    
    var forw = document.createElement('a');
    forw.href = 'javascript:void(0);';
    forw.onclick = function() {
      Gallery.getInstance(id).detailForward();
    };
    forw.title = 'Nächstes Bild anzeigen';
    forw.className = 'GALLERY_DETAIL_FORWARD';
    forw.id = 'GALLERY_DETAIL_FORWARD';
    display_img_container.insertBefore(forw, display_img);
    forw.style.width = GalleryTools.getCssUnit(parseFloat(display_img.width / 2));
    forw.style.height = GalleryTools.getCssUnit(parseFloat(display_img.height));
    forw.style.left = GalleryTools.getCssUnit(parseFloat(display_img.offsetWidth / 2));
    
    var display_button = document.createElement('a');
    display_button.style.zIndex = '3';
    display_button.href = 'javascript:void(0);';
    display_button.onclick = function() {
      Gallery.getInstance(id).detailButtonAction();
    };
    display_button.className = 'GALLERY_BOX_DISPLAY_BUTTON';
    display_button.id = 'GALLERY_BOX_DISPLAY_BUTTON_ANKER';
    display_inner.appendChild(display_button);
    
    var info = document.createElement('div');
    info.className = 'GALLERY_DETAIL_INFO';
    info.id = 'GALLERY_DETAIL_INFO';
    display_inner.appendChild(info);
    
    var close = document.createElement('a');
    close.href = 'javascript:void(0);';
    close.onclick = function() {
      Gallery.getInstance(id)._closeDetail();
    };
    close.className = "GALLERY_DETAIL_CLOSE";
    close.id = "GALLERY_DETAIL_CLOSE";
    info.appendChild(close);
    
    var h4 = document.createElement('h4');
    h4.className = 'GALLERY_DETAIL_INFO_NUMBER';
    h4.id = 'GALLERY_DETAIL_INFO_NUMBER';
    info.appendChild(h4);
    h4.innerHTML =  'Bild ' + parseFloat(item.listPosition + 1) ;
    
    var h3 = document.createElement('h3');
    h3.className = 'GALLERY_DETAIL_INFO_TITLE';
    h3.id = 'GALLERY_DETAIL_INFO_TITLE';
    info.appendChild(h3);
    var tit = '';
    if (item.title) {
      tit = item.title;
    }
    h3.innerHTML = tit;
    
    var p = document.createElement('p');
    p.className = 'GALLERY_DETAIL_INFO_TEXT';
    p.id = 'GALLERY_DETAIL_INFO_TEXT';
    var text = '';
    if (item.subtitle) {
    }
    if (item.description) {
      if (item.subtitle) {
      }
      text += item.description;
    }
    p.innerHTML = text;
    info.appendChild(p);
  }
  gallery_detail.style.visibility = 'visible';
  
  var d_width = parseFloat(display_img.offsetWidth);
  var d_height = parseFloat(display_img.offsetHeight) +parseFloat(info.offsetHeight) ;
  display.style.left = GalleryTools.getCssUnit(parseFloat(d_width / 2));
  if (IE6 || IE7) {
    display.style.top = '50px';
  }
  display.style.width = '1px';
  display.style.height = '1px';
  this._moveInDetail(display, d_width, d_height);
} 


Gallery.prototype._moveInDetail = function (elem, width, height) {
  if (this.timeout) {
    window.clearTimeout(this.timeout);
  }
  if (arguments.length != 3) {
    focus();
    throw new Error('Gallery->_moveInDetail: Falsche Anzahl von Argumten!');
  }
  var id = this.id;
  if (parseFloat(elem.style.height) <= height) {
    var func = function () {
      Gallery.getInstance(id)._moveInDetail(elem,width,height);
    }
    elem.style.height = GalleryTools.getCssUnit(parseFloat(elem.style.height) + 10);
    this.timeout = window.setTimeout(func, 2);
    return;
  }
  if (parseFloat(elem.style.width) <= width) {
    var func = function () {
      Gallery.getInstance(id)._moveInDetail(elem,width,height);
    }
    elem.style.width = GalleryTools.getCssUnit(parseFloat(elem.style.width) + 10);
    elem.style.left = GalleryTools.getCssUnit(parseFloat(elem.style.left) - 5 );
    this.timeout = window.setTimeout(func, 2);
    return;
  }
  elem.firstChild.style.visibility = 'visible';
} 


Gallery.prototype.drawItemList = function () {
  if (! this._itemListElem) {
    focus();
    throw new Error('Gallery->drawItemList: Es existiert kein ItemList-HTML-Element!');
  }
  this._navigationListElem.style.display = 'block';
  if (this.itemList.length > this.config.activeItemLength && this.itemList.length <= (this.config.activeItemLength) + 1) {
    this._cloneItems();
  }
  if (this.config.type == 'type3') {
    if (this.itemList.length <= this.config.activeItemLength) {
        this._navigationListElem.style.display = 'none';
    }
  } else if (this.config.type == 'type2') {
    if (this.itemList.length <= (parseFloat(this.config.activeItemLength) + 1)) {
        this._navigationListElem.style.display = 'none';
    }
  } else {
    if (this.itemList.length <= (parseFloat(this.config.activeItemLength) + 1)) {
        this._navigationListElem.style.display = 'none';
    }
  }
  for (var i=0; i<this.activeItemList.length; i++) {
    var item = this.activeItemList[i];
    this._drawItem(item, i);
  }  
} 


Gallery.prototype._drawItem = function (item, pos) {
  if (! arguments.length) {
    focus();
    throw new Error('Gallery->drawItem: Falsche Anzahl von Argumenten!');
  }
  if (this.config.type == 'type3') {
    return this._drawItem_type3(item, pos);
  } else if (this.config.type == 'type2') {
    return this._drawItem_type2(item, pos);
  } else {
    return this._drawItem_type1(item, pos);
  }
}  


Gallery.prototype._drawItem_type1 = function (item, pos) {
  if (! arguments.length) {
    focus();
    throw new Error('Gallery->_drawItem_type1: Falsche Anzahl von Argumenten!');
  }
  if (! this._itemListElem) {
    focus();
    throw new Error('Gallery->_drawItem_type1: Es existiert kein ItemList-HTML-Element!');
  }
  var img = item.preview;
  if (! img ) {
    item._setPreview();
    img = item.preview;
  }
  var alt = 'Bild ' + parseFloat(item.listPosition + 1) ;
  if (item.title) {
    alt += ' - ' + item.title;
  }
  alt = '';
  img.alt = alt;
  if (item.title) {
  }
  img.className = 'GALLERY_LIST_ITEM';
  var anc = document.createElement('a');
  anc.style.visibility = 'hidden';
  anc.href = "javascript:void(0);";
  anc.title = alt;
  anc.className = 'GALLERY_LIST_ITEM';
  var id = this.id;
  var item_id = item.id;
  this._itemListElem.appendChild(anc);
  var m_over = new Function ('','Gallery.getInstance(\'' + id + '\').itemOnmouseover(\'' +item_id+ '\');'); 
  GalleryTools.addEvent('mouseover', anc, m_over);
  var m_out = new Function ('','Gallery.getInstance(\'' + id + '\').itemOnmouseout(\'' +item_id+ '\');'); 
  GalleryTools.addEvent('mouseout', anc, m_out);
  var m_click = new Function ('','Gallery.getInstance(\'' + id + '\').itemOnclick(\'' +item_id+ '\');'); 
  GalleryTools.addEvent('click', anc, m_click);
  anc.appendChild(img);
  if (pos != undefined) {
    pos = parseFloat(pos);
    if (this.config.dimension == 'vertical') {
      var top = parseFloat(img.parentNode.offsetHeight);
      top *= pos;
      img.parentNode.style.top = GalleryTools.getCssUnit(top);
    } else {
      var left = parseFloat(img.parentNode.offsetWidth);
      left *= pos;
      img.parentNode.style.left = GalleryTools.getCssUnit(left);
    }
  }
  img.parentNode.style.zIndex = parseFloat(item.listPosition + 1);
  img.parentNode.style.visibility = 'visible';
  return true;
} 


Gallery.prototype._drawItem_type2 = function (item, pos) {
  if (! arguments.length) {
    focus();
    throw new Error('Gallery->_drawItem_type2: Falsche Anzahl von Argumenten!');
  }
  if (! this._itemListElem) {
    focus();
    throw new Error('Gallery->_drawItem_type2: Es existiert kein ItemList-HTML-Element!');
  }
  var img = item.preview;
  if (! img ) {
    item._setPreview();
    img = item.preview;
  }
  var alt = 'Bild ' + parseFloat(item.listPosition + 1) ;
  if (item.title) {
    alt += ' - ' + item.title;
  }
  img.alt = alt;
  if (item.title) {
  }
  alt = '';
  img.className = 'GALLERY_LIST_ITEM';
  var anc = document.createElement('a');
  anc.title = alt;
  anc.className = 'GALLERY_LIST_ITEM';
  var div = document.createElement('div');
  div.style.visibility = 'hidden';
  div.className = 'GALLERY_LIST_ITEM';
  div.appendChild(anc);
  var div_text =  document.createElement('div');
  div_text.className = 'GALLERY_LIST_ITEM_TEXT';
  var h5 =  document.createElement('h5');
  h5.className = 'GALLERY_LIST_ITEM_TEXT';
  h5.innerHTML = item.title;
  div_text.appendChild(h5);
  var p =  document.createElement('div');
  p.className = 'GALLERY_LIST_ITEM_TEXT';
  var subt = '';
  if (item.subtitle) {
    subt = item.subtitle;
  }
  p.innerHTML = subt;
  div_text.appendChild(p);
  div.appendChild(div_text);
  
  var id = this.id;
  var item_id = item.id;
  this._itemListElem.appendChild(div);
  /*
  var m_over = new Function ('','Gallery.getInstance(\'' + id + '\').itemOnmouseover(\'' +item_id+ '\');'); 
  GalleryTools.addEvent('mouseover', anc, m_over);
  var m_out = new Function ('','Gallery.getInstance(\'' + id + '\').itemOnmouseout(\'' +item_id+ '\');'); 
  GalleryTools.addEvent('mouseout', anc, m_out);
  var m_click = new Function ('','Gallery.getInstance(\'' + id + '\').itemOnclick(\'' +item_id+ '\');'); 
  GalleryTools.addEvent('click', anc, m_click);
  */
  anc.appendChild(img);
  if (pos != undefined) {
    pos = parseFloat(pos);
    if (this.config.dimension == 'vertical') {
      var top = parseFloat(div.offsetHeight);
      top *= pos;
      div.style.top = GalleryTools.getCssUnit(top);
    } else {
      var left = parseFloat(div.offsetWidth);
      left *= pos;
      div.style.left = GalleryTools.getCssUnit(left);
    }
  }
  div.style.zIndex = parseFloat(item.listPosition + 1);
  div.style.visibility = 'visible';
  return true;
}  


Gallery.prototype._drawItem_type3 = function (item, pos) {
  if (! arguments.length) {
    focus();
    throw new Error('Gallery->_drawItem_type3: Falsche Anzahl von Argumenten!');
  }
  if (! this._itemListElem) {
    focus();
    throw new Error('Gallery->_drawItem_type3: Es existiert kein ItemList-HTML-Element!');
  }
  var img = item.preview;
  if (! img ) {
    item._setPreview();
    img = item.preview;
  }
  var alt = 'Bild ' + parseFloat(item.listPosition + 1) ;
  if (item.title) {
    alt += ' - ' + item.title;
  }
  img.alt = alt;
  if (item.title) {
  }
  alt = '';
  img.className = 'GALLERY_LIST_ITEM';
  var anc = document.createElement('a');
  anc.style.visibility = 'hidden';
  anc.href = "javascript:void(0);";
  anc.title = alt;
  anc.className = 'GALLERY_LIST_ITEM';
  var id = this.id;
  var item_id = item.id;
  this._itemListElem.appendChild(anc);
  var m_over = new Function ('','Gallery.getInstance(\'' + id + '\').itemOnmouseover(\'' +item_id+ '\');'); 
  GalleryTools.addEvent('mouseover', anc, m_over);
  var m_out = new Function ('','Gallery.getInstance(\'' + id + '\').itemOnmouseout(\'' +item_id+ '\');'); 
  GalleryTools.addEvent('mouseout', anc, m_out);
  var m_click = new Function ('','Gallery.getInstance(\'' + id + '\').itemOnclick(\'' +item_id+ '\');'); 
  GalleryTools.addEvent('click', anc, m_click);
  anc.appendChild(img);
  if (pos != undefined) {
    pos = parseFloat(pos);
    if (this.config.dimension == 'vertical') {
      var top = parseFloat(img.parentNode.offsetHeight);
      top *= pos;
      img.parentNode.style.top = GalleryTools.getCssUnit(top);
    } else {
      var left = parseFloat(img.parentNode.offsetWidth);
      left *= pos;
      img.parentNode.style.left = GalleryTools.getCssUnit(left);
    }
  }
  img.parentNode.style.zIndex = parseFloat(item.listPosition + 1);
  img.parentNode.style.visibility = 'visible';
  return true;
} 


Gallery.prototype.rotate = function () {
  if (this.config.activeItemLength >= (this.itemList.length +1)) {
    return;
  }
  if (this.config.type == 'type3') {
      this._type3();
  } else if (this.config.type == 'type2') {
      this._type2();
  } else {
      this._type1();
  }
}  


Gallery.prototype._type1 = function () {
  if (this.config.direction == 'descending') {
      this._type1_descending();
  } else {
      this._type1_ascending();
  }
} 


Gallery.prototype._type2 = function () {
  if (this.config.direction == 'descending') {
      this._type2_descending();
  } else {
      this._type2_ascending();
  }
} 


Gallery.prototype._type3 = function () {
  if (this.config.direction == 'descending') {
      this._type3_descending();
  } else {
      this._type3_ascending();
  }
} 


Gallery.prototype._type1_ascending = function (n, rest) {
  if (this.timeout) {
    window.clearTimeout(this.timeout);
  }
  if (this.rotationBreak == true) {
    return;
  }
  if (n == undefined) {
    n = 0;
  }
  if (rest == undefined) {
    rest = 0;
  }
  var id = this.id;
  for (var i=n; i<this.activeItemList.length; i++) {
    var item = this.activeItemList[i];
    if (! item.preview.complete) {
      var lfunc = new Function ('','Gallery.getInstance(\'' + id + '\')._type1_ascending(\'' + i + '\');');  
      GalleryTools.addEvent('load', item.preview, lfunc);
    }
    var lastItem = this.activeItemList[this.activeItemList.length-1];
    var boundary;
    var diff;
    var pos;
    if (this.config.dimension == 'vertical') {
      boundary = parseFloat(item.preview.parentNode.offsetHeight) +1;
      boundary *= -1;
      var top = parseFloat(item.preview.style.top);
      var diff = top - boundary ;
      pos = this.config.speedPixel; 
      if (rest) {
         pos = rest;
      } else if (diff <= this.config.speedPixel) {
         pos = diff;
         rest = pos;
      } 
       top -=pos;
      item.preview.parentNode.style.top = GalleryTools.getCssUnit(top);
      if (top <= boundary) {
        if (rest) {
          if (this.config.rotate != 'auto') {  
            this.rotationBreak = true;
          }
        }
        this.activeItemList.shift();
        this._itemListElem.removeChild(item.preview.parentNode);
        var newTop = parseFloat(parseFloat(lastItem.preview.parentNode.style.top) + parseFloat(lastItem.preview.parentNode.offsetHeight));
        var nextItem;
        if (lastItem.listPosition == (this.itemList.length-1)) {
          nextItem = this.itemList[0];
        } else {
          nextItem = this.itemList[lastItem.listPosition +1];
        }
        if (! nextItem.preview || ! nextItem.preview.parentNode) {
          if (! this._drawItem(nextItem))  {
             return;
          }
        }
        nextItem.preview.parentNode.style.top = GalleryTools.getCssUnit(newTop);
        this._itemListElem.appendChild(nextItem.preview.parentNode);
        this.activeItemList.push(nextItem);
        i--;
      }
    } else {
      boundary = parseFloat(item.preview.parentNode.offsetWidth);
      boundary *= -1;
      var left = parseFloat(item.preview.parentNode.style.left);
      diff = left - boundary;
      pos = this.config.speedPixel; 
      if (rest) {
         pos = rest;
      } else if (diff <= this.config.speedPixel) {
         pos = diff;
         rest = pos;
      } 
      left -= pos;
      item.preview.parentNode.style.left = GalleryTools.getCssUnit(left);
      if (left <= boundary) {
        if (rest) {
          if (this.config.rotate != 'auto') {  
            this.rotationBreak = true;
          }
        }
        this.activeItemList.shift();
        this._itemListElem.removeChild(item.preview.parentNode);
        var newLeft = parseFloat(parseFloat(lastItem.preview.parentNode.style.left) + parseFloat(lastItem.preview.parentNode.offsetWidth));
        var nextItem;
        if (lastItem.listPosition == (this.itemList.length-1)) {
          nextItem = this.itemList[0];
        } else {
          nextItem = this.itemList[lastItem.listPosition +1];
        }
        if (! nextItem.preview || ! nextItem.preview.parentNode) {
          if (! this._drawItem(nextItem))  {
             return;
          }
        }
        nextItem.preview.parentNode.style.left = GalleryTools.getCssUnit(newLeft);
        this._itemListElem.appendChild(nextItem.preview.parentNode);
        this.activeItemList.push(nextItem);
        i--;
      }
    }
  }
  var func = new Function ('','Gallery.getInstance(\'' + id + '\')._type1_ascending(undefined,'+ rest +');'); 
  this.timeout = window.setTimeout(func, this.config.speedTime);
} 


Gallery.prototype._type1_descending = function (n, rest) {
  if (this.timeout) {
    window.clearTimeout(this.timeout);
  }
  if (this.rotationBreak == true) {
    return;
  }
  if (n == undefined) {
    n = this.activeItemList.length -1;
  }
  var id = this.id;
  for (var i=n; i>=0; i--) {
    var item = this.activeItemList[i];
    if (! item.preview.complete) {
      var lfunc = new Function ('','Gallery.getInstance(\'' + id + '\')._type1_descending(\'' + i + '\');');  
      GalleryTools.addEvent('load', item.preview, lfunc);
    }
    var lastItem = this.activeItemList[0];
    var boundary;
    var pos;
    var diff;
    if (this.config.dimension == 'vertical') {
      var diffHeight = parseFloat(item.preview.parentNode.offsetHeight) - parseFloat(item.preview.offsetHeight);
      boundary = (parseFloat(item.preview.parentNode.offsetHeight) + parseFloat(this._displayElem.offsetHeight) ) + diffHeight;
      var top = parseFloat(item.preview.parentNode.style.top);  
      diff = boundary - top;
      pos = this.config.speedPixel; 
      if (rest) {
         pos = rest;
      } else if (diff <= this.config.speedPixel) {
         pos = diff;
         rest = pos;
      } 
      top += pos;
      item.preview.parentNode.style.top = GalleryTools.getCssUnit(top);
      if (top >= boundary) {
        if (rest) {
          if (this.config.rotate != 'auto') {  
            this.rotationBreak = true;
          }
        } 
        this.activeItemList.pop();
        this._itemListElem.removeChild(item.preview.parentNode);
        var newTop = parseFloat(parseFloat(lastItem.preview.parentNode.style.top) - parseFloat(lastItem.preview.parentNode.offsetHeight));
        var nextItem;
        if (lastItem.listPosition == 0) {
          nextItem = this.itemList[this.itemList.length-1];
        } else {
          nextItem = this.itemList[lastItem.listPosition -1];
        }
        if (! nextItem.preview || ! nextItem.preview.parentNode) {
          this._drawItem(nextItem);
        }
        nextItem.preview.parentNode.style.top = GalleryTools.getCssUnit(newTop);
        this._itemListElem.appendChild(nextItem.preview.parentNode);
        this.activeItemList.unshift(nextItem);
        i++;
      }
    } else {
      var diffWidth = parseFloat(item.preview.parentNode.offsetWidth) - parseFloat(item.preview.offsetWidth);
      boundary = ( parseFloat(item.preview.parentNode.offsetWidth) + parseFloat(this._displayElem.offsetWidth) ) + diffWidth;
      var left = parseFloat(item.preview.parentNode.style.left);      
      diff = boundary - left;
      pos = this.config.speedPixel; 
      if (rest) {
         pos = rest;
      } else if (diff <= this.config.speedPixel) {
         pos = diff;
         rest = pos;
      } 
      left += pos;
      item.preview.parentNode.style.left = GalleryTools.getCssUnit(left);
      if (left >= boundary) {
        if (rest) {
          if (this.config.rotate != 'auto') {  
            this.rotationBreak = true;
          }
        } 
        this.activeItemList.pop();
        this._itemListElem.removeChild(item.preview.parentNode);
        var newLeft = parseFloat(parseFloat(lastItem.preview.parentNode.style.left) - parseFloat(lastItem.preview.parentNode.offsetWidth));
        var nextItem;
        if (lastItem.listPosition == 0) {
          nextItem = this.itemList[this.itemList.length-1];
        } else {
          nextItem = this.itemList[lastItem.listPosition -1];
        }
        if (! nextItem.preview || ! nextItem.preview.parentNode) {
          this._drawItem(nextItem);
        }
        nextItem.preview.parentNode.style.left = GalleryTools.getCssUnit(newLeft);
        this._itemListElem.appendChild(nextItem.preview.parentNode);
        this.activeItemList.unshift(nextItem);
        i++;
      }
    }
  }
  var func = new Function ('','Gallery.getInstance(\'' + id + '\')._type1_descending(undefined,'+ rest +');'); 
  this.timeout = window.setTimeout(func, this.config.speedTime);
} 


Gallery.prototype._type2_ascending = function (n, rest) {
  if (this.timeout) {
    window.clearTimeout(this.timeout);
  }
  if (this.rotationBreak == true) {
    return;
  }
  if (n == undefined) {
    n = 0;
  }
  if (rest == undefined) {
    rest = 0;
  }
  var id = this.id;
  for (var i=n; i<this.activeItemList.length; i++) {
    var item = this.activeItemList[i];
    if (! item.preview.complete) {
      var lfunc = new Function ('','Gallery.getInstance(\'' + id + '\')._type2_ascending(\'' + i + '\');');  
      GalleryTools.addEvent('load', item.preview, lfunc);
    }
    var lastItem = this.activeItemList[this.activeItemList.length-1];
    var boundary;
    var diff;
    var pos;
    if (this.config.dimension == 'vertical') {
      boundary = parseFloat(item.preview.parentNode.parentNode.offsetHeight);
      boundary *= -1;
      var top = parseFloat(item.preview.parentNode.parentNode.style.top);
      var diff = top - boundary ;
      pos = this.config.speedPixel; 
      if (rest) {
         pos = rest;
      } else if (diff <= this.config.speedPixel) {
         pos = diff;
         rest = pos;
      } 
       top -=pos;
      item.preview.parentNode.parentNode.style.top = GalleryTools.getCssUnit(top);
      if (top <= boundary) {
        if (rest) {
          if (this.config.rotate != 'auto') {  
            this.rotationBreak = true;
          }
        }
        this.activeItemList.shift();
        this._itemListElem.removeChild(item.preview.parentNode.parentNode);
        var newTop = parseFloat(parseFloat(lastItem.preview.parentNode.parentNode.style.top) + parseFloat(lastItem.preview.parentNode.parentNode.offsetHeight));
        var nextItem;
        if (lastItem.listPosition == (this.itemList.length-1)) {
          nextItem = this.itemList[0];
        } else {
          nextItem = this.itemList[lastItem.listPosition +1];
        }
        if (! nextItem.preview || ! nextItem.preview.parentNode || ! nextItem.preview.parentNode.parentNode) {
          if (! this._drawItem(nextItem))  {
             return;
          }
        }
        nextItem.preview.parentNode.parentNode.style.top = GalleryTools.getCssUnit(newTop);
        this._itemListElem.appendChild(nextItem.preview.parentNode.parentNode);
        this.activeItemList.push(nextItem);
        i--;
      }
    } else {
      boundary = parseFloat(item.preview.parentNode.parentNode.offsetWidth);
      boundary *= -1;
      var left = parseFloat(item.preview.parentNode.parentNode.style.left);
      diff = left - boundary;
      pos = this.config.speedPixel; 
      if (rest) {
         pos = rest;
      } else if (diff <= this.config.speedPixel) {
         pos = diff;
         rest = pos;
      } 
      left -= pos;
      item.preview.parentNode.parentNode.style.left = GalleryTools.getCssUnit(left);
      if (left <= boundary) {
        if (rest) {
          if (this.config.rotate != 'auto') {  
            this.rotationBreak = true;
          }
        }
        this.activeItemList.shift();
        this._itemListElem.removeChild(item.preview.parentNode.parentNode);
        var newLeft = parseFloat(parseFloat(lastItem.preview.parentNode.parentNode.style.left) + parseFloat(lastItem.preview.parentNode.parentNode.offsetWidth));
        var nextItem;
        if (lastItem.listPosition == (this.itemList.length-1)) {
          nextItem = this.itemList[0];
        } else {
          nextItem = this.itemList[lastItem.listPosition +1];
        }
        if (! nextItem.preview || ! nextItem.preview.parentNode || ! nextItem.preview.parentNode.parentNode) {
          if (! this._drawItem(nextItem))  {
             return;
          }
        }
        nextItem.preview.parentNode.parentNode.style.left = GalleryTools.getCssUnit(newLeft);
        this._itemListElem.appendChild(nextItem.preview.parentNode.parentNode);
        this.activeItemList.push(nextItem);
        i--;
      }
    }
  }
  var func = new Function ('','Gallery.getInstance(\'' + id + '\')._type2_ascending(undefined,'+ rest +');'); 
  this.timeout = window.setTimeout(func, this.config.speedTime);
} 


Gallery.prototype._type2_descending = function (n, rest) {
  if (this.timeout) {
    window.clearTimeout(this.timeout);
  }
  if (this.rotationBreak == true) {
    return;
  }
  if (n == undefined) {
    n = this.activeItemList.length -1;
  }
  var id = this.id;
  for (var i=n; i>=0; i--) {
    var item = this.activeItemList[i];
    if (! item.preview.complete) {
      var lfunc = new Function ('','Gallery.getInstance(\'' + id + '\')._type2_descending(\'' + i + '\');');  
      GalleryTools.addEvent('load', item.preview, lfunc);
    }
    var lastItem = this.activeItemList[0];
    var boundary;
    var pos;
    var diff;
    if (this.config.dimension == 'vertical') {
      var diffHeight = parseFloat(item.preview.parentNode.parentNode.offsetHeight) - parseFloat(item.preview.offsetHeight);
      boundary = (parseFloat(item.preview.parentNode.parentNode.offsetHeight) + parseFloat(this._displayElem.offsetHeight) ) + diffHeight;
      var top = parseFloat(item.preview.parentNode.parentNode.style.top);  
      diff = boundary - top;
      pos = this.config.speedPixel; 
      if (rest) {
         pos = rest;
      } else if (diff <= this.config.speedPixel) {
         pos = diff;
         rest = pos;
      } 
      top += pos;
      item.preview.parentNode.parentNode.style.top = GalleryTools.getCssUnit(top);
      if (top >= boundary) {
        if (rest) {
          if (this.config.rotate != 'auto') {  
            this.rotationBreak = true;
          }
        } 
        this.activeItemList.pop();
        this._itemListElem.removeChild(item.preview.parentNode.parentNode);
        var newTop = parseFloat(parseFloat(lastItem.preview.parentNode.parentNode.style.top) - parseFloat(lastItem.preview.parentNode.parentNode.offsetHeight));
        var nextItem;
        if (lastItem.listPosition == 0) {
          nextItem = this.itemList[this.itemList.length-1];
        } else {
          nextItem = this.itemList[lastItem.listPosition -1];
        }
        if (! nextItem.preview || ! nextItem.preview.parentNode || ! nextItem.preview.parentNode.parentNode) {
          this._drawItem(nextItem);
        }
        nextItem.preview.parentNode.parentNode.style.top = GalleryTools.getCssUnit(newTop);
        this._itemListElem.appendChild(nextItem.preview.parentNode.parentNode);
        this.activeItemList.unshift(nextItem);
        i++;
      }
    } else {
      var diffWidth = -1;
      boundary = ( parseFloat(item.preview.parentNode.parentNode.offsetWidth) + parseFloat(this._displayElem.offsetWidth) ) + diffWidth;
      var left = parseFloat(item.preview.parentNode.parentNode.style.left);      
      diff = boundary - left;
      pos = this.config.speedPixel; 
      if (rest) {
         pos = rest;
      } else if (diff <= this.config.speedPixel) {
         pos = diff;
         rest = pos;
      } 
      left += pos;
      item.preview.parentNode.parentNode.style.left = GalleryTools.getCssUnit(left);
      if (left >= boundary) {
        if (rest) {
          if (this.config.rotate != 'auto') {  
            this.rotationBreak = true;
          }
        } 
        this.activeItemList.pop();
        this._itemListElem.removeChild(item.preview.parentNode.parentNode);
        var newLeft = parseFloat(parseFloat(lastItem.preview.parentNode.parentNode.style.left) - parseFloat(lastItem.preview.parentNode.parentNode.offsetWidth));
        var nextItem;
        if (lastItem.listPosition == 0) {
          nextItem = this.itemList[this.itemList.length-1];
        } else {
          nextItem = this.itemList[lastItem.listPosition -1];
        }
        if (! nextItem.preview || ! nextItem.preview.parentNode || ! nextItem.preview.parentNode.parentNode) {
          this._drawItem(nextItem);
        }
        nextItem.preview.parentNode.parentNode.style.left = GalleryTools.getCssUnit(newLeft );
        this._itemListElem.appendChild(nextItem.preview.parentNode.parentNode);
        this.activeItemList.unshift(nextItem);
        i++;
      }
    }
  }
  var func = new Function ('','Gallery.getInstance(\'' + id + '\')._type2_descending(undefined,'+ rest +');'); 
  this.timeout = window.setTimeout(func, this.config.speedTime);
} 


Gallery.prototype._type3_ascending = function (n, rest) {
  if (this.timeout) {
    window.clearTimeout(this.timeout);
  }
  if (this.rotationBreak == true) {
    return;
  }
  if (n == undefined) {
    n = 0;
  }
  if (rest == undefined) {
    rest = 0;
  }
  var id = this.id;
  this._itemListElem.innerHTML = '';
  for (var i=n; i<this.activeItemList.length; i++) {
    var item = this.activeItemList[i];
    var nextItem = this.itemList[item.listPosition + 3];
    if (! nextItem) {
      nextItem = this.itemList[(item.listPosition + 3) - this.itemList.length];
    }
    this.activeItemList.splice(i, 1, nextItem);
  }
  this.drawItemList();
} 


Gallery.prototype._type3_descending = function (n, rest) {
  if (this.timeout) {
    window.clearTimeout(this.timeout);
  }
  if (this.rotationBreak == true) {
    return;
  }
  if (n == undefined) {
    n = 0;
  }
  if (rest == undefined) {
    rest = 0;
  }
  var id = this.id;
  this._itemListElem.innerHTML = '';
  for (var i=this.activeItemList.length-1; i>=0; i--) {
    var item = this.activeItemList[i];
    var nextItem = this.itemList[item.listPosition - 3];
    if (! nextItem) {
      nextItem = this.itemList[(item.listPosition - 3) + this.itemList.length];
    }
    this.activeItemList.splice(i, 1, nextItem);
  }
  this.drawItemList();
} 


Gallery.prototype.itemOnmouseover = function (id) {
} 


Gallery.prototype.itemOnmouseout = function (id) {
} 


Gallery.prototype.itemOnclick = function (id) {
  this._showDetail(id);
} 


Gallery._increment = [];
Gallery._autoIdxPrefix = '_Gallery_';
Gallery._registerInstance = {};
Gallery._registerInstanceLength = [];


Gallery.getInstance = function(id) {
  if (arguments.length!=1) {
    focus();
    throw new Error('Gallery.getInstance: Falsche Anzahl von Argumenten!');
  }
  if (! (Gallery._registerInstance[id])){
    focus();
    throw new Error('Gallery.getInstance: Es ist keine Gallery.Instance mit id=' + id + ' registriert!');
  }
  return Gallery._registerInstance[id];
}


Gallery.createInstance = function(id) {
  if (!arguments.length) {
    id = Gallery._autoIdxPrefix + Gallery._increment.length;
    Gallery._increment.push(1);
  }
  if (! (Gallery._registerInstance[id])){
    Gallery._registerInstance[id] = new Gallery(id);
    Gallery._registerInstanceLength.push(id);
  } else {
    focus();
    throw new Error('Gallery.createInstance: ID schon vorhanden!');
  }
  var baseElem = document.getElementById(id);
  if (! baseElem) {
    focus();
    throw new Error('Gallery.createInstance: Es existiert kein Basis-HTML-Element mit id = '+ id +'!');
  }
  return Gallery.getInstance(id);
}



function GalleryConfig(id) {
  this.id = undefined;
  this.type = 'type1'; // type1|type2|type3|...
  this.rotate = 'manual'; // manual|auto
  this.speedTime = 10; 
  this.speedPixel = 2; 
  this.direction = 'ascending'; // ascending|descending
  this.dimension = 'horizontal'; // horizontal|vertical
  this.activeItemLength = 3;
  
  this._setID(id);
}


GalleryConfig.prototype._setID = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryConfig->_setID: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('GalleryConfig->_setID: Argument str ist nicht vom Typ String!');
  }
  this.id = str;
} 


GalleryConfig.prototype.setActiveItemLength = function (n) {
  if (arguments.length!=1) {
    throw new Error("Gallery->setActiveItemLength: Falsche Anzahl von Argumenten!");
  }
  if (typeof n != "number") {
    throw new Error("Gallery->setActiveItemLength: Argument ist nicht vom Typ number!");
  }
  this.activeItemLength = n;
}  


GalleryConfig.prototype.setSpeedTime = function (n) {
  if (arguments.length!=1) {
    throw new Error("Gallery->setSpeedTime: Falsche Anzahl von Argumenten!");
  }
  if (typeof n != "number") {
    throw new Error("Gallery->setSpeedTime: Argument ist nicht vom Typ number!");
  }
  this.speedTime = n;
}  


GalleryConfig.prototype.setSpeedPixel = function (n) {
  if (arguments.length!=1) {
    throw new Error("Gallery->setSpeedPixel: Falsche Anzahl von Argumenten!");
  }
  if (typeof n != "number") {
    throw new Error("Gallery->setSpeedPixel: Argument ist nicht vom Typ number!");
  }
  this.speedPixel = n;
}  


GalleryConfig.prototype.setType = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryConfig->setType: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('GalleryConfig->setType: Argument str ist nicht vom Typ String!');
  }
  this.type = str;
}  


GalleryConfig.prototype.setRotate = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryConfig->setRotate: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('GalleryConfig->setRotate: Argument str ist nicht vom Typ String!');
  }
  this.rotate = str;
}  


GalleryConfig.prototype.setDirection = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryConfig->setDirection: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('GalleryConfig->setDirection: Argument str ist nicht vom Typ String!');
  }
  this.direction = str;
} 


GalleryConfig.prototype.setDimension = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryConfig->setDimension: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('GalleryConfig->setDimension: Argument str ist nicht vom Typ String!');
  }
  this.dimension = str;
} 


GalleryConfig._increment = [];
GalleryConfig._autoIdxPrefix = '_GalleryConfig_';
GalleryConfig._registerInstance = {};
GalleryConfig._registerInstanceLength = [];


GalleryConfig.getInstance = function(id) {
  if (arguments.length!=1) {
    focus();
    throw new Error('GalleryConfig.getInstance: Falsche Anzahl von Argumenten!');
  }
  if (! (GalleryConfig._registerInstance[id])){
    focus();
    throw new Error('GalleryConfig.getInstance: Es ist keine GalleryConfig.Instance mit id=' + id + ' registriert!');
  }
  return GalleryConfig._registerInstance[id];
}


GalleryConfig.createInstance = function(id) {
  if (!arguments.length) {
    id = GalleryConfig._autoIdxPrefix + GalleryConfig._increment.length;
    GalleryConfig._increment.push(1);
  }
  if (! (GalleryConfig._registerInstance[id])){
    GalleryConfig._registerInstance[id] = new GalleryConfig(id);
    GalleryConfig._registerInstanceLength.push(id);
  } else {
    focus();
    throw new Error('GalleryConfig.createInstance: ID schon vorhanden!');
  }
  return GalleryConfig.getInstance(id);
}




function GalleryItem(id) {
  this.id = undefined;
  this.srcPreview = undefined;
  this.srcStandard = undefined;
  this.preview = undefined;
  this.standard = undefined;
  this.title = undefined;
  this.subtitle = undefined;
  this.description = undefined;
  this.linkURL = undefined;
  this.listPosition = undefined;
  
  this._setID(id);
}


GalleryItem.prototype._setID = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryItem->_setID: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('GalleryItem->_setID: Argument str ist nicht vom Typ String!');
  }
  this.id = str;
} 


GalleryItem.prototype._setPreview = function () {
  var img = document.createElement('img');
  img.src = this.srcPreview;
  this.preview = img;
} 


GalleryItem.prototype._setStandard = function () {
  var img = document.createElement('img');
  img.src = this.srcStandard;
  this.standard = img;
} 


GalleryItem.prototype._setListPosition = function (n) {
  if (arguments.length!=1) {
    throw new Error("Gallery->_setListPosition: Falsche Anzahl von Argumenten!");
  }
  if (typeof n != "number") {
    throw new Error("Gallery->_setListPosition: Argument ist nicht vom Typ number!");
  }
  this.listPosition = n;
} 


GalleryItem.prototype.setSrcPreview = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryItem->setSrcPreview: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('GalleryItem->setSrcPreview: Argument str ist nicht vom Typ String!');
  }
  if (! GalleryTools.validateImgURL(str)) {
    alert('String : ' + str + ' ist keine valide Bild-URL.');
    return;
  }
  this.srcPreview = str;
  this._setPreview();
} 


GalleryItem.prototype.setSrcStandard = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryItem->setSrcStandard: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('GalleryItem->setSrcStandard: Argument str ist nicht vom Typ String!');
  }
  if (! GalleryTools.validateImgURL(str)) {
    alert('String : ' + str + ' ist keine valide Bild-URL.');
    return;
  }
  this.srcStandard = str;
  this._setStandard();
} 


GalleryItem.prototype.setTitle = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryItem->setTitle: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('GalleryItem->setTitle: Argument str ist nicht vom Typ String!');
  }
  this.title = str;
} 


GalleryItem.prototype.setSubtitle = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryItem->setSubtitle: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('GalleryItem->setSubtitle: Argument str ist nicht vom Typ String!');
  }
  this.subtitle = str;
} 


GalleryItem.prototype.setDescription = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryItem->setDescription: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('GalleryItem->setDescription: Argument str ist nicht vom Typ String!');
  }
  this.description = str;
} 


GalleryItem.prototype.setLinkURL = function (str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryItem->setLinkURL: Falsche Anzahl von Argumenten!');
  }
  if (typeof str != 'string') {
    focus();
    throw new Error('GalleryItem->setLinkURL: Argument str ist nicht vom Typ String!');
  }
  if (! GalleryTools.validateURL()) {
    alert('String : ' + str + ' ist keine valide URL.');
    return;
  }
  this.linkURL = str;
} 


GalleryItem._increment = [];
GalleryItem._autoIdxPrefix = '_GalleryItem_';
GalleryItem._registerInstance = {};
GalleryItem._registerInstanceLength = [];


GalleryItem.getInstance = function(id) {
  if (arguments.length!=1) {
    focus();
    throw new Error('GalleryItem.getInstance: Falsche Anzahl von Argumenten!');
  }
  if (! (GalleryItem._registerInstance[id])){
    focus();
    throw new Error('GalleryItem.getInstance: Es ist keine GalleryItem.Instance mit id=' + id + ' registriert!');
  }
  return GalleryItem._registerInstance[id];
}


GalleryItem.createInstance = function(id) {
  if (!arguments.length) {
    id = GalleryItem._autoIdxPrefix + GalleryItem._increment.length;
    GalleryItem._increment.push(1);
  }
  if (! (GalleryItem._registerInstance[id])){
    GalleryItem._registerInstance[id] = new GalleryItem(id);
    GalleryItem._registerInstanceLength.push(id);
  } else {
    focus();
    throw new Error('GalleryItem.createInstance: ID schon vorhanden!');
  }
  return GalleryItem.getInstance(id);
}





function GalleryTools(id) {
}


GalleryTools.validateURL = function(str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryTools.validateURL: Falsche Anzahl von Argumenten!');
  }
  var reg = new RegExp('^(http:\/\/|https:\/\/|ftp:\/\/|\/)');
  if (reg.exec(str)) {
    return true;
  }
  return false;
}


GalleryTools.getCssUnit = function(n) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryTools.validateURL: Falsche Anzahl von Argumenten!');
  }
  var n = parseFloat(n);
  if (typeof n != "number") {
    return "";
  }
  if (n > 0) {
    n += 'px';
  } else {
    n += 'px';
  }
  return n;
}


GalleryTools.validateImgURL = function(str) {
  if (arguments.length != 1) {
    focus();
    throw new Error('GalleryTools.validateImgURL: Falsche Anzahl von Argumenten!');
  }
  var reg = new RegExp('(\.jpg|\.JPG|\.jpeg|\.JPEG|\.gif|\.GIF|\.png|\.PNG)$');
  if (reg.exec(str)) {
    return true;
  }
  return false;
}


GalleryTools.addEvent = function(oneEvent, obj, handler, bol, ieWindow){
  if (arguments.length < 3) {
    focus();
    throw new Error('GalleryTools.addEvent: Falsche Anzahl von Argumenten!');
  }
  if(window.addEventListener){
    obj.addEventListener(oneEvent, handler, bol);
  } else if(obj.attachEvent){
    var win = window;
    if (ieWindow) {
      win = ieWindow;
    }
    obj['e' + oneEvent + handler] = handler;
    obj[oneEvent + handler] = function() { obj['e' + oneEvent + handler] ( win.event ); win.event.cancelBubble = true;};
    obj.attachEvent('on' + oneEvent, obj[oneEvent + handler]);
  }
  return true;
}


GalleryTools.removeEvent = function(oneEvent, obj, handler, bol){
  if (arguments.length < 3) {
    focus();
    throw new Error('GalleryTools.removeEvent: Falsche Anzahl von Argumenten!');
  }
  if(window.removeEventListener){
    obj.removeEventListener(oneEvent, handler, bol);
  } else if(obj.detachEvent){
    obj.detachEvent( "on"+ oneEvent, obj[oneEvent + handler] );
    obj[oneEvent + handler] = undefined;
    obj["e" + oneEvent + handler] = undefined;
  }
  return true;
}



var undefined;

function Notepad(id) {
  this.id = undefined;
  this.noteList = [];
  this.lang = "de";
  this.noteListName = 'myNotepad';
  this.urlprefix = '';
  this._setId(id);
  this._loadNoteList();
}


Notepad.prototype._setId = function(str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Notepad->_setId: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Notepad->_setId: Argument str ist nicht vom Typ String!");
  }
  this.id = str;
}                              


Notepad.prototype._loadNoteList = function() {
  if (! (Tools && Tools.setCookieValue)) {
    focus();
    throw new Error("Notepad->loadNoteList: Bitte das Modul Tools laden!");
  }
  var name = this.noteListName;  
  var val = Tools.getCookieValue(name);
  if (! val.length) {
    return;
  }
  var arr = val.split(/\,/);
  var list = [];
  for (var i=0; i<arr.length; i++) {
    var peer = arr[i].split(/\:/);
    var item = NotepadItem.createInstance();
    item.setContent(peer[0]);   
    item.setSrcImg(peer[1]);  
    var d = peer[2];  
    if (! d) {
      d = Notepad._createSetDate();
    }
    item.setSetDate(d);
    list.push(item);
  }
  this.noteList = list;
  return true;
}                       


Notepad.prototype._noteListToDBString = function() {
  var str = '';
  for (var i=0; i<this.noteList.length; i++) {
    var item = this.noteList[i];
    var cont = item.content;
    var srcImg = item.srcImg;
    var setDate = item.setDate;
    str += cont + ':' + srcImg + ':' + setDate;
    if (i < this.noteList.length -1) {
     str += ',';
    }
  }
  return str;
}                      


Notepad.prototype._createSetDate = function() {
  var date = new Date();
  var y = date.getFullYear();
  var m = date.getMonth();
  m++;
  if (m < 10) {
    m = '0' + m;
  }
  var d = date.getDate();
  if (d < 10) {
    d = '0' + d;
  }
  var str = y + '' + m + '' + d;
  return str;
}                                 


Notepad.prototype._noteListHasValue = function(str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Notepad->_noteListHasValue: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Notepad->_noteListHasValue: Argument str ist nicht vom Typ String!");
  }
  for (var i=0; i<this.noteList.length; i++) {
    var item = this.noteList[i];
    if (str != item.content) {
      continue;
    }
    return true;
  }
  return false;
}                   


Notepad.prototype.setLang = function(str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Notepad->setLang: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Notepad->setLang: Argument str ist nicht vom Typ String!");
  }
  this.lang = str;
}                                  


Notepad.prototype.setURLPrefix = function(str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Notepad->setURLPrefix: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Notepad->setURLPrefix: Argument str ist nicht vom Typ String!");
  }
  this.urlprefix = str;
}                             


Notepad.prototype.addNoteList = function(str, srcImg) {
  if (arguments.length < 1) {
    focus();
    throw new Error("Notepad->addNoteList: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Notepad->addNoteList: Argument str ist nicht vom Typ String!");
  }
  if ((srcImg && srcImg.length) && typeof srcImg != "string") {
    focus();
    throw new Error("Notepad->addNoteList: Argument srcImg ist nicht vom Typ String!");
  }
  if (! str.length) {
    return;
  }
  if (this._noteListHasValue(str)) {
    Notepad.displayAlert('list_has_value');
    return;
  }
  var item = NotepadItem.createInstance();
  item.setContent(str);        
  if (srcImg && srcImg.length) {
    item.setSrcImg(srcImg);            
  }                                  
  item.setSetDate(Notepad._createSetDate());
  this.noteList.push(item);
  this.saveNoteList();
  this.setPreviewPages();
  Notepad.displayAlert('has_added');
}                                   


Notepad.prototype.deleteNoteList = function(str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("Notepad->deleteNoteList: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("Notepad->deleteNoteList: Argument str ist nicht vom Typ String!");
  }
  if (! str.length) {
    return;
  }
  var idx;
  for (var i=0; i<this.noteList.length; i++) {
    var item = this.noteList[i];    
    if (item.content  != str) {
      continue;
    }    
    var del = this.noteList.splice(i, (i+1));
    delete del;
    break;
  }
  this.saveNoteList();
  this.setPreviewPages();
  this.showNotelist();
}              


Notepad.prototype.deleteAllItem = function() {
  while (this.noteList.length) {
    var item = this.noteList.shift();
    delete item;
  }  
  this.saveNoteList();
  this.setPreviewPages();
}                                 


Notepad.prototype.showNotelist = function() {
  if (! this.urlprefix) {
    return;
  }
  var url = this.urlprefix;
  url += '&_status=neu';
  var templ = 'notepad';
  if (this.lang == 'en') {
    templ = 'notepad_en';
  }
  if (this.lang == 'fr') {
    templ = 'notepad_fr';
  }
  if (this.lang == 'it') {
    templ = 'notepad_it';
  }
  url += '&_sprache=' + templ;
  url += '&_sortierung=titel_asc';
  if (! this.noteList.length) {
    url += '&_status=neu';
  }
  /*
  for (var i=0;i<this.noteList.length;i++) {
    var item = this.noteList[i];
    url += '&idartikel=';
    url += item.content;
  }
  */
  window.location = url;
}                             


Notepad.prototype.setPreviewPages = function() {
  var elem = document.getElementById('__NOTELIST_PREVIEW_PAGES__');
  if (! elem) {
    return;
  }
  var post_fix = 'Werbeobjekte';
  if (this.lang != 'de') {
    post_fix = 'objects';
  }
  var id = this.id;
  var html = '<a href="javascript:void(0);" onclick="Notepad.getInstance(\''+ id +'\').showNotelist();" class="notepad-link"><b>Merkzettel</b> | ' + this.noteList.length + ' ' + post_fix + '</a><br />';
  elem.innerHTML = html;
}              


Notepad.prototype.saveNoteList = function() {
  if (! (Tools && Tools.setCookieValue)) {
    focus();
    throw new Error("Notepad->saveNoteList: Bitte das Modul Tools laden!");
  }
  var name = this.noteListName;  
  var val = this._noteListToDBString(); 
  var date = new Date();
  var days365 = (1000 * 60 * 60 * 24 * 365);
  date = new Date(new Date().setTime(date.getTime() + days365));
  Tools.setCookieValue(val, name, date);
} 


Notepad._increment = [];
Notepad._registerInstance = {};
Notepad._registerInstanceLength = [];         


Notepad._createSetDate = function() {
  var date = new Date();
  var y = date.getFullYear();
  var m = date.getMonth();
  m++;
  if (m < 10) {
    m = '0' + m;
  }
  var d = date.getDate();
  if (d < 10) {
    d = '0' + d;
  }
  var str = y + '' + m + '' + d;
  return str;
}     

        
Notepad.getLangTranslation = function(str, lang){
  if (arguments.length < 1) {
    focus();
    throw new Error("Notepad->getLangTranslation: Falsche Anzahl von Argumenten!");
  }  
  if (! lang) {
    lang = 'de';
  }
  var item = {};
  item['en'] = {};
  item['fr'] = {};
  item['de'] = {};
  item['it'] = {};                       
  
  item['en']['list_has_value'] = 'You added this article to your Notelist before.';
  item['fr']['list_has_value'] = 'You added this article to your Notelist before.';    
  item['de']['list_has_value'] = 'Dieses Werbeobjekt befindet sich bereits auf Ihrem Merkzettel.';
  item['it']['list_has_value'] = 'You added this article to your Notelist before.';                          
  
  item['en']['has_added'] = 'The article has been added to your Notelist.';
  item['fr']['has_added'] = 'The article has been added to your Notelist.';    
  item['de']['has_added'] = 'Dieses Werbeobjekt wurde Ihrem Merkzettel hinzugefügt.';
  item['it']['has_added'] = 'The article has been added to your Notelist.';                        
  
  item['en']['system_alert_button'] = 'Close';
  item['fr']['system_alert_button'] = 'Close';    
  item['de']['system_alert_button'] = 'Hinweis schließen';
  item['it']['system_alert_button'] = 'Close';                                       
  
  item['en']['item_deleted'] = 'The Article has been deleted from your Notelist';
  item['fr']['item_deleted'] = 'The Article has been deleted from your Notelist';    
  item['de']['item_deleted'] = 'Der Artikel wurde von Ihrem Merkzettel entfernt.';
  item['it']['item_deleted'] = 'The Article has been deleted from your Notelist';   
  
  if (! (item[lang] && item[lang][str])) {
    return '';
  }
  return item[lang][str];
}   


Notepad.displayAlert = function(err){
  var err_str = 'Die Aktion wurd durchgeführt ';
  var txt = Notepad.getLangTranslation(err, this.lang);
  if (txt.length) {
    err_str = txt;
  } else if (err.length) {
    err_str = err;
  }
  var elem = document.getElementById('__GLOBAL_SYSTEM_ALERT_ELEMENT__');
  if (! elem) {
    elem = document.createElement('div');
    elem.setAttribute('id','__GLOBAL_SYSTEM_ALERT_ELEMENT__');
    if (IE6 || IE7) {
      elem.setAttribute('className','gloabl-system-alert');
    } else {
      elem.setAttribute('class','gloabl-system-alert');
    }
    elem.setAttribute('style','visibility: hidden;');
    var body = document.getElementsByTagName('body')[0];
    body.appendChild(elem);
  }
  elem.style.display = 'block';
  var html = '<div class="gloabl-system-alert-inner">';
  html += '<div class="gloabl-system-alert-inner-text">';
  html += err_str;
  html += '<div class="float-aufheben"><br /></div>';
  html += '</div>';
  html += '<div class="gloabl-system-alert-inner-button">';
  html += '<a href="javascript: void(0);" onclick="Notepad.hideAlert();">';
  html += Notepad.getLangTranslation('system_alert_button', this.lang);
  html += '</a>';
  html += '<div class="float-aufheben"><br /></div>';
  html += '</div>';
  html += '<div class="float-aufheben"><br /></div>';
  html += '</div>';
  elem.innerHTML = html;  
  var top = 0;
  top = Tools.getScreenHeight();
  top = top - Tools.getElementHeight(elem);
  top = top/2;
  top += Tools.getScrollPositionTop();
  top - 100;
  if (navigator.userAgent.toString().match(/Opera/)) {
      top -= 150;
  }
  elem.style.top = top + 'px';
  var body = document.getElementsByTagName('body')[0];
  var left = parseFloat(Tools.getElementWidth(body) / 2);
  var curtain = document.getElementById('GALLERY_DETAIL_CURTAIN');
  if (curtain && curtain.offsetWidth) {
    left = parseFloat(Tools.getElementWidth(curtain)/2);
  }
  left -= parseFloat(Tools.getElementWidth(elem)/2);
  elem.style.left = left + 'px';
  var h = Tools.getElementHeight(elem);
  var w = Tools.getElementWidth(elem);
  elem.style.width = '1px';
  elem.style.height = '1px';
  elem.style.visibility = 'visible';
  Notepad.slideAlert(elem , w, h);
}        


Notepad.slideAlert = function(elem, w, h){
  var fast = 0;
  var diff_h = 20;
  var diff_w = 20;
  if (Notepad.timeout) {
    window.clearTimeout(Notepad.timeout);
  }
  if (! elem) {
    return;
  }
  var eH = Tools.getElementHeight(elem);
  var eW = Tools.getElementWidth(elem);
  if (eH >= h && eW >= w) {
    return;
  }   
  if (eH < h) {
    if (h - eH < diff_h) {
      diff_h = parseFloat(h - eH);
    }
    elem.style.height = parseFloat(parseFloat(elem.style.height) + diff_h) + 'px';
  }      
  if (eW < w) {
    if (w - eW < diff_w) {
      diff_w = parseFloat(w - eW);
    }
    elem.style.width = parseFloat(parseFloat(elem.style.width) + diff_w) + 'px';
  }
  var func = function () {
    Notepad.slideAlert(elem, w, h);
  }
  Notepad.timeout = window.setTimeout(func, fast);
}  


Notepad.hideAlert = function(){
  var elem = document.getElementById('__GLOBAL_SYSTEM_ALERT_ELEMENT__');
  if (! elem) {
    return;
  }
  elem.style.display = 'none';
}        


Notepad.getSetDate = function(str) {  
  var date = '';
  var item = NotepadItem.getInstanceByContent(str);
  if (item) {
    date = item.setDate;
    date = date.substring(6,8) + '.' +date.substring(4,6)+ '.' + date.substring(0,4);
  }
  return date; 
}

  
Notepad.getInstance = function(id) {
  if (arguments.length!=1) {
    throw new Error("Notepad.getInstance: Falsche Anzahl von Argumenten!");
  }
  if (! (Notepad._registerInstance[id])){
    focus();
    throw new Error("Es ist keine Notepad.Instance mit id=" + id + " registriert!");
  }
  return Notepad._registerInstance[id];
}


Notepad.createInstance = function(id) {
  if (!arguments.length) {
    id = 'Notepad' + Notepad._increment.length;
    Notepad._increment.push(1);
  }
  if (! (Notepad._registerInstance[id])){
    Notepad._registerInstance[id] = new Notepad(id);
    Notepad._registerInstanceLength.push(id);
  } else {
    focus();
    throw new Error("Notepad.createInstance: id schon vorhanden!");
  }
  return Notepad.getInstance(id);
}


function NotepadItem(id) {
  this.id = undefined;
  this.content = '';
  this.srcImg = '';
  this.setDate = '';
  this._setId(id);
}


NotepadItem.prototype._setId = function(str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("NotepadItem->_setId: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("NotepadItem->_setId: Argument str ist nicht vom Typ String!");
  }
  this.id = str;
}             


NotepadItem.prototype.setContent = function(str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("NotepadItem->setContent: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("NotepadItem->setContent: Argument str ist nicht vom Typ String!");
  }
  this.content = str;
}                     


NotepadItem.prototype.setSrcImg = function(str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("NotepadItem->setSrcImg: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("NotepadItem->setSrcImg: Argument str ist nicht vom Typ String!");
  }
  this.srcImg = str;
}                


NotepadItem.prototype.setSetDate = function(str) {
  if (arguments.length != 1) {
    focus();
    throw new Error("NotepadItem->setSetDate: Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    focus();
    throw new Error("NotepadItem->setSetDate: Argument str ist nicht vom Typ String!");
  }
  this.setDate = str;
}              


NotepadItem._increment = [];
NotepadItem._registerInstance = {};
NotepadItem._registerInstanceLength = [];  


NotepadItem.getInstanceByContent = function(str) {
  if (arguments.length!=1) {
    throw new Error("NotepadItem.getInstanceByContent: Falsche Anzahl von Argumenten!");
  }    
  for (var i in NotepadItem._registerInstance) {
    if (NotepadItem._registerInstance[i].content != str) {
      continue;
    }
    return NotepadItem._registerInstance[i];
  }
  return undefined;
}  

  
NotepadItem.getInstance = function(id) {
  if (arguments.length!=1) {
    throw new Error("NotepadItem.Falsche Anzahl von Argumenten!");
  }
  if (! (NotepadItem._registerInstance[id])){
    focus();
    throw new Error("Es ist keine NotepadItem.Instance mit id=" + id + " registriert!");
  }
  return NotepadItem._registerInstance[id];
}


NotepadItem.createInstance = function(id) {
  if (!arguments.length) {
    id = 'Notepad' + NotepadItem._increment.length;
    NotepadItem._increment.push(1);
  }
  if (! (NotepadItem._registerInstance[id])){
    NotepadItem._registerInstance[id] = new NotepadItem(id);
    NotepadItem._registerInstanceLength.push(id);
  } else {
    focus();
    throw new Error("NotepadItem.createInstance: id schon vorhanden!");
  }
  return NotepadItem.getInstance(id);
}

