/* Initialize the navigation menu system */
var listMenu = new FSMenu('listMenu', true, 'visibility', 'visible', 'hidden');
listMenu.cssLitClass = 'highlighted';
var arrow = null;
if (document.createElement && document.documentElement) { arrow = document.createElement('span'); arrow.appendChild(document.createTextNode('>')); arrow.className = 'subind'; }
addEvent(window, 'load', new Function('listMenu.activateMenu("listMenuRoot", arrow)'));

/* Contact box functions */
function showcontactbox() {
  document.getElementById("darkenpage").style.display = "block";
  document.getElementById("contactbox").style.display = "block";
  return false;
}

function hidecontactbox() {
  document.getElementById("darkenpage").style.display = "none";
  document.getElementById("contactbox").style.display = "none";
  return false;
}

/* Table row highlighting */
var lastclass = "";
function trhoveron() { lastclass = this.className; if (lastclass != "noborder") { this.className = "hoverrow"; } }
function trhoveroff() { this.className = lastclass; }
function addtrhoverevents() {
  var rows = document.getElementsByTagName("tr");
  for (var i = 0; i < rows.length; i++) {
    var cells = rows[i].getElementsByTagName("td");
    if (cells.length > 0) { // don't highlight header rows
      if(rows[i].addEventListener) {
        rows[i].addEventListener('mouseover', trhoveron, false);
        rows[i].addEventListener('mouseout', trhoveroff, false);
      } else {
        rows[i].onmouseover = trhoveron;
        rows[i].onmouseout = trhoveroff;
      }
    }
  }
}

/**\
 **  fsMenu.js: Navigation menu code
 **  FREESTYLE MENUS v1.0 RC (c) 2001-2006 Angus Turnbull, http://www.twinhelix.com
 **  Altering this notice or redistributing this file is prohibited.
 **
 **  Code unobfuscated by David Carroll, www.uljetsfootball.com webmaster
\**/

var isDOM = document.getElementById?1:0
var isIE = document.all?1:0
var isNS4 = navigator.appName == 'Netscape' && !isDOM?1:0
var isOp = self.opera?1:0
var isDyn = isDOM || isIE || isNS4;

function getRef(i,p) {
  p = !p?document:p.navigator?p.document:p;
  return isIE?p.all[i]:isDOM?(p.getElementById?p:p.ownerDocument).getElementById(i):isNS4?p.layers[i]:null;
};

function getSty(i,p) {
  var r = getRef(i,p);
  return r?isNS4?r:r.style:null;
};

if(!self.LayerObj) var LayerObj=new Function('i','p','this.ref=getRef(i,p);this.sty=getSty(i,p);return this');

function getLyr(i,p) { return new LayerObj(i,p); };
function LyrFn(n,f) { LayerObj.prototype[n] = new Function('var a=arguments,p=a[0],px=isNS4||isOp?0:"px";with(this){'+f+'}') };

LyrFn('x','if(!isNaN(p))sty.left=p+px;else return parseInt(sty.left)');
LyrFn('y','if(!isNaN(p))sty.top=p+px;else return parseInt(sty.top)');

function addEvent(o,n,f) {
  var a = 'addEventListener', h = 'on'+n;
  if(o[a]) return o[a](n,f,false);
  if(o[h]) {
    o._c|=0;
    var b = '_b'+(++o._c);
    o[b] = o[h];
  }
  o[h] = function(e) {
    e = e || self.event;
    var r=true;
    if (o[b]) r = o[b](e) != false && r;
    o._f = f;
    r = o._f(e) != false && r;
    return r;
  }
};

function FSMenu(myName,nested,cssProp,cssVis,cssHid) {
  this.myName = myName;
  this.nested = nested;
  this.cssProp = cssProp;
  this.cssVis = cssVis;
  this.cssHid = cssHid;
  this.cssLitClass = '';
  this.menus = { root:new FSMenuNode('root',this) };
  this.menuToShow = [];
  this.mtsTimer = null;
  this.showDelay = 0;
  this.switchDelay = 125;
  this.hideDelay=500;
};

FSMenu.prototype.show = function(mN) {
  with(this) {
    menuToShow.length = arguments.length;
    for (var i = 0; i < arguments.length; i++) menuToShow[i] = arguments[i];
    clearTimeout(mtsTimer);
    mtsTimer = setTimeout(myName+'.menus.root.over()',10);
  }
};

FSMenu.prototype.hide = function(mN) {
  with(this) {
    clearTimeout(mtsTimer);
    if (menus[mN]) menus[mN].out();
  }
};

function FSMenuNode(id,obj) {
  this.id = id;
  this.obj = obj;
  this.lyr = this.child = this.par = this.timer = this.visible = null;
  this.args = [];
  var node = this;
  this.over = function(evt) {
    with(node) with(obj) {
      if (isNS4 && evt && lyr.ref) lyr.ref.routeEvent(evt);
      clearTimeout(timer);
      clearTimeout(mtsTimer);
      if (menuToShow.length) {
        var a = menuToShow, m = a[0];
        if (!menus[m] || !menus[m].lyr.ref) menus[m] = new FSMenuNode(m,obj);
        var c = menus[m];
        if (c == node) {
          menuToShow.length=0;
          return;
        }
        clearTimeout(c.timer);
        if (c != child && c.lyr.ref) {
          c.args.length = a.length;
          for (var i = 0; i < a.length; i++) c.args[i] = a[i];
          var delay = child?switchDelay:showDelay;
          c.timer = setTimeout('with('+myName+'){menus["'+c.id+'"].par=menus["'+node.id+'"];menus["'+c.id+'"].show()}',delay?delay:1);
        }
        menuToShow.length=0;
      }
      if (!nested && par) par.over();
    }
  };
  this.out = function(evt) {
    with(node) with(obj) {
      if (isNS4 && evt && lyr && lyr.ref) lyr.ref.routeEvent(evt);
      clearTimeout(timer);
      timer = setTimeout(myName+'.menus["'+id+'"].hide()',hideDelay);
      if (!nested && par) par.out();
    }
  };
  if (id != 'root') with(this) with(lyr=getLyr(id)) if(ref) {
    if (isNS4) ref.captureEvents(Event.MOUSEOVER|Event.MOUSEOUT);
    addEvent(ref,'mouseover',this.over);
    addEvent(ref,'mouseout',this.out);
  }
};

