function initIEHover(o, tag, recurse) {
	for(var cn = o.firstChild; cn; cn = cn.nextSibling) {
		if(cn.nodeName == tag) {
			cn.onmouseover = function() { this.className = "hover"; }
			cn.onmouseout = function() { this.className = ""; }
		}
		if(recurse) initIEHover(cn, tag, recurse);
	}
}

function correctProtocol(html) {
	// set http protocol for all root relative links
	var re = new RegExp('href="/', 'g');
	var s = html.replace(re, 'href="' + writeHost() + '/');
	return s;
}

function getNavigationHTML() {
	return '<div id="mnav-container"></div>';
}

function writeHost() {
	return window.location.protocol + '//' + window.location.host;
}

function initNavigation() {
	var ie = document.all && document.getElementById && !window.opera;

	document.getElementById('mnav-container').innerHTML = correctProtocol(frames['buffer'].document.body.innerHTML);
		
	if(ie) {
		initIEHover(document.getElementById("mnav"), "LI", true);
	}
	
	//force browsers to display polish marks
	var substitute = new Array("Zarząd / Dyrekcja", "Biura na świecie" , "Uczymy się razem");
	var pm = document.getElementsByTagName('LI');
	for(i = 0, j = 0; i < pm.length && j < substitute.length; i++) {
		if (pm[i].className == 'en') {
			pm[i].firstChild.firstChild.nodeValue = substitute[j];
			j++;
		}
	}
	
	var buffer = document.getElementById("buffer");
	buffer.parentNode.removeChild(buffer);
}

// cannot use display:none style for iframe before the onload event, won't get added to frames array if so
document.write('<iframe id="buffer" style="position:absolute;width:0px;height:0px;" name="buffer" src="' + writeHost() + '/en/code/data/navigation.html"></iframe>');

menu_addListener({ onload:initNavigation });
menu_addListener({ onload:accessible_popup });
