var cLayerMode = (document.layers ? 'NS4' : (document.getElementById ? 'DOM' : (document.all ? 'IE4' : '')));

function getLayer (n) {
	switch (cLayerMode) {
		case 'DOM':
			var oLayer = window.document.getElementById (n);
			if (typeof oLayer != 'object') oLayer = window.document.getElementByName (n);
			if ((typeof oLayer == 'object') && oLayer) {
				oLayer.set = function (cVar, Value) {
					var bAssign=true;
					switch (cVar) {
						case 'clip':
							Value = 'rect(' + Math.floor(Value.top) + 'px ' + Math.floor(Value.width+Value.left) + 'px ' + Math.floor(Value.height+Value.top) + 'px ' + Math.floor(Value.left) + 'px)';
							break;			
					}
					if (bAssign) eval('this.style.' + cVar + '=Value');
					return (Value);
				}
			}
			else
				oLayer = void(0);
			return (oLayer);
			
		case 'IE4':
			var oLayer = window.document.all.tags('div')[n];
			if (typeof oLayer != 'object') oLayer = window.document[n];
			if (typeof oLayer == 'object') {
				oLayer.style.parent = oLayer;
				oLayer.set = function (cVar, Value) {
					switch (cVar) {
						case 'clip':
							Value = 'rect(' + Value.top + 'px ' + (Value.width+Value.left) + 'px ' + (Value.height+Value.top) + 'px ' + Value.left + ')';
							this.clip = Value;
							break;
					}
				};
			}
			else
				oLayer = void(0);
			return (oLayer);

		case 'NS4':
			var oLayer = window.document[n];
			if (typeof oLayer == 'object') {
				oLayer.set = function (cVar, Value) {
					cVar = cVar.toLowerCase();
					switch (cVar) {
						case 'clip':
							this.clip.left = Value.left;
							this.clip.top  = Value.top;
							this.clip.right = Value.left + Value.width;
							this.clip.bottom = Value.top + Value.height;
							break;
					}
					return (Value);
				}
			}
			else
				oLayer = void(0);	
			return (oLayer);
	}	
}

function Rect (nLeft, nTop, nWidth, nHeight) {
	this.left = nLeft;
	this.top = nTop;
	this.width = nWidth;
	this.height = nHeight;
}


var oTimeout = null;
function moMenu (nChapter) {
	clearTimeout (oTimeout);
	if (!nChapter) 
		oTimeout = setTimeout ('moMenu(' + nCurrentChapter + ')', 200);
	else {
		var oLayer = getLayer ('Menu1');
		if (oLayer) {
			oLayer.set ('clip', new Rect (0, (nChapter-1)*30, 300, 31));
		}
	}
}

function getDocumentImage (cImageName) {
	var oImg = document.images[cImageName];
	if ((oImg == null || oImg+''=='undefined') && document.layers) {
		for (var i=0; i<document.layers.length; i++) {
			oImg = document.layers[i].document.images[cImageName];
			if (oImg != null && oImg+''!='undefined') return (oImg);
		}
	}
	return (oImg);
}


function mo (cButton, bOver) {
	if (cButton) {
		var oImage = getDocumentImage (cButton);
		if (oImage) {
		  cSrc = oImage.src;
			var cTeil = cSrc.substr(0,cSrc.length - 5);
			var cExt = cSrc.substr (cSrc.lastIndexOf('.'));
			cSrc = cTeil + (bOver ? '1' : '0') + cExt;
			oImage.src = cSrc;
		}
	}
	window.status = '';
	return (true);
}

