//============================================================================
// vms_home.js
// This JavaScript file contains all of the data and logic to manage
// navigation for pages generated from the Dreameweaver templates.
//============================================================================





//============================================================================
// Header Nav data
//============================================================================

//============================================================================
// Header Nav popups:
//
//  About Us
//    Overview: Mission and Vision
//    Management Team
//    History of Innovation
//    The VMS Advantage
//
//  Newsroom
//    Press Releases
//    VMS In the News
//    Media Resources
//      Media Contact
//      Company Overview
//      Product Information
//      VMS Logos
//      Management Team
//============================================================================

var header_hashtable = {};

var header_root =
[
  "BARNAV",
  "head_nav",
  '</td><td width="16" height="18">&nbsp;',
  "standardClass=barnav_std_tab",
  "hoverClass=barnav_hov_tab",
  [
    "About VMS",
    "Select A Product",
    "Newsroom",
    "Contact Us / Locations",
    "Careers",
	"Resource Center"
  ]
];


//=========================
// First Level (under root)
//=========================

header_hashtable[ "About VMS"] =
[
  "head_nav",
  "tn_about_vms",
  "About VMS",
  "a_1_about.html",
  "topic_about_vms",
  [
    "About VMS | Overview: Mission and Vision",
    "About VMS | Management Team",
    "About VMS | History of Innovation",
    "About VMS | The VMS Advantage"
  ]
];

header_hashtable[ "Select A Product"] =
[
  "head_nav",
  "tn_select_a_product",
  "Select A Product",
  "#",
  "topic_select_a_product",
  [
    "SAP | AdAlert",
    "SAP | AdExpress",
    "SAP | AdSearch",
    "SAP | AdSight",
    "SAP | BroadcastCenter",
    "SAP | Crisis Alert Reports",
    "SAP | Digital Delivery",
    "SAP | InSight",
    "SAP | Int'l Ad Monitoring",
    "SAP | Media Values",
    "SAP | Monitoring Reports",
    "SAP | Newsboards",
    "SAP | News Retrieval",
    "SAP | Occurrence Reports",
    "SAP | PrintPlus",
    "SAP | Product Placement",
	"SAP | PRtrak",
    "SAP | QuickView",
	"SAP | RealTime",
    "SAP | Transcripts",
	"SAP | Vantage",
    "SAP | VideoBoards",
    "SAP | VoiceTrak"
  ]
];

header_hashtable[ "Newsroom"] =
[
  "head_nav",
  "tn_newsroom",
  "Newsroom",
  "b_1_newsroom.html",
  "topic_vms_newsroom",
  [
    "Newsroom | Press Releases",
    "Newsroom | VMS In the News",
    "Newsroom | Media Resources"
  ]
];

header_hashtable[ "Contact Us / Locations"] =
[
  "head_nav",
  "tn_contact_us_locations",
  "Contact Us / Locations",
  "c_1_contactus.html",
  "",
  [ ]
];

header_hashtable[ "Careers"] =
[
  "head_nav",
  "tn_careers",
  "Careers",
  "d_1_careers.html",
  "",
  [ ]
];

header_hashtable[ "Resource Center"] =
[
  "head_nav",
  "tn_resource_center",
  "Resource Center",
  "4_1_demos.html",
  "topic_resource_center",
  [
    "Resource Center | Online Demos",
    "Resource Center | Product Brochures",
    "Resource Center | Product Sheets",
    "Resource Center | White Papers",
	"Resource Center | Speeches"
  ]
];


//===============================
// Second Level (under About VMS)
//===============================

header_hashtable[ "About VMS | Overview: Mission and Vision"] =
[
  "topic_about_vms",
  "lns_overview",
  "Overview: Mission and Vision",
  "a_1_1_mission.html",
  "",
  [ ]
];

header_hashtable[ "About VMS | Management Team"] =
[
  "topic_about_vms",
  "lns_management_team",
  "Management Team",
  "a_1_2_team.html",
  "",
  [ ]
];

header_hashtable[ "About VMS | History of Innovation"] =
[
  "topic_about_vms",
  "lns_history_of_innovation",
  "History of Innovation",
  "a_1_3_history.html",
  "",
  [ ]
];

header_hashtable[ "About VMS | The VMS Advantage"] =
[
  "topic_about_vms",
  "lns_the_vms_advantage",
  "The VMS Advantage",
  "a_1_4_advantage.html",
  "",
  [ ]
];


//======================================
// Second Level (under Select A Product)
//======================================

header_hashtable[ "SAP | AdAlert"] =
[
  "topic_select_a_product",
  "lns_adalert",
  "AdAlert",
  "2_1_3_adalert.html",
  "",
  [ ]
];

header_hashtable[ "SAP | AdExpress"] =
[
  "topic_select_a_product",
  "lns_adexpress",
  "AdExpress",
  "2_1_4_adexpress.html",
  "",
  [ ]
];

header_hashtable[ "SAP | AdSearch"] =
[
  "topic_select_a_product",
  "lns_adsearch",
  "AdSearch",
  "2_1_2_adsearch.html",
  "",
  [ ]
];

header_hashtable[ "SAP | AdSight"] =
[
  "topic_select_a_product",
  "lns_adsite",
  "AdSight",
  "2_1_1_adsite.html",
  "",
  [ ]
];

header_hashtable[ "SAP | BroadcastCenter"] =
[
  "topic_select_a_product",
  "lns_broadcastcenter",
  "BroadcastCenter",
  "1_1_1_broadcastcenter.html",
  "",
  [ ]
];

header_hashtable[ "SAP | Crisis Alert Reports"] =
[
  "topic_select_a_product",
  "lns_crisisalertreports",
  "Crisis Alert Reports",
  "1_1_9_crisisalert.html",
  "",
  [ ]
];

