
	
function callfrm(dest){
	frmConsole.target = "_self"
	frmConsole.action = dest
	frmConsole.method = "POST"
	frmConsole.submit()
}
function callfrm2(dest)
{
	frmConsole.target = "_blank"
	frmConsole.action = dest
	frmConsole.method = "POST"
	frmConsole.submit()
}	
function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
		num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
		cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
		num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	//return (((sign)?'':'-') + '$' + num + '.' + cents);
	return (((sign)?'':'-') + num);
}

function CheckBoxChageColor(c_id,ctmp_id,id,activecolor){
	var f = document.frmConsole;
	var a=c_id + '['+ id +']';
	var b='tr_';
	var c=ctmp_id;
	cb = eval( 'f.' + a);
	cb2 = eval(b + '' + id );
	cb3 = eval( 'f.' + c + '' + id );
	if(cb.checked==true){
		if(cb3.value==1)
			cb2.style.backgroundColor=activecolor;
		else
			cb2.style.backgroundColor="#f9fbcb";
	}else{
		if(cb3.value==0)
			cb2.style.backgroundColor=activecolor;
		else{
			cb2.style.backgroundColor="#D5E2F0";
		}
	}
}
function checkboxNum(form,chk) {
	var total = 0;
	var max = eval('form.' + chk + '.length');
	for (var idx = 0; idx < max; idx++) {
		if (eval('document.frmConsole.'+ chk +'[' + idx + '].checked') == true) {
			total += 1;
		}
	}
	return total;
}

function changerow(row){
	var b='tr_upload';
	for(i=0;i<50;i++){
		cb2 = eval(b + '' + i );
		if(i<row){
			cb2.style.display='';
		}else{			
			cb2.style.display='none';
		}
	}
}

function popupfrmPrint(dest,popname,width,height){
	popup=window.open(dest,popname,"left="+ (((800-width)/2)) + ",top=" + (((600-height)/2)) +",width="+width+",height="+height+",resizable=no,menubar=1,scrollbars=yes,location=no,alwaysRaised=yes,toolbar=yes");
	popup.focus()
}

function openNew(dest,popname,width,height){
	popup=window.open(dest,popname,"left="+ (((800-width)/2)) + ",top=" + (((600-height)/2)) +",width="+width+",height="+height+",resizable=no,menubar=0,scrollbars=yes,location=no,alwaysRaised=yes");
	popup.focus()
}

function popupPic(dest,popname,width,height){
		popup=window.open(dest,popname,"left="+ (((800-width)/2)) + ",top=" + (((600-height)/2)) +",width="+width+",height="+height+",resizable=no,menubar=0,scrollbars=no,location=no,alwaysRaised=yes");
		popup.focus()
}

function DigitOnly() {
	if ((event.keyCode>=96)&&(event.keyCode<=105))		
		return;
	if ((event.keyCode>=48)&&(event.keyCode<=57))	
		return;
	if (event.keyCode==8 || event.keyCode==9)
		return;
	if ((event.keyCode==37)||(event.keyCode==39)||(event.keyCode==46))
		return;
	event.returnValue=false;	
}

function roll_over(img_name, img_src){
	document[img_name].src = img_src;
}

function EngOnly(){
	if (String.fromCharCode(event.keyCode) < '~'){
		return;
	}
	event.returnValue=false;	
}

function CloseWindows(){
	window.close();
}

function OnMouseBG(obj,img){ //เปลี่ยน bgcolor
	obj.style.background=img;
}

function OnMouseText(obj,color){	//เปลี่ยน textcolor
	obj.style.color=color;
}

function formatNumber(num, decplaces) {
	num = parseFloat(num);
	if (!isNaN(num)) {
		var str = "" + Math.round (eval(num) * Math.pow(10,decplaces));
		if (str.indexOf("e") != -1) {
			return "Out of Range";
		}
		while (str.length <= decplaces) {
			str = "0" + str;
		}

		var decpoint = str.length - decplaces;
		var tmpNum = str.substring(0,decpoint);
		//---------------Add Commas--------------------------
		var numRet = tmpNum.toString();
		var re = /(-?\d+)(\d{3})/;
		while (re.test(numRet)) {
			numRet = numRet.replace(re, "$1,$2");
		}
	//	return numRet + "." + str.substring(decpoint,str.length);
		return numRet;
	} else {
		return "0.00";
	}
} 

function CheckEnter(callFunction,valueFunction){
	var cChr;
	cChr = window.event.keyCode;
	if (cChr == 13)
	{
		callFunction(valueFunction);
	}
}

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
	  return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
	  return "";
	}
	else{
	  return TRIM_VALUE;
	}
}

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
	  return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
	  if(VALUE.charAt(iTemp) == w_space){
	  }
	  else{
		strTemp = VALUE.substring(0,iTemp +1);
		break;
			 }
	  iTemp = iTemp-1;

	} //End While
		   return strTemp;

} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
	return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
	  if(VALUE.charAt(iTemp) == w_space){
	  }
	  else{
		strTemp = VALUE.substring(iTemp,v_length);
		break;
	  }
	  iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function

function addEvent(obj, evType, fn, useCapture) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, useCapture);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on" + evType, fn);
		return r;
	} else {
		alert("handler could not be attached");
	}
}
function CheckEnterNew(callFunction,valueFunction,e){
	var cChr;
	cChr = e.keyCode || e.which;
	if (cChr == 13)
	{
		callFunction(e,valueFunction);
	}
}
function noRightClick(){
	if(event.button==2){
		document.oncontextmenu =function(){
			return false;
		}
	}
}