var currentBG;



function initTopNavDropdown(){
    var getMenuContainer = document.getElementById('topnav');
    var getMenuItem = getMenuContainer.getElementsByTagName('li');
    
    for(i=0; i<getMenuItem.length; i++){
        var getSubMenuItem = getMenuItem[i].getElementsByTagName('ul');
        for(x=0; x<getSubMenuItem.length; x++){
            getMenuItem[i].onmouseover = function (){rollOver(this,true)}
            getMenuItem[i].onmouseout = function (){rollOver(this,false)} 
        }
    }
}

function rollOver(alt,out){
    for(y=0; y<alt.childNodes.length; y++){
        if(alt.childNodes[y].nodeName == "UL"){
            if(out){
                currentBG = alt.style.backgroundImage;
                //alt.style.backgroundColor = "#ffffff";
                //alt.style.backgroundImage = "none";
                alt.childNodes[y].style.display = "block";
            }else{
                //alt.style.backgroundColor = "#f5eb9d";
                //alt.style.backgroundImage = currentBG;
                alt.childNodes[y].style.display = "none";
            }
        }
    }
}


function initLinks() {
  for (i in document.links) {
    link = document.links[i];
    if (link.rel && link.rel.indexOf('external')!=-1) {
      link.onclick = onExternalLinkActivate;
      link.onkeypress = onExternalLinkActivate;
    }
  }
}

function onExternalLinkActivate() {
  window.open(this.href);
  return false;
}

//window.onload = initLinks;
//window.onload = initTopNavDropdown;


function start() { 
	  initLinks(); 
	  initTopNavDropdown(); 
	} 
	 
window.onload = start; 
