/*INISEAL:[xqH%2Fi64O7P7jiic0KWxHtuW1sko%3D%0A]*/
/*****************************************************************************
 * ÆÄÀÏ¸í : JHanaValidation.js
 * ÀÛ¼ºÀÏ : 2007. 12. 28
 * ÀÛ¼ºÀÚ : ork
 * ¼³   ¸í : Field Validation °ü·Ã Å¬·¡½º ¸ðÀ½
 * Dependency  : prototype.js , ext-base.js , ext-all.js , pbk-package.js
 * ¸Þ¼¼ÁöÈ¿°ú¸¦ À§ÇÏ¿© ExtJs ¾Æ·¡ Á¤ÀÇ µÇ¾î¾ß ÇÕ´Ï´Ù.
 * 
 * ===========================================================================
 * º¯°æÀÌ·Â:
 * DATE				AUTHOR		DESCRIPTION
 * ---------------------------------------------------------------------------
 * 2007.12.28	Oh,Ryunkyong 	Initial
 * 2008.02.15   Kim,Sangjun     ±â´É Ãß°¡
 * 2008.02.21   Kim,Sangjun     JNumber ¿¡ limitLength Ãß°¡
 * 2008.03.01   Kim,Sangjun     JCurrency Ãß°¡
 * 2008.03.01   Kim,Sangjun     ÀÔ·Â ±ÝÁö ¹®±¸ Ãß°¡ hana.validation.banChar
 * 2009.03.04   Kim,Sangjun     JDateLimit Ãß°¡
 * 2009.03.09   Kim,Sangjun     »ç¿ëÀÚ ¸Þ¼¼Áö Á¤ÀÇ·ÎÁ÷ Ãß°¡
 * 2009.03.19   Kim,Sangjun     JText ¿¡ Ç°¸ñ¸í Ã¼Å©·ÎÁ÷ Ãß°¡
 * º¯°æ ÀÌ·ÂÀº ÀÌ°÷¿¡ Ãß°¡ ÇÕ´Ï´Ù.
 *****************************************************************************/

/** 
 * Class ¸í : JMessage
 * ¼³¸í : ¿¡·¯¸Þ¼¼Áö °ü¸®
 */
hana.JMessage = function () { // »ý¼ºÀÚ ¸Þ¼Òµå
	/* Member field */
    this.init;
    this.messages;
}

