function FLenByte(fld) 
{
	if( fld == null ) return 0;
	
	fld.value = trim(fld.value);
	var str = fld.value;
	var len = str.length; 
	var byte_count = 0; 
	var i = 0;
    for(i=0; i<len; i++) 
    { 
    	byte_count += chrByte(str.charAt(i)); 	
    }
    return byte_count;
}
function LenByte(str) 
{
	var len = str.length; 
	var byte_count = 0; 
	var i = 0;
    for(i=0; i<len; i++) 
    { 
    	byte_count += chrByte(str.charAt(i)); 	
    }
    return byte_count;
}
function chrByte(chr) 
{ 
    if(escape(chr).length > 4) 
    return 2; 
    else 
    return 1; 
}
String.prototype.trim = function()
    {
      return this.replace(/(^\s*)|(\s*$)/gi, "");
    }
String.prototype.replaceAll = function(str1, str2)
    {
      var temp_str = "";

      if (this.trim() != "" && str1 != str2)
      {
        temp_str = this.trim();

        while (temp_str.indexOf(str1) > -1)
        {
          temp_str = temp_str.replace(str1, str2);
        }
      }

      return temp_str;
    }


function trim (strSource) {
	re = /^\s+|\s+$/g;
	return strSource.replace(re, '');
}
function isNumeric(value)
{
	/* ¹é½ºÆäÀÌ½º,ÅÜ,¿£ÅÍ,È­»ìÇ¥,µ¨¸®Æ®,0~9,¿À¸¥ÂÊ0~9 */
	if (value == 8 || value == 9 || value == 13 || value == 35 || value == 36 || value == 110 || value == 190  || (value >= 37 && value <= 40) || value == 46 || (value >= 48 && value <= 57) || (value >= 96 && value <= 105) || value==109 || value==189) {
		return true;
	} else {
		return false;
	}
}
function isNumTel(value)
{
	/* ¹é½ºÆäÀÌ½º,ÅÜ,¿£ÅÍ,È­»ìÇ¥,µ¨¸®Æ®,0~9,¿À¸¥ÂÊ0~9 189="-" ¼ýÀÚÆÇ "-" = 109*/ 
	if (value == 8 || value == 9 || value == 13 || value == 35 || value == 36 || value==189 || value==109 || (value >= 37 && 
value <= 40) || value == 46 || (value >= 48 && value <= 57) || (value >= 
96 && value <= 105)) {
		return true;
	} else {
		return false;
	}	
}
function Plus_Comma( nNumber )
{	
	var objRegExp = new RegExp('(-?[0-9]+)([0-9]{3})'); 
	
	nNumber = nNumber + "";
	while(objRegExp.test(nNumber))
	{
		nNumber = nNumber.replace(objRegExp, '$1,$2');
	}
	return nNumber;
}
function Minus_Comma(str)
{
	return str.replace(/,/g,'');
}
function CheckJumin(str)
{
	str = trim(str.replace(/-/g,''));
    if(LenByte(str)==0 || LenByte(str)!=13){
//    	alert('ÁÖ¹Îµî·Ï¹øÈ£¸¦ Á¤È®È÷ ÀÔ·ÂÇÏ¼¼¿ä.!');
    	return false;
    }
    var data = str;
	var sum_1 = 0;
	var sum_2 = 0;
	var at = 0;
	sum_1 = (data.charAt(0)*2)+(data.charAt(1)*3)+(data.charAt(2)*4)+(data.charAt(3)*5)+(data.charAt(4)*6)+(data.charAt(5)*7)+(data.charAt(6)*8)+(data.charAt(7)*9)+(data.charAt(8)*2)+(data.charAt(9)*3)+(data.charAt(10)*4)+(data.charAt(11)*5);
	sum_2 = sum_1%11;

	if (sum_2 == 0) {
	    at = 10;
	} else {
	    if (sum_2 == 1) {
	        at = 11;
	    } else {
	        at = sum_2;
	    }
	}
	var att = (11-at);
	if (data.charAt(12) != att){
//    	alert('ÁÖ¹Îµî·Ï¹øÈ£°¡ ¿Ç¹Ù¸£Áö ¾Ê½À´Ï´Ù.!');
    	return false;
	}
	return true;

}

