/*************************************************************
* Window Onload Manager (WOM) v1.0
* Author: Justin Barlow - www.netlobo.com
*
* Description:
* The WOM library of functions allows you to easily call
* multiple javascript functions when your page loads.
*
* Usage:
* Add functions to WOM using the womAdd() function. Pass the
* name of your functions (with or without parameters) into
* womAdd(). Then call womOn() like this:
*     womAdd('hideDiv()');
*     womAdd('changeBg("menuopts","#CCCCCC")');
*     womOn();
* WOM will now run when your page loads and run all of the
* functions you have added using womAdd()
*************************************************************/
/*************************************************************
* The womOn() function will set the window.onload function to
* be womGo() which will run all of your window.onload
* functions.
*************************************************************/
function womOn(){
  window.onload = womGo;
}

function wumOn(){
  window.onunload = wumGo;
}
/*************************************************************
* The womGo() function loops through the woms array and
* runs each function in the array.
*************************************************************/
function womGo(){
  for(var i = 0;i < woms.length;i++)
    eval(woms[i]);
}

function wumGo(){
  for(var i = 0;i < wums.length;i++)
    eval(wums[i]);
}
/*************************************************************
* The womAdd() function will add another function to the woms
* array to be run when the page loads.
*************************************************************/
function womAdd(func){
  woms[woms.length] = func;
}

function wumAdd(func){
  wums[wums.length] = func;
}
/*************************************************************
* The woms array holds all of the functions you wish to run
* when the page loads.
*************************************************************/
var woms = new Array();
var wums = new Array();


/**
* Function to workaround the fact that Internet Explorer 6 and below does not support the CSS :hover pseudo class.
* The function cycles through all the list items which are a direct child of the 'nav' ul, and adds onmouseover and onmouseout events to change the css class
*/
navFix = function() {

 //Only add event handlers if browser is IE6 or lower
 if (document.all && !(document.documentElement && typeof document.documentElement.style.maxHeight!="undefined")) {

  if (document.getElementById("nav") && document.getElementById("nav").childNodes.length > 0) {

   navRoot = document.getElementById("nav");
   navRootLength = navRoot.childNodes.length;

   for (j = 0; j < navRootLength; j++) {
    node = navRoot.childNodes[j];

    if (node.nodeName == "LI") {
     node.onmouseover = function() {
      this.className += " hover";
     }//end function

     node.onmouseout = function() {
      this.className = this.className.replace(" hover", "");
     }//end function
/*
    nodeLILength = node.childNodes.length;

    for (n = 0; n < nodeLILength; n++) {
     nodeUL = node.childNodes[n];

     if (nodeUL.nodeName == "UL") {
      nodeUL.onmouseout = function() {
       this.parentNode.className = this.className.replace(" hover", "");
      }//end function
     }//if

    }//for
*/

    }//end if

   }//end for

  }//end if

 }//end if

}//end function

womAdd('navFix()');
womOn();
womGo();
