/**
 * Filename         : menu.js
 * Created by       : Peter Hammans
 * Last modified by : Peter Hammans
 * Created          : 10 March 2005 16:03
 * Last Updated     : 10 March 2005 16:04
 * Comments         : Navigation manipulation and handling of mouseover and mouseout events in context
 */

/**
 * Appends class names to mouseover drop down navigation elements for CSS to drive
 */
function cssMenu(sID){
 if(document.getElementById){
  oA = document.getElementById(sID).getElementsByTagName("LI");  
  for(i=0; i<oA.length; i++){
   node = oA[i];
   if(node.nodeName=="LI"){
    node.onmouseover=function(){
     this.className="hover";
    };
    node.onmouseout=function(){
     //for some reason the replace with a space next to class name fails in Firefox and MAC IE
     this.className=this.className.replace("hover","");    
    };
   };
  };
 };
};
/**
 * Handles mouseover and mouseout for hovering over the casestudy banners
 * Note: timeout required for operation due to Win IE bug
 */
function caseStudy(sID){
 if(document.getElementById){
  oElem = document.getElementById(sID)
  oContent = document.getElementById("content");
  if (oElem){
      oSpan = oElem.getElementsByTagName("span")[0];
      sInnerHTML = oSpan.innerHTML;
      oSpan.parentNode.removeChild(oSpan);
      if(sInnerHTML!="") {
          oCaseStudy = document.createElement("div");
          oCaseStudyNested = document.createElement("div");
          oCaseStudy.setAttribute("id","casestudytext");
          oCaseStudy.appendChild(oCaseStudyNested);
          oContent.insertBefore(oCaseStudy,oContent.firstChild); 
          oCaseStudyNested.innerHTML=sInnerHTML;
          window.oTimer = null;
          oElem.onmouseover=function(){
          clearTimeout(window.oTimer);
          document.getElementById("casestudytext").className = "hover";
       };
       oElem.onmouseout=function(){
       window.oTimer = window.setTimeout('document.getElementById("casestudytext").className = document.getElementById("casestudytext").className.replace("hover","")', 300);
   };
   oCaseStudyNested.onmouseover=function(){
    clearTimeout(window.oTimer);
    document.getElementById("casestudytext").className = "hover";
   };
   oCaseStudyNested.onmouseout=function(){
    window.oTimer = window.setTimeout('document.getElementById("casestudytext").className = document.getElementById("casestudytext").className.replace("hover","")', 300);
   };   
  };
  };
 };
};