var isNS4 = (navigator.appName == 'Netscape' && parseInt(navigator.appVersion) == 4);
var isNS6 = (navigator.appName == 'Netscape' && parseInt(navigator.appVersion) >= 5)
var isIE = (navigator.appName == 'Microsoft Internet Explorer'
&& parseInt(navigator.appVersion) >= 4);
var isIE5 = (isIE && navigator.appVersion.indexOf("MSIE 5") >= 0);
var isIE6 = (isIE && navigator.appVersion.indexOf("MSIE 6") >= 0);

var docPath, docName, imgDir;
var cursorImg = "sword";
var cOffsetX = -2;
var cOffsetY =	2;

function setImgDir(){
	docPath = document.location.href;
	docName = docPath.substring(docPath.lastIndexOf("/")+1, docPath.lastIndexOf("."));
	if (docName.indexOf("nav_") >= 0)
		imgDir = "images/"
	else
		imgDir = "../images/"
}
	
function showCursor(){
	cursorObj.visibility = "visible";
	cursorObj.left = mouseX + cOffsetX;
	cursorObj.top = mouseY + cOffsetY;
}

function hideCursor(){
	cursorObj.visibility = "hidden";
}

function trackCursor(evt){
	mouseX = isNS4 ? evt.pageX : isIE ? document.body.scrollLeft + event.clientX : isNS6 ? window.pageXOffset + evt.clientX : null;
	mouseY = isNS4 ? evt.pageY : isIE ? document.body.scrollTop + event.clientY : isNS6 ? window.pageYOffset + evt.clientY : null;
}

function handleCursor(evt){
	trackCursor(evt);
	if (docName.indexOf("nav_") >= 0 || docName.indexOf("crus_") >= 0)
		showCursor();
	else {
		windowWidth = isIE ? document.body.clientWidth : window.document.width;
		windowHeight = isIE ? document.body.scrollHeight : window.document.height;
		if (mouseX + 32 + cOffsetX < windowWidth && mouseY + 32 + cOffsetY < windowHeight)
			showCursor();
		else
			hideCursor();
	}
	if (isNS4 && (cursorObj.left <= 0 || cursorObj.top - window.pageYOffset <= 0))
		hideCursor();
}

function addCursor(){
	if (isNS4 || isIE5 || isIE6){
		cursorLayer = isNS4 ? document.sCursor : isIE ? sCursor : isNS6 ? document.getElementById("sCursor") : null;
		cursorObj = isNS4 ? cursorLayer : cursorLayer.style;
		setImgDir();
		if (isNS4){
			document.captureEvents(Event.MOUSEMOVE);
			cursorLayer.document.write("<IMG SRC='" + imgDir + "cursor_" + cursorImg + ".gif' WIDTH='32' HEIGHT='32'>");
			cursorLayer.document.close();
			if (isNS4 && docName.indexOf("nav_") == -1 && docName.indexOf("crus_") == -1)
				window.onresize = addCursor;
		}
		else
			cursorLayer.innerHTML = "<IMG SRC='" + imgDir + "cursor_" + cursorImg + ".gif' WIDTH='32' HEIGHT='32'>";
		document.onmousemove = handleCursor;
		document.onmouseout = hideCursor;
	}
}

function navClick(num){
	if (parent.navLeft){
		if (!parent.navLeft.selected || (parent.navLeft.selected && parent.navLeft.selected != num))
			setTimeout("parent.navLeft.mClick(" + num + ")", 500);
	}
}

