var bLoaded = false;
var cNav

var newWin = null;
function openWin(url, w, h) {
	var props = "width=" + w + ",height=" + h + ",toolbar=no,menubar=no,personalbar=no,copyhistory=no,scrollbars=yes";
	var handle = "oNewWin";
	if(newWin && !newWin.closed) {
		newWin.focus();
	}
	newWin = window.open(url, handle, props);
}

function mouseOver(obj) {
	if(!bLoaded) return false;
	var sPath = obj.src.substring( 0, obj.src.lastIndexOf('/') +1 );
	var sImg = obj.src.substring(obj.src.lastIndexOf('/') +1, obj.src.lastIndexOf('.'));
	if(sImg.indexOf('_on') == -1) obj.src = sPath + sImg + "_on.gif";
}

function mouseOut(obj) {
	if(!bLoaded) return false;
	var sPath = obj.src.substring( 0, obj.src.lastIndexOf('/') +1 );
	var sImg = obj.src.substring(obj.src.lastIndexOf('/') +1, obj.src.lastIndexOf('.'));
	if(sImg.indexOf('_on') != -1) obj.src = sPath + sImg.replace('_on', '') + ".gif";
}

function attachMouseEvents() {
	for(var n=0; n<cNav.length; n++) {
		// no mouse events on active buttons
		if(cNav[n].src.indexOf('_on')!=-1) continue;
		cNav[n].onmouseover = function() { mouseOver(this) }
		cNav[n].onmouseout = function() { mouseOut(this) }
	}
}

function init() {
	cNav = document.getElementById('nav').getElementsByTagName('IMG');
	attachMouseEvents();
	bLoaded = true;
	document.getElementById('main').style.visibility = 'visible';
}

window.onload = init;