
/**
 * »ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ ÁÖ¹Î¹øÈ£°¡ À¯È¿ÇÑ °ªÀÎÁö¸¦ Ã¼Å©ÇÑ´Ù.
 * @param   ssn1    »ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ ÁÖ¹Î¹øÈ£ ¾ÕÀÚ¸® 
 * @param   ssn2    »ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ ÁÖ¹Î¹øÈ£ µÞÀÚ¸®
 * @return 	boolean À¯È¿ÇÑ °ªÀÏ °æ¿ì true, À¯È¿ÇÑ °ªÀÌ ¾Æ´Ñ°æ¿ì false¸¦ ¸®ÅÏÇÑ´Ù. »ç¿ëÀÚ°¡ ÀÔ·ÂÇÑ °ªÀÇ ±æÀÌ°¡ 13ÀÚ¸®°¡ ¾Æ´Ò °æ¿ì false¸®ÅÏ
 */
function isValidSSN(ssn1, ssn2){
	jumin = ssn1 + ssn2;
	
	//ÀÔ·ÂÇÑ ÁÖ¹Î¹øÈ£°¡ 13ÀÚ¸®°¡ ¾Æ´Ñ°æ¿ì false¸®ÅÏ
	if (jumin.length != 13 ) return false;

	var jumin,no,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13;
	c1 = jumin.substring(0,1);
	c2 = jumin.substring(1,2);
	c3 = jumin.substring(2,3);
	c4 = jumin.substring(3,4);
	c5 = jumin.substring(4,5);
	c6 = jumin.substring(5,6);
	c7 = jumin.substring(6,7);
	c8 = jumin.substring(7,8);
	c9 = jumin.substring(8,9);
	c10 = jumin.substring(9,10);
	c11 = jumin.substring(10,11);
	c12 = jumin.substring(11,12);
	c13 = jumin.substring(12,13);

	c1 = c1 * 2;
	c2 = c2 * 3;
	c3 = c3 * 4;
	c4 = c4 * 5;
	c5 = c5 * 6;
	c6 = c6 * 7;
	c7 = c7 * 8;
	c8 = c8 * 9;
	c9 = c9 * 2;
	c10 = c10 * 3;
	c11 = c11 * 4;
	c12 = c12 * 5;

	no = c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 + c10 + c11 + c12;
	no = (no % 11);
	no = 11 - no;

	if (no > 9) no = (no % 10);
	
	//À¯È¿ÇÑ ÁÖ¹Î¹øÈ£°¡ ¾Æ´Ò°æ¿ì false¸®ÅÏ
	if (no != c13 || (c7 > 2 && c7 < 1)) return false;
    
	return true;
}


// null check¸¦ À§ÇÑ method
function isNull(str) 
{
	return ((str == null || str == "" || str == "<undefined>" || str == "undefined") ? true:false);
}

// ÀÔ·ÂµÈ °ªÀÌ ¼ýÀÚÀÎÁö¸¦ È®ÀÎÇÏ´Â method
function isInteger(number) 
{
	if(number == "") {
		return false;
	}
	for(var i= 0; i < number.length; i++) 
	{
		if(!((number.charAt(i) >= "0" && number.charAt(i) <= "9") ? true:false))
		{
			return false; 
		}
	}
	return true;
}

/**
 * ÀÔ·Â¹®ÀÚÀÇ ±æÀÌ¸¦ ¸®ÅÏÇÑ´Ù. ÇÑ±Û 2¹ÙÀÌÆ®, ¿µ,¼ö,Æ¯¼ö¹®ÀÚ 1¹ÙÀÌÆ®
 * @param   strA       Ã¼Å©ÇÒ ¿ÀºêÁ§Æ®
 * @return 	integer     ÀÔ·Â°ªÀÇ ¹ÙÀÌÆ® ¼ö
 */
function getByteLength(strA) {
    var byteLength = 0;
    for (var inx = 0; inx < strA.length; inx++) {
        var oneChar = escape(strA.charAt(inx));
        if ( oneChar.length == 1 ) {
            byteLength ++;
        } else if (oneChar.indexOf("%u") != -1) {
            byteLength += 2;
        } else if (oneChar.indexOf("%") != -1) {
            byteLength += oneChar.length/3;
        }
    }
    return byteLength;
}

/**
 * Çã¿ëÇÒ ¹®ÀÚ¸¸ Ã¼Å©ÇÑ´Ù.
 * @param   strA       Ã¼Å©ÇÒ ¿ÀºêÁ§Æ®
 * @param   chars       Çã¿ëÇÒ ¹®ÀÚ
 * @return 	boolean     Çã¿ëÇÒ ¹®ÀÚÀÏ °æ¿ì true ¸®ÅÏ
 */
function containsCharsOnly(strA,chars) {
    for (var inx = 0; inx < strA.length; inx++) {
       if (chars.indexOf(strA.charAt(inx)) == -1)
           return false;
    }
    return true;
}


//	ÀüÈ­¹øÈ£ Ã¼Å©
function chkPhone(ddd, tel1, tel2, required) {
	if ((ddd.length == 0) && (tel1.length == 0) && (tel2.length == 0) && (required == "0")) {
		return 4;
	}

	if (getByteLength(ddd) < 2 || getByteLength(ddd) > 4) {
		return 1;
	} else if(getByteLength(tel1) < 2 || getByteLength(tel1) > 4) {
		return 2;
	} else if(getByteLength(tel2) != 4) {
		return 3;
	} else if (!isInteger(ddd)) {
		return 1;
	} else if (!isInteger(tel1)) {
		return 2;
	} else if (!isInteger(tel2)) {
		return 3;
	}
	return 0;
}

// ±ÛÀÌ ÀÖ³ª ¾ø³ª È®ÀÎ ½ºÆäÀÌ½º¹Ù·Î ³Ñ±ä°Í ±îÁö.
function checkText(e){
	var position,strOri_length;
	position = e.indexOf(" ");
	while(position != -1){
		e = e.replace(" ","");
		position = e.indexOf(" ");
	}
	if(e.length < 1){
		return true
	}else{
		return false // ¿ÇÀº ÀÔ·Â
	}
}

// ÀÌ¸ÞÀÏ ÁÖ¼Ò Á¤È®µµ È®ÀÎ
function chkEmail(email) {
	var string = email;
	var where = string.indexOf("@", 0)
	if (where == -1) {
		return true
	} else {
		address = string.split("@")
		if (address[0].length < 1 || address[1] < 1) {
			return true
		} else {
			where = string.indexOf(".", 0)
			if (where == -1) {
				return true
			} else {
				address2 = address[1].split(".")
				if(address2[0].length < 1 || address2[1].length < 1) {
					return true
				}
			}
		}
	}
	return false // ¿ÇÀº ÀÔ·Â
}

//	¿øÇÏ´Â ±ÛÀÚ¼ö°¡ Ã¡À» °æ¿ì ÀÌµ¿ÇÏ´Â ÇÔ¼ö
function moveForm(str,nextOb,len){
	if(str.length == len ) nextOb.focus();
}
