var TimeOut         = 300;
var currentLayer    = null;
var currentitem     = null;
var currentLayerNum = 0;
var noClose         = 0;
var closeTimer      = null;

function fctRollOver() {
	if (!document.getElementById) return
	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');
	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'naviItem') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_f2'+ftype);
			aImages[i].setAttribute('hsrc', hsrc);
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;
			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}
			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

function fctNaviOpen(n) {
	var l  = document.getElementById("subNaviItem"+n);
	var mm = document.getElementById("mainNaviItem"+n);
	if (l) {
		fctNaviCancelCloseTime();
		l.style.visibility='visible';
		if (currentLayer && (currentLayerNum != n))
		currentLayer.style.visibility='hidden';
		currentLayer = l;
		currentitem = mm;
		currentLayerNum = n;
	} else if (currentLayer) {
		currentLayer.style.visibility='hidden';
		currentLayerNum = 0;
		currentitem = null;
		currentLayer = null;
	}
}

function fctNaviCloseTime() {
	closeTimer = window.setTimeout(fctNaviClose, TimeOut);
}

function fctNaviCancelCloseTime() {
	if (closeTimer) {
		window.clearTimeout(closeTimer);
		closeTimer = null;
	}
}

function fctNaviClose() {
	if (currentLayer && noClose!=1) {
		currentLayer.style.visibility='hidden';
		currentLayerNum = 0;
		currentLayer = null;
		currentitem = null;
	} else {
		noClose = 0;
	}
	currentLayer = null;
	currentitem = null;
}

document.onclick = fctNaviClose;
