/*
***************************************************************************
'*  SOURCE NAME				: filedCheck.js
'*  FIRST AUTHOR				: °­ÇöÁÖ
'*  PROGRAMING DATE		: 2006-07-18
'*  DESCRIPTION				: ÀÚ¹Ù ½ºÅ©¸³Æ® ÇÊµå Ã¼Å© ÇÔ¼ö ¸ðÀÓ
'***************************************************************************
'***************************************************************************
'*  SYSTEM NAME   GUIDANCE		NAME		DATE			DESCRIPTION
'***************************************************************************
*/

/*
±ÛÀÚ Á¦ÇÑ¼ö¸¦ ÁöÁ¤ ÇÔ¼ö (by °­ÇöÁÖ 2006-07-18)
- »ç¿ë¹æ¹ý : textLengthFix(°´Ã¼¸í, Á¦ÇÑ±ÛÀÚ¼ö, ¸Þ¼¼Áö);
*/
function textLengthFix(objField, theLength, strMsg, theLang) {
	if (objField.value.length != theLength) {
		if (theLang=="kor") alert(strMsg + " " + theLength + "ÀÚ¸¦ ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù.");
		else alert("The "+ strMsg + " input " + theLength + " characters.");
		objField.focus();
		return false;
	}
	return true;
}

/*
±ÛÀÚ Á¦ÇÑ¼öÀÌ»ó Ã¼Å© ÇÔ¼ö (by °­ÇöÁÖ 2006-07-18)
- »ç¿ë¹æ¹ý : textLengthCheck(°´Ã¼¸í, Á¦ÇÑ±ÛÀÚ¼ö, ¸Þ¼¼Áö);
*/
function textLengthCheck(objField, theLimit, strMsg, theLang) {
	if (objField.value.length < theLimit) {
		if (theLang=="kor") alert(strMsg + " " + theLimit + "ÀÚ¸® ÀÌ»ó ¼ýÀÚ·Î ÀÔ·Â ÇÏ¼Å¾ß ÇÕ´Ï´Ù");
		else alert("The "+ strMsg + " do input with a number abnormal a " + theLimit + " seat.");
		objField.focus();
		return false;
	}
	return true;
}

/*
±ÛÀÚ Á¦ÇÑ¼öÀÌÇÏ Ã¼Å© ÇÔ¼ö (by °­ÇöÁÖ 2006-07-18)
- »ç¿ë¹æ¹ý : textLengthLimit(°´Ã¼¸í, Á¦ÇÑ±ÛÀÚ¼ö, ¸Þ¼¼Áö);
*/
function textLengthLimit(objField, theLimit, strMsg, theLang) {
	if (objField.value.length > theLimit) {
		if (theLang=="kor") alert(strMsg + " " + theLimit + "ÀÚ±îÁö¸¸ ¾µ ¼ö ÀÖ½À´Ï´Ù.");
		else alert(strMsg + " " + theLimit + " characters.")
		objField.value = objField.value.substring(0, theLimit);
		objField.focus();
		return false;
	}
	return true;
}

/*
±ÛÀÚ Á¦ÇÑ¼ö¹üÀ§ Ã¼Å© ÇÔ¼ö (by °­ÇöÁÖ 2006-07-18)
- »ç¿ë¹æ¹ý : textLengthRange(°´Ã¼¸í, ÃÖ¼Ò ±ÛÀÚ¼ö, ÃÖ´ë±ÛÀÚ¼ö, ¸Þ¼¼Áö);
*/
function textLengthRange(objField, theMin, theMax, strMsg, theLang) {
	if (objField.value.length < theMin || objField.value.length > theMax) {
		if (theLang=="kor") alert(strMsg + " " + theMin + "~" + theMax + "ÀÚ¸¦ ÀÔ·ÂÇØ¾ß ÇÕ´Ï´Ù.");
		else alert("The " + strMsg + " input between " + theMin + " to " + theMax + " characters");
		objField.focus();
		return false;
	}

	return true;
}

/*
ÅØ½ºÆ® ÇÊµå¿¡ °ª ÀÔ·ÂÇß´ÂÁö ¿©ºÎ¿Í ¼ýÀÚ°ªÀÎÁö ¿©ºÎ Ã¼Å© (by °­ÇöÁÖ 2006-07-18)
- »ç¿ë¹æ¹ý : numericCheck(°´Ã¼¸í, ¸Þ¼¼Áö, theLang);
*/
function numericCheck(objField, strMsg, theLang){
	//ÀÔ·Â¿©ºÎ Ã¼Å©
	if (textFieldCheck(objField, strMsg, theLang) == false) return false;
	//¼ýÀÚÀÎÁö Ã¼Å©
	if (decimalFieldCheck(objField, strMsg, theLang) == false) return false;
	return true;
}

