function init() {
  var sfEls = document.getElementById("menu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
	  if (sfEls[i].id.length > 0) {         // Only the top level li elements have an id
	    
		  sfEls[i].onmouseover = function() {
			  this.className += "sfhover";
			  TIMEOUT_ID = setTimeout(menuOpen,1200);
		  }
		  sfEls[i].onmouseout = function() {
			  this.className = "";
			  clearTimeout(TIMEOUT_ID);
		  }
		  sfEls[i].childNodes[0].onclick = menuToggle;
		}	
	}
	
	var as, popfun;
	as=document.getElementsByTagName('a');
	for (var i=0; i<as.length; i++) {
		if(as[i].target) {
			popfun=function(){
		    var width = 600;
	      var height = 500; 
        var left = (screen.width - width) / 2;
        var top = (screen.height - height) / 3;
        var windowAttributes = 'width='+width+',height='+height+',left='+left+',top='+top+',scrollbars=no,location=no,toolbar=no,status=yes,resizable=yes';
				var theWindow = window.open(this.href,this.target,windowAttributes);
				theWindow.focus();
				return false;
			}			
			as[i].onclick=popfun;
		}
	}
}

function menuOpen() {
  document.getElementById('header').className = 'expanded';
	return false;
}

function menuToggle() {
  if (document.getElementById('header').className == 'expanded') {
    document.getElementById('header').className = '';
  } else {
    document.getElementById('header').className = 'expanded';
  }
  clearTimeout(TIMEOUT_ID);
	return false;
}

    
var TIMEOUT_ID = 0;
addEvent(window, "load", init, false);   

    
function addEvent(elm, evType, fn, useCapture)
// cross-browser event handling for IE5+,  NS6 and Mozilla
// by Scott Andrew
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
} 