﻿// JScript File


var sT = 50; // Time to show menu in ms
var hT = 100; // Time to hide menu in ms

// Function for js menu
var menuFunc = {
  t: null,
  mID: null,
  s: function(id, e) {
    var m = document.getElementById? document.getElementById(id): null;
    if (!m) return;
    this.mID = id;
    if ( m.onmouseout == null ) m.onmouseout = this.chk;
    if ( m.onmouseover == null ) m.onmouseover = this.zeroTimer;
    this.p(m,e);
  },

  // Function to hide menu
  h: function() {
    this.zeroTimer();
    if (this.mID && document.getElementById) 
      this.t = setTimeout("document.getElementById('"+menuFunc.mID+"').style.visibility = 'hidden'", hT);
  },
  
  // Function to show menu
  p: function() {
    this.t = setTimeout("document.getElementById('"+menuFunc.mID+"').style.visibility = 'visible'", sT);
  },
  
  // Check for mouseOver menu
  chk: function(e) {
    e = e? e: window.event;
    var m = document.getElementById(menuFunc.mID);
    var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
    if ( m != toEl && !menuFunc.c(toEl, m) ) menuFunc.h();
  },
  
  // Contained
  c: function(c1, c2) {
    if (!c1) return; 
    while ( c1 = c1.parentNode ) 
      if ( c1 == c2 ) return true;
    return false;
  },

  // Timer
  zeroTimer: function() {
    if (menuFunc.t) clearTimeout(menuFunc.t);
  }
 }

