var xh;
function $(e) {
	if (typeof (e) != 'string') return e;
	return document.getElementById(e);
}
function $a(e, a) {
	if (typeof (e) == 'string') {
		e = document.getElementById(e);
	}
	return e.getAttribute(a);
}
function $sa(e, a, v) {
	if (typeof (e) == 'string') {
		e = document.getElementById(e);
	}
	e.setAttribute(a, v);
}
function getElementPosition(ele) {
	var offsetTrail;
	if (typeof (ele) != 'string') {
		offsetTrail = ele;
	} else {
		offsetTrail = document.getElementById(ele);
	}
	var offsetHeight = offsetTrail.offsetHeight;
	var offsetWidth = offsetTrail.offsetWidth;
	var offsetLeft = 0;
	var offsetTop = 0;
	while (offsetTrail) {
		offsetLeft += offsetTrail.offsetLeft;
		offsetTop += offsetTrail.offsetTop;
		offsetTrail = offsetTrail.offsetParent;
	}
	if (navigator.userAgent.indexOf("Mac") != -1 &&
	typeof document.body.leftMargin != "undefined") {
		offsetLeft += document.body.leftMargin;
		offsetTop += document.body.topMargin;
	}
	return { left: offsetLeft, top: offsetTop, height: offsetHeight, width: offsetWidth };
}
function getDataURL(url, async, funcName) {
	if (window.XMLHttpRequest) {
		xh = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		xh = new ActiveXObject("Microsoft.XMLHTTP")
	}
	if (async) {
		xh.onreadystatechange = function() {
			if (xh.readyState == 4) {
				switch (xh.status) {
					case 200:
						if (funcName) {
							eval(funcName);
						}
						break;
					case 404:
						alert('Error: Not Found. The requested URL ' +
					url + ' could not be found.');
						break;
					case 500:
						handleErrFullPage(xh.responseText);
						break;
					default:
						if (xh.responseText.indexOf('Error:') > -1 ||
						xh.responseText.indexOf('Debug:') > -1) {
							alert(xh.responseText);
						}
						break;
				}
			}
		}
	}
	xh.open("GET", url, async);
	xh.send("");
	if (!async) {
		return xh.responseText;
	}
}
function handleErrFullPage(strIn) {
	var errorWin;
	try {
		errorWin = window.open('', 'errorWin');
		errorWin.document.body.innerHTML = strIn;
	}
	catch (e) {
		alert('An error occurred, but the error message cannot be' +
		' displayed because of your browser\'s pop-up blocker.\n' +
		'Please allow pop-ups from this Web site.');
	}
}
String.prototype.trim = function() {
	return this.replace(/^\s*|\s*$/g, '');
}
function sendCmd(c, p) {
	var dt = new Date();
	var d = location.pathname + "?dt=" + dt.getTime() + "&cmd=" + c + "&" + p;
	return getDataURL(d, false);
}
function HttpPopulateCbo(cbo, s, value) {
	var i = 0, item, p, doc = cbo.ownerDocument;
	cbo.options.length = 0;
	if (s == "")
		return;
	p = s.split("\t");
	for (i = 0; i < p.length; i++) {
		item = doc.createElement("Option");
		item.innerHTML = p[i].substr(p[i].indexOf("|") + 1);
		item.value = p[i].substr(0, p[i].indexOf("|"));
		if (item.value == value) {
			item.selected = true;
		}
		cbo.appendChild(item);
	}
}
