﻿function g_getByteLen(obj){var str=((typeof obj=="object")? obj.value:obj);var iLen=0;for(var inx=0;inx<str.length;inx++){var oneChar=escape(str.charAt(inx));if(oneChar.length==1){iLen++}else if(oneChar.indexOf("%u")!=-1){iLen+=3}else if(oneChar.indexOf("%")!=-1){iLen+=oneChar.length/3}};return iLen};function g_CalByte(obj,bytelen){var curText;var strLen;var byteIs;var lastByte;var thisChar;var escChar;var curTotalMsg;var okMsg;curText=new String(obj.value);strLen=curText.length;byteIs=0;for(i=0;i<strLen;i++){thisChar=curText.charAt(i);escChar=escape(thisChar);if(escChar.length>4){byteIs+=2;}else if(thisChar!='\r'){byteIs+=1};if(byteIs>bytelen){ thisText=curText.substring(0,i);obj.value=thisText;byteIs=lastByte;break};lastByte=byteIs};};function g_getRight(obj,num){var str=((typeof obj=="object")? obj.value:obj);var len;len=str.length;return str.substr(len-num,num)};function g_getMid(obj,idx,num){var str=((typeof obj=="object")? obj.value:obj);return str.substr(idx-1,num)};function g_setReplace(obj,searchStr,replaceStr){var str=((typeof obj=="object")? obj.value:obj);var len,i,tmpstr;len=str.length;tmpstr="";for(var i=0;i<len;i++){if(str.charAt(i)!=searchStr){tmpstr=tmpstr+str.charAt(i)}else{tmpstr=tmpstr+replaceStr}};return tmpstr};function g_setReplaceAll(obj,searchStr,replaceStr){var str=((typeof obj=="object")? obj.value:obj);var tmpstr;tmpstr=str.substring(searchStr/gi,replaceStr);return tmpstr};function g_setTrim(obj){var str=((typeof obj=="object")? obj.value:obj);var len=str.length;for(var i=0;i<len;i++){if(str.charAt(i)!=" "){str=str.substr(i,len-i);break}};len=str.length;for(var i=len-1;i>=0;i--){if(str.charAt(i)!=" "){str=str.substr(0,i+1);break}};return str};function g_putComma(obj){var str=((typeof obj=="object")? obj.value:obj);var num=str;if(num<0){num *=-1;var minus=true}else{var minus=false};var dotPos=(num+"").split(".");var dotU=dotPos[0];var dotD=dotPos[1];var commaFlag=dotU.length%3;if(commaFlag){var out=dotU.substring(0,commaFlag);if(dotU.length>3)out+=","}else var out="";for(var i=commaFlag;i<dotU.length;i+=3){out+=dotU.substring(i,i+3);if(i<dotU.length-3)out+=","};if(minus)out="-"+out;if(dotD)return out+"."+dotD;else return out};function g_putComma2(obj){var str=((typeof obj=="object")? obj.value:obj);str=str.replace(/^0*/,'').replace(/,/g,'');var strLen=str.length;var retStr="";var start=0;if(Number(str)<0){retStr="-";start=1};for(var i=start;i<strLen;i++){retStr+=str.charAt(i);if((strLen-i)%3==1&&(strLen-1)!=i)retStr+=","};if(typeof obj=="object")obj.value=retStr;else return retStr};function g_getLPad(obj,len,padStr){var str=((typeof obj=="object")? obj.value:obj);var retStr="";var padCnt=Number(len)-String(str).length;for(var i=0;i<padCnt;i++)retStr+=String(padStr);return retStr+str};function g_getRPad(obj,len,padStr){var str=((typeof obj=="object")? obj.value:obj);var retStr="";var padCnt=Number(len)-String(str).length;for(var i=0;i<padCnt;i++)retStr+=String(padStr);return str+retStr};function g_setToUCase(obj){if(isEmpty(str))return str;var str=((typeof obj=="object")? obj.value:obj);return str.toUpperCase()};function g_amt2str(str){try{if(typeof(str)=='undefined')return'';var tmp=str;tmp=tmp.replace(/,/gi,"");return tmp};catch(e){window.status='g_amt2str Error:'+e.number+'; '+e.description}};function g_OnFocusAmtIB(obj){obj.value=g_amt2str(obj.value);obj.select();};function InputParam(){this.buffer=[]};InputParam.prototype.Append=function(str){this.buffer[this.buffer.length]=str};InputParam.prototype.ConvertToString=function(){return this.buffer.join(COL_SP)};function MakePhone(s1,s2,s3){if(g_isEmpty(s1)==false&&g_isEmpty(s2)==false&&g_isEmpty(s3)==false){return s1+"-"+s2+"-"+s3}else{return""}};function MakeJumin(s1){if(g_isEmpty(s1)==false){return s1.substring(0,6)+"-*******"}else{return""}};function fn_TransDate(s1){if(g_isEmpty(s1)==false){var tmp=s1.substr(0,8);return tmp.substr(0,4)+"-"+tmp.substr(4,2)+"-"+tmp.substr(6,2)}else{return""}};function rdval(obj){if(obj.length!=undefined){for(i=0;i<obj.length;i++){if(obj[i].checked==true){return obj[i].value;break}}}else{return obj.value}};function rdval_chked(obj,val){if(obj.length!=undefined){for(i=0;i<obj.length;i++){if(obj[i].value==val){obj[i].checked=true;break}}}else{return obj.value}};