header_hashtable[ "SAP | Digital Delivery"] =
[
  "topic_select_a_product",
  "lns_digitaldelivery",
  "Digital Delivery",
  "1_1_8_digitaldelivery.html",
  "",
  [ ]
];

header_hashtable[ "SAP | InSight"] =
[
  "topic_select_a_product",
  "lns_insight",
  "InSight",
  "1_1_2_insight.html",
  "",
  [ ]
];

header_hashtable[ "SAP | Int'l Ad Monitoring"] =
[
  "topic_select_a_product",
  "lns_intladmonitoring",
  "Int'l Ad Monitoring",
  "2_1_10_1_international.html",
  "",
  [ ]
];

header_hashtable[ "SAP | Media Values"] =
[
  "topic_select_a_product",
  "lns_mediavalues",
  "Media Values",
  "#",
  "",
  [ ]
];


header_hashtable[ "SAP | Monitoring Reports"] =
[
  "topic_select_a_product",
  "lns_monitoringreports",
  "Monitoring Reports",
  "1_1_5_monitoringreports.html",
  "",
  [ ]
];

header_hashtable[ "SAP | Newsboards"] =
[
  "topic_select_a_product",
  "lns_newsboards",
  "Newsboards",
  "1_1_10_newsboards.html",
  "",
  [ ]
];

header_hashtable[ "SAP | News Retrieval"] =
[
  "topic_select_a_product",
  "lns_newsretrieval",
  "News Retrieval",
  "1_1_7_newssegment.html",
  "",
  [ ]
];

header_hashtable[ "SAP | Occurrence Reports"] =
[
  "topic_select_a_product",
  "lns_occurencereports",
  "Occurrence Reports",
  "2_1_5_1_occurence.html",
  "",
  [ ]
];

header_hashtable[ "SAP | PrintPlus"] =
[
  "topic_select_a_product",
  "lns_printplus",
  "PrintPlus",
  "2_1_7_printplus.html",
  "",
  [ ]
];

header_hashtable[ "SAP | Product Placement"] =
[
  "topic_select_a_product",
  "lns_productplacement",
  "Product Placement",
  "2_1_5_3_productplacement.html",
  "",
  [ ]
];

header_hashtable[ "SAP | PRtrak"] =
[
  "topic_select_a_product",
  "lns_prtrak",
  "PRtrak",
  "1_1_3_prtrak.html",
  "",
  [ ]
];

header_hashtable[ "SAP | QuickView"] =
[
  "topic_select_a_product",
  "lns_quickview",
  "QuickView",
  "1_1_4_quickview.html",
  "",
  [ ]
];

header_hashtable[ "SAP | RealTime"] =
[
  "topic_select_a_product",
  "lns_realtime",
  "RealTime",
  "1_1_14_realtime.html",
  "",
  [ ]
];

header_hashtable[ "SAP | Transcripts"] =
[
  "topic_select_a_product",
  "lns_transcripts",
  "Transcripts",
  "1_1_11_transcripts.html",
  "",
  [ ]
];

header_hashtable[ "SAP | Vantage"] =
[
  "topic_select_a_product",
  "lns_vantage",
  "Vantage",
  "http://vantage.vmsinfo.com",
  "",
  [ ]
];

header_hashtable[ "SAP | VideoBoards"] =
[
  "topic_select_a_product",
  "lns_videoboards",
  "VideoBoards",
  "2_1_8_videoboards.html",
  "",
  [ ]
];

header_hashtable[ "SAP | VoiceTrak"] =
[
  "topic_select_a_product",
  "lns_voicetrak",
  "VoiceTrak",
  "2_1_9_voicetrak.html",
  "",
  [ ]
];


//==============================
// Second Level (under Newsroom)
//==============================

header_hashtable[ "Newsroom | Press Releases"] =
[
  "topic_vms_newsroom",
  "ln_vms_in_news",
  "Press Releases",
  "b_1_1_pressreleases.html",
  "",
  [ ]
];

header_hashtable[ "Newsroom | VMS In the News"] =
[
  "topic_vms_newsroom",
  "ln_in_the_news",
  "VMS In the News",
  "b_1_2_inthenews.html",
  "",
  [ ]
];

header_hashtable[ "Newsroom | Media Resources"] =
[
  "topic_vms_newsroom",
  "ln_media_resources",
  "Media Resources",
  "b_1_3_mediaresources.html",
  "sub_media_resources",
  [
    "Newsroom | Media Resources | Media Contact",
    "Newsroom | Media Resources | Company Overview",
    "Newsroom | Media Resources | Product Information",
    "Newsroom | Media Resources | VMS Logos",
    "Newsroom | Media Resources | Management Team"
  ]
];

//===============================
// Second Level (Resource Center)
//===============================

header_hashtable[ "Resource Center | Online Demos"] =
[
  "topic_resource_center",
  "lns_online_demos",
  "Online Demos",
  "4_1_demos.html",
  "",
  [ ]
];

header_hashtable[ "Resource Center | Product Brochures"] =
[
  "topic_resource_center",
  "lns_product_brochures",
  "Product Brochures",
  "4_1_demos.html",
  "",
  [ ]
];

header_hashtable[ "Resource Center | Product Sheets"] =
[
  "topic_resource_center",
  "lns_product_sheets",
  "Product Sheets",
  "4_1_demos.html",
  "",
  [ ]
];

header_hashtable[ "Resource Center | White Papers"] =
[
  "topic_resource_center",
  "lns_white_papers",
  "White Papers",
  "4_1_demos.html",
  "",
  [ ]
];

header_hashtable[ "Resource Center | Speeches"] =
[
  "topic_resource_center",
  "lns_speeches",
  "Speeches",
  "7_1_calendar.html",
  "",
  [ ]
];



