var ua = navigator.userAgent.toLowerCase(),
	check = function(r){
		return r.test(ua);
	},
	isStrict = document.compatMode == "CSS1Compat",
	isOpera = check(/opera/),
	isChrome = check(/chrome/),
	isWebKit = check(/webkit/),
	isSafari = !isChrome && check(/safari/),
	isSafari3 = isSafari && check(/version\/3/),
	isSafari4 = isSafari && check(/version\/4/),
	isIE = !isOpera && check(/msie/),
	isIE7 = isIE && check(/msie 7/),
	isIE8 = isIE && check(/msie 8/),
	isGecko = !isWebKit && check(/gecko/),
	isGecko3 = isGecko && check(/rv:1\.9/),
	isBorderBox = isIE && !isStrict,
	isWindows = check(/windows|win32/),
	isMac = check(/macintosh|mac os x/),
	isAir = check(/adobeair/),
	isLinux = check(/linux/),
	isSecure = /^https/i.test(window.location.protocol);
	
	var Active, Names, Times, xy;
	Active = new Array();
	Names = new Array();
	Times = new Array();
	xy = new Array;
	
	var popUpWin = 0;
	
	nn4 = (document.layers) ? true : false;
	ie4 = (document.all) ? true : false;
	nn6 = (document.getElementById && !ie4) ? true : false;
	
	if (nn4 || ie4 || nn6)
		ver = "good";
	
	function FindObj(n, d) {
		var p, i, x;
		if (!d)
			d = document;
		if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
			d = parent.frames[n.substring(p + 1)].document;
			n = n.substring(0, p);
		}
		if (!(x = d[n]) && d.all)
			x = d.all[n];
		for (i = 0; !x && i < d.forms.length; i++)
			x = d.forms[i][n];
		for (i = 0; !x && d.layers && i < d.layers.length; i++)
			x = FindObj(n, d.layers[i].document);
		return x;
	}
	
	function MsOv(chn) {
		var y, imgOn, imgOff;
		if (nn4 || ie4 || nn6) {
			imgOn = eval('bt' + chn + "on.src");
			imgOff = eval('bt' + chn + "off.src");
			if (document[chn].src == imgOn)
				document[chn].src = imgOff;
			else
				document[chn].src = imgOn;
		}
	}
	
	function NW(Img, Wi, He, Re, Sc, Desc) {
		Wi += 25;
		He += 25;
		if (Desc == "") {
			Desc = Img;
		}
		if (Sc == 1) {
			if (Re == 1) {
				window.open(Img, "_blank", "toolbar=0, height=" + He + ", width="
								+ Wi + ", resizable, scrollbars=yes");
			} else {
				window.open(Img, "_blank", "toolbar=0, height=" + He + ", width="
								+ Wi + ", scrollbars=yes");
			}
		} else {
			if (Re == 1) {
				window.open(Img, "_blank", "toolbar=0, height=" + He + ", width="
								+ Wi + ", resizable");
			} else {
				window.open(Img, "_blank", "toolbar=0, height=" + He + ", width="
								+ Wi);
			}
		}
	}
	
	function popUpWindow(URLStr, left, top, width, height) {
		if (popUpWin) {
			if (!popUpWin.closed)
				popUpWin.close();
		}
		popUpWin = open(
				URLStr,
				'popUpWin',
				'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=1,resizable=yes,copyhistory=yes,width='
						+ width
						+ ',height='
						+ height
						+ ',left='
						+ left
						+ ', top='
						+ top + ',screenX=' + left + ',screenY=' + top + '');
	}
	
	function ShowImage(ev, aId, typ, width, height) {
		var id = parseInt(aId, 10);
		var wdt = (width == 0) ? 500 : width + 80;
		var hgt = (height == 0) ? 400 : height + 100;
		popUpWindow("/htdocs/view_image.php?id=" + id, 50, 50, wdt, hgt);
		if (window.event) {
			window.event.cancelBubble = true;
			window.event.returnValue = false
		} else if (ev) {
			ev.cancelBubble = true;
			ev.preventDefault();
			ev.stopPropagation()
		}
	}
