var outClass = '';

function init() {
	if (document.getElementById('mid')) {
		var middiv = document.getElementById('mid');
		var links = middiv.getElementsByTagName('li');
		for (var i = 0; i < links.length; i++) {
			addEvent(links[i], 'mouseover', midOver, false);
			addEvent(links[i], 'mouseout', midOut, false);
		}
		var middiv = document.getElementById('mid');
		outClass = middiv.className;
	}
	
	var as, popfun;
	as=document.getElementsByTagName('a');
	for (var i=0; i<as.length; i++) {
		if(as[i].target) {
			popfun=function(){
			  var width = 660; var height = 500;
			  if (this.target == 'register') { width = 530; var height = 680; }
				if (this.target == 'contact') { width = 450; 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=yes,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 midOver(e) {
	var target = window.event ? window.event.srcElement : e ? e.target : null;
	if (target.nodeName.toLowerCase() != 'li') target = target.parentNode;	
	
	var newClass = target.id;
	var middiv = document.getElementById('mid');
	middiv.className = newClass;
}

function midOut(e) {
  var middiv = document.getElementById('mid');
	middiv.className = outClass;
}

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 {
    elm['on' + evType] = fn;
  }
}

function ascendDOM(e, goal) {
	while (e.nodeName.toLowerCase() != goal && 
			e.nodeName.toLowerCase() != 'html')
		e = e.parentNode;		
	return (e.nodeName.toLowerCase() == 'html') ? null : e;
}