/*
    Script: nav-swap.js
    Copyright: Fishnet NewMedia (c) 2003
    Create: 01/02/04
    Version: 1
    Compatibility: JavaScript 1.2
    Scripts: none
    Changes: none
    Description: 

    This script initializes and executes two different
    document event handlers: onmouseover & onmouseout.
    Each event is assigned a function (method) to show
    or hide a category's subnavigation when the event
    is triggered by a supported DOM element.
*/

// Parse the navigator object for browser type and platform for compatibility
// Supported browsers include MSIE version 5+ and Netscape with Gecko version 1+

var useragent = navigator.userAgent;   // user agent string for the current browser.
var browser = navigator.appName;       // official name of the current browser
var platform = navigator.platform;     // platform on which the current browser is running
var product = navigator.product;       // product name of the current browser - for Netscape
var productsub = navigator.productSub; // build number of the current browser - for Netscape

var N = 0;	// Netscape
var M = 0	// MSIE

if (product == "Gecko" && Number(productsub) > 20020605){
	// Netscape with Gecko >= 1.0
	// supported browser
	N = 1;
}
else if (browser == "Microsoft Internet Explorer" && document.getElementById) {
	// MSIE version 5+
	// check platform
	if (platform.substring(0,3) == "MacPPC"){
	    // Macintosh
	    // check version
	    if(/MSIE ([0-9\.]+)/.test(useragent) && Number(RegExp.$1) >= 5.1){
	        // Mac MSIE version >= 5.1
	        // supported browser
	        M = 1;
	    }
	    else{
	        // Mac MSIE version < 5.1
	        // unsupported browser
	        M = 0;
	    }
	}
	else{
	    // Win MSIE version 5+
	    // supported browser
	    M = 1;
	}
}
else {
	// Not MSIE 5+ or Netscape with Gecko 1+
	// unsupported browser
	M = 0;
	N = 0;
}

var categories = ["about","investing","social"]

function ShowNav(evnt) {
   // the argument "evnt" is the event object for the event
   // the event object contains properties that describe a 
   // javascript event, and is passed as an argument to an 
   // event handler when the event occurs
   if (M) {
      // create reference to the event actuator object
      actuator = window.event.srcElement;
   }
   else if (N) { 
      // create reference to the event actuator object
      actuator = evnt.target;
   }
   // ignore all events from non-category DOM elements
   for (value in categories){
      // ignore all none category elements
      if (actuator.className && actuator.className.indexOf(categories[value]) != -1){
         if (document.getElementById(categories[value])) document.getElementById(categories[value]).style.visibility = "visible";
      }
   }
}
function HideNav(evnt) {
   // the argument "evnt" is the event object for the event
   // the event object contains properties that describe a 
   // javascript event, and is passed as an argument to an 
   // event handler when the event occurs
   if (M) {
      // create reference to the event actuator object
      actuator = window.event.srcElement;
   }
   else if (N) { 
      // create reference to the event actuator object
      actuator = evnt.target;
   }
   // ignore all events from non-category DOM elements
   for (value in categories){
      // ignore all none category elements
      if (actuator.className && actuator.className.indexOf(categories[value]) != -1){
         if (document.getElementById(categories[value])) document.getElementById(categories[value]).style.visibility = "hidden";
      }
   }
}

function InitEvents() {
   if (N){ // capture all of the following events
      if (document.captureEvents) document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
   }
   // initialize event handlers
   document.onmouseover = ShowNav;    // show the navigation
   document.onmouseout = HideNav;     // hide the navigation
}