/*
ÅØ½ºÆ® ÇÊµå¿¡ ¼ýÀÚ°ªÀÎÁö ¿©ºÎ Ã¼Å© (by °­ÇöÁÖ 2006-07-18)
- »ç¿ë¹æ¹ý : decimalFieldCheck(°´Ã¼¸í, ¸Þ¼¼Áö, theLang);
*/
function decimalFieldCheck(objField, strMsg, theLang){
	if (!objField.value.checkNumeric())
	{
		if (theLang=="kor") alert(strMsg + "´Â(Àº) ¼ýÀÚ¸¸ ÀÔ·ÂÇÒ ¼ö ÀÖ½À´Ï´Ù."); 
		else alert("Please Insert the " + strMsg + " certainly with number."); 
		objField.focus(); 
		objField.select(); 
		return false;
	}
	return true;
}

/*
ÅØ½ºÆ® ÇÊµå¿¡  °ª ÀÔ·ÂÇß´ÂÁö ¿©ºÎ Ã¼Å© (by °­ÇöÁÖ 2006-07-18)
- »ç¿ë¹æ¹ý : textFieldCheck(°´Ã¼¸í, ¸Þ¼¼Áö, theLang);
*/
function textFieldCheck(objField, strMsg, theLang){
	if (objField.value.length == 0 || objField.value.split(" ").join("") == "" || objField.value.trim() == "")
	{
		if (theLang=="kor") alert(strMsg + "¸¦(À») ÀÔ·ÂÇÏ¼¼¿ä."); 
		else alert("Please input the " + strMsg); 
		objField.focus(); 
		return false;
	}
	return true;
}

/*
SELECT ÇÊµå¿¡  °ª ÀÔ·ÂÇß´ÂÁö ¿©ºÎ Ã¼Å© (by °­ÇöÁÖ 2006-07-18)
- »ç¿ë¹æ¹ý : selectFieldCheck(°´Ã¼¸í, ¸Þ¼¼Áö, theLang);
*/
function selectFieldCheck(objField, strMsg, theLang){
	if (objField.selectedIndex == 0)
	{
		if (theLang=="kor") alert(strMsg + "¸¦(À») ¼±ÅÃÇÏ¼¼¿ä."); 
		else alert("Please select the " + strMsg + " list"); 
		objField.focus(); 
		return false;
	}
	return true;
}

/*
¶óµð¿À³ª Ã¼Å©¹Ú½º¿¡  °ª ÀÔ·ÂÇß´ÂÁö ¿©ºÎ Ã¼Å© (by °­ÇöÁÖ 2006-07-18)
- »ç¿ë¹æ¹ý : boxFieldCheck(°´Ã¼¸í, ¸Þ¼¼Áö, theLang);
*/
function boxFieldCheck(objField, strMsg, theLang){
	var sCount = 0;
	for (var i=0;i<objField.length;i++) {
		if (objField[i].checked == true) sCount++;
	}

	if (sCount == 0)
	{
		if (theLang=="kor") alert(strMsg + "¸¦(À») Ã¼Å©ÇÏ¼¼¿ä."); 
		else alert("Please check the " + strMsg + " list"); 
		return false;
	}
	return true;
}


/*
Ã¼Å© ¹Ú½º Ã³¸® ºÎºÐ - Ã¼Å©¹Ú½º ÀüÃ¼¼±ÅÃ ¹× ÀüÃ¼ ÇØÁ¦ ±â´É (by °­ÇöÁÖ 2006-07-18)
- »ç¿ë¹æ¹ý : CheckAll(ÆûÀÌ¸§);
*/
function CheckAll(form){
  var i;
  if (form.checkboxAll.checked == true) {
    for(i=0; i<form.elements.length; i++) if (form.elements[i].name.indexOf('@')) form.elements[i].checked = true;
  }
  else{
    for(i=0; i<form.elements.length; i++)  if (form.elements[i].name.indexOf('@')) form.elements[i].checked = !form.elements[i].checked;
    form.checkboxAll.checked=false;
  }
}

/*
Ã¼Å© ¹Ú½º Ã³¸® ºÎºÐ -  (by °­ÇöÁÖ 2006-07-18)
- »ç¿ë¹æ¹ý : CheckList(°´Ã¼¸í, Ã³¸®URL, ¸Þ¼¼Áö);
*/
function CheckList(Form, actionURL, strMsg, theLang) {
  var chk = Form;
  var sCount = 0;

  for (var i=chk.length-1; i>=0;i--) {
      if (chk[i].type == "checkbox" && chk[i].name != "checkboxAll" && chk[i].checked == true) sCount++; 
  }

  if (theLang=="kor"){
    if (sCount == 0) {
       alert("\n"+strMsg+"ÇÒ Ç×¸ñÀ» ¸ÕÀú ¼±ÅÃÇÏ¼¼¿ä.\n");
       return;
    }else{
       if (!confirm("\n¼±ÅÃÇÏ½Å Ç×¸ñÀ» "+strMsg+" ÇÏ½Ã°Ú½À´Ï±î?\n")) return;
    }
  }else{
    if (sCount == 0) {
       alert("\n"+strMsg+"ÇÒ Ç×¸ñÀ» ¸ÕÀú ¼±ÅÃÇÏ¼¼¿ä.\n");
       return;
    }else{
       if (!confirm("\n¼±ÅÃÇÏ½Å Ç×¸ñÀ» "+strMsg+" ÇÏ½Ã°Ú½À´Ï±î?\n")) return;
    }
  }
  Form.action =actionURL;
  Form.submit();
}