var nn4 = (document.layers)? true:false;
var ie4 = (document.all)? true:false;
var dom = (document.getElementById)? true:false;
var ns6 = (document.getElementById && !document.all)? true:false;
var xMin = 0;
var xMax = 0;
var yMin = 0;
var yMax = 0;
mouseY = 0;
mouseX = 0;
var isScrolled = 0;
var menuTimer = null;
var globalLayer="";
var globalGif="";
var globalGifInLayer="";
var globalId="";
var gifName="";
var idArray = new Array();

function showLayer(whichLayer) {
	whichLayer.visibility="visible";
}

function moveArrowLayer() {
	if(ns6)
		var yKoord=ysPos(globalGif)+4;
	else
		var yKoord=ysPos(globalGif)-5;
	if(navigator.appVersion.indexOf("Mac")!=-1 && document.layers)
		yKoord+=7;
	if(navigator.appVersion.indexOf("Mac")!=-1 && document.all)
		yKoord+=10;
	var xKoord=xsPos(globalGif)+124;
	arrowSpan_s.left = xKoord;
	arrowSpan_s.top = yKoord;
	showLayer(arrowSpan_s);
}

function placeMenuLayers() {
	for (i=0; i<idArray.length;i++) {
		theGifName = "trans"+idArray[i];
		theLayerName = "lag"+idArray[i];
		thePosition = ysPos(theGifName) - 8;
		if(nn4)
			eval('document.layers.'+theLayerName+'.top='+thePosition);
		else if(ie4)
			eval('document.all.'+theLayerName+'.style.top='+thePosition);
		else
			eval('document.getElementById("'+theLayerName+'").style.top='+thePosition);
	}
}

function clearIdArray() {
	idArray.length=0;
}

function showMenuLayer(whichLayer) {
	hideLayer();
	checkScroll();
	globalId = whichLayer+"";
	globalLayer = "lag"+whichLayer;
	globalGif = "trans"+whichLayer;
	globalGifInLayer = "checkHeight"+whichLayer;
	if(globalLayer.length>15)
		return;
	else {
		setKoordinates();
		moveArrowLayer(globalId);
		if(nn4)
			eval('document.'+globalLayer+'.visibility="visible"');
		else if (ie4)
			eval('document.all.'+globalLayer+'.style.visibility="visible"');
		else
			eval('document.getElementById("'+globalLayer+'").style.visibility="visible"');
	}
}

function checkScroll() {
	if(ie4) {
		isScrolled = document.body.scrollTop;
	}
	else {
		isScrolled = window.pageYOffset;
	}
}	
	
function hideLayer(nonMenu) {
	if(globalLayer.length>15)
		return;
	else {
		if(globalId!="") {
			if(nn4)
				eval('document.'+globalLayer+'.visibility="hidden"');
			else if (ie4)
				eval('document.all.'+globalLayer+'.style.visibility="hidden"');
			else
				eval('document.getElementById("'+globalLayer+'").style.visibility="hidden"');
			arrowSpan_s.visibility="hidden";
			globalId="";
		}
	}
}

function hideNonMenu() {
	if(globalLayer!="") {
		if(nn4)
			eval('document.'+globalLayer+'.visibility="hidden"');
		else if (ie4)
			eval('document.all.'+globalLayer+'.style.visibility="hidden"');
		else
			eval('document.getElementById("'+globalLayer+'").style.visibility="hidden"');
	}
	arrowSpan_s.visibility="hidden";
}

function setKoordinates() {
	xMin = xsPos(globalGif);
	if(nn4) {
		layerHeight = eval('document.'+globalLayer+'.clip.bottom');
		yMax = parseInt(eval('document.'+globalLayer+'.top'))+layerHeight;
		yMin = parseInt(eval('document.'+globalLayer+'.top'));
		yMin-=4;
		xMax = parseInt(eval('document.'+globalLayer+'.left'));
		xMax+=135;
	}
	else if (ie4) {
		yMax = ysPos(globalGifInLayer);
		yMax+=8;
		yMin = parseInt(eval('document.all.'+globalLayer+'.style.top'));
		yMin-=4;
		xMax = parseInt(eval('document.all.'+globalLayer+'.style.left'));
		xMax+=135;
	}
	else {
		yMax = ysPos(globalGifInLayer);
		yMax+=8;
		yMin = parseInt(eval('document.getElementById("'+globalLayer+'").style.top'));
		yMin-=4;
		xMax = parseInt(eval('document.getElementById("'+globalLayer+'").style.left'));
		xMax+=135;
	}
}

function checkKoordinates(e) {
	if(document.all) {
		mouseY = event.clientY+isScrolled;
		mouseX = event.clientX;
	}
	else if (document.layers || document.getElementById) {		
		mouseY = e.pageY;
		mouseX = e.pageX;
	}
	if(globalId!="") {
		if(mouseX < xMin || mouseX > xMax || mouseY < yMin || mouseY > yMax) {
			hideLayer();
		}
	}
}
	
function ysPos(what){
	if(ie4){
		return yIE(eval('document.'+what));
	}
	else if(nn4){
		return eval('document.'+what+'.y');
	}
	else if(dom){
		return parseInt(yIE(eval('document.getElementById("' + what + '")')));
	}
}

function ysPosnn4(what) {
	return eval('document.lag'+globalId+'.document.'+what+'.y');
}

function xsPos(what){
	if(ie4){
		return xIE(eval('document.'+what));
	}
	else if(nn4){
		return eval('document.'+what+'.x');
	}
	else if(dom){
		return parseInt(xIE(eval('document.getElementById("' + what + '")')));
	}
}

function yIE(what) {
	if(what.offsetParent) {
		return parseInt((what.offsetTop + yIE(what.offsetParent)));
	} else {
		return parseInt(what.offsetTop);
	}
}
function xIE(what) {
	if(what.offsetParent) {
		return parseInt((what.offsetLeft + xIE(what.offsetParent)));
	} else {
		return parseInt(what.offsetLeft);
	}
}
if (document.layers) {
	document.captureEvents(Event.MOUSEMOVE)
}
document.onmousemove = checkKoordinates;
