// string type¿¡¼­ trim()À» »ç¿ëÇÒ ¼ö ÀÖ°Ô ÇÔ
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g,""); 
}

// strInputÀÇ °ªÀÌ ÀÖ´ÂÁö ¿©ºÎ °Ë»ç
function isNull(str) {
	if (str.length == 0 || str.split(" ").join("") == "" || str.trim() == "") {
		return true;
	} else {
		return false;
	}
}

// ¼ýÀÚ, ¿µ¹®ÀÚÀÎÁö Ã¼Å©
function isNumeric(instr) {
	var str;
	str=Math.abs(instr);
	for (i = 0; i < str.length; i++) {
		c = str.charAt(i);
		
		if (!(c >= '0' && c <= '9')) {
			return true;
		}
	}
	
	return false;
}

// ¼ýÀÚ, ¿µ¹®ÀÚÀÎÁö Ã¼Å©
function isAlphaNumeric(instr) {
	var str;
	str=Math.abs(instr);
	for (i = 0; i < str.length; i++) {
		c = str.charAt(i);
		
		if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) {
			return true;
		}
	}
	
	return false;
}

// <input type="text"> ÀÔ·Â¿©ºÎ °Ë»ç
function inputTextCheck(objInput, strMessage) {
	if (isNull(objInput.value)) {
		alert(strMessage + " ÀÔ·ÂÇÏ¼¼¿ä.");
		objInput.focus();
		return false;
	} else {
		return true;
	}
}

//
function inputTextIsAlphaNumeric(objInput, strMessage) {
	if (isAlphaNumeric(objInput.value)) {
		alert(strMessage + " ¿µ¹®ÀÚ¿Í ¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù.");
		objInput.focus();
		return false;
	} else {
		return true;
	}
}

//
function inputTextIsNumeric(objInput, strMessage) {
	if (isNumeric(objInput.value)) {
		alert(strMessage + " ¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù.");
		objInput.focus();
		return false;
	} else {
		return true;
	}
}

// 
function inputTextLengthCheck(objInput, limit, strMessage) {
	if (objInput.value.length > limit) {
		alert(strMessage + " " + limit + "ÀÚ±îÁö¸¸ ¾µ ¼ö ÀÖ½À´Ï´Ù.");
		objInput.value = objInput.value.substring(0, limit);
		objInput.focus();
		return false;			
	} else {
		return true;
	}
}

function inputTextLengthRangeCheck(objInput, intMin, intMax, strMessage) {
	if (objInput.value.length < intMin || objInput.value.length > intMax) {
		alert(strMessage + " " + intMin + "~" + intMax + "ÀÚ¸¦ ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù.");
		objInput.focus();
		return false;			
	}
	
	return true;
}

function inputTextLengthFixCheck(objInput, intLen, strMessage) {
	if (objInput.value.length != intLen) {
		alert(strMessage + " " + intLen + "ÀÚ¸¦ ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù.");
		objInput.focus();
		return false;			
	}
	
	return true;
}

function inputSelectCheck(objInput, strMessage) {
	if (isNull(objInput.value)) {
		alert(strMessage + " ¼±ÅÃÇÏ¼¼¿ä.");
		objInput.focus();
		return false;
	} else {
		return true;
	}
}

// ÁÖ¹Îµî·Ï¹øÈ£ À¯È¿¼º °Ë»ç
function juminNoCheck(juminNo1, juminNo2) {
	a1 = juminNo1.substring(0, 1);
		aa1 = a1 * 2;
	a2 = juminNo1.substring(1, 2);
		aa2 = a2 * 3;
	a3 = juminNo1.substring(2, 3);
		aa3 = a3 * 4;
	a4 = juminNo1.substring(3, 4);
		aa4 = a4 * 5;
	a5 = juminNo1.substring(4, 5);
		aa5 = a5 * 6;
       a6 = juminNo1.substring(5, 6);
		aa6 = a6 * 7;
       b1 = juminNo2.substring(0, 1);
		bb1 = b1 * 8;
       b2 = juminNo2.substring(1, 2);
		bb2 = b2 * 9;
       b3 = juminNo2.substring(2, 3);
		bb3 = b3 * 2;
       b4 = juminNo2.substring(3, 4);
		bb4 = b4 * 3;
       b5 = juminNo2.substring(4, 5); 
		bb5 = b5 * 4;
       b6 = juminNo2.substring(5, 6);
		bb6 = b6 * 5;
   
	pivot = juminNo2.substring(6,7);
   
	sum = aa1 + aa2 + aa3 + aa4 + aa5 + aa6 + bb1 + bb2 + bb3 + bb4 + bb5 + bb6;
	modulus = sum % 11
	endnumber = 11 - modulus
      
	if (endnumber == 11) {
		endnumber = 1;
	} else if (endnumber == 10) { 
		endnumber = 0;
	} else {
		endnumber = endnumber;
	}
	
	if (pivot != endnumber) {
		return false;
	} else {
		return true;
	}
}

// ÀÌ¸ÞÀÏ À¯È¿¼º °Ë»ç
function emailCheck(email)
{
// ÀÌ¸ÞÀÏ Æû¿¡ ¸Â´ÂÁö È®ÀÎ
	//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 (email.indexOf(".") > 2) && (email.indexOf("@") > 0);
	}
	else
	{// Áö¿øµÇ¸é
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
		return (!r1.test(email) && r2.test(email));
	}
}