//================================================
// Third Level (under Newsroom >> Media Resources)
//================================================

header_hashtable[ "Newsroom | Media Resources | Media Contact"] =
[
  "sub_media_resources",
  "ln_media_contact",
  "Media Contact",
  "b_1_3_mediaresources.html#mediacontact",
  "",
  [ ]
];

header_hashtable[ "Newsroom | Media Resources | Company Overview"] =
[
  "sub_media_resources",
  "ln_company_overview",
  "Company Overview",
  "b_1_3_mediaresources.html#companyoverview",
  "",
  [ ]
];

header_hashtable[ "Newsroom | Media Resources | Product Information"] =
[
  "sub_media_resources",
  "ln_product_information",
  "Product Information",
  "b_1_3_mediaresources.html#productinformation",
  "",
  [ ]
];

header_hashtable[ "Newsroom | Media Resources | VMS Logos"] =
[
  "sub_media_resources",
  "ln_vms_logos",
  "VMS Logos",
  "b_1_3_mediaresources.html#logos",
  "",
  [ ]
];

header_hashtable[ "Newsroom | Media Resources | Management Team"] =
[
  "sub_media_resources",
  "ln_management_team",
  "Management Team",
  "a_1_2_team.html",
  "",
  [ ]
];




//============================================================================
// Footer Nav data
//============================================================================

var footer_nav_bar =
[
  [
    "Home",
    "home.gif",
    "index.html",
    "29"
  ],
  [
    "FAQ",
	"faq.gif",
	"e_1_faq.html",
	"25"
  ],
  [
    "Site Map",
	"site_map.gif",
    "f_1_sitemap.html",
    "42"
  ],
  [
    "Legal Terms",
    "legal_terms.gif",
    "g_1_legal.html",
    "63"
  ],
  [
    "Privacy Policy",
    "privacy_policy.gif",
    "h_1_privacy.html",
    "70"
  ]
 ];



//============================================================================
// Support for dynamic popup menus (for this version for header nav only)
//============================================================================

var simpleTableAttrs = new Array( 'cellspacing', '0',
                                  'cellpadding', '0',
                                  'border',      '0');

var AllMenus         = new Object();
var AllMenuTabs      = new Object();
var AllMenusByTab    = new Object();
var AllMenuBehaviors = new Object();
var AllMenuZones     = new Object();

if (  document.all
 && ! document.getElementById)
{
  document.getElementById = function( id)
    { return document.all[ id]; }
}

var agentString = navigator.userAgent.toLowerCase();

var OPERA   = (  agentString.indexOf( 'opera') != -1                 );
var IE_JUNK = ( (agentString.indexOf( 'msie' ) != -1) && ( ! OPERA ) );
var MAC     = (  agentString.indexOf( 'mac'  ) != -1                 );

var _tpNS = (document.all ? false : true);



function getOffsetLeft( el)
{
  var sl = el;
  var ol = el.offsetLeft;
  var sh = 0;

  while ((el=el.offsetParent) != null)
  {
    ol += el.offsetLeft;

    if (el.offsetParent
     && el.offsetParent.offsetParent)
    {
      var scrollLeft = el.offsetParent.scrollLeft;

      if (! isNaN( scrollLeft))
        { sh -= scrollLeft; }
    }
  }

  el = sl;

  if (_tpNS)
  {
    while ((el=el.parentNode) != null)
    {
      if (el.parentNode
       && el.parentNode.parentNode
       && !(el.parentNode.tagName
         && el.parentNode.tagName.toUpperCase() == "BODY"))
      {
        var scrollLeft = el.parentNode.scrollLeft;

        if (!isNaN( scrollLeft)
         && scrollLeft > 0     )
          { sh -= scrollLeft; }
      }
    }
  }

  return (ol + sh);
}



function getElementLeft( id)
{
  var el = document.getElementById( id);

  return getOffsetLeft( el);
}



function imgURL( imgName)
  { return ('images/home/' + imgName); }

function btnURL( id)
  { return ('images/home/' + id + '_btn.gif'); }

function btnHoverURL( id)
  { return ('images/home/' + id + '_hov_btn.gif'); }



function attrGen( addrNameValueList)
{
  var list = ' ';

  for (var i=0; i<addrNameValueList.length; i+=2)
  {
    list += ' '
          + addrNameValueList[ i]
          + '="'
          + addrNameValueList[ i + 1]
          + '"';
  }

  return list;
}



function div( attrs)
{
  var html = '<div ' + attrGen( attrs) + '>';

  for (var i=1; i<div.arguments.length; i++)
    { html += div.arguments[ i]; }

  html += '</div>';

//alert( html);

  return html;
}



function td( attrs)
{
  var html = '<td ' + attrGen( attrs) + '>';

  for (var i=1; i<td.arguments.length; i++)
    { html += td.arguments[ i]; }

  html += '</td>';

//alert( html);

  return html;
}



function a( attrs)
{
  var html = '<a ' + attrGen( attrs) + '>';

  for (var i=1; i<a.arguments.length; i++)
    { html += a.arguments[ i]; }

  html += '</a>';

//alert( html);

  return html;
}



function select_tag( attrs,
                     options)
{
  var html = '<select ' + attrGen( attrs) + '>';

  for (var i=0; i<options.length; i++)
    { html += options[ i]; }

  html += '</select>';

//alert( html);

  return html;
}



function img( attrs)
  { return ('<img '+ attrGen( attrs) + '/>'); }



function SingleRowTable( attrs)
{
  var html = '<table ' + attrGen( attrs) + '>' + '<tbody><tr>';

  for (var i=1; i<SingleRowTable.arguments.length; i++)
    { html += SingleRowTable.arguments[ i]; }

  html += '</tr></tbody></table>';

  return html;
}



