function Trim(str)
{
    str = str.replace(/^\s*/,'').replace(/\s*$/, ''); 
    return str;
}

function Trim2(st)
{
	while(st && st.indexOf(" ") == 0) st = st.substring(1);
	while(st && st.lastIndexOf(" ") == st.length - 1) st = st.substring(0, st.length -1);
	
	return st
}

function isImageFile(attachfile)
{
	if (attachfile.match(/.jpg|.jpeg|.gif|.bmp$/i))
		return true;
	else
		return false;
}

function C_CheckSpecialChar(str)
{
	var bRet = true;
	var sSpChar = "'\"&%";
	var i ; 
	for( i=0; i < str.length; i++ )  
	{
		if(sSpChar.indexOf(str.substring(i, i+1)) >= 0) {
			bRet = false;
			break ; 
		}
	}

	return bRet;
}

function C_CheckChar(obj)
{
	var str = obj.value;
	if(!C_CheckSpecialChar(str)) {
		alert("Æ¯¼ö¹®ÀÚ ',\",&,% ´Â »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
		obj.value = obj.value.substring(0, obj.value.length-1);
		obj.focus();
	}
}

function IsValidLastDay(Year, Mon, Day) 
{
	var Days_in_Month = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);  
	
	if ((Year % 400 == 0) || ((Year % 4 == 0) && (Year % 100 != 0))) {
		Days_in_Month[1] = 29;
	}
	
	if(Day > Days_in_Month[Mon - 1])
		return false;
		
	return true;
}

function IsValidEmailAddr2(sAddr)
{
	var nLen = sAddr.length;
	var idxFst = sAddr.indexOf("@");
	var idxLst = sAddr.lastIndexOf("@");
	var idxFstDot = sAddr.indexOf(".");
	var idxLstDot = sAddr.lastIndexOf(".");
	var idxSpc = sAddr.indexOf(" ");
	
	if(	(idxFst < 1) || 				// @test.com
		(idxFst != idxLst) || 			// aa@bbb@cc.com
		(idxFstDot < idxFst) || 		// aa.bb@ccc.com
		((nLen - idxLstDot) <= 2) || 	// aaa@bbb., aaa@bbb.c
		(idxSpc != -1)) 				// aaa bb@ccc.com
		return false;
	else
		return true; 
}

function IsValidEmailAddr(str)
{
        // ¾ÆÀÌµð Ã¹±ÛÀÚ´Â ¿µ¹®ÀÚ ³ª¸ÓÁö´Â ¿µ¹®ÀÚ ¶Ç´Â ¼ýÀÚ
        // µµ¸ÞÀÎ°ú ¾ÆÀÌµð´Â @À¸·Î ±¸ºÐµÈ´Ù
        // µµ¸ÞÀÎ¸í¿¡´Â ¿µ¹®ÀÚ¿Í ¼ýÀÚ¸¸ÀÌ ¿Ã ¼ö ÀÖÀ¸¸ç µÎ¹øÂ° ºÎÅÍ´Â Á¡(.) ÀÌÈÄ¿¡ ¿µ¹®ÀÚ¿Í ¼ýÀÚ°¡ ¿Â´Ù
        if ( ! /^[a-zA-Z0-9][a-zA-Z0-9\-]+[@][a-zA-Z0-9\-]+([.][a-zA-Z0-9\-]+)+$/.test(str) ) {
            return false;
        } else {
            return true;
        }
}

function IsValidUserID(str)
{
        // ¾ÆÀÌµð Ã¹±ÛÀÚ´Â ¿µ¹®ÀÚ ³ª¸ÓÁö´Â ¿µ¹®ÀÚ ¶Ç´Â ¼ýÀÚ. ÃÖ¼Ò 4ÀÚ ÀÌ»óÀÌ´Ù.
        if ( ! /^[a-zA-Z][a-zA-Z0-9\-]{3,}$/.test(str) ) {
            return false;
        } else {
            return true;
        }
}

function IsValidPasswd(str)
{
        // ºñ¹Ð¹øÈ£ Ã¹±ÛÀÚ´Â ¿µ¹®ÀÚ ³ª¸ÓÁö´Â ¿µ¹®ÀÚ ¶Ç´Â ¼ýÀÚ. ÃÖ¼Ò 4ÀÚ ÀÌ»óÀÌ´Ù.
        if ( ! /^[a-zA-Z0-9]{4,}$/.test(str) ) {
            return false;
        } else {
            return true;
        }
}