function openWindow( _url, _name, _width, _height, _scroll ){		

    var LeftPosition=(screen.width)?(screen.width-_width)/2:100 ;
    var TopPosition=(screen.height)?(screen.height-_height)/2:100 ;
	var settings='width='+_width+',height='+_height+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+_scroll+',resizable=no, titlebar=no' ;
	var Remote = window.open(_url, _name, settings);
	if(Remote) Remote.focus();
} 
function mail_input(val,Obj) {  
	try{
		if(val=='etc'){
				frm[Obj].style.visibility='visible';
				frm[Obj].focus();	
		}else{
				frm[Obj].style.visibility='hidden';
		} 
	}catch(e){}
}
//ÀÌ¸ÞÀÏ Æ¯¼ö¹®ÀÚ °Ë»ç Ãß°¡ 
function email_check(email) {
  var invalidChars = "\"|&;<>!*\'\\"   ;
  for (var i = 0; i < invalidChars.length; i++) {
    if (email.indexOf(invalidChars.charAt ) != -1) {
      return false;
    }
  }
  if (email.indexOf("@")==-1){
    return false;
  }
  if (email.indexOf(" ") != -1){
    return false;
  }
  if (window.RegExp) {
    var reg1str = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
    var reg2str = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
    var reg1 = new RegExp (reg1str);
    var reg2 = new RegExp (reg2str);
 
    if (reg1.test(email) || !reg2.test(email)) {
      return false;
    }
  }
  return true;
} 
/*function email_check(input) {
	var emailEx1 = /^([A-Za-z0-9]{0,1})([A-Za-z0-9]{1,15})([A-Za-z0-9-]{0,1})([A-Za-z0-9]{1,15})([A-Za-z0-9]{0,1})(@{1})([A-Za-z0-9_]{1,15})(.{1})([A-Za-z0-9_]{2,10})(.{1}[A-Za-z]{2,10})?(.{1}[A-Za-z]{2,10})?$/; 
  if(!emailEx1.test(input)) return false;
	return true;
}
*/
function getMailID(str){
	var arID = str.split('@');
	if(arID.length>0)
		return arID[0];
	else
		return;
}
function getSpit(str,token,pos){
	var ar = str.split(token);
	if(ar.length>=pos)
		return ar[pos];
	else
		return;
}
function getMailAddr(str){
	var arID = str.split('@');
	if(arID.length>0)
		return arID[1];
	else
		return;
}
function SetSelectBox(str,Obj){
	try{	
		if(Obj.length>0){
				for(var i=0;i<Obj.length;i++){		
					if(Obj[i].value==str){
						Obj[i].selected = true ;
						return true;
					}
				}
		}
	}catch(e){}
	return false;
}
function getCookieVal(Name) {
   var search = Name + "="
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search)
      if (offset != -1) { // if cookie exists
         offset += search.length
         // set index of beginning of value
         end = document.cookie.indexOf(";", offset)
         // set index of end of cookie value
         if (end == -1)
            end = document.cookie.length
         return unescape(document.cookie.substring(offset, end))

      }
   }
}
function openWnd( _url, _name, _width, _height, _scroll ){		

    var LeftPosition=(screen.width)?(screen.width-_width)/2:100 ;
    var TopPosition=(screen.height)?(screen.height-_height)/2:100 ;
	var settings='width='+_width+',height='+_height+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+_scroll+',resizable=no, titlebar=no' ;
	var Remote = window.open(_url, _name, settings);
	if(Remote) Remote.focus();
}
function num2won(val) {
	if( val=='' || Number(val)<=0 ) return;
var won = new Array();
re = /^[1-9][0-9]*$/;
num = val.toString().split(',').join('');
if (!re.test(num)) {
chknum.value = '';
hanview.innerHTML = '';
} else {
var price_unit0 = new Array('','ÀÏ','ÀÌ','»ï','»ç','¿À','À°','Ä¥','ÆÈ','±¸');
var price_unit1 = new Array('','½Ê','¹é','Ãµ');
var price_unit2 = new Array('','¸¸','¾ï','Á¶','°æ','ÇØ','½Ã','¾ç','±¸','°£','Á¤');
for(i = num.length-1; i >= 0; i--) {
won[i] = price_unit0[num.substr(num.length-1-i,1)];
if(i > 0 && won[i] != '') won[i] += price_unit1[i%4];
if(i % 4 == 0) won[i] += price_unit2[(i/4)];
}
for(i = num.length-1; i >= 0; i--) {
if(won[i].length == 2) won[i-i%4] += '-';
if(won[i].length == 1 && i > 0) won[i] = '';
if(i%4 != 0) won[i] = won[i].replace('ÀÏ','');
}
won = won.reverse().join('').replace(/-+/g,'');
document.write( won+' ¿ø' );
}
}