function MultiRowTable( attrs)
{
  var html = '<table ' + attrGen( attrs) + '>' + '<tbody>';

  for (var i=1; i<MultiRowTable.arguments.length; i++)
    { html += '<tr>' + MultiRowTable.arguments[ i] + '</tr>'; }

  html += ' </tbody></table>';                      

  return html;
}



function MultiRowTableFromArray( attrs,
                                 rows)
{
  var html = '<table ' + attrGen( attrs) + '>' + '<tbody>';

  for (var i=0; i<rows.length; i++)
    { html += '<tr>' + rows[i] + '</tr>'; }

  html += '</tbody></table>';

  return html;
}



function Styles()
{
  var styles = new Object();

  for (i=0; i<Styles.arguments.length; i+=2)
    { styles[ Styles.arguments[ i]] = Styles.arguments[ i + 1]; }

  return styles;
}



function setElementStyles( id,
                           styles)
{
  var el = document.getElementById( id);

  if (el)
  {
    for (styleName in styles)
    {
//alert( "setElementStyles - key: " + styleName + ", value: " + styles[ styleName]);

      el.style[ styleName] = styles[ styleName];
    }
  }
}



var hiddenStyle     = Styles( 'visibility', 'hidden');
var unHiddenStyle   = Styles( 'visibility', 'visible');



function setElementClass( id,
                          className)
{
  var el = document.getElementById( id);

  if (el)
    { el.className = className; }
}



function unHideAndPositionElement( id,
                                   t,
                                   l)
{
  var el = document.getElementById( id);

  if (el)
  {
    el.style.left       = (l + 'px');
    el.style.visibility = "visible";
  }
}



function mtGenKey( menuTab)
  { return (menuTab.parentId + ':' + menuTab.id); }

function mtLookup( menuTabId)
  { return AllMenuTabs[ menuTabId]; }

function mtGetParent( menuTab)
  { return AllMenus[ menuTab.parentId]; }

function mtGetChild( menuTab)
{
  if (menuTab.childId == '')
    { return 0; }

  return AllMenus[ menuTab.childId];
}

function mtGetImgElement( menuTab)
{
  if (menuTab.buttonElement == 0)
    { menuTab.buttonElement = document.getElementById( menuTab.buttonId); }

  return menuTab.buttonElement;
}

function mtSetHoverImage( menuTab)
  { mtGetImgElement( menuTab).src = menuTab.hoverImageName; }

function mtSetStandardImage( menuTab)
  { mtGetImgElement( menuTab).src = menuTab.standardImageName; }

function mtSetHoverStyle( menuTab)
{
  if (menuTab.hoverClass)
    { setElementClass( menuTab.buttonId, menuTab.hoverClass); }
}

function mtSetStandardStyle( menuTab)
{
  if (menuTab.standardClass)
    { setElementClass( menuTab.buttonId, menuTab.standardClass); }
}

function ShowSubMenu( menuTab)
  { setElementStyles( menuTab.childId, unHiddenStyle); }

function HideSubMenu( menuTab)
  { setElementStyles( menuTab.childId, hiddenStyle); }



function BAR_ShowSubMenu( menuTab)
{
//alert( "BAR_ShowSubMenu for: " + menuTab.childId);

  var childMenu  = AllMenus[ menuTab.childId];
  var myLeft     = getElementLeft( menuTab.buttonId);
  var parentLeft = getElementLeft( menuTab.parentId);
  var childTop   = 0;   // not actually using this right now
  var childLeft  = (myLeft - parentLeft);

//alert( "BAR_HighlightMM() parentLeft " + parentLeft + " / myLeft " + myLeft + " / childleft  " + childLeft);

  unHideAndPositionElement( menuTab.childId, childTop, childLeft);
}



function BAR_ShowSubSubMenu( menuTab)
{
//alert( "BAR_ShowSubMenu for: " + menuTab.childId);

  var childMenu    = AllMenus[ menuTab.childId];
  var refElement   = document.getElementById( menuTab.id);
  var myLeft       = getElementLeft(          menuTab.buttonId);
  var parentLeft   = getElementLeft(          menuTab.parentId);
  var parentHeight = refElement.offsetHeight;
  var parentWidth  = refElement.offsetWidth;
  var childLeft    = ((myLeft - parentLeft) + parentWidth);

//alert( "BAR_ShowSubSubMenu refElement .className: " + refElement.className + " offsetWidth: " + refElement.offsetWidth);
//alert( "BAR_ShowSubSubMenu parentLeft " + parentLeft + " / myLeft " + myLeft + " / childleft  " + childLeft);

  var childElement = document.getElementById( menuTab.childId);

  if (childElement)
  {
    if (! IE_JUNK
     && childElement.style.top == '')
    {
      var childTop = (childElement.offsetTop - parentHeight);

      childElement.style.top = (childTop + 'px');
    }

    childElement.style.left       = (childLeft + 'px');
    childElement.style.visibility = "visible";
  }
}



function FindMenuZone( menuType)
{
  for (menuZoneKey in AllMenuZones)
  {
    menuZone = AllMenuZones[ menuZoneKey];

    // Look to see if our Zone name is within the MenuBehavior type (name)

    if (menuType.indexOf( menuZoneKey,0) >= 0)
      { return menuZone; }
  }

  alert( "Could not find a MenuZone for menu type: " + menuType);

  return FindMenuZone( 'VOID');
}



function mtLight( menu,
                  menuTab)
{
  menu.behavior.tab.hoverDraw( menuTab);           // light up this tab

  if (menuTab.childId != '')
    { menu.behavior.tab.showSubMenu( menuTab); }   // bring up submenu

  // can only be one lit tab per menu; remember it

  menu.litTab = menuTab;
}



