<!--
/** 
 * 좌측 공백 제거
 */
function Ltrim(strValue){
    while (strValue.length>0){
       if(strValue.charAt(0)==' '){
           strValue=strValue.substring(1,strValue.length);              
	   }
       else
          return strValue;	    
    }
	return strValue;
}


/** 
 * 우측 공백 제거
 */
function Rtrim(strValue){
    while (strValue.length>0){
       if(strValue.charAt(strValue.length-1)==' '){
           strValue=strValue.substring(0,strValue.length-1);              
	   }
       else
           return strValue;	    
   }
   return strValue;
}


/** 
 * 양측 공백제거
 */
function Trim(strValue){
   strValue = Ltrim(strValue);
   strValue = Rtrim(strValue);
   return strValue;
}


/** 
 * 날짜 비교 
 */
function dateCompare(yyyymmdd1, yyyymmdd2) {
	var date1 = document.all[yyyymmdd1].value;
	var date2 = document.all[yyyymmdd2].value;
	if (date1 > date2) {
		return false;
	}
	return true;
}


/** 
 * 날짜 유효성 체크
 */
function dateCheck(dateVal) {

	//var dateVal = document.all[yyyymmdd];

	if (dateVal.length != 8) {
		return false;		
	}

	var year = dateVal.substring(0,4);
	var month = dateVal.substring(4,6);
	var date = dateVal.substring(6,8);

	if(isNaN(year) || isNaN(month) || isNaN(date)) {
		return false;
	}

	if (month < 1 || month > 12) {
		return false;
	}
	if (date < 1) {
		return false;
	}

	switch (month) {
		case "02"	:
			if (year % 400 == 0) {
				if (date > 29) {
					return false;
				} else { 
					return true;
				}
			}
			if (year % 100 == 0) {
				if(date > 28) {
					return false;
				} else { 
					return true;
				}
			}
			if (year % 4 == 0) {
				if (date > 29) {
					return false;
				} else {
					return true;
				}
			}
			if (date > 28) {
				return false;
			} else {
				return true;
			}
		case "04"	:
		case "06"	:
		case "09"	:
		case "11"	:
			if (date > 30) {
				return false;
			} else {
				return true;
			}
		default		:
			if (date > 31) {
				return false;
			} else {
				return true;
			}
	}
}
/**
* 정수값인지 체크
*/
function isNumber(numval){
	for(i=0; i<numval.length; i++){
		str=numval.charCodeAt(i);
		if(str<48 || str>57)
			return false;
	}
	return true;
}	


/**
* 정수값인지 체크
*/
function isFloat(numval){
	return !isNaN(numval);
}	

/**
* 전화번호(정수와 '-' 만 허용) 체크
*/
function isTel(val){
	for(i=0; i<val.length; i++){
		str=val.charCodeAt(i);
		if(!((str>=48 && str<=57) || str==45))
			return false;
	}
	return true;
}	

function isHangul(x)
{

    for(i=0 ; i<x.length ; i++) {
        // 유니코드로 반환
        var valUni = x.charCodeAt(i);
        
        // 한글은 128이상
        if(valUni < 128) {
				return false;
        }
    }
}

function isChar(txtValue)
{
	for(j=0; j< txtValue.length; j++){
		ch=txtValue.charAt(j);
		if(isEngChar(ch)==false && isHangul(ch) ==false)
			return false;	
	}
	return true;
}
/**
* 영문자값인지  체크
*/
function isEngChar(charval){
	for(i=0; i<charval.length; i++){
		str=charval.charCodeAt(i);
		if(str<65 || (str>90 && str <97) || str>122)
			return false;
	}
	return true;
}	

/**
* 영문자,정수값인지 체크
*/
function isNumEngChar(txtValue){
	for(j=0; j< txtValue.length; j++){
		ch=txtValue.charAt(j);
		if(isNumber(ch)==false && isEngChar(ch)==false)
			return false;	
	}
	return true;
}	

/**
 *	comma 제거 
 *
 */
function unFormatComma(str) {
	return str.replace(/[,]/g, "");
}

/**
 *	comma 삽입 
 *
 */
function formatComma(num) {
	idx = num.length-3;
	while(idx > 0) {
		num = num.substr(0, idx) + "," + num.substr(idx);
		idx -= 3;
	}
	return num;
}