hana.JMessage.prototype = {
	/* Member method */

    initMsgs : function() {
        if (!this.init) {
        	this.messages = new Array();
	        //this.messages["JSM-1001"] = "ÀúÀåÇÏ½Ã°Ú½À´Ï±î?";
			this.messages["JSM-1001"] = "Would you like to save?";
			
	        //this.messages["JSM-1002"] = "¾ÆÀÌµð";
			this.messages["JSM-1002"] = "ID";
			
	        //this.messages["JSM-1003"] = "»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?";
			this.messages["JSM-1003"] = "Would you like to delete?";
			
	        //this.messages["JSM-1004"] = "{0} ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù.";
			this.messages["JSM-1004"] = "{0} should be inserted.";
			
			//this.messages["JSM-1005"] = "{0} {1}ÀÚ¸® ÀÔ´Ï´Ù.";
			this.messages["JSM-1005"] = "It is {0} {1} digit";
			
	        //this.messages["JSM-1006"] = "{0} {1}ÀÚ¸® ÀÌ»ó {2}ÀÚ¸® ÀÌÇÏ¿©¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1006"] = "It must be above ¡°{0} {1} digits and below {2} digits¡°";
			
	        //this.messages["JSM-1007"] = "{0}¿¡´Â ´ÙÀ½({1}) Æ¯¼ö ¹®ÀÚ´Â ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù";
			this.messages["JSM-1007"] = "In {0} shouldn't be inserted special characters like this ({1})";
			
	        //this.messages["JSM-1008"] = "{0}¿¡´Â ¼ýÀÚ¸¸À» ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1008"] = "In{0} should be insert only Numeric Character";
			
	        //this.messages["JSM-1009"] = "{0}ÀÇ ¼ýÀÚ´Â {1}ÀÌ¿©¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1009"] = "Number {0} should be {1}";
			
	        //this.messages["JSM-1010"] = "{0}ÀÇ ¼ýÀÚ´Â {1} {2} »çÀÌ¿©¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1010"] = "Number {0} should be between {1} and {2}";
			
	        //this.messages["JSM-1011"] = "{0} ¼±ÅÃÇØ¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1011"] = "{0} should select";
			
	        //this.messages["JSM-1012"] = "¼±ÅÃÇÒ ¼ö ÀÖ´Â {0}ÀÇ ¼ö´Â {1}°³ ÀÔ´Ï´Ù";
			this.messages["JSM-1012"] = "Selectable {0} are {1}";
			
	        //this.messages["JSM-1013"] = "¼±ÅÃÇÒ ¼ö ÀÖ´Â {0}ÀÇ ¼ö´Â {1} ~ {2}°³ »çÀÌ¿©¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1013"] = "Selectalbe {0} number should be between{1} ~ {2}";
			
	        //this.messages["JSM-1014"] = "{0}ÀÇ ±Ý¾×Àº {1} ÀÌ¿©¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1014"] = "Amount{0} should be {1}";
			
	        //this.messages["JSM-1015"] = "{0}ÀÇ ±Ý¾×´Â {1} {2} »çÀÌ¿©¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1015"] = "Amount {0} should be between {1} and {2}";
			
	        //this.messages["JSM-1016"] = "{0} ¿Ã¹Ù¸£°Ô ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À";
			this.messages["JSM-1016"] = "Please enter {0} correctly";
			
	        //this.messages["JSM-1017"] = "ÀÔ·ÂÇÏ½Å {0} ÀüÀÚ¿ìÆíÁÖ¼Ò·Î À¯È¿ÇÏÁö ¾Ê½À´Ï´Ù.<br/> ´Ù½Ã ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À!";
			this.messages["JSM-1017"] = "Entered {0} e-mail address is not valid. <br/> Please enter again!";
			
			//this.messages["JSM-1018"] = "{0} ¿Ã¹Ù¸¥ ³¯Â¥°¡ ¾Æ´Õ´Ï´Ù. È®ÀÎÇÏ¿© ÁÖ¼¼¿ä";
			this.messages["JSM-1018"] = "{0} Unavailable Date. Check Please.";
			
	        //this.messages["JSM-1019"] = "{0}ÀÇ ³¯Â¥´Â {1} ÀÌÀü ÀÌ¾î¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1019"] = "Date{0}should be before {1}.";
			
	        //this.messages["JSM-1020"] = "{0}ÀÇ ³¯Â¥´Â {1} ÀÌÈÄ ÀÌ¾î¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1020"] = "Date{0}should be past {1}";
			
	        //this.messages["JSM-1021"] = "¼±ÅÃÇÒ ¼ö ÀÖ´Â {0}ÀÇ ³¯Â¥´Â {1} {2} »çÀÌ¿©¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1021"] = "Selectable Date{0} should be between {1}and {2}";
			
	        //this.messages["JSM-1022"] = "¿Ã¹Ù¸¥ ÆÄÀÏ¸íÀÌ ¾Æ´Õ´Ï´Ù. ÆÄÀÏÀ» ´Ù½Ã ÀÔ·ÂÇØ ÁÖ½Ã±â ¹Ù¶ø´Ï´Ù";
			this.messages["JSM-1022"] = "Not correct file name. Please Insert file name again.";
			
	        //this.messages["JSM-1023"] = "{0}¿¡ ´ëÇÑ ÆÄÀÏÀ» Ã·ºÎÇØ¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1023"] = "File should be attached about {0}";
			
	        //this.messages["JSM-1024"] = "{0}¿¡ ´ëÇÑ Ã·ºÎ °¡´ÉÇÑ ÆÄÀÏÀÇ È®ÀåÀÚ´Â {1} ÀÔ´Ï´Ù";
			this.messages["JSM-1024"] = "Attachable file's extension for {0} is {1}";
			
	        //this.messages["JSM-1025"] = "{0}¿¡ ´ëÇÏ¿© È®ÀåÀÚ°¡ {1}ÀÎ ÆÄÀÏÀº Ã·ºÎ°¡ ±ÝÁöµÇ¾î ÀÖ½À´Ï´Ù";
			this.messages["JSM-1025"] = "Extension{1}file for{0} attaching is restricted.";

	        //this.messages["JSM-1026"] = "ÀÔ·ÂÇÏ½Å {0} Crontab Ç¥Çö½ÄÀ¸·Î À¯È¿ÇÏÁö ¾Ê½À´Ï´Ù.<br/> ´Ù½Ã ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À!";
			this.messages["JSM-1026"] = "Inserted {0} is not available as Crontab expression.<br/> Please Insert again.!";
			
	        //this.messages["JSM-1027"] = "{0}ÀÇ  {1} ¿Ã¹Ù¸¥ ¼Ó¼º Ç¥Çö½ÄÀÌ ¾Æ´Õ´Ï´Ù";
			this.messages["JSM-1027"] = "{0}of {1} Not correct attibute expression.";
			
	        //this.messages["JSM-1028"] = "{0}ÀÇ ¼Ó¼º  {1} ÇÊ¿äÇÕ´Ï´Ù";
			this.messages["JSM-1028"] = "{0}'s attribute{1} needs.";
			
	        //this.messages["JSM-1029"] = "°ü·Ã ´ä±Ûµµ ÇÔ²² »èÁ¦µË´Ï´Ù. »èÁ¦ÇÏ½Ã°Ú½À´Ï±î?";
			this.messages["JSM-1029"] = "Relevant comment would delete as well. Would you like to delete?";
			
	        //this.messages["JSM-1030"] = "ÀÔ·ÂÇÏ½Å {0} ÀüÈ­¹øÈ£ Çü½Ä¿¡ ¸ÂÁö ¾Ê½À´Ï´Ù.<br/> ´Ù½Ã ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À";
			this.messages["JSM-1030"] = "Inserted {0} is not correct with phone no. type.<br/> Please Insert again.";
			
	        //this.messages["JSM-1031"] = "ÀÔ·ÂÇÏ½Å {0} ÇÑ±Û¸¸ ÀÔ·Â ÇÒ ¼ö ÀÖ½À´Ï´Ù.<br/> ´Ù½Ã ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À";
			this.messages["JSM-1031"] = "Inserted {0} is only available Korean characters.<br/> Please Insert again.";
			
	        //this.messages["JSM-1032"] = "ÀÔ·ÂÇÏ½Å {0} ¿µ¾î¸¸ ÀÔ·Â ÇÒ ¼ö ÀÖ½À´Ï´Ù.<br/> ´Ù½Ã ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À";
			this.messages["JSM-1032"] = "Inserted {0} is only available Alphabet.<br/> Please Insert again.";
			
	        //this.messages["JSM-1033"] = "{0}ÀÇ ÀÚ¸®¼ö´Â {1}ÀÚ ÀÌ¿©¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1033"] = "{0}'s digits should be {1}digit(s)";
			
	        //this.messages["JSM-1034"] = "{0}ÀÇ ÀÚ¸®¼ö´Â {1}ÀÚ¿¡¼­ {2}ÀÚ »çÀÌ¿©¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1034"] = "{0}'s digits should be between {1}digits and {2}digits";
			
            //this.messages["JSM-1035"] = "ÀÔ·ÂÇÏ½Å {0}ÀÇ ¹øÈ£¿Í {1}ÀÇ ¹øÈ£°¡ ÀÏÄ¡ÇÏÁö¾Ê½À´Ï´Ù.<br/> ´Ù½Ã ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À";
			this.messages["JSM-1035"] = "Inserted {0}'s number and {1}'s number is not matched.<br/> Please Insert again";
			
            //this.messages["JSM-1036"] = "{0} {1}¿ø ÀÌ»ó {2}¿ø ÀÌÇÏ·Î °¡´ÉÇÕ´Ï´Ù.";
			this.messages["JSM-1036"] = "{0} Available over {1}won under{2}won.";
			
			//this.messages["JSM-1036-TRANS"] = "Ãâ±Ý°èÁÂÀÇ Áö±Þ°¡´ÉÀÜ¾×ÀÌ ºÎÁ·ÇÕ´Ï´Ù.";
			this.messages["JSM-1036-TRANS"] = "Withdrawal available balance is not sufficent in the Account.";
			
            //this.messages["JSM-1036-FOR"] = "{0} [{1}] {2}{4} ÀÌ»ó {3}{4} ÀÌÇÏ·Î °¡´ÉÇÕ´Ï´Ù.";
			this.messages["JSM-1036-FOR"] = "{0} [{1}] over{2}{4} under {3}{4} available.";
			
            //this.messages["JSM-1037"] = "{0} {1}¿ø ÀÌ»ó {2}¿ø ÀÌÇÏ ¸¸¿ø´ÜÀ§·Î °¡´ÉÇÕ´Ï´Ù.";
			this.messages["JSM-1037"] = "{0} {1}won over {2}won under available 10,000won unit.";
			
            //this.messages["JSM-1038"] = "{0} {1}¿ø ÀÌ»ó °¡´ÉÇÕ´Ï´Ù.";
			this.messages["JSM-1038"] = "{0} {1}won over available.";

            //this.messages["JSM-1039"] = "{0}¿¡ µ¥ÀÌÅÍ°¡ ¾ø½À´Ï´Ù.";
			this.messages["JSM-1039"] = "There is no data in {0}.";
			
            //this.messages["JSM-1040"] = "{0}¿¡ µ¥ÀÌÅÍ¸¦ ¼±ÅÃÇØ ÁÖ¼¼¿ä";
			this.messages["JSM-1040"] = "Please select data in{0}";
			
            //this.messages["JSM-1041"] = "{0}¿¡ ÀÔ·Â ±ÝÁö ¹®±¸ÀÎ <font color='red'>{1}</font> (ÀÌ)°¡ µé¾îÀÖ½À´Ï´Ù.<br/> ´Ù½Ã ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À";
			this.messages["JSM-1041"] = "Restricted pharagraph <font color='red'>{1}</font> is inserted in {0}.<br/> Please insert again.";
			
            //this.messages["JSM-1042"] = "{0}Çà {1}¿­ {2} {3}";
			this.messages["JSM-1042"] = "{0}line {1}row {2} {3}";
			
            //this.messages["JSM-1043"] = "ÀÔ·ÂÇÏ½Å {0} »ç¾÷ÀÚ¹øÈ£ Çü½Ä¿¡ ¸ÂÁö ¾Ê½À´Ï´Ù.<br/> ´Ù½Ã ÀÔ·ÂÇÏ¿© ÁÖ½Ê½Ã¿À";
			this.messages["JSM-1043"] = "Inserted {0} is not correct with Business Reg.Number Type.<br/> Please Insert again.";
			
            //this.messages["JSM-1044"] = "{0) {1}ÀÌ¿©¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1044"] = "{0) should be {1}";
			
            //this.messages["JSM-1045"] = "{0} {1} {2}»çÀÌ¿©¾ß ÇÕ´Ï´Ù";
			this.messages["JSM-1045"] = "{0} be between {1} and {2}";
			
            //this.messages["JSM-1046"] = "{0} ÃÖ´ë {1}ÀÔ´Ï´Ù. {2} Á¶Á¤ÇÏ¿© ÁÖ½Ê½Ã¿À.";
			this.messages["JSM-1046"] = "{0} is up to {1}. {2} adjust please.";
			
            //this.messages["JSM-1047"] = "ºÎÀûÀýÇÑ {0}ÀÔ´Ï´Ù.";
			this.messages["JSM-1047"] = "Incorrect {0}.";
			this.messages["JSM-1048"] = "Inserted {0} Korean character or special character is not available.<br/> Available special character is /-?:().,'+{}.<br/>Please insert again.";
            this.init = true;
        }
    },

    get : function(id, args) {
        //init ½ÇÇà
        this.initMsgs();

        var message = this.messages[id];


        if (!message) {
	        return id;
	    }

        if (args) {

            try{
                if (typeof args == "object" && args.length) {
                    for (var i = 0; i < args.length; i++) {
                        var pattern = new RegExp("\\{" + i + "\\}", "g");
                        message = message.replace(pattern, args[i]);
                    }
                } else {
                    message = message.replace(/\{0\}/g, args);
                }
            }catch(e){}
        }

        return message;
	},

    /**
     * ¸Þ¼¼Áö ¼³Á¤
     * @param id ¸Þ¼¼Áö ID
     * @param msg Ãâ·Â ÇÒ ¸Þ¼¼Áö
     */
    set : function(id, msg){
        //init ½ÇÇà
        this.initMsgs();

        this.messages[id] = msg; 
    },

    /**
	 * È­¸é´Ü¿¡ ¸Þ¼¼Áö¹Ú½º¸¦ ExtJS·Î ±¸ÇöÇÑ´Ù.
	 * @param {Object} obj ¸Þ¼¼Áö¹Ú½º°¡ ÆîÃÄÁú¶§ ¾Ö´Ï¸ÞÀÌ¼ÇÀÌ ½ÃÀÛÇÒ ¿ÀºêÁ§Æ®
	 * @param {Object} id Ãâ·ÂÇÒ ¸Þ¼¼ÁöÆÐÅÏ ¾ÆÀÌµð
	 * @param {Object} args ¸Þ¼¼ÁöÆÐÅÏ¿¡ µî·ÏÇÒ µ¥ÀÌÅÍ
	 * @param {Object} isFocus ¾Ö´Ï¸ÞÀÌ¼ÇÀÌ ½ÃÀÛÇÒ ¿ÀºêÁ§Æ®¿¡ Æ÷Ä¿½º¼±ÅÃ ¿©ºÎ
	 */
	alert : function(obj, id, args, isFocus) {
		var alertMsg = this.get(id, args);

        //¿¡·¯ ¸Þ¼¼Áö ÃÊ±âÈ­
        this.init = false;

        pbk.extJS.messageBox.errMsgBox({
			isConfirm: false,
			title: 'Input Error',
			message: alertMsg,
			callback: function(e){
                if (isFocus) {
					try{
                        obj.focus();
                        obj.select();
                    }catch(ex){/* ignore this */}
				}
			}
		});
    },

    /**
	 * ±×¸®µå µ¥ÀÌÅÍ °ËÁõ alert Ã¢
	 * @param {rowIdx} ÇØ´ç rowIdx
	 * @param {colIdx} ÇØ´ç colIdx
	 * @param {gridObj} ±×¸®µå Object
	 * @param {msg} Ãâ·Â µÉ ¹®ÀÚ¿­
	 */
	gridAlert : function(rowIdx, colIdx, gridObj, msg) {
		var columnName = gridObj.GetColumn(colIdx).Caption;
        pbk.extJS.messageBox.errMsgBox({
			isConfirm: false,
			title: 'ÀÔ·Â¿À·ù',
			message: this.get('JSM-1042', [(rowIdx+1), colIdx, columnName, msg]),
			callback: function(e){
                gridObj.FocusedRecordIndex = rowIdx;
                gridObj.FocusedItemIndex = colIdx;
                gridObj.SetFocus();
			}
		});
    }
}
var messages = new hana.JMessage();

/** #. start JForm control **/
/**
 * Class ¸í : JForm
 * ¼³¸í : Form °ü¸®
 */
hana.JForm = function() { // »ý¼ºÀÚ ¸Þ¼Òµå
    /* Member field */
    this.children = new Array();
}

hana.JForm.prototype = {
	/* Member method */
	add : function(child) {
	    this.children[this.children.length] = child;
	    return this;
	},
	validate : function() {
	    for (var i = 0; i < this.children.length; i++) {
	        if (!this.children[i].validate()) {
	            return false;
	        }
	    }
	    return true;
	}
}
/** #. end JForm control **/

/** #. start JText control TYPE¿¡ µû¶ó Ãß°¡ Á¤ÀÇÇÑ´Ù. **/
/**
 * Class ¸í : JText
 *
 * ¼³¸í : text Å¸ÀÔ °ü¸®
 * validate method¸¦ Á¦¿ÜÇÑ ³ª¸ÓÁö´Â ¸ðµÎ chained method ÀÔ´Ï´Ù.
 *
 * »ç¿ë ¿¹ :
 * new hana.JText('ÀÌ¸§', formObj.name).nullable().range(4,10).isEnglish()
 * À§ ¼Ò½º´Â name ÇÊµå¿¡ ºó°ªÀÌ ¿Ã ¼ö ÀÖÀ¸¸ç 4,10ÀÚ »çÀÌÀÇ ¿µ¾î¸¸ ÀÔ·Â ÇÒ ¼ö ÀÖµµ·Ï
 * ¼³Á¤ÇÑ ³»¿ëÀÔ´Ï´Ù.
 *
 * filter method ¸¦ ÅëÇØ Æ¯¼ö¹®ÀÚÀÔ·ÂÀ» filtering ÇÕ´Ï´Ù.
 *
 * checkRegExp method ´Â Á¤±Ô½ÄÀ» ÅëÇÑ Ã¼Å©¸¦ °¡´ÉÇÏ°Ô ÇØÁÝ´Ï´Ù.
 * ÇÏÁö¸¸ »ç¿ëÀ» À§ÇØ¼± ¸Þ¼¼Áö¸¦ ¼³Á¤ ÇØ¾ß ÇÕ´Ï´Ù.
 *
 * @param {String} name
 * @param {HTMLElement} object
 */
