// This is a hacked up version of:
// http://www.codestyle.org/javascript/dom_h/css/visibility-Horizontalmenu_hs.shtml
// Copyright (c) 2001-2003, Philip Shaw
// This hack is by K. Chayka, at:
// http://accessat.c-net.us/articles/menu_h/h_drop-down-menu_h.html
// If you take the code, please give credit where it is due.  thanks!

//  customize these variables as needed
var mTix_h   = "";          // main group link tabindex value (numeric, blank=none)
var sTix_h   = "";          // sub-menu_h link item tabindex value (numeric, blank=none)
var lSep_h   = " &#8226; "  // link separator (space-bullet-space) for legacy browsers
var sInd_h   = "&nbsp;<span><img src=\"darrow.gif\" height=\"9\" width=\"9\" alt=\"\"><\/span>"
                           // sub-menu_h indicator (small down arrow image)
                           // might also try &#9660; or &#8595; instead of img
var dbug_h = false;         // set to true to dump the generated code

//  variables below do not need customizing
var mOpen_h = null;         // currently open menu_h
var mClose_h = null;        // menu_h to close
var stddom_h_h = document.getElementById;
var dom_h = "";



function makeArray(n) {
  this.size = n;
  for(i=1; i<=n; i++){
    this[i] = 0;
  }
  return(this);
}

// Top-level menu_h group/category constructor:
function menu_hGroup(n,groupName,groupURL,groupTitle,groupAkey) {
// I personally like the idea of the submenu_h 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_h links
  this.groupName  = groupName;     // button 'label'
//  if (stddom_h_h && (n > 0)) { this.groupName += sInd_h; }  // submenu_h indicator
  this.groupURL   = groupURL;      // button URL
  this.groupTitle = groupTitle;    // title attribute
  this.groupAkey  = groupAkey;     // accesskey value
  this.item       = new makeArray(n);
}

// Submenu_h list item constructor:
function menu_hItem(itemName,itemURL,itemTitle) {
  this.itemName  = itemName;       // link label
  this.itemURL   = itemURL;        // link url
  this.itemTitle = itemTitle;      // title attribute
}

// ********** All the menu_h building starts here
// group[#] = new menu_hGroup(# submenu_h links, group label, URL, title, accesskey);
// group[#].submenu_hLink[#] = new menu_hItem(link label, URL, title);

  

  // For W3C-compliant browsers, make divs for each group and lists for the drop-down menu_hs.
  // For legacy browsers, include just the main links (delimited with lSep_h).

function BuildMenuString_h( menu, mCount_h )
{
	
	var mStr_h = "";
	
  for(var i=1; i<=mCount_h; i++) {
    if (stddom_h_h) {
       mStr_h += "<div class=\"menu_hgroup\" id=\"group" + i + "\">";  // start menu_h group container
    }
    mStr_h += "<a href=\"" + menu_h[i].groupURL + "\"";  // the main link for this group
    if (mTix_h) {                 // include tabindex if defined
      mStr_h += " tabindex=\"" + mTix_h + "\"";
    }
    if (menu_h[i].groupAkey) {    // include accesskey if defined
      mStr_h += " accesskey=\"" + menu_h[i].groupAkey + "\"";
    }
    if (menu_h[i].groupTitle) {   // include title attribute if defined
      mStr_h += "\n title=\"" + menu_h[i].groupTitle + "\"";
    }
    if (stddom_h_h) {              // extra goodies for W3C-compliant browsers
      mStr_h += " class=\"grouplink_h\"";
      if (menu_h[i].size > 0) {   // skip if no submenu_h
        mStr_h += "\n onmouseover=\"menu_hOver('menu_h" + i + "'); return true;\"";
        mStr_h += " onmouseout=\"menu_hOut('menu_h" + i + "'); return true;\"";
      }
    }
    mStr_h += ">" + menu_h[i].groupName + "<\/a>";
    if (stddom_h_h) {              // add the drop-down links for W3C-compliant browsers
      if (menu_h[i].size > 0) {  // skip if no submenu_h
        mStr_h += "\n<ul class=\"menu_h\" id=\"menu_h" + i + "\">\n";
        for( var j=1; j<=menu_h[i].size; j++) {
        						        
          mStr_h += "<li><a href=\"" + menu_h[i].item[j].itemURL + "\"";
          
          if( menu_h[i].item[j].itemURL.indexOf("http://") != -1 )
				mStr_h += " target=\"_blank\" ";
          
          if (sTix_h) {          // include tabindex if defined
            mStr_h += " tabindex=\"" + sTix_h + "\"";
          }
          if (menu_h[i].item[j].itemTitle) {  // include title attribute if defined
            mStr_h += "\n title=\"" + menu_h[i].item[j].itemTitle + "\"";
          }
          mStr_h += "\n onmouseover=\"stayOpen_h('menu_h" + i + "'); return true;\"";
          mStr_h += " onmouseout=\"menu_hOut('menu_h" + i + "'); return true;\">";
          mStr_h += menu_h[i].item[j].itemName;
          mStr_h += "<\/a><\/li>\n";
        }
        mStr_h +="<\/ul>";
      }
      mStr_h += "<\/div>\n";      // end menu_h group
    } else {
      if (i<mCount_h) {mStr_h += lSep_h + "\n";}      // for legacy browsers, add link separator
    }
  }
// *************** End menu_h building

if (dbug_h) {debugWindow(mStr_h);}  // see the generated code in a pop-up window


	return mStr_h;

} //BuildMenuString_h


function debugWindow (val) { 
  var newWin = window.open("","dbug_h");
  newWin.document.write(val);
  newWin.document.close();
}

// *************** Functions called by mouseover/mouseout start here
// Mouseover a menu_h
function menu_hOver(m){
  if (!stddom_h_h) {return;}
  dom_h = document.getElementById(m);
  if (dom_h != null) {
    if (mOpen_h == dom_h) {       // already open
      clearTimeout(mClose_h);   // don't close
    } else {
      if (mOpen_h != null) {    // another is open
        clearTimeout(mClose_h);
        hideNow_h();            // close it now
      }
    }
  mOpen_h = dom_h;                // set new open menu_h
  mOpen_h.style.visibility = "visible";    // show it
}
}
// Keep menu_h open
function stayOpen_h(m){
  // If menu_hOver has not been called or the menu_h is hidden, do nothing
  if ((mOpen_h == null) || ((mOpen_h.style) && (mOpen_h.style.visibility) && (mOpen_h.style.visibility == "hidden"))) return;
  else menu_hOver(m);
}
// Close menu_h after timeout
function menu_hOut(m){
  dom_h = document.getElementById(m);
  if ((stddom_h_h) && (dom_h != null)) {
    mOpen_h = dom_h;	// get current open menu_h
    mClose_h = window.setTimeout("hideNow_h();",400);  // auto-close after 400ms
  }
}
// Close previous menu_h now
function hideNow_h(){
  if ((mOpen_h.style) && (mOpen_h.style.visibility)) {
    mOpen_h.style.visibility = "hidden";
  }
}

function DisplayMenu_h( mStr )
{
	if (mStr && (mStr != "")) 
	{
		document.write(mStr);
		
		if (document.layers) 
		{
			document.close();
		}
	}

}

// the end -->