// ----------------------------------------
// Common functions
// ----------------------------------------
function HideLinks () {
	if (document.all) {
		for (var i in document.links)
			document.links [i].onfocus = document.links [i].blur;

		for (i = 0; i < document.all.length; i++) {
			if (document.all(i).tagName == "INPUT") {
				var sType = document.all(i).type.toLowerCase ();
				if ((sType == "radio") || (sType == "checkbox") || 
						(sType == "button") || (sType == "submit") || 
						(sType == "reset") || (sType == "image"))
					document.all(i).onfocus = document.all(i).blur;
	        }
		}
	}
}

aCachedImagesArr = new Array ();

function CacheImages (sStartDir, aImgNameArray, sImgExt) { // Cache set of images, not show
// sStartDir can be "", sImgExt can be not set
// Usage: CacheImages ("images/menu/", MyArr, "gif") or CacheImages ("", MyArr)
	for (var i = 0; i < aImgNameArray.length; i ++) {
		var sImgName = "" + sStartDir + aImgNameArray [i];
		if (sImgExt)
			sImgName += "." + sImgExt;
		CacheImage (sImgName);
	}
}

function CacheImage (sImgName) { // Cache image, not show
	var CacheImg = new Image ();
	CacheImg.src = sImgName;
	aCachedImagesArr [aCachedImagesArr.length] = CacheImg;
}

CacheImage ("i/markerbottom.gif");

function ScriptOneFrame () { // Prevent showing site inside alien frame
	if (self.parent.frames.length != 0 && self.parent.location != location) {
		self.parent.location=document.location;
		return;
	}
}
// ----------------------------------------
// Open window with form
// ----------------------------------------
function OpenForm (nForm, nHeight) {
	nWndWidth = 400;
	x = (screen.width - nWndWidth) / 2;
	y = (screen.height - nHeight) / 2;
	window.open ("nchelp.phtml?topic=" + nForm, "_blank", 
				"scrollbars=1,width=" + nWndWidth + ",height=" + nHeight + 
				",left=" + x + ",top=" + y);
	return false;
}
// ----------------------------------------
// Marker functions
// ----------------------------------------
nMarkerW = 18;
nNeededPos = 0;
nLeftPos = 0;
nRightPos = 0;
nTopPos = 0;
nBotPos = 0;

function Spy () {
    if (bNC && nVer >= 4) {
		nMarkerLeft = document.layers["marker"].left;
		if (nMarkerLeft < nLeftPos)
			nMarkerLeft = nLeftPos;
		if (nMarkerLeft > nRightPos - nMarkerW)
			nMarkerLeft = nRightPos - nMarkerW;
		document.layers["marker"].left = nMarkerLeft;
		if (nCurrentPos != nNeededPos) {
			nCurrentPos += Math.round ( (nNeededPos - nCurrentPos) / 3);
			document.layers["marker"].left = nCurrentPos;
		}
	}
	if (bIE && nVer >= 4 && !bMacIE) {
		pnt = document.all["marker"].style;
		if (pnt.left < nLeftPos)
			pnt.left = nLeftPos;
		if (pnt.left > nRightPos - nMarkerW)
			pnt.left = nRightPos - nMarkerW;

		if (nCurrentPos != nNeededPos) {
			nCurrentPos += Math.round ( (nNeededPos - nCurrentPos) / 3);
			pnt.left = nCurrentPos;
		}
	}
}

function ScriptResizing () {
    if (bNC && nVer >= 4) {
		nRightPos = window.pageXOffset + window.innerWidth - 18;
		if (nRightPos < nCurrentPos + nMarkerW && nRightPos > nLeftPos + nMarkerW)
			document.layers["marker"].left = nNeededPos = nCurrentPos = nRightPos - nMarkerW;
	}
	if (bIE && nVer >= 4 && !bMacIE) {
		pnt = document.all["marker"].style;
		nRightPos = document.body.scrollLeft + document.body.clientWidth - 4;
		if (nRightPos < nCurrentPos + nMarkerW && nRightPos > nLeftPos + nMarkerW)
			pnt.pixelLeft = nNeededPos = nCurrentPos = nRightPos - nMarkerW;
	}
}