FSMenuNode.prototype.show = function() {
  with(this) with(obj) {
    if (!lyr || !lyr.ref) return;
    if (par.child && par.child != this) par.child.hide();
    par.child = this;
    var offR = args[1], offX = args[2], offY = args[3], lX = 0, lY = 0, doX = ''+offX!='undefined', doY = ''+offY!='undefined';
    if (self.page && offR && (doX || doY)) {
      with (page.elmPos(offR,par.lyr?par.lyr.ref:0)) lX = x, lY = y;
      if (doX) lyr.x(lX+eval(offX));
      if (doY) lyr.y(lY+eval(offY));
    }
    if (offR) lightParent(offR,1);
    visible = 1;
    if (obj.onshow) obj.onshow(id);
    setVis(1);
  }
};

FSMenuNode.prototype.hide = function() {
  with(this) with(obj) {
    if (!lyr || !lyr.ref) return;
    if (isNS4 && self.isMouseIn && isMouseIn(lyr.ref)) return show();
    if (args[1]) lightParent(args[1],0);
    if (lyr) {
      visible = 0;
      if (obj.onhide) obj.onhide(id);
      setVis(0);
    }
    if (child) child.hide();
    if (par && par.child == this) par.child=null;
    par=null;
  }
};

FSMenuNode.prototype.lightParent = function(elm,lit) {
  with(this) with(obj) {
    if (!cssLitClass || isNS4) return;
    if (lit) elm.className += (elm.className?' ':'')+cssLitClass;
    else elm.className = elm.className.replace(new RegExp('\\s*'+cssLitClass+'$'),'');
  }
};

FSMenuNode.prototype.setVis = function(sh) { with(this) with(obj) { lyr.sty[cssProp] = sh?cssVis:cssHid; } };

FSMenu.prototype.activateMenu = function(id,subIText) {
  with(this) {
    if (!isDOM) return;
    var a, ul, li, mRoot = getRef(id), nodes, count=1;
    var lists = mRoot.getElementsByTagName('ul');
    for (var i = 0; i < lists.length; i++) {
      li = ul = lists[i];
      while(li) {
        if (li.nodeName.toLowerCase() == 'li') break;
        li = li.parentNode;
      }
      if (!li) continue;
      a = null;
      for (var j = 0; j < li.childNodes.length; j++) { if (li.childNodes[j].nodeName.toLowerCase() == 'a') a = li.childNodes[j]; }
      if (!a) continue;
      var menuID = myName+'-id-'+count++;
      if (ul.id) menuID = ul.id;
      else ul.setAttribute('id',menuID);
      addEvent(a,'mouseover',new Function('e',myName+'.show("'+menuID+'",this)'));
      addEvent(a,'mouseout',new Function('e',myName+'.hide("'+menuID+'")'));
      if (subIText) {
        var subI = document.createElement?document.createElement('span'):0;
        if (subI) {
          subI.appendChild(document.createTextNode(subIText));
          subI.className = 'subind';
          a.insertBefore(subI,a.firstChild);
        }
      }
    }
  }
};

if (!self.page) var page = { win:self, minW:0, minH:0, MS:isIE && !isOp };

page.elmPos = function(e,p) {
  var x = 0, y = 0, w = p?p:this.win;
  e = e?(e.substr?(isNS4?w.document.anchors[e]:getRef(e,w)):e):p;
  if (isNS4) {
    if (e && (e != p)) {
      x = e.x;
      y = e.y;
    };
    if (p) {
      x += p.pageX;
      y += p.pageY;
    }
  }
  else if (e && e.focus && e.href && this.MS && navigator.platform.indexOf('Mac')>-1) {
    e.onfocus = new Function('with(event){self.tmpX=clientX-offsetX;self.tmpY=clientY-offsetY}');
    e.focus();
    x = tmpX;
    y = tmpY;
    e.blur();
  }
  else while(e) {
    x += e.offsetLeft;
    y += e.offsetTop;
    e = e.offsetParent;
  }
  return { x:x, y:y }
};

/* Netscape 4 compatibility
if (isNS4) {
  var fsmMouseX, fsmMouseY, fsmOR = self.onresize, nsWinW = innerWidth, nsWinH = innerHeight;
  document.fsmMM = document.onmousemove;
  self.onresize = function() {
    if (fsmOR) fsmOR();
    if (nsWinW != innerWidth || nsWinH != innerHeight) location.reload();
  }
  document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove = function(e) {
    fsmMouseX = e.pageX;
    fsmMouseY = e.pageY;
    return document.fsmMM?document.fsmMM(e):document.routeEvent(e);
  };
  function isMouseIn(sty) { with(sty) return((fsmMouseX > left) && (fsmMouseX < left+clip.width) && (fsmMouseY > top) && (fsmMouseY < top+clip.height)); }
}; */