function mtUnLight(menu, menuTab)
{
  menu.behavior.tab.standardDraw( menuTab);        // unlight this tab

  if (menuTab.childId != '')
    { menu.behavior.tab.hideSubMenu( menuTab); }   // take down submenu

  menu.litTab = 0;                                 // we ain't lit no more
}



function mzActivate( menu,
                     menuTab)
{
  menu.zone.over = true;   // entering tab, so over zone

  // if other tab was active, take it down

  menu.zone.DeactivateDescendents( menu);

  if (menu.zone.topLevelMenu == 0)       // if this is the first menu seen,
    { menu.zone.topLevelMenu = menu; }   // remember it as the top level menu

  mtLight( menu, menuTab);   // light this tab
}



function mzDeactivate( menu,
                       menuTab)
{
  menu.zone.over = false;   // leaving tab, so not 'over' zone anymore
                            // (though it may immediately re-enter
                            //  zone if mouse rolls over another tab)

  if (menu.zone.timeoutInMS == 0)   // No timeout? Take down menu *immediately*
    { menu.zone.DeactivateAll( menu); }
  else                              // Take down menu after timeout
  {
    if (menu.zone.timer != 0)   // if timer active, take it down
      { window.clearTimeout( menu.zone.timer); }
                          
    // start new timer for full term

    menu.zone.timer = window.setTimeout( "TimeOutMenu('"
                                       + menu.id
                                       + "');",
                                         menu.zone.timeoutInMS);
  }
}



function mzDeactivateDescendents( menu)
{
  while (menu
      && menu.litTab != 0)   // the menu remembers the lit tab
  {
    var lit = menu.litTab;

    mtUnLight( menu, menu.litTab);  // unlight it

    if (menu.zone.topLevelMenu
     && menu.zone.topLevelMenu.id == menu.id)
      { menu.zone.topLevelMenu = 0; }

    menu = mtGetChild( lit);   // descend through sub-menus
  }
}



function mzDeactivateAll( menu)
{
  if (menu.zone.over)   // if over any tab in zone, forget it
    { return; }

  menu.zone.DeactivateDescendents( menu.zone.topLevelMenu);
}



function MenuZone( zone,
                   timeout)
{
  menuZone = new Object();

  menuZone.zone                  = zone;

  menuZone.timer                 = 0;
  menuZone.timeoutInMS           = timeout;

  menuZone.over                  = false;
  menuZone.topLevelMenu          = 0;

  menuZone.Activate              = mzActivate;
  menuZone.Deactivate            = mzDeactivate;
  menuZone.DeactivateDescendents = mzDeactivateDescendents;
  menuZone.DeactivateAll         = mzDeactivateAll;

  AllMenuZones[ zone] = menuZone;
}



function TimeOutMenu( menuId)
{
  var menu = AllMenus[ menuId];

  menu.zone.timer = 0;              // mark timer 'not in use'
  menu.zone.DeactivateAll( menu);   // take down all menus in zone
}



function mouseOverTab( menu,
                       menuTab)
  { menu.zone.Activate( menu, menuTab); }

function mouseOffTab( menu,
                      menuTab)
  { menu.zone.Deactivate( menu, menuTab); }



function TabAction( actionKey,
                    menuTabId)
{
  var menu    = AllMenusByTab[     menuTabId];
  var menuTab = AllMenuTabs[       menuTabId];
  var Action  = menu.behavior.tab[ actionKey];

  if (Action)
    { Action( menu, menuTab); }
}



function genTabActionCall( actionKey,
                           menuTab)
  { return "TabAction('" + actionKey + "','" + mtGenKey( menuTab) + "')"; }



function createRolloverLink( menuTab)
{
  return a( new Array( 'href',
                       menuTab.href,
                       'onmouseover',
                       genTabActionCall( 'mouseOn',
                                         menuTab),
                       'onmouseout',
                       genTabActionCall( 'mouseOff',
                                         menuTab)   ),
            img( new Array( 'src',
                            menuTab.standardImageName,
                            'alt',
                            menuTab.alt,
                            'id',
                            menuTab.buttonId)         ));
}



function createTextRolloverLink( menuTab)
{
  return a( new Array( 'href',
                       menuTab.href,
                       'style',
                       'text-decoration: none;',
                       'onmouseover',
                       genTabActionCall( 'mouseOn',
                                         menuTab),
                       'onmouseout',
                       genTabActionCall( 'mouseOff',
                                         menuTab)   ),
            div( new Array( 'class',
                            menuTab.standardClass,
                            'id',
                            menuTab.buttonId),
                 menuTab.alt                      )   );
}



function generateNavTab( menuTab)
{
  var html = createRolloverLink( menuTab);

//alert( html);

  return html;
}



function generateTextNavTab( menuTab)
{
  var html = createTextRolloverLink( menuTab);

//alert( html);

  return html;
}



function generateSpacerTabs( count)
{
  var spacer =
'<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';

  var html = '';

  for (var i=0; i<count; i++)
    { html += spacer; }

  return html;
}



function generateBARNavSubMenu( menu)
{
  var html     = '';
  var rows     = new Array();
  var rowCount = 0;

  for (var i=0; i<menu.tabCount; i++)
  {
    var menuTab = menu.orderedTabs[ i];

    if (menu.separatorTag != ''
     && i                 >  0 )
      { rows[ rowCount++] = td( new Array(), menu.separatorTag); }

    html =  menu.behavior.tab.generateHTML( menuTab);

    if (menuTab.childId != '')
    {
      var childMenu = AllMenus[ menuTab.childId];

      html += childMenu.behavior.generateHTML( childMenu);
    }

    rows[ rowCount++] = td( new Array( 'class',
                                       menu.behavior.tab.cssClass,
                                       'id',
                                       menuTab.id,
                                       'align',
                                       'center'),
                            html);
  }

  html = div( new Array( 'class',
                         menu.behavior.cssClass,
                         'id',
                         menu.id),
              MultiRowTableFromArray( simpleTableAttrs,
                                      rows)            );

//alert( html);

  return html;
}



