
var pWin, dvWin;
function toggleMAT(obj) {
	if (obj.className == "TG") {
		obj.className = "TGH";
		document.getElementById("HBAR").className = "hidden";
		document.getElementById("IBAR").className = "hidden";
	} else {
		obj.className = "TG";
		document.getElementById("HBAR").className = "";
		document.getElementById("IBAR").className = "";
	}
}
function UISearchMore(obj, event, did) {
	showLayer(did, event, findPosX(obj), findPosY(obj) + 17, false);
}
function UIDomTip(status) {
	if (status == "show") {
		changeObjectVisibility("MF:DT", "visible", "inline");
		setTimeout("UIDomTip('hide')", 6000);
	} else {
		changeObjectVisibility("MF:DT", "hidden", "none");
	}
}
function UILayerQMenu(obj, event) {
	var newY = findPosY(obj) - 160;
	showLayer("QMP", event, findPosX(obj) - 9, newY, false);
}
function UIQMenuServices(obj, event) {
	var newY = findPosY(obj) - 220;
	showLayer("QMS", event, findPosX(obj) + 152, newY, true);
}
function UIQMenuOptions(obj, event) {
	var newY = findPosY(obj);
	showLayer("QMPO", event, findPosX(obj) + 152, newY, true);
}
function UIQMenuControls(obj, event) {
	var newY = findPosY(obj);
	showLayer("QMC", event, findPosX(obj) + 152, newY, true);
}
function upgrating() {
	grayOut(true, {"opacity":"25"});
}
function DiMe(msgType, imsg, aclose, modal) {
	var DMD = document.createElement("div");
	DMD.id = "DMD";
	var borderColor = "";
	var bgColor = "";
	if (msgType == "INFO") {
		bgColor = "#D4FFCE";
		borderColor = "#597B5B";
	} else {
		if (msgType == "WARNING") {
			bgColor = "#FFFFCE";
			borderColor = "#F0C000";
		} else {
			if (msgType == "ERROR") {
				bgColor = "#FFDECE";
				borderColor = "#F03300";
			}
		}
	}
	DMD.style.background = bgColor;
	DMD.style.borderColor = borderColor;
	var DMDMessage = document.createElement("div");
	DMDMessage.id = "DMDMessage";
	DMDMessage.innerHTML = imsg;
	DMD.appendChild(DMDMessage);
	if (aclose == "false") {
		var DMDControl = document.createElement("div");
		DMDControl.id = "DMDControl";
		var DMDButton = document.createElement("a");
		DMDButton.href = "#";
		DMDButton.appendChild(document.createTextNode("OK"));
		DMDButton.onclick = function () {
			DiMeC();
		};
		DMDControl.appendChild(DMDButton);
		DMD.appendChild(DMDControl);
	} else {
		setTimeout("DiMeC()", 3000);
	}
	if (modal == "true") {
		grayOut(true, {"opacity":"25"});
	}
	document.body.appendChild(DMD);
	if (window.navigator.appName == "Microsoft Internet Explorer") {
		moveObject("DMD", window.screen.width / 2 - 160, 150);
		window.scrollTo(0, 0);
	} else {
		moveObject("DMD", window.screen.width / 2 - 160, window.pageYOffset + 150);
	}
}
function DiMeC() {
	document.body.removeChild(document.getElementById("DMD"));
	MDB.AJAX.sendRequest("?cmd=dmc");
}
function UIDoHomePage(obj) {
	obj.style.behavior = "url(#default#homepage)";
	obj.setHomePage("http://www.aiax.mn");
}
function UIDoFavorite() {
	window.external.AddFavorite("http://www.aiax.mn", "AIAX.MN");
}
A4J.AJAX.onError = function (req, status, message) {
	DiMe("ERROR", "EXCEPTION ...", "false", "true");
};
A4J.AJAX.onExpired = function (loc, expiredMsg) {
	DiMe("ERROR", "SESSION TIMED OUT", "false", "true");
};
function MediaPlayer(media, mediaID) {
	var url = "media=" + media + "&mid=" + mediaID;
	pWin = window.open("MediaPlayer.jspx?" + url, "MediaPlayer", "toolbar=no,location=yes,status=no,menubar=no,scrollbars=no,resizable=no,width=927,height=584");
	if (!pWin) {
		pWin.opener = self;
	}
	pWin.focus();
}
function DocumentViewer(url) {
	dvWin = window.open("DocumentViewer.jspx?" + url, "DocumentViewer", "toolbar=no,location=yes,status=no,menubar=no,scrollbars=no,resizable=no,width=800,height=550");
	if (!dvWin) {
		dvWin.opener = self;
	}
	dvWin.focus();
}
function onEnter(obj, event, did) {
	if (event.keyCode == 13) {
		if (document.getElementById(did)) {
			document.getElementById(did).click();
		}
	}
}
function onCloseModule(obj) {
	obj.parentNode.parentNode.removeChild(obj.parentNode);
}
function onCloseDOM(obj) {
	obj.parentNode.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode.parentNode);
}
function number(e) {
	if (window.event) {
		keynum = e.keyCode;
	} else {
		if (e.which) {
			keynum = e.which;
		}
	}
	if (keynum > 47 && keynum < 58 || keynum == 8 || keynum == 9) {
		return true;
	} else {
		return false;
	}
}
window.onscroll = function () {
	moveObject("MF:SI", window.screen.width / 2 - 50, window.pageYOffset + 180);
	if (document.getElementById("WQL")) {
		moveObject("WQL", window.screen.width / 2 - 150, window.pageYOffset + 170);	
	}
	if (document.getElementById("CID")) {
		moveObject("CID", window.screen.width / 2 - 150, window.pageYOffset + 170);	
	}
	if (document.getElementById("ARS")) {
		moveObject("ARS", window.screen.width / 2 - 165, window.pageYOffset + 170);	
	}
	if (document.getElementById("DMD")) {
		moveObject("DMD", window.screen.width / 2 - 160, window.pageYOffset + 150);	
	}
};
window.onload = function () {
	if (document.location.hostname == "www.aiax.mn") {
		setTimeout("UIDomTip('show')", 1000);
	}
};

isIE = document.all;
isNN = !document.all && document.getElementById;
isN4 = document.layers;
if (isIE || isNN) {
	document.oncontextmenu = checkV;
} else {
	document.captureEvents(Event.MOUSEDOWN || Event.MOUSEUP);
	document.onmousedown = checkV;
}
function checkV(e) {
	if (isN4) {
		if (e.which == 2 || e.which == 3) {
			return false;
		}
	} else {
		return false;
	}
}