/********************************************************
    common.js
   °øÅë JavaScript ¶óÀÌºê·¯¸®
*********************************************************/


function length_chk(temp1, temp2, temp3) {
	fmname = eval("document."+temp1);

	if(fmname.value.length == temp2) {
		eval("document."+temp3).focus();
	} 
    
}

function charLength(temp,maxlength, minlength) {
	fmname = eval("document."+temp);
	if(fmname > maxlength) {
		alert(maxlength+"±îÁö ÀÔ·ÂÇÒ¼ö ÀÖ½À´Ï´Ù.");
		eval("document."+temp).focus();
	}else if(fmname < minlength) {
		alert(minlength+"ÀÌ»ó ÀÔ·ÂÇÏ¼Å¾ß ÇÕ´Ï´Ù.");
		eval("document."+temp).focus();
    }
}

function IsInt(str)  {
    var    _intValue   = '0123456789'; 
    for(var j = 0; j < _intValue.length; j++) 
        if( str == _intValue.charAt(j) ) { 
	    return true; 
        }
    return false;
}


  function SetComma(frm) {
	var rtn = "";
	var val = "";
	var j = 0;
	x = frm.value.length;
	
		for(i=x; i>0; i--) {
			if(frm.value.substring(i,i-1) != ",") {
				val = frm.value.substring(i,i-1)+val;
			}
		}
		
		x = val.length;
		for(i=x; i>0; i--) {
			if(j%3 == 0 && j!=0) {
				rtn = val.substring(i,i-1)+","+rtn; 
			}else {
				rtn = val.substring(i,i-1)+rtn;
			}
		  j++;
		}
	return rtn;
	
  }


  function removeCommas(str)
  {
	 return str.replace(/,/g, "");
  }


function checkChar(object) {
	var retCode = 0;
	var special_char = '~`!@#$%^&*()-+=|[]{}:;"<>,.?/'+String.fromCharCode(39)+String.fromCharCode(92);	
	var i ;
	for ( i=0; i<object.length; i++ ) {
		if( special_char.indexOf(object.substring(i,i+1)) >= 0){
			break;
		}
	}
	if ( i !=object.length ) {
		retCode = 1;
	}
	return (retCode)
}


function checkChar2(object) {
	var retCode = 0;
	var special_char = '`!@#$%^&*()-+=|[]{}:;"<>,?/'+String.fromCharCode(39)+String.fromCharCode(92);	
	var i ;
	for ( i=0; i<object.length; i++ ) {
		if( special_char.indexOf(object.substring(i,i+1)) >= 0){
			break;
		}
	}
	if ( i !=object.length ) {
		retCode = 1;
	}
	return (retCode)
}

function checkChar3(object) {
	var retCode = 0;
	var special_char = '`!@#$%^&*|"<>?'+String.fromCharCode(39)+String.fromCharCode(92);	
	var i ;
	for ( i=0; i<object.length; i++ ) {
		if( special_char.indexOf(object.substring(i,i+1)) >= 0){
			break;
		}
	}
	if ( i !=object.length ) {
		retCode = 1;
	}
	return (retCode)
}

function openWin(strUrl, strName, nWidth, nHeight, strFeatures){
  var nTop  = (screen.height - nHeight) / 2;
  var nLeft = (screen.width - nWidth) / 2;
  strFeatures += ",height="+nHeight+",width="+nWidth+",top="+nTop+",left="+nLeft;
  window.open(strUrl, strName, strFeatures);
}


function searchCode(temp1, temp2) {
   strUrl = "/cyj_ams/include/codeSearch.jsp?lcode="+temp1+"&type="+temp2;
   openWin(strUrl, "searchCode", 340, 200, "scrollbars=yes,toolbar=no")
}

function searchPost(temp){
	strUrl = "/sub/postsearch.html?gubun="+temp;
    openWin(strUrl, "searchpost", 430, 190, "scrollbars=yes,toolbar=no")

}


function openCal(temp) {
	this_date = eval("document."+temp).value;
	//alert(this_date);
	strUrl = "/include/opencal.html?this_date="+this_date+"&this_form="+temp;
    openWin(strUrl, "cal", 270, 245, "scrollbars=no,toolbar=no")
}


function CheckTelephone(temp1, temp2) {
    var thisform = document.fm;
    var countryCode = new Array(23);

    countryCode[0] = "02";
    countryCode[1] = "031";
    countryCode[2] = "032";
    countryCode[3] = "033";
    countryCode[4] = "041";
    countryCode[5] = "042";
    countryCode[6] = "043";
    countryCode[7] = "051";
    countryCode[8] = "052";
    countryCode[9] = "053";
    countryCode[10] = "054";
    countryCode[11] = "055";
    countryCode[12] = "061";
    countryCode[13] = "062";
    countryCode[14] = "063";
    countryCode[15] = "064";
	countryCode[16] = "010";
	countryCode[17] = "011";
	countryCode[18] = "016";
	countryCode[19] = "017";
	countryCode[20] = "018";
	countryCode[21] = "019";
	countryCode[22] = "0341";

	for (i = 0; i < 23; i++) {
		if (eval("thisform."+temp1).value == countryCode[i]) {
			eval("thisform."+temp2).focus();
			return;
		}
	}
	
  }



function trim(value)
	{
		var s = '';
		var sidx = 0;
		var eidx = value.length;
		
		for (var i = 0; value.length; i++) {
			if (value.charAt(i) != ' ') {
				sidx = i;
				break;
			}
		}
			
		for (var i = value.length - 1; i >= 0; i--) {
			if (value.charAt(i) != ' ') {
				eidx = i;
				break;
			}
		}
		return value.substring(sidx, eidx + 1);
}


  function ReplaceStr(strOriginal, strFind, strChange)
  {
	return strOriginal.split(strFind).join(strChange);
  }


//ÆÄÀÏÀÇ È®ÀåÀÚ¸¦ °¡Á®¿Å
function getFileExtension( filePath ) {
    var lastIndex = -1;
    lastIndex = filePath.lastIndexOf('.');
    var extension = "";

	if ( lastIndex != -1 )
	{
		extension = filePath.substring( lastIndex+1, filePath.len );
	} else {
		extension = "";
	}
	return extension;
 }

//ÆÄÀÏÀ» ¼±ÅÃ ÈÄ Æ÷Ä¿½º ÀÌµ¿½Ã È£Ãâ
function uploadImg(value) {

    var src = getFileExtension(value);
    if (src != "") {
		if (!((src.toLowerCase() == "gif") || (src.toLowerCase() == "jpg") || (src.toLowerCase() == "jpeg")) ) {
			alert('ÀÌ¹ÌÁö ¾÷·Îµå´Â gif ¿Í jpg ÆÄÀÏ¸¸ Áö¿øÇÕ´Ï´Ù.');
			return false;
		}
	}

    return true;

}


function changeImg(value1,value2) {
	//alert(value2);
	//temp = eval("document."+value1);
	eval(value1).src = value2;
	//alert(value1.src);
}