function generateBARNavMenu( menu)
{
  var html        = '';
  var sub_html    = '';
  var main_html   = '';
  var hasSubMenus = false;

  main_html += generateSpacerTabs( menu.preSpace);

  for (var i=0; i<menu.tabCount; i++)
  {
    var menuTab = menu.orderedTabs[ i];

    if (menu.separatorTag != ''
     && i                 >  0 )
      { main_html += td( new Array(), menu.separatorTag); }

    main_html += td( new Array( 'align',
                                'center'),
                     menu.behavior.tab.generateHTML( menuTab));
  }

  main_html += generateSpacerTabs( menu.postSpace);

  main_html  = div( new Array( 'class',
                               menu.behavior.cssClass,
                               'id',
                               menu.id),
                    SingleRowTable( simpleTableAttrs,
                                    main_html)       );

  for (var i=0; i<menu.tabCount; i++)
  {
    var menuTab = menu.orderedTabs[ i];

    if (menuTab.childId != '')
    {
      var childMenu = AllMenus[ menuTab.childId];

      sub_html += childMenu.behavior.generateHTML( childMenu);

      hasSubMenus = true;
    }
  }

  if (hasSubMenus)
  {
    // NOTE !!!  Figure out how to auto-name this class!!!!!!

    sub_html = div( new Array( 'class',
                               'barnav_sub_spaceholder',
                               'id',
                               (menu.id + '_subarea')),
                    sub_html);

    if (menu.invertSubMenus)
      { html = sub_html + main_html; }
    else
      { html = main_html + sub_html; }
  }
  else
    { html = main_html; }

  return html;
}



function MenuBehavior( type,
                       generateHTML,
                       cssClass,
                       tabBehavior)
{
  var menuBehavior = new Object();

  menuBehavior.type         = type;
  menuBehavior.generateHTML = generateHTML;
  menuBehavior.cssClass     = cssClass;
  menuBehavior.tab          = tabBehavior;

  AllMenuBehaviors[ type] = menuBehavior;
}



function MenuTabBehavior( generateHTML,
                          cssClass,
                          mouseOn,
                          mouseOff,
                          onClick,
                          showSubMenu,
                          hideSubMenu,
                          standardDraw,
                          hoverDraw)
{
  var menuTabBehavior = new Object();

  menuTabBehavior.generateHTML = generateHTML;
  menuTabBehavior.cssClass     = cssClass;
  menuTabBehavior.mouseOn      = mouseOn;
  menuTabBehavior.mouseOff     = mouseOff;
  menuTabBehavior.onClick      = onClick;
  menuTabBehavior.showSubMenu  = showSubMenu;
  menuTabBehavior.hideSubMenu  = hideSubMenu;
  menuTabBehavior.standardDraw = standardDraw;
  menuTabBehavior.hoverDraw    = hoverDraw;

  return menuTabBehavior;
}



function noop()
  { }



MenuBehavior( 'BARNAV',
              generateBARNavMenu,
              'barnav',
              MenuTabBehavior( generateNavTab,
                               'barnav_tab',
                               mouseOverTab,
                               mouseOffTab,
                               noop,
                               BAR_ShowSubMenu,
                               HideSubMenu,
                               mtSetStandardImage,
                               mtSetHoverImage)    );

MenuBehavior( 'BARNAV_TEXT_SUBMENU',
              generateBARNavSubMenu,
              'barnav_sub_block',
              MenuTabBehavior( generateTextNavTab,
                               'barnav_sub_tab',
                               mouseOverTab,
                               mouseOffTab,
                               noop,
                               BAR_ShowSubSubMenu,
                               HideSubMenu,
                               mtSetStandardStyle,
                               mtSetHoverStyle)    );

MenuZone( 'BARNAV', 500);



function Menu( type,
               id,
               separatorTag)
{
  var fixedArgCount = 3;

  if (! AllMenuBehaviors[ type])
  {
    alert( "Menu " + id + " has invalid type: " + type);
    return;
  }

  var newMenu = new Object();

  newMenu.behavior       = AllMenuBehaviors[ type];
  newMenu.id             = id;
  newMenu.separatorTag   = separatorTag;
  newMenu.tabs           = new Object();   // will be filled in by submenu create function
  newMenu.tabCount       = 0
  newMenu.orderedTabs    = new Array( 30); // nav menu should not exceed this length anyway
  newMenu.preSpace       = 0;
  newMenu.postSpace      = 0;
  newMenu.invertSubMenus = false;
  newMenu.litTab         = 0;              // when a MenuTab gets lit up, remember it here
  newMenu.inZone         = '';
  newMenu.zone           = 0;              // until we know

  // These exist to support text-based tabs.  The Menu doesn't use
  // them, the MenuTabs do. This is only a place to set them centrally,
  // the MenuTabs inherit from here.

  newMenu.standardClass  = 'unspecified';  // unless and until we need these
  newMenu.hoverClass     = 'unspecified';

  // Process the varargs part of the argument list
  // These will be 'key=value' format, where 
  //  key is the menuTab var name  and  value gets put in that var

  for (var i=fixedArgCount; i<Menu.arguments.length; i++)
  {
    var keyValuePair = new Array();

    keyValuePair = Menu.arguments[i].split('=');

    if (keyValuePair[1])  // saw equals sign, successful split
      { newMenu[ keyValuePair[ 0]] = keyValuePair[ 1]; }
    else
    {
      alert( "Improperly formatted Key/Value param for menu '"
           + id
           + "': "
           + keyValuePair[ 0]);
    }
  }

  if (newMenu.inZone != '')
  {
    newMenu.zone = AllMenuZones[ newMenu.inZone];

    if (! newMenu.zone)
    {
      alert( "Menu "
           + id
           + " - inZone override - no MenuZone: "
           + newMenu.inZone);
    }
  }

  if (! newMenu.zone)   // if no override, join most appropriate zone
    { newMenu.zone = FindMenuZone( type); }

  AllMenus[ id] = newMenu;
}



