/*************************************************************************

  dw_viewport.js
  version date July 2003

  This code is from Dynamic Web Coding
  at http://www.dyn-web.com/
  Copyright 2003 by Sharon Paine
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  Permission granted to use this code
  as long as this entire notice is included.

  Example usage (after body tag or after page loaded):
  viewport.getWinWidth();
  alert(viewport.width)

*************************************************************************/

viewport = {
  getIECanvas: function () {
    var canv = null;
    if (!window.opera && document.all && typeof document.body.clientWidth != "undefined") {
      var cm = document.compatMode && document.compatMode == "CSS1Compat";
      canv = cm? document.documentElement: document.body;
    }
      return canv;
  },

  getWinWidth: function () {
    var canv;
    if ( canv = this.getIECanvas() ) this.width = canv.clientWidth;
    else this.width = window.innerWidth - 18;
  },

  getWinHeight: function () {
    var canv;
    if ( canv = this.getIECanvas() ) this.height = canv.clientHeight;
    else this.height = window.innerHeight - 18;
  },

  getScrollX: function () {
    var canv;
    if ( canv = this.getIECanvas() ) this.scrollX = canv.scrollLeft;
    else if (window.pageXOffset) this.scrollX = window.pageXOffset;
    else if (window.scrollX) this.scrollX = window.scrollX;
    else this.scrollX = 0;
  },

  getScrollY: function () {
    var canv;
    if ( canv = this.getIECanvas() ) this.scrollY = canv.scrollTop;
    else if (window.pageYOffset) this.scrollY = window.pageYOffset;
    else if (window.scrollY) this.scrollY = window.scrollY;
    else this.scrollY = 0;
  },

  getAll: function () {
    this.getWinWidth();   this.getWinHeight();
    this.getScrollX(); this.getScrollY();
  }

}

// new part, previously in header

var menuLayers = {
  timer: null,
  activeMenuID: null,
  offX: -7,   // horizontal offset
  offY: -7,  // vertical offset
  show: function(id, e) {
    var mnu = document.getElementById? document.getElementById(id): null;
    if (!mnu) return;
    this.activeMenuID = id;
    if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
    if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
    window.viewport.getAll();
    this.position(mnu,e);
  },

  hide: function() {
    this.clearTimer();
    if (this.activeMenuID && document.getElementById)
      this.timer = setTimeout("document.getElementById('"+menuLayers.activeMenuID+"').style.visibility = 'hidden'", 200);
  },

  position: function(mnu, e) {
    var x, y;
    e = e? e: window.event;

    if ( e.clientX + mnu.offsetWidth + this.offX > viewport.width )
      x = 122;
    else x = 122;

    if ( e.clientY + mnu.offsetHeight + this.offY > viewport.height )
      y = viewport.height + viewport.scrollY - mnu.offsetHeight;
    else y = e.clientY + viewport.scrollY + this.offY;

    mnu.style.left = x + "px"; mnu.style.top = y + "px";
    this.timer = setTimeout("document.getElementById('" + menuLayers.activeMenuID + "').style.visibility = 'visible'", 200);
  },

  mouseoutCheck: function(e) {
    e = e? e: window.event;
    // is element moused into contained by menu? or is it menu (ul or li or a to menu div)?
    var mnu = document.getElementById(menuLayers.activeMenuID);
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( mnu != toEl && !menuLayers.contained(toEl, mnu) ) menuLayers.hide();
  },

  // returns true of oNode is contained by oCont (container)
  contained: function(oNode, oCont) {
    if (!oNode) return; // in case alt-tab away while hovering (prevent error)
    while ( oNode.parentNode ) {
      oNode = oNode.parentNode;
      if ( oNode == oCont ) return true;
    }
    return false;
  },

  clearTimer: function() {
    if (menuLayers.timer) clearTimeout(menuLayers.timer);
  }

}

function resizeText(multiplier) {

if (document.body.style.fontSize == "") {

   document.body.style.fontSize = "1.0em";

 }

  document.body.style.fontSize = parseFloat(document.body.style.fontSize) + (multiplier * 0.2) + "em";

}
