function openBrWindow(theURL,winName,features) {
  winobj = window.open(theURL,winName,features);
  winobj.focus();
}

function winOpen(url, breite, hoehe) {
  // Errechnet Koordinaten, um das Popup zentriert zu platzieren
  links = (screen.width/2)-(breite/2);
  oben = (screen.height/2)-(hoehe/2);
  window.open(url,"soundpopup","height="+hoehe+",width="+breite+",status = no,toolbar = no,menubar = no,location = no,resizable = no,titlebar = no,scrollbars = yes,fullscreen = no,top ="+oben+",left ="+links);
}

function goHome() {
  self.location.href='/index.html';
}


function replacelogo() {
  try {
    var contentHeight = Position.cumulativeOffset($('boje'));
    var contentHeightY = parseInt(contentHeight[1]);
    var contentHeightX = parseInt(contentHeight[0]);
    if (contentHeightY > 0) {
        h = contentHeightY < 400 ? 400 : contentHeightY;
        $('main').style.backgroundPosition  = "650px " + parseInt(h - 555) +"px";
    }
  } catch (e){}
  if (!window.replacelogo_done) {
    // safari kriegt manchmal die höhen nicht richtig raus, weil er noch rendert,
    // daher nach ner sekunde einfach nochmal das ganze
    window.setTimeout('replacelogo()', 1000);
    window.replacelogo_done = true;
  }
}

/* <![CDATA[ */

function x_koord(event) {
  return event.pageX || (event.clientX +
   (document.documentElement.scrollLeft || document.body.scrollLeft));
}

function y_koord(event) {
    return event.pageY || (event.clientY +
      (document.documentElement.scrollTop || document.body.scrollTop));
}

