/*************************************************************
* 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").firstChild;
   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

     //Now add hover class to subnav LIs
     navSubRootLength = node.childNodes.length;
     for (k = 0; k < navSubRootLength; k++) {
      nodeSub = node.childNodes[k];

      if (nodeSub.nodeName == "UL") {

       navSubULLength = nodeSub.childNodes.length;
       for (m = 0; m < navSubULLength; m++) {
        nodeLI = nodeSub.childNodes[m];

        nodeLI.onmouseover = function() {
         this.className += " hover";
        }//end function

        nodeLI.onmouseout = function() {
         this.className = this.className.replace(" hover", "");
        }//end function

       }//for

      }//end if

     }//end for

    }//end if

   }//end for

  }//end if

 }//end if

}//end function


function favFix() {
 var newLI = document.createElement('li');

 var newA = document.createElement('a');
 newA.setAttribute('href', 'javascript:void(false)');

 var newT = document.createTextNode('add to favourites');

 if (nodeActions = document.getElementById('actions')) {

  nodeActionsLength = nodeActions.childNodes.length;
  nodeActionsUL = false;

  for (j = 0; j < nodeActionsLength; j++) {
   node = nodeActions.childNodes[j];

   if (node.nodeName == 'UL') {
    nodeActionsUL = node;
   }//if

  }//for

  if (nodeActionsUL) {

   newA.appendChild(newT);
   newLI.appendChild(newA);

   if (window.sidebar) {
    nodeActionsUL.appendChild(newLI);
    nodeActionsUL.lastChild.onclick = function() {window.sidebar.addPanel(document.title,self.location,'')};

   } else if (window.external) {
    nodeActionsUL.appendChild(newLI);
    nodeActionsUL.lastChild.onclick = function() {window.external.AddFavorite(self.location,document.title)};

   } else if (window.opera) {
    nodeActionsUL.appendChild(newLI);
    nodeActionsUL.lastChild.onclick = function() {
         var e = document.createElement('a');
         e.setAttribute('href',self.location);
         e.setAttribute('title',document.title);
         e.setAttribute('rel','sidebar');
         e.click();
      }//function
   }//if

  }//if

 }//if

}//function

function newCode() {
 document.getElementById('captchaimage').attributes.getNamedItem('src').value = "captchaimage.php?src=" + String(Math.random());
}//function

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