

//	function commatize(num)
//	function echoIntegersOnly(returnBox) 
//	function placeAdminLinks() 
//	function changeBgColor(obj,method) 
//	function trim(str)
//
//
//






// this function rewrites a plain integer value into an integer given with commas
// (i.e. 10000=10,000, 125963=125,963)
//
function commatize(num) {
	var temp = '';
	for(var i=0; i<num.length; i++)
		if(num.substring(i,i+1)!=',')
			temp += num.substring(i,i+1);

	num = temp;

	// if less than 1000
	if(num.length<4)
		return num;
	
	// this part assumes number is larger than 999
	var index = num.length%3;
	var str = '';

	if(index>0)
		str += num.substring(0,index);
	
	while(num.substring(index,num.length)) {
		if(str.length>0)
			str += ',';
		str += num.substring(index,index+3);
		index += 3;
	}
	return str;
}


//	NOTE:	"str_allow" is entered in the form of Regular Experssion to be matched against "event.keyCode".
//			characters including (-),(/) must be placed in the beginning of the "str_allow".
//			To include (") (double quote) always include it with a back slash (\)
//			To include (') (single quote) always include it with a back slash (\)
//			To include (\) (back slash) always include it with another back slash (\)
//
function echoChars(str_allow) {
	//				 0        0         0         0          0         0         0         0         0         0          1         1         1         1
	//				 0        1         2         3          4         5         6         7         8         9          0         1         2         3
	//				 123456789012345678901234567890123 4567890123456789012345678901234567890123456789012345678901 234567890123456789012345678901234567890
	var aChars =   "                                 !\"#$%&'()*+,-./0123456789 ;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~    ";

	var KeyCode = 0;
	var Char = 0;
	var ReEx_Allow = new RegExp("["+ str_allow +"]");


	// Check For Browser Type
	// if IE
	if (document.all)
		KeyCode = event.keyCode;
	else
		KeyCode = event.which;

	Char = aChars.substring(KeyCode,KeyCode+1);

	if(Char.match(ReEx_Allow))
		return true;
	
	return false;
}


//
function placeAdminLinks() {
	var oDiv = document.getElementById("admin_links");

	with(oDiv) {
		style.left	= 0;
		style.top	= document.body.scrollTop;
	}
}


//
function changeBgColor(obj,method) {
	if(method=='mouseover' || method=='mouseout') {
		if(obj.id=='mouseclick')
			return;
		else
			obj.id = method;
	}
	else if(method=='mouseclick') {
		if(obj.id=='mouseclick')
			obj.id = 'mouseover';
		else
			obj.id = 'mouseclick';
	}
}



//
function printLoadingLayer() {
	var oDiv = document.getElementById("loading_status");

	with(oDiv) {
		if(document.readyState!='complete') {
			style.visibility = 'visible';
		}
		else {
			style.visibility = 'hidden';
		}
	}
}






function trim(str) {
   return str.replace(/^\s*|\s*$/g,"");
}