/*  Your are permitted to reuse this code as long as the following copyright
    notice is not removed:
    The HTML tip handling code is copyright 1998 by insideDHTML.com, LLC. More information about this
    code can be found at Inside Dynamic HTML: HTTP://www.insideDHTML.com
*/

  // Support for all collection
  var allSupport = document.all!=null
  var x = 0;
  var y = 0;
  var _tbos = null;

  function tipBoxsetupEventObject(e) {
    // Map NS event object to IEs
    if (e==null) return // IE returns
    window.event = e
    window.event.fromElement = e.target;
    window.event.toElement = e.relatedTarget ? e.relatedTarget : e.target;
    window.event.srcElement = e.target;
    window.event.x = e.x
    window.event.y = e.y
    // Route the event to the original element
    // Necessary to make sure _tip is set.
    //window.event.srcElement.handleEvent(e); // Funktioniert nicht! Schrott, JS
  }

  function tipBoxcheckName(src) {
    // Look for tooltip in IE
    while (src && src._tip == null)
      src = src.parentElement
    return src
  }

  function tipBoxgetElement(elName) {
    // Get an element from its ID
    if (allSupport)
      return document.all[elName]
    else
      return document.getElementById(elName) // test! JS
  }

  function tipBoxwriteContents(el, tip) {
    // Replace the contents of the tooltip

    if (true)
      el.innerHTML = tip
    else {
      // In NS, insert a table to work around
      // stylesheet rendering bug.
      // NS fails to apply style sheets when writing
      // contents into a positioned element.
      el.document.open()
      el.document.write(tip)
      el.document.close()
    }
  }

  function tipBoxgetOffset(el, which) {
    // Function for IE to calculate position
    // of an element.

    var amount = el["offset"+which]
    if (which=="Top")
      amount+=el.offsetHeight
    el = el.offsetParent
    while (el!=null) {
      amount+=el["offset"+which]
      el = el.offsetParent
    }
    return amount
  }

  function tipBoxsetPosition(el) {

    // Set the position of an element
    src = window.event.srcElement

    el.style.zIndex = "1000000"
    el.style.position="absolute"
    el.style.width = "300px";
    el.style.overflow = "visible";

    var my_dim;

    if (el.style && el.style.display != 'none') {
      my_dim = {width: el.offsetWidth, height: el.offsetHeight}
    } else {

      // All *Width and *Height properties give 0 on elements with display none,
      // so enable the element temporarily
      var els = el.style;
      var originalVisibility = els.visibility;
      var originalPosition = els.position;
      els.visibility = 'hidden';
      els.position = 'absolute';
      els.display = '';
      var originalWidth = el.clientWidth;
      var originalHeight = el.clientHeight;
      els.display = 'none';
      els.position = originalPosition;
      els.visibility = originalVisibility;
      my_dim = {width: originalWidth, height: originalHeight};
    }

    var con = document.getElementById('main');

    var max_x = parseInt(con.style.width) - 20 + con.scrollLeft;
    var max_y = parseInt(con.style.height) - 20 + con.scrollTop;
    var left = parseInt(x) - Math.ceil(my_dim.width / 2);
    var top = parseInt(y);

    if (left >= 10 && left + my_dim.width <= max_x) {
       left = left; // passt
    } else if (left >= 10) {
      // links passt es, aber rechts nicht.
      var i = 0;
      while (i < Math.ceil(my_dim.width / 2) && left >= 10 && left + my_dim.width > max_x) {
        left = left - 2;
        i++;
      }
    } else if (left + my_dim.width <= max_x) {
      var i = 0;
      while (i < Math.ceil(my_dim.width / 2) && left < 10 && left + my_dim.width <= max_x) {
        left = left + 2;
        i++;
      }
    } // wenn es weder rechts noch links passt, dann kann man nix mehr retten

    if (top >= 10 && top + my_dim.height <= max_y) {
      top = top; // passt
    } else if (top + my_dim.height <= max_y) {
      var i = 0;
      while (i < my_dim.height / 3 && top < 10 && top + my_dim.height <= max_y) {
        top = top + 3;
        i++;
      }
    } else if (top >= 10) {
      // oben passt es, aber unten nicht.
      var i = 0;
      while (i < my_dim.height / 3 && top >= 10 && top + my_dim.height > max_y) {
        top = top - 3;
        i++;
      }
    }

    el.style.top = top + "px";
    el.style.left = left + "px";
  }

  function tipBoxsetVisibility(el, bDisplay) {
//  alert ("setze vislibilty fuer " + el);
    // Hide or show to tip
    if (bDisplay)
      if (allSupport || true)
        el.style.visibility = "visible"
      else
        el.visibility = "show";
    else
      if (allSupport || true)
        el.style.visibility = "hidden"
      else
        el.visibility = "hidden"
  }


  function tipBoxdisplayContents(tip) {
    // Display the tooltip.
    var el = tipBoxgetElement("tipBox")
    tipBoxwriteContents(el, tip)
    tipBoxsetVisibility(el, true);
    tipBoxsetPosition(el);
  }


  function tipBoxdoMouseOver(e) {

    // Mouse moves over an element
    tipBoxsetupEventObject(e)
    var ev = e || window.event;

    x = x_koord(ev);
    y = y_koord(ev);
    var el = tipBoxcheckName(window.event.srcElement);
    if (el && !el._display) {
      tipBoxdoShow(el);
    } else if (!el && _tbos) {
      var tb = tipBoxgetElement("tipBox");
      if (_tbos != window.event.srcElement && tb != window.event.srcElement) {
        if (!isChildOf(window.event.srcElement, _tbos) && !isChildOf(window.event.srcElement, tb)) {
          tipBoxdoHide(_tbos);
        }
      }
    }
  }

  function tipBoxdoMouseOut(e) {
    // Mouse leaves an element
    //alert ("mouseout begonnen");
    tipBoxsetupEventObject(e)
    var tb = tipBoxgetElement("tipBox");
    var to = window.event.toElement;
    if (!tb || !_tbos) {
        return; // ???
    }
    var el, tip
    if (window.event.srcElement.id != 'tipBox' && (!window.event.toElement || window.event.toElement.id != 'tipBox')) {
      el = tipBoxcheckName(window.event.srcElement);
      if (el && el._display && el == _tbos && !(isChildOf(to, tb) || isChildOf(to, _tbos))) {
        tipBoxdoHide(el);
      }
    } else if (window.event.toElement.id != 'tipBox') {
      if (to != _tbos && !isChildOf(to, tb) && !isChildOf(to, _tbos)) {
        tipBoxdoHide(_tbos);
      }
    }
  }

  function tipBoxdoHide(el) {
    tipBoxsetVisibility(tipBoxgetElement("tipBox"), false);
    el._display = false;
    _tbos._display = false;
    tooltip_reenable_selects();
  }

  function tipBoxdoShow(el) {
    if (_tbos) {
      _tbos._display = false;
    }
    _tbos = el;
    _tbos._display = true;
    tipBoxdisplayContents(_tbos._tip);
    tooltip_disable_selects();
  }

  function tipBoxdoLoad() {
    // Do Loading
    if ((window.document.captureEvents==null) && (!allSupport))

      return // Not IE4 or NS4
    if (window.document.captureEvents!=null)  // NS - capture events
      window.document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)

    document.onmouseover = function() {tipBoxdoMouseOver(arguments[0])}
    document.onmouseout = function() {tipBoxdoMouseOut(arguments[0])}

  }

  function setTipBoxStyle(styleId) {
	  tipBoxgetElement("tipBox").className = "tipBox" + styleId;
  }

  function isChildOf(child, parent) {
    if (!child || !parent) {
      return false;
    }
    if (parent && parent.contains) {
      return parent.contains(child);
    }
    var result = child == parent;
    while (!result && child) {
      child = child.parentNode && child.parentNode != child && child.parentNode != window ? child.parentNode : false;
      result = child == parent;
    }
    return result;
  }


  /*
    * Die Funktion blendet alle <select> aus
    */
    function tooltip_disable_selects()
    {
      var selects = document.getElementsByTagName('select');
      for (var i = 0; i<selects.length; i++)
      {
        selects[i].style.visibility = 'hidden';
      }

    }

    function tooltip_reenable_selects()
    {
      var selects = document.getElementsByTagName('select');
      for (var i = 0; i<selects.length; i++)
      {
        selects[i].style.visibility = 'visible';
      }

    }

/* ]]> */
    // <![CDATA[
    window.onload = function() {
      tipBoxdoLoad();
    }
   // ]]>
