function clearMsg() {
	var obj = document.getElementById('lblMsg');
	if(!obj) return;
	obj.innerHTML = '';
}
function clearError(obj) {
	if(!obj) return;
	obj.innerHTML = '';
}
function setError(obj, strMsg) {
	if(!obj) return;
	showHideLoading(true);
	obj.innerHTML = strMsg;
}
function showHideLoading(isShow) {
	setLoadingLocation()
	var obj = document.getElementById('lblLoading');
	if(!obj) return;
	if(isShow)
		obj.style.visibility = 'visible';
	else {
		clearError();
		obj.style.visibility = 'hidden';
	}
}
function setLoadingLocation(){
	/*var obj = document.getElementById('lblLoading')
	x = 10;
	y = document.body.clientHeight - obj.offsetHeight + document.body.scrollTop;
	obj.style.left = x;
	obj.style.top = y;
	obj.style.position = 'absolute';*/
}
function URLEncode(plaintext) {
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
		if (ch == " ") {
			encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
			encoded += ch;
		} else {
			var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				alert( "Unicode Character '" 
						+ ch 
						+ "' cannot be encoded using standard URL encoding.\n" +
						  "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
}
function trimAll(sString) {
	while (sString.substring(0,1) == ' ') {
		sString = sString.substring(1, sString.length);
	}
	while (sString.substring(sString.length-1, sString.length) == ' ') {
		sString = sString.substring(0,sString.length-1);
	}
	return sString;
}
function OpenWindow(mUrl, mName, mHeight, mWidth) {
	var mTop = (screen.availHeight - 668) / 2;
	var mLeft = ((screen.availWidth - 1000) / 2)-4;
	window.open(mUrl, mName, 'width=' + mWidth + ',height=' + mHeight + ',left=' + mLeft + ',top=' + mTop + ',menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,userbars=no');
}
