// WCC JavaScript utilities

// Jump out of frameset
function ie6bugsolution5() {
	if (window.self != window.top) {
		var timerId = setTimeout("top.location.href = location.href;",300);
	}
}

// Make menu adjustments including hover behaviour for IE
function addHover() {

// Browser sniffing based on code from http://webreference.com/tools/browser/javascript.html
var agt = navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_opera = (agt.indexOf("opera") != -1);
if (agt.indexOf("konqueror") != -1) { var is_konq = true; }
else { var is_konq = false; }
if ((agt.indexOf("safari") != -1) && (agt.indexOf("mac") != -1)) { var is_safari = true; }
else { var is_safari = false; }
var is_khtml = (is_safari || is_konq);
var is_ie = ((appVer.indexOf("msie") != -1) && (!is_opera) && (!is_khtml));
var is_win = ((agt.indexOf("win") != -1) || (agt.indexOf("16bit") != -1));


// Opera has a float bug so needs the width specified
if (is_opera) {
	menuRoot = document.getElementById("menubox");
	menuRoot.style.width = "80%";
}

// Only add JavaScript hover behaviour when it is proven to be necessary and is working
// Note: it is necessary for IE on Mac too, but not yet working!
var nohover = false;
if ((is_ie) && (is_win)) {var nohover = true; }

if (nohover == true) {
	menuRoot = document.getElementById("menubox");
	if (menuRoot != null) {
		for (var i = 0; i < menuRoot.childNodes.length; i++) {
			var node1 = menuRoot.childNodes[i];
			if (node1.nodeName == "UL") {
				for (var j = 0; j < node1.childNodes.length; j++) {
					var node2 = node1.childNodes[j];
					if (node2.nodeName == "LI") {
						node2.onmouseover = function() { this.className += " hover"; }
						node2.onmouseout = function() { this.className = this.className.replace(" hover", ""); }
					}
				}
			}
		}
	}
}
}


allLoaded = function() {
	addHover();
	ie6bugsolution5();
}

window.onload = allLoaded;