/**
* 대문자로 변환
*/
function autoCapitalize(txtFld) {
	txtFld.value = (txtFld.value).toUpperCase() ;
	return ;
}	

/**
* 문자바이트 계산
*/


/**
* 메일이 올바른지 검사
*/
function isEmail(str) {
	  // regular expression 지원 여부 점검
	  var supported = 0;
	  if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	  }
	  if (!supported) 
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	  return (!r1.test(str) && r2.test(str));
}

/**
* 주민등록번호 유효성 검사
*/
function ValidSerial(sno1,sno2) {  
        var serialValue        = sno1 + - + sno2;  
        //주민등록번호의 형태와 7번째 자리(성별) 유효성 검사  
        var chkValue        = /^\d{6}-[1234]\d{6}$/;  
        if (!chkValue.test(serialValue)) {  
                return false;  
        }  
        //날짜 유효성 검사  
        birthYear        = (serialValue.charAt(7) <= 2) ? 19 : 20;  
        birthYear        += serialValue.substr(0, 2);  
        birthMonth        = serialValue.substr(2, 2) - 1;  
        birthDate        = serialValue.substr(4, 2);  
        var birth        = new Date(birthYear, birthMonth, birthDate);  
        if ((birth.getYear() % 100 != serialValue.substr(0, 2)) ||  
                (birth.getMonth() != birthMonth) ||  
                (birth.getDate() != birthDate)) {  
                return false;  
        }  
        //코드 유효성 검사  
        var buf = new Array(13);  
        for (var i = 0; i < 6; i++) {  
                buf[i] = parseInt(serialValue.charAt(i));  
        }  
        for (var i = 6; i < 13; i++) {  
                buf[i] = parseInt(serialValue.charAt(i + 1));  
        }  
        var multipliers = [2,3,4,5,6,7,8,9,2,3,4,5];  
        for (var i = 0, sum = 0; i < 12; i++) {  
                sum += (buf[i] *= multipliers[i]);  
        }  
        if ((11 - (sum % 11)) % 10 != buf[12]) {  
                return false;  
        }  

		return true;
}   

function optionYear2(){
	document.write("<option value=''>선택</option>");
	for(i=1980;i<2010;i++){
		document.write("<option value='"+ i+"'>"+ i +"</option>");
	}
}

function optionYear(){
	document.write("<option value=''>선택</option>");
	for(i=2000;i<2010;i++){
		document.write("<option value='"+ i+"'>"+ i +"</option>");
	}
}

function optionMonth(){
	var mm = "";
	document.write("<option value=''>선택</option>");
	for(i=1;i<13;i++){
		if(i<10){
			mm = "0" + i;
		}else{
			mm = i;
		}
		document.write("<option value='"+ mm +"'>"+ i +"</option>");
	}
}

function optionDate(){
	var dd = "";
	document.write("<option value=''>선택</option>");
	for(i=1;i<31;i++){
		if(i<10){
			dd = "0" + i;
		}else{
			dd = i;
		}
		document.write("<option value='"+ dd +"'>"+ i +"</option>");
	}
}

function optionHour(){
	var dd = "";
	document.write("<option value=''>선택</option>");
	for(i=0;i<24;i++){
		if(i<10){
			dd = "0" + i;
		}else{
			dd = i;
		}
		document.write("<option value='"+ dd +"'>"+ i +"</option>");
	}
}

function optionMin(){
	var dd = "";
	document.write("<option value=''>선택</option>");
	for(i=0;i<60;i++){
		if(i<10){
			dd = "0" + i;
		}else{
			dd = i;
		}
		document.write("<option value='"+ dd +"'>"+ i +"</option>");
	}
}
 
function getByteLength(s){
   var len = 0;
   if ( s == null ) return 0;
   for(var i=0;i<s.length;i++){
      var c = escape(s.charAt(i));
      if ( c.length == 1 ) len ++;
      else if ( c.indexOf("%u") != -1 ) len += 2;
      else if ( c.indexOf("%") != -1 ) len += c.length/3;
   }
   return len;
}

function calc_length(content,len)
{ 
	alert(len);
		var doc1 = content.value;         //계산될 메시지 내용
		 value = getByteLength(doc1); //메시지 길이를 바이트로

		if(value > len){
			alert("지정된 크기를 넘기셨습니다.");
			content.focus();
			return;
		}
}


	function goUrlPopup(url){
		window.open(url,'_blank');
	}
//-->