hana.JText = function (name, object) {
    /* Member Field */
    this.name = name;
    this.object = object;

    this.min;
    this.max;

    this.nullCheck = true;
    this.rangeCheck = false;
    this.filterCheck = false;
    this.denyCharCheck = false;
    this.regExpCheck = false;

    this.pattern;
    this.filterPattern = "`~!@#$%^&*'\"/|";
	this.messageCode = "JSM-1004";
    this.messageParam = [name];

    this.nullable = hana.validation.nullable;
    this.range = hana.validation.range;

    this.setMsg = hana.validation.setMsg;
}
hana.JText.prototype =  {
    /* Member Method */
	/**
	 * ¹®ÀÚ¿­ Å¸ÀÔ À¯È¿¼º °Ë»ç
	 */
    validate : function(){

        //¿¡·¯ ¸Þ¼¼Áö ¼³Á¤
        if(this.isSetMsg)
            messages.set(this.id, this.msg);

        var value = this.object.value;

        if (this.nullCheck && hana.validation.isNull(value)) {
	        return messages.alert(this.object, "JSM-1004", this.name, true);
	    }

        if (this.regExpCheck && !hana.validation.isNull(value) && !this.pattern.test(value) ){
            return messages.alert(this.object, this.messageCode, this.messageParam, true);
        }

        if (this.rangeCheck && !hana.validation.isNull(value) && !hana.validation.checkCharacterSize(value, this.min, this.max)) {
	        if (this.min == this.max) {
	            return messages.alert(this.object, "JSM-1005", [this.name, this.min], true);
	        } else {
	            return messages.alert(this.object, "JSM-1006", [this.name, this.min, this.max], true);
	        }
	    }

        if (this.filterCheck && hana.validation.isExistSpacialChar(value, this.filterPattern) ){
            return messages.alert(this.object, "JSM-1007", [this.name, this.filterPattern], true);
        }

        //Ç°¸ñ¸í °ËÁõ
        if (this.denyCharCheck){
            var message = hana.validation.getExistDenyCharArr(value);

            if( message.length > 0 ){
                messages.alert(this.object, "JSM-1041", [this.name, message.join(", ")], true);
                return false;
            }

            //ºÎÀûÀýÇÑ Ç°¸ñ¸íÀÎÁö Ã¼Å©ÇÕ´Ï´Ù.
            if(hana.validation.isInCorrectRpsMitmNm(value)){
                messages.alert(this.object, "JSM-1047", [this.name], true);
                return false;
            }

        }

        return true;
	},

    /**
	 * ÀüÈ­¹øÈ£ Çü½Ä Ã¼Å©ÇÔ.
	 * ex) 02-523-5353, 023.3552.2353, 02 202 4024, 0324236450
	 * ÁÖÀÇ: ±¸ºÐÀÚ°¡ ¾øÀ» °æ¿ì Á¤È®ÇÑ ÀüÈ­¹øÈ£¸¦ Ã¼Å©ÇÒ ¼ö ¾øÀ½
	 */
    isTelnum : function() {
        this.checkRegExp( new RegExp("^(02|031|032|033|041|042|043|051|052|053|054|055|061|062|063|064|010|011|015|016|017|018|019)[-. ]?[0-9]{3,4}[-. ]?[0-9]{4}$","g"), "JSM-1030", ([this.name]));
        return this;
	},

    /**
	 * ÀÌ¸ÞÀÏ Çü½Ä Ã¼Å©ÇÔ.
	 */
    isEmail : function() {
	    this.checkRegExp( new RegExp("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$","ig"), "JSM-1017", ([this.name]));
        return this;
	},

    /**
	 * ÇÑ±Û Çü½ÄÃ¼Å©ÇÔ. ÇÑ±Û¸¸ Á¸Àç ÇØ¾ßÇÔ. (°ø¹é ºÒ°¡´É)
	 */
    isKorean : function() {
	    this.checkRegExp( new RegExp("^[°¡-Èþ]+$","g"), "JSM-1031", ([this.name]));
        return this;
	},

    /**
	 * ¿µ¾î Çü½ÄÃ¼Å©ÇÔ. ¿µ¾î¸¸ Á¸Àç ÇØ¾ßÇÔ. (°ø¹é, ',', '.', '_' °¡´É)
	 */
    isEnglish : function() {
	    this.checkRegExp( new RegExp("^[A-Z0-9.,_\\s]+$","ig"), "JSM-1032", ([this.name]));
        return this;
	},

    /**
	 * »ç¾÷ÀÚ¹øÈ£ Çü½ÄÃ¼Å©ÇÔ. 000-00-00000, 0000000000
	 */
    isBizNo : function() {
	    this.checkRegExp( new RegExp("^[0-9]{3}-?[0-9]{2}-?[0-9]{5}-?$","ig"), "JSM-1043", ([this.name]));
        return this;
	},


    /**
     * Á¤±Ô½ÄÀ» ÀÎÀÚ·Î ¹Þ¾Æ¼­ Ã¼Å©ÇÑ´Ù.
     * ¸Þ¼¼Áö Á¤ÀÇ ÇÊ¿äÇÕ´Ï´Ù.
     *
     * @param reg Á¤±Ô½Ä
     * @param msgCd ¸Þ¼¼Áö ÄÚµå
     * @param msgParam ¸Þ¼¼Áö param
     */
    checkRegExp : function(reg, msgCd, msgParam) {
	    this.regExpCheck = true;
        this.pattern = reg;
        this.messageCode = msgCd;
        this.messageParam = msgParam;
        return this;
	},

    /**
     * Æ¯¼ö¹®ÀÚ Çã¿ë¾ÈÇÔ
     * `~!@#$%^&*'\"
     */
    filter : function (pattern){
		if( pattern ){
			this.filterPattern = pattern;
		}
        this.filterCheck = true;
        return this;
    },

    /**
     * ÀÔ·Â ±ÝÁö ¹®±¸ Ã¼Å©¿©ºÎ
     */
    denyChar : function (){
        this.denyCharCheck = true;
        return this;
    }
}
/** #. end JText**/

/** #. start JNumber control TYPE¿¡ µû¶ó Ãß°¡ Á¤ÀÇÇÑ´Ù. **/
/**
 * Class ¸í : JNumber
 *
 * ¼³¸í : number Å¸ÀÔ °ü¸®
 * validate method¸¦ Á¦¿ÜÇÑ ³ª¸ÓÁö´Â ¸ðµÎ chained method ÀÔ´Ï´Ù.
 *
 * »ç¿ë ¿¹ :
 * new hana.JNumber('³ªÀÌ', formObj.age).nullable().range(1,999)
 * À§ ¼Ò½º´Â age ÇÊµå¿¡ ¼ýÀÚ¸¸ ÀÔ·Â °¡´ÉÇÏ°í ºó°ªÀÌ ¿Ã ¼ö ÀÖÀ¸¸ç 1~999 ±îÁöÀÇ ¼ýÀÚ¸¸ ÀÔ·Â
 * ÇÒ ¼ö ÀÖµµ·Ï ¼³Á¤ÇÑ ³»¿ëÀÔ´Ï´Ù.
 *
 * @param {String} name
 * @param {HTMLElement} object
 * @param {String} »ý¼ºµÉ hidden ÇÊµå¸í
 */
hana.JNumber = function(name, object, targetElId){
    /* Member Field */
    this.name = name;
    this.object = object;
    this.targetElId = targetElId;

    this.nullCheck = true;
    this.rangeCheck = false;
    this.lengthCheck = false;

    this.min;
    this.max;

    this.minlength;
    this.maxlength;

    this.nullable = hana.validation.nullable;
    this.range = hana.validation.range;

    this.setMsg = hana.validation.setMsg;
}
hana.JNumber.prototype = {
	/* Member Method */
	/**
	 * NumberÅ¸ÀÔ À¯È¿¼º °Ë»ç
	 */
	validate : function(){

        //¿¡·¯ ¸Þ¼¼Áö ¼³Á¤
        if(this.isSetMsg)
            messages.set(this.id, this.msg);

        var value = this.object.value;

        //nullcheck
        if (this.nullCheck && hana.validation.isNull(value) ) {
	        return messages.alert(this.object, "JSM-1004", (this.name), true);
	    }

        // null ÀÌ ¾Æ´Ñ °æ¿ì ¼ýÀÚÀÎÁö Ã¼Å©
	    if (isNaN(value)) {
	        return messages.alert(this.object, "JSM-1008", this.name, true);
	    }

        //¹üÀ§ Ã¼Å© ex) 1~999
        if (this.rangeCheck && !hana.validation.isNull(value) && !hana.validation.checkNumberSize(value, this.min, this.max)) {
	        if (this.min == this.max) {
	            return messages.alert(this.object, "JSM-1009", [this.name, this.min], true);
	        } else {
	            return messages.alert(this.object, "JSM-1010", [this.name, (this.min), this.max], true);
	        }
	    }

        // ÀÚ¸®¼ö Ã¼Å©
        if (this.lengthCheck && !hana.validation.isNull(value) && !hana.validation.checkNumberLength(value, this.minlength, this.maxlength)) {
	        if (this.minlength == this.maxlength) {
	            return messages.alert(this.object, "JSM-1033", [this.name, this.minlength], true);
	        } else {
	            return messages.alert(this.object, "JSM-1034", [this.name, this.minlength, this.maxlength], true);
	        }
	    }

        return true;
	},

    limitLength : function(min, max){
        this.minlength = min;
        this.maxlength = max;
        this.lengthCheck = true;
        return this;
    }
}
/** #. end JNumber control **/

/** #. start JCurrency control TYPE¿¡ µû¶ó Ãß°¡ Á¤ÀÇÇÑ´Ù. **/
/**
 * Class ¸í : JCurrency
 *
 * ¼³¸í : number Å¸ÀÔ °ü¸®
 * validate method¸¦ Á¦¿ÜÇÑ ³ª¸ÓÁö´Â ¸ðµÎ chained method ÀÔ´Ï´Ù.
 *
 * »ç¿ë ¿¹ :
 * new hana.JCurrency('³ªÀÌ', formObj.age).nullable().range(1,999)
 * À§ ¼Ò½º´Â age ÇÊµå¿¡ ¼ýÀÚ¸¸ ÀÔ·Â °¡´ÉÇÏ°í ºó°ªÀÌ ¿Ã ¼ö ÀÖÀ¸¸ç 1~999 ±îÁöÀÇ ¼ýÀÚ¸¸ ÀÔ·Â
 * ÇÒ ¼ö ÀÖµµ·Ï ¼³Á¤ÇÑ ³»¿ëÀÔ´Ï´Ù.
 *
 * @param {String} name
 * @param {HTMLElement} object
 * @param {String} »ý¼ºµÉ hidden ÇÊµå¸í
 */