var ButtonIdUniqueNumber = 1;

function MenuTab( parentId,
                  id,
                  alt,
                  href)
{
  var fixedArgCount = 4;
  var parentMenu    = AllMenus[ parentId];

  if (! parentMenu)
  {
    alert( "MenuTab " + id + " has no parent Menu: '" + parentId);
    return;
  }

  if (parentMenu.tabs[ id])
  {
    alert( "Attempting to redefine MenuTab " + id + " in Menu: '" + parentId);
    return;
  }

  var newMenuTab = new Object();

  newMenuTab.parentId          = parentId;
  newMenuTab.id                = id;
  newMenuTab.alt               = alt;
  newMenuTab.href              = href;
  newMenuTab.buttonId          = id + '_b' + ButtonIdUniqueNumber;
  newMenuTab.standardImageName = btnURL(      id);
  newMenuTab.hoverImageName    = btnHoverURL( id);
  newMenuTab.buttonElement     = 0;
  newMenuTab.childId           = '';

  ButtonIdUniqueNumber++;

  // These exist to support text-based tabs -
  // These are initially inherited from the parent.  The parent doesn't
  // use them, it just provides a convenient place to set them once for
  // all tabs in the menu - the usual case.  If you're doing something
  // tricky like varying tab colors within the menu, you can override
  // them on a tab-by-tab basis, in the varargs processing below.

  newMenuTab.standardClass     = parentMenu.standardClass;
  newMenuTab.hoverClass        = parentMenu.hoverClass;

  // Process the varargs part of the argument list
  // These will be 'key=value' format, where 
  //  key is the menuTab var name  and  value gets put in that var
  // If it is just a 'value', that will get stuffed into childId
  // so we are backward-compatible with older menus

  for (var i=fixedArgCount; i<MenuTab.arguments.length; i++)
  {
    var keyValuePair = new Array();

    keyValuePair = MenuTab.arguments[ i].split( '=');

    if (keyValuePair[ 1])   // saw equals sign, successful split
      { newMenuTab[ keyValuePair[ 0]] = keyValuePair[ 1]; }
    else // assume any non key=value param is childId, for backward compatibility
      { newMenuTab.childId            = keyValuePair[ 0]; }
  }

  parentMenu.tabs[ id] = newMenuTab;

  // normally the .tabs[] hash would be enough, but we want 
  // to emit the menu tabs in the order that they were found.

  parentMenu.orderedTabs[ parentMenu.tabCount++] = newMenuTab;

  AllMenuTabs[ mtGenKey( newMenuTab)] = newMenuTab;

  // need a quick way to look up the menu the tab belongs to

  AllMenusByTab[ mtGenKey( newMenuTab)] = parentMenu;
}



function InsertMenuHere( menuId)
{
  var menu = AllMenus[ menuId];

  if (! menu)
  {
    alert( "Attempting to insert a nonexistent Menu: '" + menuId + "'");
    return;
  }

  document.write( menu.behavior.generateHTML( menu));

// var out = menu.behavior.generateHTML( menu);
//
// alert(          out);
// document.write( out);
}



//============================================================================
// Header Nav logic
//============================================================================

function new_emit_header_nav_bar()
{
  //===============================================
  // Load header nav arrays into header nav objects
  //===============================================

  Menu( header_root[ 0],
        header_root[ 1],
        header_root[ 2],
        header_root[ 3],
        header_root[ 4]);

  var child = header_root[ 5];

  //=========================
  // First Level (under root)
  //=========================

  if (child.length > 0)
  {
    for (var ii=0; ii<child.length; ii++)
    {
      var child_tab = header_hashtable[ child[ ii]];

      MenuTab( child_tab[ 0],
               child_tab[ 1],
               child_tab[ 2],
               child_tab[ 3],
               child_tab[ 4]);

      var gchild = child_tab[ 5];

      if (gchild.length > 0)
      {
        Menu( 'BARNAV_TEXT_SUBMENU',
              child_tab[ 4],
              '',
              'standardClass=barnav_sub_std_tab',
              'hoverClass=barnav_sub_hov_tab');

        for (var jj=0; jj<gchild.length; jj++)
        {
          var gchild_tab = header_hashtable[ gchild[ jj]];

          MenuTab( gchild_tab[ 0],
                   gchild_tab[ 1],
                   gchild_tab[ 2],
                   gchild_tab[ 3],
                   gchild_tab[ 4]);

          var ggchild = gchild_tab[ 5];

          if (ggchild.length > 0)
          {
            Menu( 'BARNAV_TEXT_SUBMENU',
                  gchild_tab[ 4],
                  '',
                  'standardClass=barnav_sub_std_tab',
                  'hoverClass=barnav_sub_hov_tab');

            for (var kk=0; kk<ggchild.length; kk++)
            {
              var ggchild_tab = header_hashtable[ ggchild[ kk]];

              MenuTab( ggchild_tab[ 0],
                       ggchild_tab[ 1],
                       ggchild_tab[ 2],
                       ggchild_tab[ 3],
                       ggchild_tab[ 4]);
            }
          }
        }
      }
    }
  }

  //=====================================================
  // Use logic styled after last year's support.js module
  //=====================================================

  InsertMenuHere( 'head_nav');
}



