// Simple JavaScript Libraries v0.7.1
// http://simple-javascripts.googlecode.com
// Copyright (c) 2008 Jonathan Bowman and Eastern Mennonite University
// MIT-style License <http://opensource.org/licenses/mit-license.php>
var Simple = {
  add_event: function(C, A, B){
    if (typeof C["on" + A] === "function") {
      this["old" + A] = C["on" + A];
      C["on" + A] = function(D){
        Simple["old" + A](D);
        B(D)
      }
    }
    else {
      C["on" + A] = B
    }
  },
  oldie:  /*@cc_on(@_jscript_version < 5.7) || @*/
  false,
  Modal: {
    accommodations: function(B){
      if (Simple.oldie) {
        var A;
        if (B) {
          this.hidden_selects = document.getElementsByTagName("select");
          A = "hidden";
          Simple.add_event(window, "scroll", this.position);
          Simple.add_event(window, "resize", function(){
            Simple.Modal.position();
            Simple.Modal.stretch()
          });
          this.position();
          this.stretch()
        }
        else {
          A = "visible";
          window.onscroll = this.oldscroll || null;
          window.onresize = this.oldresize || null
        }
        for (var C = 0; C < this.hidden_selects.length; C++) {
          this.hidden_selects[C].style.visibility = A
        }
      }
    },
    close: function(){
      this.center.style.visibility = "hidden";
      this.center.style.display = "none";
      this.overlay.style.display = "none";
      this.accommodations(false)
    },
    open: function(A){
      this.box.innerHTML = A;
      this.overlay.style.display = "block";
      this.center.style.display = "block";
      this.box.style.marginLeft = "-" + (this.box.offsetWidth / 2).toString() + "px";
      this.box.style.top = "-" + (this.box.offsetHeight / 2).toString() + "px";
      this.accommodations(true);
      this.center.style.visibility = "visible"
    },
    position: function(){
      Simple.Modal.center.style.top = (document.documentElement.scrollTop + (document.documentElement.clientHeight / 2)) + "px"
    },
    setup: function(){
      this.overlay = document.getElementById("simple_modal_overlay");
      if (!this.overlay) {
        this.overlay = document.createElement("div");
        this.overlay.id = "simple_modal_overlay";
        this.overlay.style.display = "none";
        document.body.appendChild(this.overlay)
      }
      this.center = document.getElementById("simple_modal_center");
      if (!this.center) {
        this.center = document.createElement("div");
        this.center.id = "simple_modal_center";
        this.center.style.display = "none";
        document.body.appendChild(this.center)
      }
      this.box = document.getElementById("simple_modal_box");
      if (!this.box) {
        this.box = document.createElement("div");
        this.box.id = "simple_modal_box";
        this.center.appendChild(this.box)
      }
      if (Simple.oldie) {
        this.overlay.style.position = "absolute";
        this.center.style.position = "absolute"
      }
    },
    stretch: function(){
      Simple.Modal.overlay.style.height = (document.documentElement.clientHeight > document.body.offsetHeight ? document.documentElement.clientHeight : document.body.offsetHeight) + "px"
    }
  },
  Tooltip: {
    className: "tooltip",
    hide: function(){
      if (this.trigger) {
        this.box.style.display = "none";
        this.trigger.title = this.title;
        delete this.trigger
      }
    },
    setup: function(){
      if (!document.getElementById("simple_tooltip_box")) {
        this.box = document.createElement("div");
        this.box.id = "simple_tooltip_box";
        this.box.style.position = "absolute";
        this.box.style.display = "none";
        document.body.appendChild(this.box);
        Simple.add_event(document.body, "mouseover", function(A){
          Simple.Tooltip.show(A)
        });
        Simple.add_event(document.body, "mouseout", function(){
          Simple.Tooltip.hide()
        })
      }
    },
    show: function(A){
      var C;
      var G = (A) ? A : ((event) ? event : null);
      if (G) {
        var D = (G.target) ? G.target : ((G.srcElement) ? G.srcElement : null);
        if (!this.trigger) {
          try {
            (D.nodeType === 1)
          } 
          catch (F) {
            return false
          }
          find_trigger: while (D && D !== document.body && !this.trigger) {
            if (!this.className && D.title && D.title !== "") {
              this.trigger = D;
              break
            }
            else {
              C = (D.className) ? D.className.split(" ") : [];
              for (var B = 0; B < C.length; B++) {
                if (C[B] === this.className && D.title) {
                  this.trigger = D;
                  break find_trigger
                }
              }
            }
            var E = D.parentNode;
            while (E.nodeType && E.nodeType !== 1) {
              E = E.parentNode
            }
            D = E
          }
        }
      }
      if (this.trigger) {
        this.box.style.top = (document.documentElement.scrollTop + G.clientY + 10) + "px";
        this.box.style.left = (document.documentElement.scrollLeft + G.clientX + 10) + "px";
        this.box.innerHTML = this.trigger.title;
        this.title = this.trigger.title;
        this.trigger.title = "";
        this.box.style.display = "block"
      }
    }
  }
};
Simple.add_event(window, "load", function(){
  Simple.Modal.setup();
  Simple.Tooltip.setup()
});


