// set extra css class on element on 'mouseover' (for IE ofcourse)
function ieHover() {
	// vars
	var sfParent = document.getElementById('nav');
	var sfEls = sfParent.getElementsByTagName('li');
	for (var i = 0; i < sfEls.length; i++) {
		sfEls[i].onmouseover = function() {
			this.className += ' sfhover';
		}
		sfEls[i].onmouseout = function() {
			this.className = this.className.replace(new RegExp(' sfhover\\b'), '');
		}
	}
}


function isOpera() {
	return (navigator.userAgent.indexOf('Opera') != -1);
}


function isMSIE7() {
	return (navigator.appVersion.indexOf('MSIE 7') != -1);
}



function macHover() {
	// vars
	var sfParent = document.getElementById('nav');
	var sfEls = sfParent.getElementsByTagName('li');
	for (var i = 0; i < sfEls.length; i++) {
		// for width
		if(sfEls[i].parentNode == sfParent) {
			sfEls[i].style.width = 1 + 'px';
		}
	}
}


// and for IE again; prevent form elements from peeking through dropdown
function iePeekaboo(){
	// vars
	var ieULs = document.getElementById('nav').getElementsByTagName('ul');

	for (var j = 0; j < ieULs.length; j++) {
		ieULs[j].innerHTML = ('<iframe src="about:blank" scrolling="no" frameborder="0"></iframe>' + ieULs[j].innerHTML);
		var ieMat             = ieULs[j].firstChild;
		ieMat.style.width     = ieULs[j].offsetWidth + 'px';
		ieMat.style.height    = ieULs[j].offsetHeight + 'px';	
		ieULs[j].style.zIndex = '99';
	}
}


// Only IE versions need these 'fixes', so here goes
// if (document.all && !isOpera()) { //MS IE (or Opera, sigh)     - erweitert, um IE7 zu unterstützen / Oliver Brahmstädt
if (document.all && !isOpera() && !isMSIE7()) { //MS IE (or Opera, sigh)
	if (window.attachEvent) {
		window.attachEvent('onload', ieHover);
		window.attachEvent('onload', iePeekaboo);
	}
	else { //IE 5.2 Mac does not support attachEvent
		var onLoad = window.onload;
		window.onload = function() {
			if (onLoad) onLoad();
			ieHover();
			macHover();
		}
	}
}