hana.JCurrency = function(name, object, targetElId){
    /* Member Field */
    this.name = name;
    this.object = object;
    this.targetElId = targetElId;

    this.nullCheck = true;
    this.rangeCheck = false;
    this.rangePointCheck = false;
    this.rangeMoneyCheck = false;
    this.rangeDollarCheck = false;
    this.lengthCheck = false;

    this.min;
    this.max;
    this.type;
    this.curr;

    this.minlength;
    this.maxlength;

    this.nullable = hana.validation.nullable;
    this.range = hana.validation.range;
    this.rangeMoney = hana.validation.rangeMoney;
    this.rangePoint = hana.validation.rangePoint;
    this.rangeDollar = hana.validation.rangeDollar;

    this.setMsg = hana.validation.setMsg;
}

hana.JCurrency.prototype = {
    /**
	 * CurrencyÅ¸ÀÔ À¯È¿¼º °Ë»ç
	 */
	validate : function(){

        //¿¡·¯ ¸Þ¼¼Áö ¼³Á¤
        if(this.isSetMsg)
            messages.set(this.id, this.msg);

        var value = this.object.value;

        //nullcheck
        if (this.nullCheck && hana.validation.isNull(value) ) {
	        return messages.alert(this.object, "JSM-1004", (this.name), true);
	    }

        // null ÀÌ ¾Æ´Ñ °æ¿ì ¼ýÀÚÀÎÁö Ã¼Å©
        if (!hana.validation.isNull(value) && hana.validation.isNaN(value)) {
	        return messages.alert(this.object, "JSM-1008", this.name, true);
	    }

        //¹üÀ§ Ã¼Å© ex) 1~999
        if (this.rangeCheck && !hana.validation.isNull(value) && !hana.validation.checkNumberSize(value, this.min, this.max)) {
	        if (this.min == this.max) {
	            return messages.alert(this.object, "JSM-1009", [this.name, this.min], true);
	        } else {
	            return messages.alert(this.object, "JSM-1010", [this.name, (this.min), this.max], true);
	        }
	    }

        //¹üÀ§ Ã¼Å© ex) 1~999,999
        if (this.rangePointCheck && !hana.validation.isNull(value) && !hana.validation.checkNumberSize(value, this.min, this.max)) {
            //@±èÁØ : ¼ýÀÚ ¿¡·¯¸Þ¼¼Áö½Ã¿¡ ÀÚ¸®¼ö ',' Ãß°¡ÇÏ¿© Ç¥½ÃÇÕ´Ï´Ù.
            var str_min = html.toMoney(this.min);
            var str_max = html.toMoney(this.max);        
            if (this.min == this.max) {
                return messages.alert(this.object, "JSM-1044", [(this.name), str_min], true);
            } else if(this.type == '1'){
                return messages.alert(this.object, "JSM-1045", [(this.name), (str_min), str_max], true);
            } else if(this.type == '2'){
                str_max = html.toMoney(this.max+'0000');    // ¸¸¿ø´ÜÀ§ ÀÔ·ÂÃ¢¿¡¼­ max°ª ¿À·ù¸Þ¼¼Áöµµ ¸¸¿ø´ÜÀ§·Î º¸¿©ÁØ´Ù.
                return messages.alert(this.object, "JSM-1037", [(this.name), str_min, str_max], true);    
            }
        }        
	    
	    //±Ý¾×Ã¼Å© 
	    if(this.rangeMoneyCheck && !hana.validation.isNull(value) && "" != hana.validation.checkMoney(value,this.min, this.max, this.type)) {
		    //var str_min = hana.validation.getKoreaMoney(this.min);
		    //var str_max = hana.validation.getKoreaMoney(this.max);
			//@¸ð±Ù¿ø : ±Ý¾× ¿¡·¯¸Þ¼¼Áö½Ã¿¡ ¼ýÀÚ·Î Ç¥½ÃÇÕ´Ï´Ù.
			var str_min = html.toMoney(this.min);
		    var str_max = html.toMoney(this.max);
	    	if(this.type == "1") {
	    		return messages.alert(this.object, "JSM-1036", [(this.name), str_min, str_max], true);
	    	} else if(this.type == "2") {
	    		return messages.alert(this.object, "JSM-1037", [(this.name), str_min, str_max], true);
	    	} else if(this.type == "3") {
	    		return messages.alert(this.object, "JSM-1038", [(this.name), str_min, str_max], true);
	    	} else if(this.type == "4") {
	    		return messages.alert(this.object, "JSM-1036-TRANS", [this.name, str_min, str_max], true);
	    	}
	    }
	    //¿ÜÈ­ ±Ý¾×Ã¼Å© 
	    if(this.rangeDollarCheck && !hana.validation.isNull(value) && !hana.validation.checkDollar(value, this.min, this.max, this.type)) {
			//@±èÁØ : ¿ÜÈ­ ±Ý¾× ¿¡·¯¸Þ¼¼Áö½Ã¿¡ ¼ýÀÚ·Î Ç¥½ÃÇÕ´Ï´Ù.
            var str_min = hana.JHanaUtils.input.toFormatDollarMoney(this.min);
            var str_max = hana.JHanaUtils.input.toFormatDollarMoney(this.max); 

            // ¼Ò¼öÁ¡ ÇÊ¿ä¾ø´Â ÅëÈ­ÄÚµå
            var NO_POINT_CUR_MAP = ['KRW','ESP','IDR','ITL','JPY'];
            
            for(i=0; i<NO_POINT_CUR_MAP.length; i++){
                if(NO_POINT_CUR_MAP[i] == this.type){
                    if(str_min.indexOf('.') > -1) str_min = str_min.substring(0,str_min.indexOf('.'));  // ¼Ò¼öÁ¡ »èÁ¦
                    if(str_max.indexOf('.') > -1) str_max = str_max.substring(0,str_max.indexOf('.'));  // ¼Ò¼öÁ¡ »èÁ¦
                }
            }
        
	    	return messages.alert(this.object, "JSM-1036-FOR", [(this.name), this.type, str_min, str_max, this.curr], true);
	    }

        // ÀÚ¸®¼ö Ã¼Å©
        if (this.lengthCheck && !hana.validation.isNull(value) && !hana.validation.checkNumberLength(value, this.minlength, this.maxlength)) {
	        if (this.minlength == this.maxlength) {
	            return messages.alert(this.object, "JSM-1033", [this.name, this.minlength], true);
	        } else {
	            return messages.alert(this.object, "JSM-1034", [this.name, this.minlength, this.maxlength], true);
	        }
	    }

        //hana.validation.makeHiddenInput(this, value, /[,]/g);
        return true;
	},
    limitLength : function(min, max){
        this.minlength = min;
        this.maxlength = max;
        this.lengthCheck = true;
        return this;
    }
}
/** #. end JCurrency control **/

/** #. start Date control **/
/**
 * Class ¸í : JDate
 *
 * ¼³¸í : Date Å¸ÀÔ °ü¸®
 * nullable °ú range method¸¸ÀÌ chained method ÀÔ´Ï´Ù.
 *
 * toString Àº ÀÔ·ÂµÈ ³¯Â¥¸¦ this.format = "YYYY³âMM¿ùDDÀÏ(DAY)" ¿¡ Á¤ÀÇµÈ
 * Çü½ÄÀ¸·Î ¹ÝÈ¯ÇØ ÁÖ´Â methodÀÔ´Ï´Ù.( ¸Þ¼¼Áö Ãâ·Â½Ã ³»ºÎÀû È£Ãâ )
 * toDate => Date Å¬·¡½º·Î ¹ÝÈ¯.
 *
 * »ç¿ë ¿¹ :
 * new hana.JDate('³¯Â¥', formObj.date).nullable().range('20050101','20070101')
 * À§ ¿¹Á¦´Â date ÇÊµå¿¡ ºó°ªÀÌ ¿Ã¼ö ÀÖÀ¸¸ç 20050101 ºÎÅÍ 20070101 ±îÁö ³¯Â¥ ÀÔ·Â¿¡
 * Á¦ÇÑÀ» µÐ ¼³Á¤ÀÔ´Ï´Ù.
 *
 * new hana.JDate('³¯Â¥', formObj.date, /^\d{4}[³â]?\d{2}[¿ù]?\d{2}[ÀÏ]?$/)
 * date ÇÊµå¿¡ ÀÔ·ÂµÇ´Â ³¯Â¥ Çü½ÄÀÌ 2007³â02¿ù20ÀÏ °ú °°Àº Çü½ÄÀÏ ¶§ ³¯Â¥ ÀÔ·Â
 * ¿©ºÎ¸¦ Ã¼Å©ÇÏµµ·Ï ¼³Á¤ÇÑ ³»¿ëÀÔ´Ï´Ù.
 *
 * ±âÁ¸ ¼³Á¤Àº ±¸ºÐÀÚ°¡ ¾ø°Å³ª '-','.','/'¸¦ ±¸ºÐÀÚ·Î »ç¿ëÇÏ´Â ³¯Â¥ Çü½ÄÀÌ¸ç
 * ÀÌ¿ÜÀÇ ³¯Â¥ ÀÔ·Â½Ã Àß¸øµÈ ³¯Â¥·Î °£ÁÖ ÇÕ´Ï´Ù.
 *
 * ¹Ýµå½Ã ³âµµ 4ÀÚ¸®, ¿ù 2ÀÚ¸®, ÀÏ 2ÀÚ¸®·Î ±¸¼ºµÇ´Â Çü½ÄÀÌ¿©¾ß ÇÏ¸ç
 * Æ¯º°ÇÑ ±¸ºÐÀÚ¸¦ »ç¿ëÇÒ °æ¿ì ÇØ´çÇÏ´Â ±¸ºÐÀÚ Çü½ÄÀÇ Á¤±Ô½ÄÀ» ³Ñ°ÜÁÖ¾î¾ß ÇÕ´Ï´Ù.
 *
 * Ãß°¡ ÀÛ¾÷ : targetElId ÀÎÀÚ¸¦ ¹Þ¾Æ validation ¼º°ø ½Ã targetElId ·Î hidden ÇÊµå¸¦ ¸¸µì´Ï´Ù.
 *
 * @param {String} name
 * @param {HTMLElement} object
 * @param {String} »ý¼ºµÉ hidden ÇÊµå¸í
 * @param {Object} regExp Á¤±Ô½Ä °´Ã¼
 *
 */
