/*
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
*/
function errorIgnore()  {
  return true;
}

//onerror = errorIgnore;

openLayers = new Array();
defaultTime = 350;
timerID = '';

//MV 2004-08-31 new menuimage functions
function swapImage(id, newSrc) {
    var theImage = FWFindImage(document, id, 0);
    if (theImage) {
        theImage.src = newSrc;
    }
}

/* Functions that track and set toggle group button states. */

function FWFindImage(doc, name, j) {
    var theImage = false;
    /* EH: now uses id instead of name attribute */
    if (theImage = doc.getElementById(name)) {
	    return theImage;
    }
    if (doc.images) {
        theImage = doc.images[name];
    }
    if (theImage) {
        return theImage;
    }
    if (doc.layers) {
        for (j = 0; j < doc.layers.length; j++) {
            theImage = FWFindImage(doc.layers[j].document, name, 0);
            if (theImage) {
                return (theImage);
            }
        }
    }
    return (false);
}

function getElemRoot(elemId)  {
  isComp = true;
  if (document.layers)  {
    isComp = false;
    }
  else if (document.all)  {
    elemRoot = document.all[elemId];
    }
  else if (document.getElementById) {
    elemRoot = document.getElementById(elemId);
    }
  else  {
    isComp = false;
    }

}

function frameElemRoot(framename,elemId)  {
  isComp = true;
  if (framename.document.layers)  {
    isComp = false;
    }
  else if (framename.document.all)  {
    elemRoot = framename.document.all[elemId];
    }
  else if (framename.document.getElementById) {
    elemRoot = framename.document.getElementById(elemId);
    }
  else  {
    isComp = false;
    }

}

function doItNow(elemId,styleObj,styleVal)  {
  getElemRoot(elemId);
  if (isComp) {
    elemRoot.style[styleObj] = styleVal;
    }
  }

function doItLater(elemId,styleObj,styleVal,timerVal) {
  if (timerVal) {
    thisTimeout = timerVal;
    }
  else  {
    thisTimeout = defaultTime;
    }
  timerID = setTimeout("doItNow('" + elemId + "','" + styleObj + "','" + styleVal + "')",thisTimeout);
  }

function openBranch(blockID) {
  openLayers.push(blockID);
  doItNow(blockID,'visibility','visible');
}

function closeBranches()  {
  for (i=0;i = openLayers.length; i++)  {
    layerID = openLayers.pop();
    doItNow(layerID,'visibility','hidden');
  }
  openLayers = new Array();
}

function closeLayers(thisLayer) {
  tempLayers = openLayers;
  for (i=0;i = openLayers.length; i++)  {
    layerID = tempLayers.pop();
    if(layerID!=thisLayer)  {
      doItNow(layerID,'visibility','hidden');
    } else  {
      tempLayers.push(layerID);
      openLayers = tempLayers;
      break;
    }
  }
}

function closeBranchesDelay(thisTimeout)  {
  timerID = setTimeout("closeBranches()",thisTimeout);
}

function resetTimer() {
  //alert();
  clearTimeout(timerID);
}
function styleChange(objId,fieldId)  {
  getElemRoot(fieldId);
  if (isComp) {
    stVal = elemRoot.value;
    doItNow(objId,fieldId,stVal);
    }
  }


function doMouseOver(menuRoot,menuCurrent) {
  clearTimeout(timerID);
  if(menuRoot=='')  {
    closeLayers();
  } else  {
    closeLayers(menuRoot);
  }
  if(menuCurrent!='') {
    openBranch(menuCurrent);
  }
  return true;
}

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;