nCursorY = 200;

function ScriptMouseMove (oEvent) {
    if (bNC && nVer >= 4) {
		nMouseX = oEvent.pageX;
		nMouseY = oEvent.pageY;
		nRightPos = 750 - nMarkerW / 2;
		nCursorY = oEvent.pageY;
	}
	if (bIE && nVer >= 4 && !bMacIE) {
		nMouseX = event.clientX;
		if (document.body.scrollLeft)
			nMouseX += document.body.scrollLeft;
		nMouseY = event.clientY;
		if (document.body.scrollTop)
			nMouseY += document.body.scrollTop;
		nRightPos = 750 - nMarkerW / 2;
	}
	if (nMouseY <= nBotPos && nMouseY >= nTopPos &&  
		nMouseX <= nRightPos && nMouseX >= nLeftPos) {
		nNeededPos = nMouseX - nMarkerW / 2;
		if (nNeededPos < nLeftPos)
			nNeededPos = nLeftPos;
		if (nNeededPos > nRightPos - nMarkerW)
			nNeededPos = nRightPos - nMarkerW;

		if (nMouseY >= nTopPos && nMouseY < nTopPos + 19) {
			if (bDirection == 0) { // Was to bottom
				bDirection = 1;
				if (nVer >= 4 && !bMacIE && bIE)
					document.images['markerimg'].src = "i/markertop.gif";
			}
		}

		if (nMouseY <= nBotPos && nMouseY > nBotPos - 19) {
			if (bDirection == 1) { // Was to top
				bDirection = 0;
				if (nVer >= 4 && !bMacIE && bIE)
					document.images['markerimg'].src = "i/markerbottom.gif";
			}
		}

		return;
	}
}

function ScriptStart () {
	bDirection = 1;// To top
    if (bNC && nVer >= 4) {
		window.captureEvents(Event.MOUSEMOVE);
		window.onMouseMove = ScriptMouseMove;
		nCurrentW = window.innerWidth;
		nCurrentH = window.innerHeight;
		nLeftPos = 202;
		nRightPos = 746 - nMarkerW / 2;
		nTopPos = 39 + 43;
		nBotPos = nTopPos + 28 + 19;

		nCurrentPos = nNeededPos = document.layers["marker"].left = nLeftPos;
		document.layers["marker"].top = nTopPos + 18;
		document.layers["marker"].visibility = "visible";
		setInterval ("Spy ()", 90);
	}
	if (bIE && nVer >= 4 && !bMacIE) {
		pnt = document.all["marker"].style;
		nLeftPos = 202;
		nRightPos = 746 - nMarkerW / 2;
		nTopPos = 39 + 43;
		nBotPos = nTopPos + 28 + 19;
		nCurrentPos = nNeededPos = pnt.left = nLeftPos;
		pnt.top = nTopPos + 18;
		pnt.visibility = "visible";
		setInterval ("Spy ()", 90);
	}
}
// ----------------------------------------
// Dynamic help functions
// ----------------------------------------
bHelpShowed = false;
function ShowHelp (sHelpId) {
	if (bHelpShowed)
		return;
	if (bIE && nVer >= 4 && !bMacIE) {
		pnt = document.all[sHelpId].style;
		pnt.pixelTop = event.clientY + 25;
		if (document.body.scrollTop)
			pnt.pixelTop += document.body.scrollTop;
		pnt.visibility = "visible";
	}
	bHelpShowed = true;
}

function HideHelp (sHelpId) {
	if (bIE && nVer >= 4 && !bMacIE) {
		pnt = document.all[sHelpId].style;
		pnt.visibility = "hidden";
		pnt.pixelTop = 0;
	}
	bHelpShowed = false;
}
// ----------------------------------------
bScriptLoaded = true;