hana.JDate = function(name, object, targetElId, re) { // »ý¼ºÀÚ ÇÔ¼ö
	this.DAY_OF_WEEK = new Array("Sun","Mon","Tue","Wed","Tue","Fri","Sat");
    /* Member Field */
    this.name = name;
    this.object = object;

    this.nullCheck = true;
    this.rangeCheck = false;

    this.date = null;

	this.targetElId = targetElId;

    if (re)  {
    	this.re = re;
    } else {
		this.re = /^\d{4}[-.\/]?\d{2}[-.\/]?\d{2}$/;
    }

    this.min = null; /* YYYYMMDD Format */
    this.max = null; /* YYYYMMDD Format */

    this.format = "YYYY-MM-DD (DAY)";

    this.parse();

    this.nullable = hana.validation.nullable;
    this.range = hana.validation.range;

    this.setMsg = hana.validation.setMsg;
}
hana.JDate.prototype = {
	/* Member Method */
	/**
	 * DateÅ¸ÀÔ À¯È¿¼º °Ë»ç
	 */
    validate : function(){

        //¿¡·¯ ¸Þ¼¼Áö ¼³Á¤
        if(this.isSetMsg)
            messages.set(this.id, this.msg);

        var value = this.object.value;

        // null check
        if (this.nullCheck && hana.validation.isNull(value)) {
	        return messages.alert(this.object, "JSM-1004", (this.name), true);
	    }

        // nullable ÀÎ °æ¿ì null ÀÌ¸é ¿©±â¼­ return true ÇÑ´Ù.
        if (!this.nullCheck && hana.validation.isNull(value)) {
	        //hana.validation.makeHiddenInput(this, value, /[^\d]/g);
            return true;
	    }

        // À¯È¿³¯Â¥ Ã¼Å©
        if (this.date == null) {
	        return messages.alert(this.object, "JSM-1018", (this.name), true);
	    }

        // ¹üÀ§ Ã¼Å©
        if (this.rangeCheck) {
	        var aDate = this.toDate();
	        var minDate, maxDate;

	        if (this.min != null && this.min != "") {
	            minDate = new hana.JDate().parse(this.min);
	        } else {
	            minDate = new hana.JDate().parse("10000101");
	        }
	        if (this.max != null && this.max != "") {
                maxDate = new hana.JDate().parse(this.max);
	        } else {
	            maxDate = new hana.JDate().parse("99991231");
	        }

            if (this.min == null && aDate > maxDate.toDate()) {
	            return messages.alert(this.object, "JSM-1019", [this.name, maxDate], true);
	        } else if (this.max == null && aDate < minDate.toDate()) {
	            return messages.alert(this.object, "JSM-1020", [this.name, minDate], true);
	        } else if (aDate > maxDate.toDate() || aDate < minDate.toDate()) {
	            return messages.alert(this.object, "JSM-1021", [this.name, minDate, maxDate], true);
	        }
	    }

        //hana.validation.makeHiddenInput(this, value, /[^\d]/g);
        return true;
	},

    /**
	 * Date ¹ÝÈ¯
	 */
	toDate :  function() {
	    return this.date;
	},

	/**
	 * ¹®ÀÚ¿­À» Date Å¬·¡½º·Î parsing ÇÕ´Ï´Ù.
	 */
	parse : function() {
	    var value = this.object;
	    if (this.parse.arguments.length > 0) {
	        value = this.parse.arguments[0];
	    } else if (this.object && typeof this.object=="object") {
	        value = this.object.value;
	    } else {
	        this.date = new Date();
	        return this;
	    }

	    this.date = null;
	    if (value.search(this.re) >= 0) {
            var chkVal = value.replace(/[^\d]/g,"");
//	        value = value.replace(/[^\d]/g,"");
	        var aDate = new Date(chkVal.substring(0,4),chkVal.substring(4,6)-1,chkVal.substring(6,8));
	        if (   aDate.getFullYear()  == Math.abs(chkVal.substring(0,4))
	            && aDate.getMonth() == Math.abs(chkVal.substring(4,6))-1
	            && aDate.getDate()  == Math.abs(chkVal.substring(6,8)) ) {
	            this.date = aDate;
	        }
	    }
	    return this;
	},

	/**
	 * string Å¸ÀÔÀ¸·Î ¹ÝÈ¯
	 */
	toString : function() {
	    var formatString = this.format;
	    if (toString.arguments != undefined && toString.arguments.length > 0) {
	        formatString = toString.arguments[0];
	    }
	    var str = formatString.replace(/YYYY/g , this.getYear());
	    str = str.replace(/MM/g , this.getMonth());
	    str = str.replace(/DD/g , this.getDate());
	    str = str.replace(/DAY/g , this.getDay());
	    str = str.replace(/yy/g , new String(this.getYear()).substring(2,4));
	    return str;
	},
	getYear : function() {
	    return this.date == null ? 1000 : this.date.getFullYear();
	},
	getMonth : function () {
	    var num = (this.date == null ? 0 : this.date.getMonth()+1);
	    return (num < 10 ? '0' + new String(num) : num);
	},
	getDate : function() {
	    var num = (this.date == null ? 0 : this.date.getDate());
	    return (num < 10 ? '0' + new String(num) : num);
	},
	getDay : function() {
	    return (this.date == null ? this.DAY_OF_WEEK[0] : this.DAY_OF_WEEK[this.date.getDay()]);
	}
}
/** #. end Date control **/

/** #. start Check/Radio control **/
/**
 * Class ¸í : JCheck
 *
 * ¼³¸í : JCheck Å¸ÀÔ °ü¸®
 * nullable °ú range method¸¸ÀÌ chained method ÀÔ´Ï´Ù.
 *
 * »ç¿ë ¿¹ :
 * new hana.JCheck('Ã¼Å©', formObj.chk).nullable().range(2,3)
 * À§ ¿¹Á¦´Â chk ¼±ÅÃÀÌ ¼±ÅÃ µÇÁö ¾Ê¾Æµµ µÇ¸ç ¼±ÅÃ µÈ´Ù¸é 2°³¿¡¼­ 3°³ »çÀÌ°¡ ¼±ÅÃ µÇµµ·Ï
 * Á¦ÇÑÀ» µÐ ¼³Á¤ÀÔ´Ï´Ù.
 *
 * @param {String} name
 * @param {HTMLElement} object
 */
hana.JCheck = function (name, object) {

    /* Member Field */
    this.name = name;
    this.object = object;

    this.min;
    this.max;

    this.nullCheck = true;
    this.rangeCheck;

    this.nullable = hana.validation.nullable;
    this.range = hana.validation.range;

    this.setMsg = hana.validation.setMsg;
}

hana.JCheck.prototype = {
	validate : function() {

        //¿¡·¯ ¸Þ¼¼Áö ¼³Á¤
        if(this.isSetMsg)
            messages.set(this.id, this.msg);

        //var value = this.object;
	    var number = hana.validation.isCheckedCnt(this.object);

		if (this.nullCheck && number == 0) {
			return messages.alert(this.object, "JSM-1011", (this.name), false);
		}

		if (this.rangeCheck && number != 0 && (number < this.min || number > this.max)) {
		    if (this.min == this.max) {
				return messages.alert(this.object, "JSM-1012", [this.name, this.min], false);
		    } else {
				return messages.alert(this.object, "JSM-1013", [this.name, (this.min), this.max], false);
		    }
		}
	    return true;
	}
}
/** #. end Check/Radio control **/


/** #. start Select control **/
/**
 * Class ¸í : JSelect
 *
 * ¼³¸í : JSelect Å¸ÀÔ °ü¸®
 * nullable °ú range method¸¸ÀÌ chained method ÀÔ´Ï´Ù.
 *
 * »ç¿ë ¿¹ :
 * new hana.JSelect('¼±ÅÃ', formObj.select).nullable().range(1,2)
 * À§ ¿¹Á¦´Â select ¼±ÅÃÀÌ ¼±ÅÃ µÇÁö ¾Ê¾Æµµ µÇ¸ç ¼±ÅÃ µÈ´Ù¸é 1°³¿¡¼­ 2°³ »çÀÌ°¡ ¼±ÅÃ µÇµµ·Ï
 * Á¦ÇÑÀ» µÐ ¼³Á¤ÀÔ´Ï´Ù.
 *
 * @param {String} name
 * @param {HTMLElement} object
 */
hana.JSelect = function (name, object) {

    /* Member Field */
    this.name = name;
    this.object = object;

    this.min;
    this.max;

    this.nullCheck = true;
    this.rangeCheck;

    this.range = hana.validation.range;
    this.nullable = hana.validation.nullable;

    this.setMsg = hana.validation.setMsg;
}

hana.JSelect.prototype = {
    validate : function () {

        //¿¡·¯ ¸Þ¼¼Áö ¼³Á¤
        if(this.isSetMsg)
            messages.set(this.id, this.msg);

        var value = this.object.value;

        if (this.nullCheck && hana.validation.isNull(value)) {
            return messages.alert(this.object, "JSM-1011", (this.name), false);
        }

        var number = hana.validation.isSelectedCnt(this.object);

        if (this.rangeCheck && number != 0 && (number < this.min || number > this.max)) {
		    if (this.min == this.max) {
				return messages.alert(this.object, "JSM-1012", [this.name, this.min], false);
		    } else {
				return messages.alert(this.object, "JSM-1013", [this.name, (this.min), this.max], false);
		    }
		}
        return true;
    }
}
/** #. end Select control **/

/** #. start JFile control **/
/**
 * Class ¸í : JFile
 *
 * ¼³¸í : JFile Å¸ÀÔ °ü¸®
 * nullable, arrowFileExt, denyFileExt ÀÌ chained method ÀÔ´Ï´Ù.
 *
 * »ç¿ë ¿¹ :
 * new hana.JFile('ÆÄÀÏ', formObj.file).nullable().denyFileExt(['zip','exe'])
 * À§ ¿¹Á¦´Â file ¿¡ ÆÄÀÏÀ» Ã·ºÎ ÇÏÁö ¾Ê¾Æµµ µÇ¸ç Ã·ºÎ ½Ã È®ÀåÀÚ°¡ 'zip','exe' ÀÎ Çü½ÄÀº
 * Á¦ÇÑÀ» µÐ ¼³Á¤ÀÔ´Ï´Ù.
 *
 * @param {String} name
 * @param {HTMLElement} object
 */