var header_nav_bar1 =
[
  '<table width="750" border="0" align="center" bgcolor="white" cellspacing="0" cellpadding="0">',
    '<tr align="center" class="SideNavBackgroundColor">',
      '<td height="5"></td>',
      '<td height="5"></td>',
    '</tr>',
    '<tr>',
      '<td width="139"><a href="index.html"><img src="images/VMS_logo.gif" alt="VMS Logo"',
                          ' width="139" height="79" /><a/></td>',
      '<td width="611" align="right" valign="middle">',
        '<table align="center" border="0" cellspacing="0" cellpadding="8">',
          '<tr>'
];

var header_nav_bar2 =
[
          '</tr>',
        '</table>',
      '</td>',
    '</tr>',
  '</table>',
  '<table width="750" border="0" cellspacing="0" cellpadding="0">',
    '<tr class="SideNavBackgroundColor">',
      '<td height="3"></td>',
    '</tr>',
    '<tr><td>'
];

var header_nav_bar3 =
[
    '</td></tr>',
  '</table>',
  '<table width="750" border="0" cellpadding="0" cellspacing="0">',
    '<tr>',
      '<td width="178" class="HeaderSpacerLightBlue">&nbsp;</td>',
      '<td width="2" height="25" class="HeaderSpacerLightBlue">&nbsp;</td>',
      '<td width="570" class="HeaderSpacerLightBlue">&nbsp;</td>',
    '</tr>',
  '</table>'
];

function emit_header_nav_bar()
{
  var home_image = 'Inner';

  if (arguments.length > 0
   && (arguments[ 0] == "Home"
    || arguments[ 0] == "Home_static"))
    { home_image = arguments[ 0]; }

  //==================
  // Emit block prefix
  //==================

  for (var ii=0; ii<header_nav_bar1.length; ii++)
    { document.write( header_nav_bar1[ ii]); }

  //================
  // Emit menu block
  //================

  document.write( '<td>');
  new_emit_header_nav_bar();
  document.write( '</td>');

  //==========================================
  // Emit block suffix, including header image
  //==========================================

  for (var ii=0; ii<header_nav_bar2.length; ii++)
    { document.write( header_nav_bar2[ ii]); }

  if      (home_image == "Home")
  {
    document.write( '<OBJECT'
                    + ' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
                    + ' codebase="http://download.macromedia.com/pub/shockwave'
                    + '/cabs/flash/swflash.cab#version=6,0,0,0"'
                    + ' WIDTH="750"'
                    + ' HEIGHT="90"'
                    + ' id="headerImageAnimation"'
                    + ' ALIGN="center">'
                    + ' <PARAM NAME="movie"'
                    + ' VALUE="header_flash.swf"></PARAM>'
                    + ' <PARAM NAME="quality"'
                    + ' VALUE="high"></PARAM>'
                    + ' <PARAM NAME="bgcolor"'
                    + ' VALUE="#FFFFFF"></PARAM>'
                    + ' <PARAM NAME="wmode"'
                    + ' VALUE="opaque"></PARAM>'
                    + ' <EMBED src="header_flash.swf"'
                    + 'quality="high"'
                    + 'bgcolor="#FFFFFF"'
                    + 'wmode="opaque"'
                    + 'WIDTH="750"'
                    + 'HEIGHT="90"'
                    + 'NAME="headerImageAnimation"'
                    + 'ALIGN="center"'
                    + 'TYPE="application/x-shockwave-flash"'
                    + 'PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">'
                    + '</EMBED>'
                    + ' </OBJECT>');
  }
  else if (home_image == "Home_static")  // Left it, but it doesn't make sense!
  {
    document.write( '<img src="images/header.jpg" alt="Header Graphic"'
                  + ' width="750" height="90" />');
  }
  else
  {
    document.write( '<img src="images/header_small.jpg" alt="Header Graphic"'
                  + ' width="750" height="90" />');
  }

  for (var ii=0; ii<header_nav_bar3.length; ii++)
    { document.write( header_nav_bar3[ ii]); }
}



//============================================================================
// Footer Nav logic
//============================================================================

var footer_nav_bar1 =
[
      '</td>',
    '</tr>',
  '</table>',
  '<table width="750" border="0" cellpadding="0" cellspacing="0" align="center">',
    '<tr>',
      '<td width="179" class="FooterDarkBlue"></td>',
      '<td width="2" height="25">&nbsp;</td>',
      '<td width="569" align="right" class="FooterLightColor">',
        '<table border="0" align="right" cellpadding="0" cellspacing="0" align="center">',
          '<tr>',
            '<td><img src="images/vms_logo_footer.gif" alt="VMS Logo"',
                    ' width="58" height="32" /></td>'
];

var footer_nav_bar2 =
[
        '</tr>',
      '</table>',
    '</td></tr>',
  '</table><table width="750" border="0" cellpadding="0" cellspacing="0" align="center"><tr><td><div align="right" style="padding-top: 5px;">Copyright© VMS</div></td></tr></table>'
];

function emit_footer_nav_bar()
{
  //==================
  // Emit block prefix
  //==================

  for (var ii=0; ii<footer_nav_bar1.length; ii++)
    { document.write( footer_nav_bar1[ ii]); }

  //=================
  // Emit block items
  //=================

  for (var ii=0; ii<footer_nav_bar.length; ii++)
  {
    document.write( '<td><a href="'
                  + footer_nav_bar[ ii][ 2]
                  + '"><img src="images/'
                  + footer_nav_bar[ ii][ 1]
                  + '" alt="'
                  + footer_nav_bar[ ii][ 0]
                  + '" width="'
                  + footer_nav_bar[ ii][ 3]
                  + '" height="32" border="0" /></a></td>');
  }

  //==================
  // Emit block suffix
  //==================

  for (var ii=0; ii<footer_nav_bar2.length; ii++)
    { document.write( footer_nav_bar2[ ii]); }
}


