
  addEvent(window, "load", globalInit);

  // indicates whether tooltip display will be suppressed
  var suppressTips = Number(getCookie(location.pathname + "/suppressTips"));
  suppressTips = (suppressTips == NaN) ? 0 : suppressTips;

  // categories that require specifying a cuisine (restaurant, bistro, etc)
  var catsWithCuisines = new Array('10', '11', '12', '13', '16', '17', '21', '90');
  
  // holds the current mouse pointer position
  var mouseX;
  var mouseY;
  
  // holds positional information from the geolocation object
  var glLat = 0;
  var glLong = 0;  
  var glAcc = 0;
  var glDone = 0;
  //
  var waitForGlLoopCounter = 0; 
  
  // ppk browser detection script
  var BrowserDetect = {
  	init: function () {
  		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
  		this.version = this.searchVersion(navigator.userAgent)
  			|| this.searchVersion(navigator.appVersion)
  			|| "an unknown version";
  		this.OS = this.searchString(this.dataOS) || "an unknown OS";
  	},
  	searchString: function (data) {
  		for (var i=0;i<data.length;i++)	{
  			var dataString = data[i].string;
  			var dataProp = data[i].prop;
  			this.versionSearchString = data[i].versionSearch || data[i].identity;
  			if (dataString) {
  				if (dataString.indexOf(data[i].subString) != -1)
  					return data[i].identity;
  			}
  			else if (dataProp)
  				return data[i].identity;
  		}
  	},
  	searchVersion: function (dataString) {
  		var index = dataString.indexOf(this.versionSearchString);
  		if (index == -1) return;
  		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
  	},
  	dataBrowser: [
  		{
  			string: navigator.userAgent,
  			subString: "Chrome",
  			identity: "Chrome"
  		},
  		{ 	string: navigator.userAgent,
  			subString: "OmniWeb",
  			versionSearch: "OmniWeb/",
  			identity: "OmniWeb"
  		},
  		{
  			string: navigator.vendor,
  			subString: "Apple",
  			identity: "Safari",
  			versionSearch: "Version"
  		},
  		{
  			prop: window.opera,
  			identity: "Opera"
  		},
  		{
  			string: navigator.vendor,
  			subString: "iCab",
  			identity: "iCab"
  		},
  		{
  			string: navigator.vendor,
  			subString: "KDE",
  			identity: "Konqueror"
  		},
  		{
  			string: navigator.userAgent,
  			subString: "Firefox",
  			identity: "Firefox"
  		},
  		{
  			string: navigator.vendor,
  			subString: "Camino",
  			identity: "Camino"
  		},
  		{		// for newer Netscapes (6+)
  			string: navigator.userAgent,
  			subString: "Netscape",
  			identity: "Netscape"
  		},
  		{
  			string: navigator.userAgent,
  			subString: "MSIE",
  			identity: "Explorer",
  			versionSearch: "MSIE"
  		},
  		{
  			string: navigator.userAgent,
  			subString: "Gecko",
  			identity: "Mozilla",
  			versionSearch: "rv"
  		},
  		{ 		// for older Netscapes (4-)
  			string: navigator.userAgent,
  			subString: "Mozilla",
  			identity: "Netscape",
  			versionSearch: "Mozilla"
  		}
  	],
  	dataOS : [
  		{
  			string: navigator.platform,
  			subString: "Win",
  			identity: "Windows"
  		},
  		{
  			string: navigator.platform,
  			subString: "Mac",
  			identity: "Mac"
  		},
  		{
  			   string: navigator.userAgent,
  			   subString: "iPhone",
  			   identity: "iPhone/iPod"
  	    },
  		{
  			string: navigator.platform,
  			subString: "Linux",
  			identity: "Linux"
  		}
  	]

  };
  BrowserDetect.init();
  // check for ie6
  if (BrowserDetect.browser == "Explorer") {
    if (BrowserDetect.version <=6)  {
      document.location = "/ie6";
    }
  }


  function $$$(id) {
    return document.getElementById(id);
  } 
  
  function globalInit() {

    // set rollOverHandlers
    addEvent($$$("logo"), "click", function() {
      document.location = "/";
    });
    addBottomDiv();
    setRollOverHandlersMainMenu();
    setRollOverHandlersBrownBox();
    setRollOverHandlersLinks();
    setRollOverHandlersButtons();
    animateRestaurantNews();
    locationDetect();
  }
  
  function locationDetect() {

    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
        glLat = position.coords.latitude;
        glLong = position.coords.longitude;
        glAcc = position.coords.accuracy;
        glDone = 1;
      });
    }
  }

  function showGeolocationSearchLink() {
    
    if (glDone) { 
      if ((glAcc <= 25000) && (glLat > 0) && (glLong > 0)) {
        
        rgc = new GReverseGeocoder(0);
        
        var rad = (glAcc < 1000) ? 1 : 5;
        
        GEvent.addListener(rgc, "load", function(placemark) {
          var position = placemark.address.replace(", Germany","");
          var href = "/restaurant_map.php?radius=" + rad + "&lat=" + glLat 
            + "&long=" + glLong + "&position=" + position + "&new_query=1";
          insertGeolocationSearchLink(href);  
        });          
        GEvent.addListener(rgc, "error", function(placemark) {
          var position = latLng.lat().toFixed(5) + ", " + latLng.lng().toFixed(5);
          var href = "/restaurant_map.php?radius=" + rad + "&lat=" + glLat 
            + "&long=" + glLong + "&position=" + position + "&new_query=1";
          insertGeolocationSearchLink(href);  
        });
        rgc.reverseGeocode(new GLatLng(glLat, glLong));
        return false;
      }     
    } else {
      if (waitForGlLoopCounter++ < 60) {
        window.setTimeout("showGeolocationSearchLink()", 1000);
      }
    }     
  }

  function insertGeolocationSearchLink(href) {

    var div = document.createElement("div");
    div.id = "gl_link";
    var a = document.createElement("a");
    a.href = href;
    a.className = "arrow";  
    var linkText = document.createTextNode("Hier geht's direkt zu Restaurants in Ihrer Umgebung!");
    a.appendChild(linkText);
    div.appendChild(a);
    var cm = $$$("cm");
    if (cm) {
      cm.appendChild(div);
    }    
  }
  
  function addBottomDiv() {

    var div = document.createElement("div");
    div.id = "pb";
    if ($$$("p").nextSibling) {
      document.body.insertBefore(div, $$$("p").nextSibling);
    } else {
      document.body.appendChild(div);
    }
  }

  function setCookie(name, value, seconds) {

    if (typeof(seconds) != 'undefined') {
      var date = new Date();
      date.setTime(date.getTime() + (seconds*1000));
      var expires = "; expires=" + date.toGMTString();
    }
    else {
      var expires = "";
    }

    document.cookie = name+"="+value+expires+"; path=/";
  }

  function getCookie(name) {

    if (document.cookie) {
      name = name + "=";
      var carray = document.cookie.split(';');

      for(var i=0;i < carray.length;i++) {
        var c = carray[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
      }
    }
  }

  function deleteCookie(name) {
    setCookie(name, "", -1);
  }

  function rollOver(obj, state) {

    if (state) {
      obj.setAttribute("orig_bg_color", obj.style.backgroundColor);
      obj.setAttribute("orig_fg_color", obj.style.color);
      obj.setAttribute("rolled_over", true);
      obj.style.backgroundColor = "#965A0A";
      obj.style.color = "#FFFFFF";
    } else {
      obj.rolledOver = false;
      obj.style.backgroundColor = obj.getAttribute("orig_bg_color");
      obj.style.color = obj.getAttribute("orig_fg_color");
    }
  }

  function rollOverCalendar(obj, state) {

    if (state) {

      obj.origBgColor = obj.style.backgroundColor;
      obj.origFgColor = obj.style.color;
      obj.rolledOver = true;
      obj.style.backgroundColor = "#965A0A";
      obj.style.color = "#FFFFFF";

      for (i=0; i < obj.childNodes.length; i++) {
        subObj = obj.childNodes[i];
        subObj.origBgColor = subObj.style.backgroundColor;
        subObj.origFgColor = subObj.style.color;
        subObj.rolledOver = true;
        subObj.style.backgroundColor = "#965A0A";
        subObj.style.color = "#FFFFFF";
      }

    } else {

      obj.rolledOver = false;
      obj.style.backgroundColor = obj.origBgColor;
      obj.style.color = obj.origFgColor;

      for (i=0; i < obj.childNodes.length; i++) {
        subObj = obj.childNodes[i];
        subObj.rolledOver = false;
        subObj.style.backgroundColor = subObj.origBgColor;
        subObj.style.color = subObj.origFgColor;
      }
    }
  }
  
  function rollOverMainMenuItem(obj, state) {
    
    if (obj) {
      if (state) {
        obj.className = obj.className.replace(/item\b/, "item_r");
      } else {
        obj.className = obj.className.replace("item_r", "item");
      }
    }
  }

  function rollOverBrownBoxItem(obj, state) {

    if (obj) {
      if (state) {
        obj.className += " bb_rollover";
      } else {
        obj.className = obj.className.replace(" bb_rollover", "");
      }
    }
  }

  function rollOverLink(obj, state) {

    if (obj) {
      if (state) {
        obj.className += " active_link";
      } else {
        obj.className = obj.className.replace("active_link", "");
      }
    }
  }

  function setRollOverHandlersMainMenu() {

    var mm = document.getElementById("mm");
    if (mm) {
      var divs = mm.getElementsByTagName("div");
      var z = divs.length;

      for (var i=0; i<z; i++) {
        if ((divs[i].className == "mm1_item") || (divs[i].className == "mm2_item")) {
          addEvent(divs[i], "mouseover", function() {
            rollOverMainMenuItem(this, true);
          });
          addEvent(divs[i], "mouseout", function() {
            rollOverMainMenuItem(this, false);
          });
        }
      }
    } else {
      // alert("mm not loaded");
    }
  }

  function setRollOverHandlersButtons() {

    var img1 = new Image;
    img1.src = "/images/controls/button_l_hover.png";
    var img2 = new Image;
    img2.src = "/images/controls/button_r_hover.png";

    var btn = $$$("btn_qs_search");
    if (btn) setRollOverHandlerButton(btn);
    var btn = $$$("btn_search");
    if (btn) setRollOverHandlerButton(btn);
    var btn = $$$("btn_search1");
    if (btn) setRollOverHandlerButton(btn);
    var btn = $$$("btn_search2");
    if (btn) setRollOverHandlerButton(btn);
    var btn = $$$("btn_submit");
    if (btn) setRollOverHandlerButton(btn);
    var btn = $$$("btn_update");
    if (btn) setRollOverHandlerButton(btn);
    var btn = $$$("btn_cancel");
    if (btn) setRollOverHandlerButton(btn);
  }

  function setRollOverHandlerButton(btn) {
    var left = btn;
    var right = left.getElementsByTagName("div")[0];
    left.setAttribute("orig_class", left.className);
    right.setAttribute("orig_class", right.className);
    addEvent(btn, "mouseover", function() {
      var left = this
      var right = left.getElementsByTagName("div")[0];
      left.className = left.getAttribute("orig_class") + " blhover";
      right.className = right.getAttribute("orig_class") + " brhover";
    });
    addEvent(btn, "mouseout", function() {
      var left = this;
      var right = left.getElementsByTagName("div")[0];
      left.className = left.getAttribute("orig_class");
      right.className = right.getAttribute("orig_class");
    });
  }

  function setRollOverHandlersBrownBox() {

    var cols = new Array($$$("cl"), $$$("cr"));
    for (var i=0; i<cols.length; i++) {
      if (cols[i]) {
        var divs = cols[i].getElementsByTagName("div");
        var z = divs.length;
  
        for (var j=0; j<z; j++) {
          var hasRollOver = (divs[j].className.substr(0,7) == "bb_item");
          hasRollOver = (hasRollOver && (divs[j].className.search("greyed_out") < 0));
          if (hasRollOver) {
            addEvent(divs[j], "mouseover", function() {
              rollOverBrownBoxItem(this, true);
            });
            addEvent(divs[j], "mouseout", function() {
              rollOverBrownBoxItem(this, false);
            });
          }
        }
      }
    }
  }
  
  function setRollOverHandlersLinks() {

    var c = document.getElementById("cm");
    c = (c) ? c : document.getElementById("cw");
    if (c) {
      var as = c.getElementsByTagName("a");
      var z = as.length;

      for (var i=0; i<z; i++) {
        addEvent(as[i], "mouseover", function() {
          rollOverLink(this, true);
        });
        addEvent(as[i], "mouseout", function() {
          rollOverLink(this, false);
        });
      }
    }
    var pf = document.getElementById("pf");
    if (pf) {
      var as = pf.getElementsByTagName("a");
      var z = as.length;

      for (var i=0; i<z; i++) {
        addEvent(as[i], "mouseover", function() {
          rollOverLink(this, true);
        });
        addEvent(as[i], "mouseout", function() {
          rollOverLink(this, false);
        });
      }
    }
  }

  function animateRestaurantNews() {

    var news = $$$("restaurant_news");
    if (news) {
      for (var i=4; i<20; i++) {
        var command = "$$$('restaurant_news').style.borderStyle = '"
          + ((i % 2 == 0) ? "solid" : "dashed") + "'";
        window.setTimeout(command, i*250);
      }
    }
  }
  
  function setPosOrangeText() {

    oDivBoxArea = document.getElementById("box_area");
    oDivHead = document.getElementById("orange_head");
    oDivContent = document.getElementById("orange_content");
    oDivFoot = document.getElementById("orange_foot");
    oDivText = document.getElementById("orange_text");
    oDivCaption = document.getElementById("orange_caption");

    oDivCaption.style.top = oDivHead.offsetTop + "px";
    oDivText.style.top = oDivContent.offsetTop + "px";
    oDivContent.style.height = oDivText.offsetHeight + "px";
    oDivBoxArea.style.visibility = "visible";
  }

  function setPosBrownText() {

    oDivBoxArea = document.getElementById("box_area");
    oDivHead = document.getElementById("brown_head");
    oDivContent = document.getElementById("brown_content");
    oDivFoot = document.getElementById("brown_foot");
    oDivText = document.getElementById("brown_text");
    oDivCaption = document.getElementById("brown_caption");
    oImgContent = document.getElementById("img_br_cont");

    oDivCaption.style.top = (12 + oDivHead.offsetTop) + "px";
    oDivText.style.top = oDivContent.offsetTop + "px";
    oDivContent.style.height = oDivText.offsetHeight + "px";
    oImgContent.height = oDivContent.offsetHeight;
    oDivBoxArea.style.visibility = "visible";
  }

  function setPosCalendarText() {

    oDivBoxArea = document.getElementById("right_column");
    oDivHead = document.getElementById("calendar_head");
    oDivContent = document.getElementById("calendar_content");
    oDivFoot = document.getElementById("calendar_foot");
    oDivText = document.getElementById("calendar_text");
    oDivCaption = document.getElementById("calendar_caption");
    oImgContent = document.getElementById("img_cal_cont");

    oDivCaption.style.top = (12 + oDivHead.offsetTop) + "px";
    oDivText.style.top = oDivContent.offsetTop + "px";
    oDivContent.style.height = oDivText.offsetHeight + "px";
    oImgContent.height = oDivContent.offsetHeight;
    oDivText.style.visibility = "visible";
  }

  function initTips() {
  
    var all = document.getElementsByTagName("*");
    var z = all.length;

    for (var i=0;i<z;i++) {
      var hint = all[i].getAttribute("hint");
      if (hint) {
        if (all[i].getAttribute("hint_type_input")) {
          addEvent(all[i], "focus", function() { showHint(this); });
          addEvent(all[i], "blur", function () { hideHint(this); });
        } else {
          addEvent(all[i], "mouseover", function() { showHint(this); });
          addEvent(all[i], "mouseout", function () { hideHint(this); });
        }
      }
    }
  }

  function initTipControl() {

    var divcl = $$$("cl");
    var divlm = $$$("left_menu");
    var divTipControl = document.createElement("div");
    var tbl = document.createElement("table");
    tbl.width = "100%";
    var tbody = document.createElement("tbody");
    var tr = document.createElement("tr");
    var tdImg = document.createElement("td");
    tdImg.width = "20%";
    var tdText = document.createElement("td");
    var img = document.createElement("img");
    img.src = "/images/controls/balloon.png";
    img.width = 16;
    img.height = 16;

    divTipControl.id = "tip_control";
    tdImg.id = "tip_control_icon";
    tdText.id = "tip_control_label";

    if (divlm && divlm.nextSibling) {
      divcl.insertBefore(divTipControl, divlm.nextSibling);
    } else {
      divcl.appendChild(divTipControl);
    }
    divTipControl.appendChild(tbl);
    tbl.appendChild(tbody);
    tbody.appendChild(tr);
    tr.appendChild(tdImg);
    tr.appendChild(tdText);
    tdImg.appendChild(img);

    addEvent(tdText, "click", toggleTipDisplay);
    addEvent(tdText, "mouseover", function() { this.style.cursor = "pointer"; });

    if (suppressTips) {
      text = document.createTextNode(lblShowTips);
      tdText.setAttribute("hint", hintShowTips);
    } else {
      text = document.createTextNode(lblHideTips);
      tdText.setAttribute("hint", hintHideTips);
    }

    tdText.setAttribute("force_hint", 1);
    tdText.appendChild(text);
  }

  function toggleTipDisplay() {

    var tdLabel = document.getElementById("tip_control_label");

    suppressTips = !suppressTips;

    if (suppressTips) {
      tdLabel.innerHTML = lblShowTips;
      tdLabel.setAttribute("hint", hintShowTips);
    } else {
      tdLabel.innerHTML = lblHideTips;
      tdLabel.setAttribute("hint", hintHideTips);
    }
    var cookieName = location.pathname + "/suppressTips";
    setCookie(cookieName, Number(suppressTips), 365*24*60*60);
  }

  function isNumeric(sText) {

    var validChars = "0123456789.,";
    var isNumber = true;
    var c;

    for (i = 0; i < sText.length && isNumber == true; i++) {

      c = sText.charAt(i);
      if (validChars.indexOf(c) == -1) {
        isNumber = false;
      }
    }

   return isNumber;
  }

  function isPosInt(str) {

    for(var position=0; position<str.length; position++){
      var chr = str.charAt(position)
      if  ((chr < "0") || (chr > "9")) {
        return false;
      }
    }
    return true;
  }

  function isDate(s) {

    s = s.replace(/[-,/]/g, ".");
    parts = s.split(".");

    if (parts.length < 3) {
      return false;
    }

    day = parts[0];
    month = parts[1];
    year = parts[2];

    if ((month < 1) || (month > 12)) {
      return false;
    }

    if ((month == 1) || (month == 3) || (month == 5) || (month == 7)
     || (month == 8) || (month == 10) || (month == 12)) {
      if (day > 31) {
          return false;
      }
    } else {
      if (month != 2) {
        if (day > 30) {
          return false;
        }
      } else {
        if (year % 4 != 0) {
          if (day > 28) {
              return false;
          }
        } else {
          if ((year % 100 == 0) && (year % 400 != 0)) {
            if (day > 28) {
              return false;
            }
          } else {
            if (day > 29) {
              return false;
            }
          }
        }
      }
    }

    return true;
  }

  // strict = false: allow 24:00
  function isTime(sTime, strict) {

    if (typeof strict == 'undefined' ) strict = true;

    parts = sTime.split(":");

    if ((parts.length < 2) || (parts.length > 3)) {
      return false;
    }

    if (strict) {
      if ((!isPosInt(parts[0])) || (parts[0] > 23)) {
        return false;
      }
    } else {
      if ((!isPosInt(parts[0])) || (parts[0] > 24)) {
        return false;
      }    
    }

    if (parts[1].length != 2) {
      return false;
    }
    
    if ((strict) || (Number(parts[0]) < 24)) {
      if ((!isPosInt(parts[1])) || (parts[1] > 59)) {
        return false;
      }
    } else {
      if (parts[1] != 0) {
        return false;
      }
    }

    if (parts.length == 3) {
      if ((!isPosInt(parts[2])) || (parts[2] > 59)) {
        return false;
      }
    }

    return true;
  }

  function isEMail(sAddr) {

    re = /^([a-z+-_]+)((\.[a-z+-_]+)*)(@)([a-z+-_]+\.)+([a-z]{2,6})$/i;
    if (sAddr.match(re)) {
      return true;
    } else {
      return false;
    }

  }
  
  function isChildOf(child, parent) {
  
    var p = child.parentNode;
    if (!p) return false;
    
    while ((p.nodeName != "BODY") && (p != parent)) {
      p = p.parentNode;
    } 
    if (p == parent) {
      return true;
    } else {
      return false;
    }
  }
  
  function hasElement(a, e) {
    for (var i=0; i<a.length; i++) {
      if (a[i] == e) {
        return true;
      }
    }
    return false;
  }
  
  function convertDateMysqlToEuropean(sDate) {

    if (sDate != "") {
      parts = sDate.split("-");
      return parts[2] + "." + parts[1] + "." + parts[0];
    } else {
      return "";
    }

  }

  function getOptionIndex(select, optValue) {

    for (i=0;i<select.length;i++) {
      if (select.options[i].value == optValue) {
        return i;
        break;
      }
    }
    return -1;
  }

  function selectOption(select, optValue, optText) {

    if (optText == "") {
      for (i=0;i<select.length;i++) {
        if (select.options[i].value == optValue) {
          select.selectedIndex = i;
          return i;
        }
      }
    } else {
      for (i=0;i<select.length;i++) {
        if (select.options[i].innerHTML == optText) {
          select.selectedIndex = i;
          return i;
        }
      }
    }
    return -1;
  }

  function addHttp(uri) {

    if (uri.length > 6) {
      if (uri.substr(0,7) != "http://") {
        uri = "http://" + uri;
      }
    }
    return uri;
  }

  function escapeEx(s) {

    s = escape(s);
    s = s.replace(/\+/, "%2B");

    return s;
  }

  function getX(oElement) {

    var iReturnValue = 0;
    while (oElement != null) {
      iReturnValue += oElement.offsetLeft;
      oElement = oElement.offsetParent;
    }
    return iReturnValue;
  }

  function getX2(oElement) {

    var iReturnValue = getX(oElement) + oElement.offsetWidth;
    return iReturnValue;
  }

  function getY(oElement) {

    var iReturnValue = 0;
    while (oElement != null) {
        iReturnValue += oElement.offsetTop;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
  }

  function getY2(oElement) {

    var iReturnValue = getY(oElement) + oElement.offsetHeight;
    return iReturnValue;
  }

  function getWindowHeight() {

    if(typeof(window.innerWidth) == 'number') {
      //Non-IE
      return window.innerHeight;
    } else if(document.documentElement &&
       (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
      //IE 6+ in 'standards compliant mode'
      return document.documentElement.clientHeight;
    } else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
      //IE 4 compatible
      return document.body.clientHeight;
    }

  }

  function getWindowWidth() {

    if(typeof(window.innerWidth) == 'number') {
      //Non-IE
      return window.innerWidth;
    } else if(document.documentElement &&
       (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
      //IE 6+ in 'standards compliant mode'
      return document.documentElement.clientWidth;
    } else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
      //IE 4 compatible
      return document.body.clientWidth;
    }

  }

  function trackMouseCoords(e) {

    e = (!e) ? window.event : e;
    if (e.pageX) {
      mouseX = e.pageX;
      mouseY = e.pageY;
    } else {
      mouseX = e.clientX + document.documentElement.scrollLeft;
      mouseY = e.clientY + document.documentElement.scrollTop;
    }
  }

  function isMouseOver(oElement) {

    var elX1 = getX(oElement);
    var elX2 = getX2(oElement);
    var elY1 = getY(oElement);
    var elY2 = getY2(oElement);

    if (((mouseX >= elX1) && (mouseX <= elX2)) && ((mouseY >= elY1) && (mouseY <= elY2))) {
      return true;
    } else {
      return false;
    }
  }

  function showHint(element) {
    if ((!suppressTips) || (element.getAttribute("force_hint"))) {
      if (element.getAttribute("hint")) {
        if (element.getAttribute("hint_type_input")) {
          var x = getX2(document.getElementById("cm")) + 7;
          Tip(element.getAttribute("hint"), FIX, [x, getY(element)], ABOVE, false, STICKY, true);
        } else {
          Tip(element.getAttribute("hint"));
        }
      }
    }
  }

  function hideHint(element) {
    UnTip();
  }

  function showPic(fileName, desc, width, height) {

    var w = ((Number(width) + 100) > screen.width) ? screen.width : Number(width) + 100;
    var h = ((Number(height) + 100) > screen.height) ? screen.height : Number(height) + 100;
    var l = (screen.width - w) / 2;
    var t = (screen.height - h) / 2;

    window.open("/client_pic.php?pic_name=" + fileName + "&pic_desc=" + encodeURIComponent(desc),
        "_blank", "location=0,menubar=0,toolbar=0,scrollbars=0,width=" + w + ",height=" + h
            + ",screenX=" + l + ",screenY=" + t
    );
  }

  function handleJsError(e) {
    throw(e);
  }

  function getNextSibling(e) {

    e = e.nextSibling;
    while (e && (e.nodeType != 1)) {
      e = e.nextSibling;
    }
    return e;
  }

  function trimStr(s) {

    return s.replace(/^\s+|\s+$/g,"");

  }

  function lPad(s, len, paddingChar) {

    var n = len - s.length;
    var prepend = "";

    for (var i=1; i<=n; i++) {
      prepend += paddingChar;
    }

    return prepend + s;
  }

  function extractNumber(s) {

    s = String(s);
    s = s.replace(",", ".");
    s = s.replace("€", "");
    s = s.replace(" ", "");
    return s;
  }

  function formatPrice(p) {

    p = Number(p);
    p = String(p.toFixed(2));
    p = p.replace(".", ",");
    return p;
  }

  function extractWords(s, quotes) {

    s = String(s);
    var words = s.match(/\b[\wäöüÄÖÜßéè]+\b/g);

    if (quotes) {
      var z = words.length;
      for (var i=0; i<z; i++) {
        words[i] = "'" + words[i] + "'";
      }
    }
    return words;
  }

  function seperateWords(s, delimiter, position) {

    s = String(s);
    var words = s.split(delimiter);
    return words[position];
  }
  
  function moveCursorToEnd(input) {

    if (input.createTextRange) {
      var r = input.createTextRange();
      r.moveStart('character', input.value.length);
      r.collapse();
      r.select();
    } else {
      input.selectionStart = input.value.length;
      input.selectionEnd = input.value.length;
    }
    if (input.type == "textarea") {
      input.scrollTop = input.scrollHeight;
    }
  }

  function watchTextareaLength(textArea, maxLength, callback) {
    
    if (textArea.value.length > maxLength) {
      callback();
    } 
  } 