hana.JFile = function (name, object) {
    /* Member Field */
    this.name = name;
    this.object = object;

    this.nullCheck = true;
    this.allowedExtension;
    this.disallowedExtension;

    this.nullable = hana.validation.nullable;

    this.setMsg = hana.validation.setMsg;
}

hana.JFile.prototype = {

    validate : function () {

        //¿¡·¯ ¸Þ¼¼Áö ¼³Á¤
        if(this.isSetMsg)
            messages.set(this.id, this.msg);

        var value = this.object.value;

        /*IE ¹ö±×·Î ÀÎÇÑ ÀÔ·Â°ª Á¤È®¼º Ã¼Å© */
        var re = /^[a-z]:\\(.){0,300}$/i;

        if (value != "" && !value.match(re)) {
            return messages.alert(this.object, "JSM-1022", true);
        }

        if (this.nullCheck && hana.validation.isNull(value)) {
            return messages.alert(this.object, "JSM-1023", [this.name], false);
        }

        if (this.allowedExtension) {
            var passed = true;
            var extension = hana.validation.getFileExt(value);
            if (extension) {
                for(var j = 0; j < this.allowedExtension.length ; j++) {
                    if (this.allowedExtension[j].toLowerCase() == extension) {
                        break;
                    }
                    if (j == this.allowedExtension.length - 1) {
                        passed = false;
                    }
                }
            }
            if (!passed) {
                return messages.alert(this.object, "JSM-1024", [this.name, this.allowedExtension.join(", ")], false);
            }
        }

        if (this.disallowedExtension) {
            var passed = true;
            var extension = hana.validation.getFileExt(value);
            if (extension) {
                for(var j = 0; j < this.disallowedExtension.length ; j++) {
                    if (this.disallowedExtension[j].toLowerCase() == extension) {
                        passed = false;
                        break;
                    }
                    if (j == this.disallowedExtension.length - 1) {
                        passed = true;
                    }
                }
            }
            if (!passed) {
                return messages.alert(this.object, "JSM-1025", [this.name, this.disallowedExtension.join(", ")], false);
            }
        }
        return true;
    },

    /**
     * Çã¿ë È®Àå¸í ¼³Á¤
     * @param array È®ÀåÀÚ array
     */
    allowFileExt : function (array) {
        this.allowedExtension = array;
        return this;
    },

    /**
     * ºÒ°¡ È®Àå¸í ¼³Á¤
     * @param array È®ÀåÀÚ array
     */
    denyFileExt : function (array) {
        this.disallowedExtension = array;
        return this;
    }

}
/** #. end JFile control **/


/** #. start JGrid control **/
/**
 * Class ¸í : JGrid
 *
 * ¼³¸í : JGrid Å¸ÀÔ °ü¸®
 * checkedData °¡ chained method ÀÔ´Ï´Ù.
 *
 * »ç¿ë ¿¹ :
 *
 *  ±×¸®µå¿¡ ¼±ÅÃÇÑ µ¥ÀÌÅÍ°¡ ÀÖ´ÂÁö Ã¼Å©ÇÕ´Ï´Ù.
 *
 *  if( !new hana.JGrid(gridObject).checkedData().validate() ){
 *      return;
 *  }
 *
 *  ±×¸®µå¿¡ Ã¼Å© °¡´ÉÇÑ µ¥ÀÌÅÍÀÇ °³¼ö¸¦ 1~5·Î Á¦ÇÑ ÇÕ´Ï´Ù.
 *
 *  if( !new hana.JGrid(gridObject).range(1,5).validate() ){
 *      return;
 *  }
 *
 *  ±×¸®µå¿¡ µ¥ÀÌÅÍ°¡ ÀÖ´ÂÁö Ã¼Å©ÇÕ´Ï´Ù.
 *
 *  if( !new hana.JGrid(gridObject).validate() ){
 *      return;
 *  }
 *
 * À§ ¿¹Á¦´Â grid¿¡¼­ Ã¼Å©µÈ µ¥ÀÌÅÍ°¡ ÀÖ´ÂÁö validation ÇÏ´Â ÄÚµåÀÔ´Ï´Ù.
 *
 * default´Â µ¥ÀÌÅÍ°¡ µé¾îÀÖ´ÂÁö¸¸ Ã¼Å©ÇÕ´Ï´Ù.
 *
 * @param {String} name
 * @param {Object} grid object
 */
hana.JGrid = function (object) {
    /* Member Field */
    this.object = object;
    this.name = object.GridName;
    this.isCheckedData = false;

    this.min;
    this.max;
    this.rangeCheck;

    this.range = hana.validation.range;

    this.setMsg = hana.validation.setMsg;
}

hana.JGrid.prototype = {

    validate : function () {

        //¿¡·¯ ¸Þ¼¼Áö ¼³Á¤
        if(this.isSetMsg)
            messages.set(this.id, this.msg);

        //±×¸®µå¿¡ µ¥ÀÌÅÍ°¡ Á¸ÀçÇÏ´ÂÁö Ã¼Å©ÇÕ´Ï´Ù.
        var rowCnt = this.object.RecordCount;
        //¼±ÅÃÇÑ row °³¼ö
        var checkedCnt = getSelectedCount(this.object, "¼±ÅÃ");

        if (rowCnt == null || typeof(rowCnt) == "undefined" || rowCnt == 0) {
            return messages.alert(this.object, "JSM-1039", [this.name], false);
        }

        //±×¸®µå¿¡ ¼±ÅÃÇÑ µ¥ÀÌÅÍ°¡ Á¸ÀçÇÏ´ÂÁö Ã¼Å©ÇÕ´Ï´Ù.
        if( this.isCheckedData && checkedCnt == 0){
            return messages.alert(this.object, "JSM-1040", [this.name], false);
        }

        //±×¸®µå¿¡ ¼±ÅÃÇÑ °³¼ö Á¦ÇÑ
        if (this.rangeCheck && (checkedCnt < this.min || checkedCnt > this.max)) {
            if (this.min == this.max) {
                return messages.alert(this.object, "JSM-1012", [this.name, this.min], false);
		    } else {
				return messages.alert(this.object, "JSM-1013", [this.name, (this.min), this.max], false);
		    }
		}

        return true;
    },

    checkedData : function () {
        this.isCheckedData = true;
        return this;
    }
}
/** #. end JGrid control **/



/** #. start JDateLimit control **/
/**
 * usage :
 * new hana.JDateLimit("Á¶È¸±â°£", formObj.inqBascStrDt, formObj.inqBascEndDt, 'M', 6).validate()
 *
 * @param name   ¸Þ¼¼Áö
 * @param strObj ½ÃÀÛÀÏ ÇÊµå
 * @param endObj Á¾·áÀÏ ÇÊµå
 * @param type  'Y' ³â, 'M' ¿ù, 'D' ÀÏ
 * @param cnt   ±â°£
 */
hana.JDateLimit = function(name, strObj, endObj, type, cnt) { // »ý¼ºÀÚ ÇÔ¼ö

    /* Member Field */
    this.name = name;
    this.strObj = strObj;
    this.endObj = endObj;

    this.type = type;
    this.cnt = cnt;

    this.setMsg = hana.validation.setMsg;
}
hana.JDateLimit.prototype = {
	/* Member Method */

    /**
	 * Date ±â°£ Ã¼Å©
	 */
    validate : function(){

        //¿¡·¯ ¸Þ¼¼Áö ¼³Á¤
        if(this.isSetMsg)
            messages.set(this.id, this.msg);

        var strVal = this.strObj.value;
	    var endVal = this.endObj.value;

        var strDt = this.parse(strVal);
        var endDt = this.parse(endVal);

        // Á¶È¸½ÃÀÛÀÏ ±âÁØÀ¸·Î ÃÖ´ë this.cnt ÀÌ³»¸¸ Á¶È¸µÇµµ·Ï °­Á¦ÇÔ
        if (this.addDate(strDt, this.type, this.cnt) < endDt) {
            var cntMsg = this.rangeMsg(this.type, this.cnt);
            return messages.alert(this.strObj, "JSM-1046", [(this.name), cntMsg, (this.name)], true);
        }

        return true;
	},

    /**
     * ±â°£ ¸Þ¼¼Áö parse
     * @param type
     * @param cnt
     */
    rangeMsg : function(type, cnt){
        var rangeMsg = 'month';
        if( type == 'Y' ){
            rangeMsg = 'year';
        }
        if( type == 'M' ){
            rangeMsg = 'month';
        }
        if( type == 'D' ){
            rangeMsg = 'days';
        }

        return cnt + rangeMsg;
    },

    /**
     * ³¯Â¥ ´õÇÏ±â
     * @param dt
     * @param type
     * @param cnt
     */
    addDate : function(dt, type, cnt) {
        var addType = Date.DAY;
        if( type == 'Y' ){
            addType = Date.YEAR;
        }
        if( type == 'M' ){
            addType = Date.MONTH;
        }
        if( type == 'D' ){
            addType = Date.DAY;
        }

        return dt.add(addType, new Number(cnt));
    },

    /**
     * ³¯Â¥ string parse
     * @param value
     */
	parse : function(value) {
        value = value.replace(/[^\d]/g,"");
        return Date.parseDate(value, "Ymd");
	}
}
/** #. end JDateLimit control **/



