/*************************************************************
* 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 isDefined(variable) {
 return eval("(typeof("+variable+") != 'undefined');");
}//function

function initImages() {

  objImg = new Image();
  objImg.src = 'images/nav/home_on.gif';
  objImg = new Image();
  objImg.src = 'images/nav/about_on.gif';
  objImg = new Image();
  objImg.src = 'images/nav/approach_on.gif';
  objImg = new Image();
  objImg.src = 'images/nav/projects_on.gif';
  objImg = new Image();
  objImg.src = 'images/nav/news_on.gif';
  objImg = new Image();
  objImg.src = 'images/nav/links_on.gif';
  objImg = new Image();
  objImg.src = 'images/nav/contact_on.gif';
  objImg = new Image();
  objImg.src = 'images/home1.jpg';
  objImg = new Image();
  objImg.src = 'images/home2.jpg';
  objImg = new Image();
  objImg.src = 'images/home3.jpg';
  objImg = new Image();
  objImg.src = 'images/home4.jpg';
  objImg = new Image();
  objImg.src = 'images/home5.jpg';
  objImg = new Image();
  objImg.src = 'images/home6.jpg';
  objImg = new Image();
  objImg.src = 'images/shape_home.gif';
  objImg = new Image();
  objImg.src = 'images/shape_about.gif';
  objImg = new Image();
  objImg.src = 'images/shape_approach.gif';
  objImg = new Image();
  objImg.src = 'images/shape_projects.gif';
  objImg = new Image();
  objImg.src = 'images/shape_news.gif';
  objImg = new Image();
  objImg.src = 'images/shape_links.gif';
  objImg = new Image();
  objImg.src = 'images/shape_contact.gif';

}//function

navFix = function() {
/* The following workaround is to fix the fact that Internet
   Explorer 6 or below does not support the CSS :hover pseudo
   class. It 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, and make the menus work. */

 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() {
     if (document.all) {
      if (this.className.indexOf(' hover') == -1) {
       this.className += " hover";
      }//if
     }//if

     /*
     var nodeShape = document.getElementById('shape');
     var strShapeSrc = '';

     switch (this.id) {
      case "navHome":
       strShapeSrc = "images/shape_home.gif";
       break;
      case "navAbout":
       strShapeSrc = "images/shape_about.gif";
       break;
      case "navApproach":
       strShapeSrc = "images/shape_approach.gif";
       break;
      case "navProjects":
       strShapeSrc = "images/shape_projects.gif";
       break;
      case "navNews":
       strShapeSrc = "images/shape_news.gif";
       break;
      case "navLinks":
       strShapeSrc = "images/shape_links.gif";
       break;
      case "navContact":
       strShapeSrc = "images/shape_contact.gif";
       break;
     }//switch

     nodeNewShape = document.createElement('img');
     nodeNewShape.src = strShapeSrc;
     nodeNewShape.width = 67;
     nodeNewShape.height = 67;
     nodeNewShape.id = "shape2";
     document.getElementById('header').appendChild(nodeNewShape);
     */

    }//end function

    node.onmouseout = function() {
     if (document.all) {
      this.className = this.className.replace(" hover", "");
     }//if

     /*
     if (document.getElementById('shape2')) {
      document.getElementById('shape2').parentNode.removeChild(document.getElementById('shape2'));
     }//if
     */

    }//end function

   }//end if
  }//end for
 }//end if

}//end function

doBlocks = function() {
 if (nodeBlocks = document.getElementById("blocks")) {
  arrBlocks = nodeBlocks.getElementsByTagName('div');

  for (j = 0; j < arrBlocks.length; j++) {
   nodeBlock = arrBlocks[j];
   nodeBlockAnchor = nodeBlock.childNodes[0];

   nodeBlockAnchor.onmouseover = function() {
    var nodeBlocks = document.getElementById('blocks');
    var nodeBlockHover = document.getElementById(this.parentNode.id);
    var blockName = this.parentNode.id.replace('block', '');
    arrDivs = nodeBlocks.getElementsByTagName('div');

    for (i = 0; i < arrDivs.length; i++) {
     if (arrDivs[i].id != nodeBlockHover.id) {
      arrNodeImages = arrDivs[i].getElementsByTagName('img');

      for (k = 0; k < arrNodeImages.length; k++) {
       arrNodeImages[k].style.display = "none";
      }//for
     }//if
    }//for

    var nodeMessages = document.getElementById('messages');
    arrDivs = nodeMessages.getElementsByTagName('div');
    for (k = 0; k < arrDivs.length; k++) {
     arrDivs[k].style.display = "none";
    }//for

    var nodeMessage = document.getElementById('message' + blockName);
    nodeMessage.style.display = "block";

   }//end function

   nodeBlockAnchor.onmouseout = function() {
    var nodeBlocks = document.getElementById('blocks');
    arrDivs = nodeBlocks.getElementsByTagName('div');

    for (i = 0; i < arrDivs.length; i++) {
     arrNodeImages = arrDivs[i].getElementsByTagName('img');

     for (k = 0; k < arrNodeImages.length; k++) {
      arrNodeImages[k].style.display = "block";
     }//for
    }//for

    var nodeMessages = document.getElementById('messages');
    arrDivs = nodeMessages.getElementsByTagName('div');
    for (k = 0; k < arrDivs.length; k++) {
     arrDivs[k].style.display = "none";
    }//for

   }//end function

  }//for
 }//if
}//function

doThumbnails = function() {
 if (nodeThumbnails = document.getElementById("thumbnails")) {
  arrThumbnails = nodeThumbnails.getElementsByTagName('img');

  for (j = 0; j < arrThumbnails.length; j++) {

   arrThumbnails[j].onclick = function() {
    var imgID = this.id.replace('thumbnail', 'image');
    if (nodeImage = document.getElementById(imgID)) {

     nodeImages = document.getElementById("images");
     arrImages = nodeImages.getElementsByTagName('img');

     for (k = 0; k < arrImages.length; k++) {
      if (arrImages[k].id.indexOf('image') != -1) {
       arrImages[k].style.display = 'none';
      }//if
     }//for

     nodeImage.style.display = 'block';
    }//if
   }//function

  }//for

 }//if

 if (nodeImages = document.getElementById("images")) {
  arrImages = nodeImages.getElementsByTagName('img');

  for (k = 1; k < arrImages.length; k++) {
   if (arrImages[k].id.indexOf('image') != -1) {
    arrImages[k].style.display = 'none';
   }//if
  }//for
 }//if

}//function

womAdd('initImages()');
womAdd('navFix()');
womAdd('doBlocks()');

if (isDefined('blnDoBlocks') && eval('blnDoBlocks')) {
 womAdd('doThumbnails()');
}//if

womOn();
womGo();
