/**
 * This script makes links to floormaps open in a popup window.
 *
 * Used by:
 *  /vol/info/www/docs/uni/gebaeude/header.shtml
 *  /vol/info/www/docs/uni/plan/interaktiv/institute/*.html
 *
 * @author Daniel Klaus <klausd@uni-koeln.de>
 */

function hasClass(element, class_) {
  var attr = element.getAttribute("class");
  if (!attr) return false;
  var classes = attr.split(" ");
  for (var i = 0; i < classes.length; i++) {
    var c = classes[i].replace(/^\s+|\s+$/g, ""); // strip white space
    if (class_ == c) return true;
  }
  return false;
}

var oldOnload = window.onload || null;
window.onload = function() {
  if (oldOnload) oldOnload();
  var links = document.getElementsByTagName("a");
  for (var i = 0; i < links.length; i++) {
    if (hasClass(links[i], "floormap")) {
      links[i].onclick = function(event) {
        var popup = window.open(
          links[i].getAttribute("href"),
          "floormap",
          "height=700,width=800,menubar=no,toolbar=no,location=no,status=no"
        );
        if (window.focus) popup.focus();
        return false;
      };
    }
  }
};

