

// This is a hacked up version of:
// http://www.codestyle.org/javascript/dom/css/visibility-HorizontalMenus.shtml
// Copyright (c) 2001-2003, Philip Shaw
// This hack is by K. Chayka, at:
// http://accessat.c-net.us/articles/menu/h_drop-down-menu.html
// If you take the code, please give credit where it is due.  thanks!

//  customize these variables as needed
var mCount = 6;           // number of menu groups
var mTix   = "";          // main group link tabindex value (numeric, blank=none)
var sTix   = "";          // sub-menu link item tabindex value (numeric, blank=none)
var lSep   = " &#8226; "  // link separator (space-bullet-space) for legacy browsers
var sInd   = "&nbsp;<span><img src=\"darrow.gif\" height=\"9\" width=\"9\" alt=\"\"><\/span>"
                           // sub-menu indicator (small down arrow image)
                           // might also try &#9660; or &#8595; instead of img
var dbug = false;         // set to true to dump the generated code

//  variables below do not need customizing
var mOpen = null;         // currently open menu
var mClose = null;        // menu to close
var stdDOM = document.getElementById;
var dom = "";
var mStr = "";
var menu = new makeArray(mCount);

// *************** main end

function makeArray(n) {
    this.size = n;
    for(i=1; i<=n; i++) {
        this[i] = 0;
    }
    return(this);
}

function debugWindow (val) {
    var newWin = window.open("","dBug");
    newWin.document.write(val);
    newWin.document.close();
}

// Top-level menu group/category constructor:
function menuGroup(n,groupName,groupURL,groupTitle,groupAkey) {
// I personally like the idea of the submenu indicator, but the Unicode characters 
// that would give desireable results are not supported in the standard Mac (Classic)
// fonts.  A small image might be substituted, but that is not scalable and doesn't
// look as good, IMO.  Uncomment the 'if' statement if you'd like to experiment with it.
  this.size       = n;             // number of submenu links
  this.groupName  = groupName;     // button 'label'
//  if (stdDOM && (n > 0)) { this.groupName += sInd; }  // submenu indicator
  this.groupURL   = groupURL;      // button URL
  this.groupTitle = groupTitle;    // title attribute
  this.groupAkey  = groupAkey;     // accesskey value
  this.item       = new makeArray(n);
}

// Submenu list item constructor:
function menuItem(itemName,itemURL,itemTitle) {
  this.itemName  = itemName;       // link label
  this.itemURL   = itemURL;        // link url
  this.itemTitle = itemTitle;      // title attribute
}

// *************** Functions called by mouseover/mouseout start here

// Mouseover a menu
function menuOver(m){
    if (!stdDOM) {return;}
    dom = document.getElementById(m);
    if (dom != null) {
        if (mOpen == dom) {       // already open
            clearTimeout(mClose);   // don't close
        } else {
            if (mOpen != null) {    // another is open
                clearTimeout(mClose);
                hideNow();            // close it now
            }
        }
        mOpen = dom;                // set new open menu
        mOpen.style.visibility = "visible";    // show it
    }
}

// Keep menu open
function stayOpen(m){
    // If menuOver has not been called or the menu is hidden, do nothing
    if ((mOpen == null) || ((mOpen.style) && (mOpen.style.visibility) && (mOpen.style.visibility == "hidden"))) return;
    else menuOver(m);
}

// Close menu after timeout
function menuOut(m){
	// alert(m.substr(4.1));
	// unsetI(m.substr(4,1));
    dom = document.getElementById(m);
    if ((stdDOM) && (dom != null)) {
        mOpen = dom;    // get current open menu
        mClose = window.setTimeout("hideNow();",400);  // auto-close after 400ms
    }
}
// Close previous menu now
function hideNow(){
	unsetI(selected);
    if ((mOpen.style) && (mOpen.style.visibility)) {
		// alert(selected);
        mOpen.style.visibility = "hidden";
    }
}


// img mouseovers

function setI(nr) {
    // if (nr == selected) return;
    if (document.images) {
        name = "navig" + nr;
        document.images[name].src = imagesOn[nr].src;
		// if (nr != 1)
			 selected = nr;
    }
}

function unsetI(nr) {
    // if (nr == selected) return;
	if (nr == 0) return;
    if (document.images) {
        name = "navig" + nr;
        document.images[name].src = images[nr].src;
		selected = 0;
    }
}

var images      = new Array();
var imagesOn    = new Array();
var names       = new Array("1", "2", "3", "4");
var numimages   = names.length;
var selected    = 0;
var frameloaded = 0;


for (i=1; i<=numimages; i++) {
    image       = new Image();
    imageOn     = new Image();
    name        = names[i-1];
    image.src   = "images/navig/" + name + ".gif";
    imageOn.src = "images/navig/" + name + "_on.gif";
    images[i]   = image;
    imagesOn[i] = imageOn;
}


// the end -->