hana.validation = {

    /**
     * ¿¡·¯ ¸Þ¼¼Áö ¼³Á¤
     * @param id
     * @param msg
     */
    setMsg : function(id, msg){
        this.isSetMsg = true;
        this.id = id;
        this.msg = msg;
        return this;
    },

    /**
     * ÀÔ·ÂµÈ ¹®ÀÚ¿­ Áß Æ¯Á¤ ¹®ÀÚ¸¦ Áö¿ì°í ÀÌ¸¦ targetElId ÀÇ input hidden ÇÊµå·Î ³Ö¾îÁÖ´Â ÇÔ¼ö
     * ÀÌ¶§ »ý¼ºµÈ input hidden ÅÂ±×´Â Object ÀÇ ¾Õ¿¡ µé¾î°£´Ù. (parentNode.insertBefore)
     *
     * @param obj {Object} validation °´Ã¼¿¡ ³Ñ¾î¿Â Object
     * @param value {String} value
     * @param regExp {Object} replace ½Ã ¼öÇàÇÒ Á¤±Ô½Ä
     */
    makeHiddenInput : function(obj, value, regExp){
        var replaceVal = value.replace(regExp,"");

        if (obj.targetElId && document.getElementById(obj.targetElId)) {
			// ¼ýÀÚ¸¦ Á¦¿ÜÇÑ ¹®ÀÚµéÀº ÀüºÎ »«´Ù. replace
			document.getElementById(obj.targetElId).value = replaceVal;
		} else if( obj.targetElId ) {
			var cEl = document.createElement("INPUT");
			cEl.type = "hidden";
			cEl.name = obj.targetElId;
			cEl.id = obj.targetElId;
			cEl.value = replaceVal;
			obj.object.parentNode.insertBefore(cEl, obj.object);
		} else{
            obj.object.value = replaceVal;
        }
    },


    /**
     * °øÅëÇÔ¼öÀÔ´Ï´Ù.
     *
	 * Null Ã¼Å© ºñÈ°¼ºÈ­
	 */
    nullable : function() {
	   this.nullCheck = false;
	   return this;
	},

	/**
	 * °øÅëÇÔ¼öÀÔ´Ï´Ù.
	 *
	 * À¯È¿¼º °Ë»ç ¹üÀ§ ¼³Á¤
	 * @param {Object} min ÃÖ¼Ò°ª
	 * @param {Object} max ÃÖ´ë°ª
	 */
	range : function(min, max) {
	    this.rangeCheck = true;
	    this.min = min;
	    this.max = max;
	    return this;
	},
	
	/**
	 * °øÅëÇÔ¼öÀÔ´Ï´Ù.
	 * ¾Ë¸²Ã¢¿¡ ',' ÀÚ¸®¼ö Æ÷ÀÎÆ®¸¦ Ãß°¡ÇØ¼­ Ãâ·Â.
	 * À¯È¿¼º °Ë»ç ¹üÀ§ ¼³Á¤
	 * @param {Object} min ÃÖ¼Ò°ª
	 * @param {Object} max ÃÖ´ë°ª
	 */
	rangePoint : function(min, max, type) {
	    this.rangePointCheck = true;
	    this.min = min;
	    this.max = max;
        if(type == undefined) type = '1';
        this.type = type;
	    return this;
	},
	
	/**°øÅëÇÔ¼öÀÔ´Ï´Ù.
	 * ±Ý¾× ¹üÀ§ Ã¼Å©ÇÔ.
	 * ±Ý¾×ÀÌ min ¿Í max »çÀÌ°¡ ¾Æ´Ò°æ¿ì ¾È³»¸Þ½ÃÁö
	 * type : ('1':ÀÏ¹Ý) ('2':¸¸¿ø´ÜÀ§·Î ÀÔ·ÂÃ¼Å© ÇØ¾ßÇÒ°æ¿ì) 
	 * ('3':min°ª¸¸ ÀÖÀ»°æ¿ì ) rangeMoney(3000000,999999999999,'3'); => "»ï¹é¸¸¿ø ÀÌ»ó °¡´ÉÇÕ´Ï´Ù"
	 */
	rangeMoney : function(min, max, type) {
		this.rangeMoneyCheck = true;
	    this.min = min;
	    this.max = max;
	    this.type = type;
	    return this;
	},
    
	/**°øÅëÇÔ¼öÀÔ´Ï´Ù.
	 * ¿ÜÈ­ ±Ý¾× ¹üÀ§ Ã¼Å©ÇÔ.
	 * ¿ÜÈ­ ±Ý¾×ÀÌ min ¿Í max »çÀÌ°¡ ¾Æ´Ò°æ¿ì ¾È³»¸Þ½ÃÁö
	 * type : ÅëÈ­´ÜÀ§ ¿µ¹®(USD,EUR,JPY..)
	 * curr : ÅëÈ­´ÜÀ§ ÇÑ±Û('´Þ·¯','À¯·Î','¿£'..)
	 */
	rangeDollar : function(min, max, type, curr) {
		this.rangeDollarCheck = true;
	    this.min = min;
	    this.max = max;
	    this.type = type;
	    this.curr = curr;
	    return this;
	},
    
    /**
	 * ±Ý¾× ¹üÀ§ Ã¼Å©ÇÔ.
	 * ±Ý¾×ÀÌ min ¿Í max »çÀÌ°¡ ¾Æ´Ò°æ¿ì ¾È³»¸Þ½ÃÁö
	 * type : ('1':ÀÏ¹Ý) ('2':¸¸¿ø´ÜÀ§·Î ÀÔ·ÂÃ¼Å© ÇØ¾ßÇÒ°æ¿ì) 
	 * ('3':min°ª¸¸ ÀÖÀ»°æ¿ì ) rangeMoney(this,3000000,999999999999,'3'); => "»ï¹é¸¸¿ø ÀÌ»ó °¡´ÉÇÕ´Ï´Ù"
	 */
    checkMoney : function(value,min, max, type) {
	    if (!this.nullCheck || !hana.validation.isNull(value) ) {
            var flag = hana.validation.checkNumberSize(value,min,max);
		    if(flag && "1" == type) {	    			                
	    		type = "";
	    	} else if("2" == type) {
	    		var money = Number(value.replace(/[,]/g,"").replace(/[.][0-9]+$/g,""));
	    		if(flag && money%10000 == 0) {
	    			type = "";
	    		}
	    	} else if("3" == type && flag) {
	    		type = "";
            } else if("4" == type && flag) {
	    		type = "";
	    	}
	        return type;
        }
	},	
    /**
	 * ¿ÜÈ­ ±Ý¾× ¹üÀ§ Ã¼Å©ÇÔ.
	 * ±Ý¾×ÀÌ min ¿Í max »çÀÌ°¡ ¾Æ´Ò°æ¿ì ¾È³»¸Þ½ÃÁö
	 */
    checkDollar : function(value, min, max, type) {
	    if (!this.nullCheck || !hana.validation.isNull(value) ) {
            var flag = hana.validation.checkDoubleSize(value,min,max,type);
	        return flag;
        }
	},	

    /* ³»ºÎÇÔ¼ö (ÇÑ±Û Á¾¼ºÃ¼Å©) */
    isJongsong : function (wd) {

        var INDETERMINATE = 0;
        var NOJONGSONG = 1;
        var JONGSONG = 2;

        var word = new String(wd);                    /* ¼ýÀÚ°¡ µé¾î¿À´Â µî¿¡ ´ëºñÇØ ¹«Á¶°Ç ¹®ÀÚ¿­·Î ¹Ù²Þ */
        var numStr1 = "013678lmnLMN";                 /* 'Á¶' Àü±îÁö´Â 0ÀÌ ¹ÞÄ§ÀÌ ÀÖ´Â°É·Î ³ª¿È --; */
        var numStr2 = "2459aefhijkoqrsuvwxyzAEFHIJKOQRSUVWXYZ";
        /* bdgptµéÀº ÀÐ±â¿¡ µû¶ó ¹ÞÄ§ÀÌ ÀÖ±âµµ ÇÏ°í ¾ø±âµµ ÇÑ´Ù°í ÆÇ´Ü. */
        /* ´ë¹®ÀÚ´Â ´Üµ¶À¸·Î ÀÐÀ» ¶§¸¦ °¨¾ÈÇÏ¸é ¹ÞÄ§ ÀÖ´Ù°í È®Á¤µÇ´Â °ÍÀÌ ´õ ÀûÀ½. */

        if (word == null || word.length < 1) {
            return INDETERMINATE;
        }

        var lastChar = word.charAt(word.length - 1);
        var lastCharCode = word.charCodeAt(word.length - 1);

        if (numStr1.indexOf(lastChar) > -1) {
            return JONGSONG;
        }else if (numStr2.indexOf(lastChar) > -1) {
            return NOJONGSONG;
        }

        if (lastCharCode<0xac00 || lastCharCode>0xda0c) {
            return INDETERMINATE;
        }
        else{
            var lastjongseong = (lastCharCode - 0xAC00) % (21*28) % 28  ;

            if (lastjongseong == 0){
                return NOJONGSONG;
            }else{
                return JONGSONG;
            }
        }
    },

    /* ³»ºÎÇÔ¼ö (À»/¸¦) */
    ul : function (s) {
        var ul0 = new Array("(À»)¸¦", "¸¦", "À»");
        return s + ul0[hana.validation.isJongsong(s)];
    },

    /* ³»ºÎÇÔ¼ö (ÀÌ/°¡) */
    ka : function (s){
        var ka0 = new Array("(ÀÌ)°¡", "°¡", "ÀÌ");
        return s + ka0[hana.validation.isJongsong(s)];
    },

    /* ³»ºÎÇÔ¼ö (Àº/´Â) */
    un : function (s){
        var un0 = new Array("(Àº)´Â", "´Â", "Àº");
        return s + un0[hana.validation.isJongsong(s)];
    },

    /* ³»ºÎÇÔ¼ö (¿Í/°ú) */
    wa : function (s){
        var arr = new Array("(¿Í)°ú", "¿Í", "°ú");
        return s + arr[hana.validation.isJongsong(s)];
    },

    /**
     * Text »çÀÌÁî¸¦ check
     * @param {String} data
     * @param {int} min
     * @param {int} max
     */
    checkCharacterSize : function (data, min, max) {
        if( !data ) return false;
        
        var total = 0;

        for (var i = 0; i < data.length; i++) {
            var a = data.charAt(i);
            /* ÇÑ±ÛÀÎ °æ¿ì ±æÀÌ°¡ 6 ÀÌ´Ù. */
            if (escape(a).length >= 6) {
                total = total + 2;
            } else {
                total = total + 1;
            }
        }
        return total >= min && total <= max;
    },

    /**
     * NumberÀÇ »çÀÌÁî¸¦ Ã¼Å©
     * data¿¡ µé¾î¿Â ',' ¹®ÀÚ¿Í ¼Ò¼öÁ¡À» Á¦¿ÜÇÏ°í min, max¸¦ ºñ±³ÇÑ´Ù.
     *
     * @param {number} data
     * @param {int} min
     * @param {int} max
     */
    checkNumberSize : function(data, min, max){
        if( !data ) return false;
		
		if(typeof min == 'string'){
			min = min.replace(/[,]/g,"").replace(/[.][0-9]+$/g,"");
		}
		
		if(typeof max == 'string'){
			max = max.replace(/[,]/g,"").replace(/[.][0-9]+$/g,"");
		}

        if(typeof data == 'string'){
			data = data.replace(/[,]/g,"").replace(/[.][0-9]+$/g,"");
		}

        min = new Number(min);
        max = new Number(max);

        var parseData = new Number(data);

        if(max <= 0) {
            return parseData >= min;
        } else {
            return parseData >= min && parseData <= max;
        }
    },
    
    /**
     * DoubleÀÇ »çÀÌÁî¸¦ Ã¼Å©
     * data¿¡ µé¾î¿Â ',' ¹®ÀÚ¸¦  Á¦¿ÜÇÏ°í min, max¸¦ ºñ±³ÇÑ´Ù.
     *
     * @param {double} data
     * @param {int} min
     * @param {int} max
     */
    checkDoubleSize : function(data, min, max, type){
        if( !data ) return false;
        
		if(typeof min == 'string'){
			min = min.replace(/[,]/g,"").replace(/[0-9]+$/g,"");
		}
		
		if(typeof max == 'string'){
			max = max.replace(/[,]/g,"").replace(/[0-9]+$/g,"");
		}
        if(typeof data == 'string'){
			data = data.replace(/[,]/g,"");
		}

        min = parseFloat(min);
        max = parseFloat(max);

        var parseData = parseFloat(data);

        if(max <= 0) {
            return parseData >= min;
        } else {
            return parseData >= min && parseData <= max;
        }
    },

    /**
     * NumberÀÇ »çÀÌÁî¸¦ Ã¼Å©
     * data¿¡ µé¾î¿Â ',' ¹®ÀÚ¿Í ¼Ò¼öÁ¡À» Á¦¿ÜÇÏ°í min, max¸¦ ºñ±³ÇÑ´Ù.
     *
     * @param {number} data
     * @param {int} min
     * @param {int} max
     */
    checkNumberLength : function(data, min, max){
        if( !data ) return false;

        var parseData = data.replace(/[,]/g,"").replace(/[.][0-9]+$/g,"");
        var total = parseData.length;
        return total >= min && total <= max;
    },

    /**
     * °ø¹é¹®ÀÚ¸¦ Á¦¿ÜÇÑ ±ÛÀÚ°¡ ÀÖ´ÂÁö Ã¼Å©
     * @param val {String} check ÇÒ ¹®ÀÚ¿­
     */
    isNull : function(val){
        return !new RegExp("[^\\s]+","g").test(val);
    },


    /**
     * ºó ¹®ÀÚ¿­ÀÎ °æ¿ì false ÀÓ.
     * ¾Õ¿¡ +- ¸¦ Á¦¿ÜÇÏ°í ¼¼ÀÚ¸® ¸¶´ÙÂïÈ÷´Â ','¸¦ Á¦¿ÜÇÏ°í ¼Ò¼öÁ¡ 2ÀÚ¸® ±îÁö¸¸ ¼ýÀÚ·Î Ã¼Å©
     * @param val {String} check ÇÒ ¹®ÀÚ¿­
     */
    isNaN : function(val){

        return !new RegExp("^[+-]?[0-9]{1,3}(?:,?[0-9]{3})*(?:\\.[0-9]{2})?$","g").test(val);
    },

    /**
     * Æ¯¼ö ¹®ÀÚ°¡ Æ÷ÇÔµÇ¾îÀÖ´ÂÁö Ã¼Å©
     * @param val {String} check ÇÒ ¹®ÀÚ¿­
     */
    isExistSpacialChar : function(val, pattern){
        return new RegExp("["+pattern+"]","g").test(val);
    },

    /**
     * checkbox/radio list ¿¡¼­ check µÈ °³¼ö¸¦ returnÇÑ´Ù.
     * @param list checkbox/radio list
     */
    isCheckedCnt : function(list) {
        if (list == null) return 0;
        var result = 0;

        /* list arrayÀÇ µ¥ÀÌÅÍ°¡ 1ÀÎ °æ¿ì */
        if (list.checked) {
            return 1;
        }
        for (var i = 0; i < list.length; i++) {
            if (list[i].checked) {
                result++;
            }
        }
        return result;
    },

    /**
     * selectbox ¿¡¼­ ¼±ÅÃµÈ item ÀÇ °³¼ö¸¦ return ÇÑ´Ù.
     * @param item selecbox
     */
    isSelectedCnt : function (item) {
        if (item == null) return 0;
        var result = 0;

        for (var i = 0; i < item.length; i++) {
            if (item[i].selected) {
                result++;
            }
        }
        return result;
    },

    /**
     * ÆÄÀÏÀÇ È®ÀåÀÚ °¡Á®¿È
     * @param val {String} ÆÄÀÏ°æ·Î
     */
    getFileExt : function (value) {
        var ext;
        var extension = value;
        var index = extension.lastIndexOf(".");

        if (index != -1){
            ext = extension.substring(index + 1).toLowerCase();
        }

        return ext;
	},

    /*
    * ÀÔ·ÂµÈ ¼ýÀÚ¸¦ ¹®ÀÚ ±Ý¾×À¸·Î º¯È¯
    * @param val {money}
    */
    getKoreaMoney : function (money) {
        var arrayNum=new Array("","ÀÏ","ÀÌ","»ï","»ç","¿À","À°","Ä¥","ÆÈ","±¸");
        var arrayUnit=new Array("","½Ê","¹é","Ãµ","¸¸ ","½Ê¸¸ ","¹é¸¸ ","Ãµ¸¸ ",
                                "¾ï ","½Ê¾ï ","¹é¾ï ","Ãµ¾ï ","Á¶ ","½ÊÁ¶ ","¹éÁ¶");
        var arrayStr= new Array();
        var numStr = String(money);
        var numStr = pbk.stripCommas(numStr);
        var len = numStr.length;

        var isValid = true;
        var hanStr = "";
        if (isValid) {
            for (i = 0; i < len; i++) {
                arrayStr[i] = numStr.substr(i, 1)
            }
            code = len;
            for (i = 0; i < len; i++) {
                code--;
                tmpUnit = "";
                if (arrayNum[arrayStr[i]] != "") {
                    tmpUnit = arrayUnit[code];
                    if (code > 4) {
                        if ((Math.floor(code / 4) == Math.floor((code - 1) / 4) &&
                        arrayNum[arrayStr[i + 1]] != "") ||
                        (Math.floor(code / 4) == Math.floor((code - 2) / 4) &&
                        arrayNum[arrayStr[i + 2]] != "")) {
                            tmpUnit = arrayUnit[code].substr(0, 1);
                        }
                    }
                }
                hanStr += arrayNum[arrayStr[i]] + tmpUnit;
            }
        }
        return hanStr;
    },


    /**
     * ÀÔ·Â ±ÝÁö ¹®±¸µé...
     */
    denyChar : ["°¡°øºñ", "°áÀç", "°áÁ¦", "°è¾à", "±¸¸Å", "±âÅ¸", "³³Ç°", "´ë¿ì", "´ëÃâ",
               "µµ¸Å", "µµ¼Ò¸Å", "µ¿±¹", "µÎ»ê", "¸Å´ã", "¸ÅÃâ", "¹«¿ª", "¹°Ç°",
               "ºÎ°¡°¡Ä¡", "ºñÇ°", "»óÇ°", "¼­ºñ½º", "¼±±Þ±Ý", "¼±¼ö±Ý", "¼¼±Ý",
               "½áºñ½º", "¾îÀ½", "¿¤Áö", "¿Ü»ó", "ÀÓ°¡°ø", "Àâ±â", "Á¤»êºñ", "Á¦Á¶",
               "Ã¤±Ç", "Ãß½É", "ÆÇ¸Å", "ÇÒÀÎ", "Çö±Ý", "Çö´ë", "È¯¾îÀ½", "È¿¼º"],

    /**
     * ÀÔ·Â ±ÝÁö ¹®±¸°¡ Á¸ÀçÇÏ¸é Á¸ÀçÇÏ´Â ÀÔ·Â ±ÝÁö¹®±¸ÀÇ Array ¸¦ ¹ÝÈ¯ÇÕ´Ï´Ù.
     * @param str Ç°¸ñ¸í ¹®ÀÚ¿­
     */
    getExistDenyCharArr : function(str){

        var arr = hana.validation.denyChar;
        var message = new Array();

        for( var i = 0; i< arr.length; i++){
            if( str.indexOf(arr[i]) != -1 ){
                message.push(arr[i]);
            }
        }

        return message;
    },


    /**
     * ¿Ã¹Ù¸£Áö ¾ÊÀº Ç°¸ñ¸íÀÎÁö Ã¼Å©ÇÕ´Ï´Ù.
     *
     * Á¶°Ç
     * 1. ¿µ¹® ¼ýÀÚ¸¦ Á¦¿ÜÇÑ ³²Àº ¹®ÀÚ°¡ Á¤»óÀûÀÎ ÇÑ±ÛÀÌ ¾Æ´Ñ°æ¿ì
     * 2. ´Ù¸¥ ¹®ÀÚ¿Í Á¶ÇÕµÇÁö ¾Ê°í ¿µ¹®ÀÌ³ª ¼ýÀÚ¸¸ 1ÀÚ ÀÖ´Â °æ¿ì ¿¹) a, 1
     * 3. ´Ù¸¥ ¹®ÀÚ¿Í Á¶ÇÕµÇÁö ¾Ê°í °°Àº ¿µ¹®ÀÌ³ª ¼ýÀÚ¸¸ 2ÀÚÀÌ»ó ¹Ýº¹µÇ´Â °æ¿ì  ¿¹) aa, 11
     * @param str Ç°¸ñ¸í ¹®ÀÚ¿­
     */
    isInCorrectRpsMitmNm : function(str){
        var strTmp = str.replace(/[0-9a-z]/ig,'');

        //¿µ¹® ¼ýÀÚ¸¦ Á¦¿ÜÇÑ ³²Àº ¹®ÀÚ°¡ Á¤»óÀûÀÎ ÇÑ±ÛÀÌ ¾Æ´Ñ°æ¿ì
        if(strTmp && !new RegExp("^[°¡-Èþ]+$","g").test(strTmp)){
            return true;
        }

        //´Ù¸¥ ¹®ÀÚ¿Í Á¶ÇÕµÇÁö ¾Ê°í ¿µ¹®ÀÌ³ª ¼ýÀÚ¸¸ 1ÀÚ ÀÖ´Â °æ¿ì ¿¹) a, 1
        if(new RegExp("^[0-9a-z]{1}$","g").test(str)){
            return true;
        }

        //´Ù¸¥ ¹®ÀÚ¿Í Á¶ÇÕµÇÁö ¾Ê°í °°Àº ¿µ¹®ÀÌ³ª ¼ýÀÚ¸¸ 2ÀÚÀÌ»ó ¹Ýº¹µÇ´Â °æ¿ì  ¿¹) aa, 11
        var re = new RegExp("^([a-z0-9])","gi");

        var matches = re.exec(str);

        if(matches != null){
            re = new RegExp("^["+matches[0]+"]*$","gi");

            var chkStr = str.replace(re, '');

            if(!chkStr){
                return true;
            }
        }

        return false;
    }

}

