
/*--------------------------------------------------------------------------*
 *
 * 문자열 함수 모음
 *
 *---------------------------------------------------------------------------*/

  var NUM = "0123456789";
  var SALPHA = "abcdefghijklmnopqrstuvwxyz";
  var ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"+SALPHA;
  var ERRORMSG = ""; 
  var article_fontSize = 12;



function setFont(article_fontSize) { 
  
  document.getElementById("articleBody").style.fontSize = article_fontSize + "px";

  // 하위노드도 있으면 처리

  var mydom = document.getElementById("articleBody");

  for (var i=0; i < mydom.childNodes.length; i++) {

    if (mydom.childNodes[i].nodeType == 1) mydom.childNodes[i].style.fontSize = article_fontSize + "px";

  }

}


function fontPlus()
{
  if (article_fontSize < 18)
  {
    article_fontSize = article_fontSize + 1;
    setFont(article_fontSize);
  }
}


function fontMinus()
{
  if (article_fontSize > 9) {
    article_fontSize = article_fontSize - 1;
    setFont(article_fontSize);
  }
}



 /*--------------------------------------------------------------------------*
  * boolean IsEmpty(str)
  * 문자열이 공백을 포함하여 빈문자열이면 True, 아니면 False
  *--------------------------------------------------------------------------*/
  function IsEmpty(str) {

	for (var i=0;i<str.length;i++) {
		if (str.substring(i,i+1) != " ") return false;  
	}   
	return true; 
  }


  // 문자열 사이에 공백이 있는지 체크

function IsSpace(data) {
  
  var str = trim(data);

  for (var i=0; i < str.length; i++) { 
	if (str.substring(i,i+1) == " ") return true;
  }
  
  return false; 
}


 /*--------------------------------------------------------------------------*
  * boolean IsSpcialString(str, spc)
  * 해당 문자가 포함되어 있는지 체크
  *--------------------------------------------------------------------------*/
  function IsSpcialString(str, chkstr) { 
	var flag = str.indexOf(chkstr);

	if (flag > -1) return true;              
	else  return false; 
  }



// 해당 문자가 있는지 체크

function chk_string(str, word) {
  var chk = str.indexOf(word);
  if (chk > -1) return true;              
  else  return false; 
}



// 자료가 영문,숫자로만 이루어 졌는지 체크

function IsAlphaNumeric(checkStr) {
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789";
  for (i = 0; i < checkStr.length; i++ ) {
	ch = checkStr.charAt(i);
	for (j = 0; j < checkOK.length; j++)  if (ch == checkOK.charAt(j)) break;
 	if (j == checkOK.length) { 
	    return false;
		break;
	}
  }
  return true; 
}



// 자료가 영문 로만 이루어 졌는지 체크

function IsAlpha(checkStr) {
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
  for (i = 0; i < checkStr.length; i++ ) {
	ch = checkStr.charAt(i);
	for (j = 0; j < checkOK.length; j++)  if (ch == checkOK.charAt(j)) break;
 	if (j == checkOK.length) { 
	    return false;
		alert("cc")
		break;
	}
  }
  return true; 
}



// 자료가 영문,한글 로만 이루어 졌는지 체크

function IsAlphaHangul(checkStr) {
  
  for (i=0; i < checkStr.length; i++) {
	
	ch = checkStr.charAt(i);    
	if ( (ch >= '0' && ch <= '9') || !((ch >= 'a' && ch <='z') || (ch == '_') || (ch < 255) || (ch > 0) || (ch >= '가' && ch <= '힣')) ) {
	    return false;
		break;     
    }
  }
  
  return true;
}



// 자료가 숫자인지 체크

function checkDigit(tocheck) {
  var isnum = true;
  if ((tocheck ==null) || (tocheck == "")) {
       isnum = false;
       return isnum; 
  }

  for (var j= 0 ; j< tocheck.length; j++ ) {
       if ( ( tocheck.substring(j,j+1) != "0" ) &&
            ( tocheck.substring(j,j+1) != "1" ) &&
            ( tocheck.substring(j,j+1) != "2" ) &&
            ( tocheck.substring(j,j+1) != "3" ) &&
            ( tocheck.substring(j,j+1) != "4" ) &&
            ( tocheck.substring(j,j+1) != "5" ) &&
            ( tocheck.substring(j,j+1) != "6" ) &&
            ( tocheck.substring(j,j+1) != "7" ) &&
            ( tocheck.substring(j,j+1) != "8" ) &&
            ( tocheck.substring(j,j+1) != "9" ) ) {
            isnum = false; }  
   }
   return isnum; 
}


// 자료가 숫자인지 체크

function checkDigit_s(tocheck) {
  var isnum = true;
  if ((tocheck ==null) || (tocheck == "")) {
       isnum = false;
       return isnum; 
  }

  for (var j= 0 ; j< tocheck.length; j++ ) {
       if ( ( tocheck.substring(j,j+1) != "0" ) &&
            ( tocheck.substring(j,j+1) != "1" ) &&
            ( tocheck.substring(j,j+1) != "2" ) &&
            ( tocheck.substring(j,j+1) != "3" ) &&
            ( tocheck.substring(j,j+1) != "4" ) &&
            ( tocheck.substring(j,j+1) != "5" ) &&
            ( tocheck.substring(j,j+1) != "6" ) &&
            ( tocheck.substring(j,j+1) != "7" ) &&
            ( tocheck.substring(j,j+1) != "8" ) &&
			( tocheck.substring(j,j+1) != "9" ) &&
			( tocheck.substring(j,j+1) != "-" ) &&
            ( tocheck.substring(j,j+1) != "/" ) ) {
            isnum = false; }  
   }
   return isnum; 
}




// 자료가 숫자, 소수점 - 인지 체크

function checkDigit_point(tocheck) {
  var isnum = true;
  if ((tocheck ==null) || (tocheck == "")) {
       isnum = false;
       return isnum; 
  }

  for (var j= 0 ; j< tocheck.length; j++ ) {
       if ( ( tocheck.substring(j,j+1) != "0" ) &&
            ( tocheck.substring(j,j+1) != "1" ) &&
            ( tocheck.substring(j,j+1) != "2" ) &&
            ( tocheck.substring(j,j+1) != "3" ) &&
            ( tocheck.substring(j,j+1) != "4" ) &&
            ( tocheck.substring(j,j+1) != "5" ) &&
            ( tocheck.substring(j,j+1) != "6" ) &&
            ( tocheck.substring(j,j+1) != "7" ) &&
            ( tocheck.substring(j,j+1) != "8" ) &&
            ( tocheck.substring(j,j+1) != "9" ) &&
            ( tocheck.substring(j,j+1) != "-" ) &&
            ( tocheck.substring(j,j+1) != "." ) ) {
            isnum = false; }  
   }
   return isnum; 
}






/*--------------------------------------------------------------------------*
 *
 * 폼처리 함수
 *
 *---------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------*
 * void chk_all(f, checker)
 * 모든 항목을 체크하던가 해제한다.
 *--------------------------------------------------------------------------*/

 function chk_all(f, checker){
	var check = checker.checked;
	var cnt = 0;
	for (var i=0; i<f.elements.length; i++) {
		if (f.elements[i].name=='sno') { 
			f.elements[i].checked = check; cnt+=1; 
		}
	}
}

/*--------------------------------------------------------------------------*
 * int chk_count()
 * 체크된 항목의 카운터를 리턴한다.
 *--------------------------------------------------------------------------*/
 function chk_count(f){

	var checkobj  = new Array();
	var checkcnt=0;

	for (var i=0;i<f.elements.length;i++) {
		if ( f.elements[i].name!='sno') continue;
		if ( f.elements[i].checked==true) {
			checkobj[checkcnt]  = f.elements[i];
			checkcnt++;
		}
	}
	return checkcnt;
}

/*--------------------------------------------------------------------------*
 * int is_checked()
 * 체크박스에서 선택된것이 하나라도 있으면 true 를 리턴
 *--------------------------------------------------------------------------*/
 function is_checked(field) {

	var obj = eval(field);

	for (var i=0;i<obj.length;i++) {
		if ( obj[i].checked == true) {
			return true;
		}
	}
	return false;
 }


// trim 함수 

function trim(str){
  
  // 정규 표현식을 사용하여 화이트스페이스를 빈문자로 전환
  str = str.replace(/^\s*/,'').replace(/\s*$/, ''); 
  return str;

} 


// 메일 도메인 처리및 한메일 처리

function fillaccount(f1, f2) {

  if (f1.value != '') {
      f2.value = f1.value;  
  }

}

 /*--------------------------------------------------------------------------*
  * boolean IsNumber(str)
  * 문자열이 숫자로만 이루어져 있으면 True, 아니면 False
  *--------------------------------------------------------------------------*/
  function IsNumber(str) {
    return IsOnlySpcialString(str, NUM);
  }

 /*--------------------------------------------------------------------------*
  * boolean IsOnlySpcialString(str, spc)
  * str 문자열이 spc 문자열로만 이루어져 있으면 True, 아니면 False
  *--------------------------------------------------------------------------*/
  function IsOnlySpcialString(str, spc) {
	var i;

	for(i=0; i<str.length; i++) {
		if (spc.indexOf(str.substring(i, i+1)) < 0) {
			return false;
      	}
	}
	return true;
  }


// 폼전송전 공백제거 

function all_textForm_trim() {
  var frm = document.form1;

  for (var i = 0; i < frm.elements.length; i++) {
    if (frm.elements[i].type == "text") {
        frm.elements[i].value = trim(frm.elements[i].value);
	 }
  }

}


 /*--------------------------------------------------------------------------*
  * void setSelect (obj, value)
  * 셀렉트폼에서 value 와 일치하는 항목을 선택상태로 만들어준다.
  *--------------------------------------------------------------------------*/
  function setSelect (obj, value) {

	  for (i=0;i<obj.length;i++) {
		  if (obj.options[i].value == value) obj.options[i].selected = true;
	  }
  }

 /*--------------------------------------------------------------------------*
  * void getSelectValue (obj)
  * 셀렉트폼의 선택상태 값을 가져온다.
  *--------------------------------------------------------------------------*/
  function getSelectValue (obj) {
	  var idx = obj.selectedIndex;
	  var value = obj.options[idx].value;
	  return value;
  }


 /*--------------------------------------------------------------------------*
  * void unsetSelect (obj)
  * 셀렉트폼의 선택상태를 해제한다. -- 테스트 요함
  *--------------------------------------------------------------------------*/
  function unsetSelect (obj)  {
	  for (i=0;i<obj.length;i++) {
		  obj.options[i].selected = false;
	  }
  }

 /*--------------------------------------------------------------------------*
  * void setChecked (obj, value)
  * radio, checkbox 의 항목중에 value 값이 일치하는 항목이 체크되도록 설정
  *--------------------------------------------------------------------------*/
  function setChecked (obj, value) {
	  for (i=0;i<obj.length;i++) {
		  if (obj[i].value == value) obj[i].checked = true;
	  }
  }

 /*--------------------------------------------------------------------------*
  * void getRadioValue (obj)
  * radio, checkbox 의 항목중에 value 값이 일치하는 항목이 체크되도록 설정
  *--------------------------------------------------------------------------*/
  function getRadioValue (obj) {

	   value = "";

	  for (var i=0; i < obj.length; i++) {
		  if( obj[i].checked == true) {
			  value = obj[i].value;
			  break;
		  }
	  }
	  return value;
  }



// 주민번호 첫째자리 6자리 입력시 다음으로 포커스 이동 시키기

function juminNextFocus (f1,f2) {
  
  if (f1.value.length == 6)  f2.focus();

}


// 주민번호 체크

function CheckJuminNo(f1, f2) {

  var strresidentno1 = f1.value;
  var strresidentno2 = f2.value;

  if (strresidentno1.length < 6) {
      alert ("주민등록번호 길이가 정확 하지 않습니다.");
      f1.focus();
      return false; 
  }

  if (strresidentno2.length < 7 ) {
      alert ("주민등록번호 길이가 정확 하지 않습니다.");
      f2.focus();
      return false; 
  } 

  var strresidentno = strresidentno1 + strresidentno2;
  var strA, strB, strC, strD, strE, strF, strG, strH, strI, strJ, strK, strL, strM, strN, strO;
  var nCalA, nCalB, nCalC; 

  strA = strresidentno.substr(0, 1);
  strB = strresidentno.substr(1, 1);
  strC = strresidentno.substr(2, 1);
  strD = strresidentno.substr(3, 1);
  strE = strresidentno.substr(4, 1);
  strF = strresidentno.substr(5, 1);
  strG = strresidentno.substr(6, 1);
  strH = strresidentno.substr(7, 1);
  strI = strresidentno.substr(8, 1);
  strJ = strresidentno.substr(9, 1); 
  strK = strresidentno.substr(10, 1);
  strL = strresidentno.substr(11, 1);
  strM = strresidentno.substr(12, 1);            

  strO = strA*2 + strB*3 + strC*4 + strD*5 + strE*6 + strF*7 + strG*8 + strH*9 + strI*2 + strJ*3 + strK*4 + strL*5;

  nCalA = eval(strO);
  nCalB = nCalA % 11;
  nCalC = 11 - nCalB;
  nCalC = nCalC % 10; 

  strv = '19';
  strw = strresidentno.substr(0, 2);
  strx = strresidentno.substr(2, 2);
  stry = strresidentno.substr(4, 2);      	

  strz = strv + strw;

  if ((strz % 4 == 0) && (strz % 100 != 0) || (strz % 400 == 0)) {	yunyear = 29;  }
  else yunyear = 28;       	

  if ((strx <= 0) || (strx > 12)) {
       alert("생년월일이 맞지 않습니다.");
       f1.focus();
       return false; 
  }

  if ((strx == 1 || strx == 3 || strx == 5 || strx == 7 || strx == 8 || strx == 10 || strx == 12) && (stry > 31 || stry <= 0)) {
      alert("생년월일이 맞지 않습니다.");
      f1.focus();
      return false; 
  }

  if ((strx == 4 || strx == 6 || strx == 9 || strx == 11) && (stry > 30 || stry <= 0)) {
	  alert("생년월일이 맞지 않습니다.");
      f1.focus();
      return false; 
  }

  if (strx == 2 && (stry > yunyear || stry <= 0)) {
      alert(strz + "생년월일이 맞지 않습니다." + yunyear);
      f1.focus();
      return false;  
  }

  if (!((strG == 1) || (strG == 2) || (strG == 3) || (strG ==4))) {
	  alert("주민등록번호 뒷자리의 시작은 1 ~ 4 이여야 합니다.");
      f2.focus();
      return false;  
  }

  if (nCalC != strM) { 
	  alert("주민등록번호가 규칙에 어긋 납니다.");
	  f1.focus();
	  return false;
  }
  
  return true;
}



// 주민번호 첫째자리 입력시 생년월일 맞추기

function fillBirth(birth,f1,f2,f3) {
  
  var tyear = '';
  var tmon = '';
  var tday = '';

  if (birth.length == 6) {
	  if (birth.substring(0,2) > "10")  tyear = "19" + birth.substring(0,2);
	  else  tyear = "20" + birth.substring(0,2);
     f1.value = tyear;
     f2.value = birth.substring(2,4);
     f3.value = birth.substring(4,6)
  }

}


// 주민번호 두째자리 입력시 성별 채우기

function fillSex(jumin2, sexF) {

  if (jumin2.substring(0,1) == '1' || jumin2.substring(0,1) == '3')      sexF[0].checked = true;
  else if (jumin2.substring(0,1) == '2' || jumin2.substring(0,1) == '4') sexF[1].checked = true;

}






/*--------------------------------------------------------------------------*
 * int CheckBID (bid_first, bid_mid, bid_last)
 * 사업자 등록번호가 유효한 형식인지 검사한다.
 * 유효한 형식이면 0, 첫번째 자리에 이상이 있으면 1, 두번째는 2, 세번째는 3 을 리턴
 *--------------------------------------------------------------------------*/
 function CheckBID (bid_first, bid_mid, bid_last) {     

	var sName = "사업자등록번호";

	// 공백 체크
	if (trim(bid_first) == "") {
		ERRORMSG = sName + "를 입력해 주세요.";
		return 1;
	}
	// 형식 체크
	if (!IsNumber(bid_first, NUM)) {
		ERRORMSG = sName + "에 잘못된 문자가 있습니다.";
		return 1;
	}
	// 자릿수 체크
	if ( bid_first.length != 3 ) {
		ERRORMSG = sName + "의 자릿수가 잘못되었습니다.";
		return 1;
	}

	// 공백 체크
	if (trim(bid_mid) == "") {
		ERRORMSG = sName + "를 입력해 주세요.";
		return 2;
	}
	// 형식 체크
	if (!IsNumber(bid_mid, NUM)) {
		ERRORMSG = sName + "에 잘못된 문자가 있습니다.";
		return 2;
	}
	// 자릿수 체크
	if ( bid_mid.length != 2 ) {
		ERRORMSG = sName + "의 자릿수가 잘못되었습니다.";
		return 2;
	}

	// 공백 체크
	if (trim(bid_last) == "") {
		ERRORMSG = sName + "를 입력해 주세요.";
		return 3;
	}
	// 형식 체크
	if (!IsNumber(bid_last, NUM)) {
		ERRORMSG = sName + "에 잘못된 문자가 있습니다.";
		return 3;
	}
	// 자릿수 체크
	if ( bid_last.length != 5 ) {
		ERRORMSG = sName + "의 자릿수가 잘못되었습니다.";
		return 3;
	}

	var ls_epno = bid_first + bid_mid + bid_last;   
	var li_epno = new Array(10);
	var sum = 0;

	var li_chkvalue = new Array(1,3,7,1,3,7,1,3,5);

	for (i=0; i<10; i++) {
		li_epno[i] = parseInt(ls_epno.charAt(i));
	}

	for (i=0; i<9; i++) {
		sum += li_epno[i] * li_chkvalue[i];
	}

	sum = sum + parseInt(((li_epno[8] * 5) / 10));      
	li_y = sum % 10;

	if (li_y == 0) {
		epno_chk = 0;
	} else {
		epno_chk = 10 - li_y;    
	}

	if (epno_chk == li_epno[9]) {         
		return 0;           
	} else {
		ERRORMSG = "유효하지 않은 사업자등록번호입니다.";          
		return 1;
	}       
 }

 /*--------------------------------------------------------------------------*
  * void setBirthdayForm(sRIDFirst,f1,f2,f3)
  * 주민등록번호 앞자리가 채워지면 생년월일이 자동으로 선택된다.
  *--------------------------------------------------------------------------*/
  function setBirthdayForm(sRIDFirst,f1,f2,f3) {

	  var byear = '';
	  var bmon = '';
	  var bday = '';
	  
	  if (sRIDFirst.length == 6) {
		  if (sRIDFirst.substring(0,2) > "10")  byear = "19" + sRIDFirst.substring(0,2);
		  else byear = "20" + sRIDFirst.substring(0,2);
		  
		  setSelect(f1, byear);
		  setSelect(f2, sRIDFirst.substring(2,4));
		  setSelect(f3, sRIDFirst.substring(4,6));
	  }
  }

 /*--------------------------------------------------------------------------*
  * void setSexForm(sRIDLast, sexfield)
  * 주민등록번호 뒷자리가 채워지면 성별이 자동 선택된다.
  *--------------------------------------------------------------------------*/
  function setSexForm(sRIDLast, sexfield) {
	  
	  if (sRIDLast.substring(0,1) == '1' || sRIDLast.substring(0,1) == '3') sexfield[0].checked = true;
	  else if (sRIDLast.substring(0,1) == '2' || sRIDLast.substring(0,1) == '4') sexfield[1].checked = true;

  }

 /*--------------------------------------------------------------------------*
  * void CheckEmail(str)
  * 전자우편이 유효한 형식이면 True, 아니면 False 리턴
  *--------------------------------------------------------------------------*/
  function CheckEmail(str) {
	  
	  var i;
	  var strEmail = str;
	  var strCheck1 = false;
	  var strCheck2 = false;
	  var result = true;
	  
	  for (i=0; i < strEmail.length; i++) {

		  if ((strEmail.substring(i,i+1) == "~") || (strEmail.substring(i,i+1) == ".") ||
			  (strEmail.substring(i,i+1) == "_") || (strEmail.substring(i,i+1) == "-") ||
			  ((strEmail.substring(i,i+1) >= "0") && (strEmail.substring(i,i+1) <= "9")) ||
			  ((strEmail.substring(i,i+1) >= "@") && (strEmail.substring(i,i+1) <= "Z")) ||
			  ((strEmail.substring(i,i+1) >= "a") && (strEmail.substring(i,i+1) <= "z"))) {
			  
			  if (strEmail.substring(i,i+1) == ".")  strCheck1 = true;
			  if (strEmail.substring(i,i+1) == "@")  strCheck2 = true;
		  } else {
			  result = false;
			  break;
		  }
	  }
	  if ((strCheck1 == false) || (strCheck2 == false)) {
		  result = false;
	  }
	  return result;
  }


 /*--------------------------------------------------------------------------*
  * void CheckBusinessID (bid_first, bid_mid, bid_last)
  * 사업자 등록번호가 유효한 형식이면 True, 아니면 False 리턴
  *--------------------------------------------------------------------------*/
  function CheckBusinessID (bid_first, bid_mid, bid_last) {
	  
	  var sName = "사업자등록번호";

      // 형식 체크
	  if (!IsNumber(bid_first, NUM)) {
		  ERRORMSG = sName + "에 잘못된 문자가 있습니다.";
		  return 1;
	  }
      if (!IsNumber(bid_mid, NUM)) {
		  ERRORMSG = sName + "에 잘못된 문자가 있습니다.";
		  return 2;
      }
      if (!IsNumber(bid_last, NUM)) {
		  ERRORMSG = sName + "에 잘못된 문자가 있습니다.";
		  return 3;
      }
	  
	  // 길이 체크
	  if ( !CheckLenEng(bid_first, sName, 3, 3, 1) ) {
		  return 1;
      }
      if ( !CheckLenEng(bid_mid, sName, 2, 2, 1) ) {
		  return 2;
      }
      if ( !CheckLenEng(bid_last, sName, 5, 5, 1) ) {
		  return 3;
      }

      var ls_epno = bid_first + bid_mid + bid_last;
	  var li_epno = new Array(10);
	  var sum = 0;

      var li_chkvalue = new Array(1,3,7,1,3,7,1,3,5);
                  
      for (i=0; i<10; i++) {
		  li_epno[i] = parseInt(ls_epno.charAt(i));
      }

      for (i=0; i<9; i++) {
		  sum += li_epno[i] * li_chkvalue[i];
      }
        
      sum = sum + parseInt(((li_epno[8] * 5) / 10));      
      li_y = sum % 10;

      if (li_y == 0) {
		  epno_chk = 0;
      } else {
		  epno_chk = 10 - li_y;    
      }
        
      if (epno_chk == li_epno[9]) {
		  return 0;
	  } else {
		  ERRORMSG = "유효하지 않은 사업자등록번호입니다.";          
		  return 1;
      }       
  } 

 /*--------------------------------------------------------------------------*
  * void CheckBusinessID2 (bid_first, bid_mid, bid_last)
  * 사업자 등록번호가 유효한 형식이면 True, 아니면 False 리턴
  *--------------------------------------------------------------------------*/
  function CheckBusinessID2(ThisVal1, ThisVal2, ThisVal3) {
	  var chkRule = "137137135";
	  var strCorpNum = ThisVal1 + ThisVal2 + ThisVal3; // 사업자번호 10자리
	  var step1, step2, step3, step4, step5, step6, step7;
	  
	  step1 = 0; // 초기화
	  
	  for (i=0; i<7; i++) {
		  step1 = step1 + (strCorpNum.substring(i, i+1) * chkRule.substring(i, i+1));
	  }
	  
	  step2 = step1 % 10;
	  step3 = (strCorpNum.substring(7, 8) * chkRule.substring(7, 8))% 10;
	  step4 = strCorpNum.substring(8, 9) * chkRule.substring(8, 9);
	  step5 = Math.round(step4 / 10 - 0.5);
	  step6 = step4 - (step5 * 10);
	  step7 = (10 - ((step2 + step3 + step5 + step6) % 10)) % 10;
	  
	  if (strCorpNum.substring(9, 10) != step7) return false;
	  else return true;
  }


 /*--------------------------------------------------------------------------*
  * void copy_clipBoard (str)
  * 문자열을 클립보드로 복사한다.
  *--------------------------------------------------------------------------*/
 function copy_clipBoard(str) {
	window.clipboardData.setData('Text', str);
	window.alert("복사 되었습니다.");
 }



 /*--------------------------------------------------------------------------*
  * void copy_clipBoard (str)
  * 문자열을 클립보드로 복사한다.
  *--------------------------------------------------------------------------*/
 function movie_clipBoard(movie) {

   var host = "www.costel.com";

   var f = "<embed pluginspage='http://www.macromedia.com/go/getflashplayer' src='http://" + host + "/js/player.swf?file=" + movie + "&autostart=true' width='265' height='220' type='application/x-shockwave-flash'></embed>";

   window.clipboardData.setData('Text', f);
   window.alert("동영상 태그가 복사 되었습니다.\n태그가 지원 되는 게시판은 복사된 태그를 입력 하시고\n태그가 지원 되지 않는 게시판은 동영상을 다운로드후\n직접 동영상을 해당 게시판에 업로드 바랍니다.");
 }


 /*--------------------------------------------------------------------------*
  * void copy_clipBoard (str)
  * 문자열을 클립보드로 복사한다.
  *--------------------------------------------------------------------------*/
 function movie_clipBoard2(movie) {

   var host = "www.costel.com";

   var f = "<embed pluginspage='http://www.macromedia.com/go/getflashplayer' src='http://" + host + "/js/player.swf?file=" + movie + "&autostart=true' width='325' height='200' type='application/x-shockwave-flash'></embed>";

   window.clipboardData.setData('Text', f);
   window.alert("동영상 태그가 복사 되었습니다.\n태그가 지원 되는 게시판은 복사된 태그를 입력 하시고\n태그가 지원 되지 않는 게시판은 동영상을 다운로드후\n직접 동영상을 해당 게시판에 업로드 바랍니다.");
 }


// 셀렉트 박스 선택

function set_select(input, str) {

  for (i=0; i < input.options.length; i++) {
    if (input.options[i].value == str) input.options[i].selected = true;
  }

}



// 라디오,체크박스 체크갯수


function ch_radiocount(frm, strval) {
  var cnum = 0;

  for (var i = 0; i < frm.elements.length; i++) {
	if (frm.elements[i].name == strval) {		
        if (frm.elements[i].checked == true) cnum = cnum + 1;
    }
  }

  return cnum;
}




// 라디오,체크박스 체크값


function val_radiocount(frm, strval) {
  var val = '';

  for (var i = 0; i < frm.elements.length; i++) {
	if (frm.elements[i].name == strval) {		
        if (frm.elements[i].checked == true)  val = frm.elements[i].value;
    }
  }

  return val;
}




// 라디오 버튼 선택 확인

function check_radio_cnt (frm, strval) {
  
  var cnt = 0;

  for (var i=0; i < frm.elements.length; i++) {
    if (frm.elements[i].name == strval) {
        if (frm.elements[i].checked == true)  cnt = cnt + 1;
    }
  }

  return cnt;

}



// 라디오 버튼 값 가져오기

function get_radioValue (frm, strval) {
  
  var myval = '';

  for (var i=0; i < frm.elements.length; i++) {
    if (frm.elements[i].name == strval) {
        if (frm.elements[i].checked == true && frm.elements[i].disabled == false)  myval = frm.elements[i].value;
    }
  }

  return myval;

}




/*--------------------------------------------------------------------------*
 *
 * 페이지 이동 함수
 *
 *---------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*
  * void ask_movePage(msg, url)
  * 메세지(msg) 출력 후 예를 클릭하면 해당 페이지(url)로 이동
  *--------------------------------------------------------------------------*/
  function ask_movePage (msg, url) {     
	  if (confirm(msg) == true) {
		  window.location.href = url;
	  }
  }

 /*--------------------------------------------------------------------------*
  * void movePage(url)
  * 이동하여 url 열기
  *--------------------------------------------------------------------------*/
  function movePage (url) { 

	  if (IsEmpty(url) == false) window.location.href = url;

  }

 /*--------------------------------------------------------------------------*
  * void openPage(url)
  * 새창으로 url 열기
  *--------------------------------------------------------------------------*/
  function openPage (url) { 

	  if (IsEmpty(url) == false) window.open(url,"","");

  }

 /*--------------------------------------------------------------------------*
  * void openPageXY(url, wname, top, left, width, height)
  * 새창으로 위치, 크기 지정하여 url 열기 (스크롤 no, 사이즈변경:no)
  *--------------------------------------------------------------------------*/
  function openPageXY (url, wname, top, left, width, height) {
	  window.open(url, wname, 'scrollbars=no,resizable=no,top='+top+',left='+left+',width='+width+',height='+height);
  }

 /*--------------------------------------------------------------------------*
  * void openPageMax(url, wname)
  * 새창으로 최대크기로 url 열기
  *--------------------------------------------------------------------------*/
  function OpenPageMax (url, wname) {
	  window.open(url, wname, 'scrollbars=yes,toolbar=yes,location=yes,resizable=yes,status=yes,menubar=yes,resizable=yes,fullscreen=no');
  }

function pop_window(w,h,url, nm) {

  var width_half  = (screen.width - w) / 2;
  var height_half = (screen.height - h) / 2;

  open_attr = 'height='+h+',width='+w+',top='+height_half+',left='+width_half+',resizable=no'

  window.open(url, nm, open_attr);
}

 /*--------------------------------------------------------------------------*
  * void openPageCenter(url, wname, width, height)
  * 새창으로 가운데로 url 열기 
  * 호환 : Firefox(x)
  *--------------------------------------------------------------------------*/
  function openPageCenter (url, wname, width, height) {

	  var screenWidth  = screen.availwidth;
	  var screenHeight = screen.availheight;
	  
	  var intLeft = (screenWidth - width) / 2;
	  var intTop  = (screenHeight - height) / 2;

	  window.open(url, wname, 'scrollbars=no,resizable=no,top='+intTop+',left='+intLeft+',width='+width+',height='+height);
  }

 /*--------------------------------------------------------------------------*
  * void openPageCenterS(url, wname, width, height)
  * 새창으로 가운데로 url 열기, 스크롤 허용
  * 호환 : Firefox(x)
  *--------------------------------------------------------------------------*/
  function openPageCenterS (url, wname, width, height) {
	  
	  var screenWidth  = screen.availwidth;
	  var screenHeight = screen.availheight;
	  
	  var intLeft = (screenWidth - width) / 2;
	  var intTop  = (screenHeight - height) / 2;

	  window.open(url, wname, 'scrollbars=yes,resizable=no,top='+intTop+',left='+intLeft+',width='+width+',height='+height);
  }


 /*--------------------------------------------------------------------------*
  * void openPageSubmit(obj, url, wname, width, height) --- 테스트 요함
  * 새창으로 폼전송
  *--------------------------------------------------------------------------*/
  function openPageSubmit (obj, url, wname, width, height) {

	  var screenWidth  = screen.availwidth;
	  var screenHeight = screen.availheight;
	  
	  var intLeft = (screenWidth - width) / 2;
	  var intTop  = (screenHeight - height) / 2;
	  
	  var opts = "scrollbars=no,resizable=no,top="+intTop+",left="+intLeft+",width="+width+",height="+height;
	  window.open("", wname, opts);
	  
	  obj.action = url;
	  obj.target = wname;
	  obj.submit(); 
}



 /*--------------------------------------------------------------------------*
  * void check_email(formName, fieldName, str) --- 
  * 이메일 검사
  *--------------------------------------------------------------------------*/

	function check_email(formName, fieldName, str) 
		{
			
			var emailVal = true;
			var temp = document.forms[formName].elements[fieldName];
			var A = temp.value.indexOf('@');
			var prd = temp.value.lastIndexOf('.');
			var space = temp.value.indexOf(' ');
			var length = temp.value.length - 1;

		if ( (temp.value) && ((A < 1) || (prd <= A+1) ||  (prd == length ) ||  (space  != -1)) )  
			{  
				emailVal = false;
				alert(str);
				//temp.value = "";
				temp.select();
			}
				return emailVal;
		}





// 우편번호 선택창

function findPost() {
  
  winOpenCenter('/member/post_list.asp', 'post_list', '400', '440');
} 



// ajax 에서 escape 로 인코딩시 + 문자 문제해결

function escape_plus (value) {
  return escape(value).replace(/\+/g, '%2B');
}





/*--------------------------------------------------------------------------*
 *
 * 레이어 처리 함수
 *
 *---------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*
  * void layerToggle(div)
  * 레이어 토글
  *--------------------------------------------------------------------------*/
  function layerToggle(div) {
	  
	  if (document.getElementById(div)) {		  
		  if (document.getElementById(div).style.display == "block")  document.getElementById(div).style.display = "none";
		  else document.getElementById(div).style.display = "block";
		  //return false;
	  } else { 
		  //return true; 
      }
  }




// 쿠키 굽기

function setCookie(name, value, expiredays) {
  
  var todayDate = new Date();
  todayDate.setDate(todayDate.getDate() + expiredays);   
  document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"

}


// 쿠기 검색

function getCookieVal (offset) {

  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1) endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));

}


// 쿠키읽기

function GetCookie (name) {

  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  
  while (i < clen) {	//while open
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
  }	//while close
  
  return null;

}


// 쿠키 삭제

function deleteCookie(cookieName) {
   
  document.cookie = cookieName+"=; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}


function show_Iframe (posid, myid, width, src, scroll) {

  var str = "";

  str += "<iframe id=\"" + myid + "\" name=\"" + myid + "\" frameborder=\"0\" width=\"" + width + "\" height=\"0\" hspace=\"0\" vspace=\"0\" "
  str += "marginheight=\"0\" marginwidth=\"0\" scrolling=\"" + scroll + "\" onload=\"resizeFrame(this);\" src=\"" + src + "\" allowTransparency='true'></iframe>\n"

  document.getElementById(posid).innerHTML = str;
}


function resizeFrame(iframeObj) {
	
  var innerBody = iframeObj.contentWindow.document.body; 
   
  oldEvent = innerBody.onclick; 
  innerBody.onclick = function() {
	resizeFrame(iframeObj, 1);
	oldEvent;
  }; 
   
  var innerHeight = innerBody.scrollHeight + (innerBody.offsetHeight - innerBody.clientHeight); 
  iframeObj.style.height = innerHeight; 
  var innerWidth = innerBody.scrollWidth + (innerBody.offsetWidth - innerBody.clientWidth); 
  iframeObj.style.width = innerWidth;    
  //if (!arguments[1]) this.scrollTo(1,1); 
} 



/*--------------------------------------------------------------------------*
 *
 * 날짜 처리 함수
 *
 *---------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*
  * string getToDay()
  * 오늘 날짜 구하기
  *--------------------------------------------------------------------------*/
  function getToDay() {
	  
	  var date = new Date();
	  
	  var year  = date.getFullYear();
	  var month = date.getMonth() + 1;
	  var day   = date.getDate();
	  
	  if (("" + month).length == 1)  month = "0" + month;
	  if (("" + day).length   == 1)  day   = "0" + day;
	  
	  return ("" + year + month + day)
  }




// 날짜검색 처리

function sel_seday(f1, f2, val_a, val_b) {

  f1.value = val_a;
  f2.value = val_b;

}



/*--------------------------------------------------------------------------*
 *
 * 메뉴 와 미디어 로드
 *
 *---------------------------------------------------------------------------*/
function flashplayObj(src,w,h) { 
  html = '';
  html += '<object type="application/x-shockwave-flash" data="/kr/flash/movie.swf" width="'+w+'" height="'+h+'">';
  html += '<param name="movie" value="/kr/flash/movie.swf" />';
  html += '<param name="flashvars" value="videofile='+ src + '" />';
  html += '<param name="quality" value="high" /> ';
  html += '<param name="wmode" value="transparent" /> ';
  html += '<param name="allowScriptAccess" value="sameDomain" />';
  html += '<param name="allowFullScreen" value="false" />';
  html += '</object>';

  document.write(html);
}



function flashObj2(src, w, h, id) {
  html = '';
  html += '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" id="'+id+'" width="'+w+'" align="center" height="'+h+'">\r\n';  
  html += '<param name="allowScriptAccess" value="always">\r\n';  // fscommand적용플래쉬 추가 파라미터값
  html += '<param name="movie" value="'+src+'">\r\n'; 
  html += '<param name="quality" value="high">\r\n'; 
  html += '<param name="bgcolor" value="#ffffff">\r\n';
  html += '<param name="wmode" value="window">\r\n';		
  html += '<param name="menu" value="false">\r\n';  
  html += '<embed src="'+src+'" quality=high bgcolor="#ffffff" wmode="window" menu="false" width="'+w+'"  height="'+h+'" id="'+id+'" name="'+id+'" swLiveConnect="true" align="center" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>\r\n'; 
  html += '</object>\r\n'; 

  document.write(html);

  eval("window." + id + " = document.getElementById('" + id + "');");

}


function flashObj(src, w, h, id) {
  html = '';
  html += '<object type="application/x-shockwave-flash" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0" id="'+id+'" width="'+w+'" align="center" height="'+h+'">\r\n';  
  html += '<param name="allowScriptAccess" value="alway" />\r\n'; 
  html += '<param name="movie" value="'+src+'" />\r\n'; 
  html += '<param name="quality" value="high" />\r\n'; 
  html += '<param name="bgcolor" value="#ffffff" />\r\n';
  html += '<param name="wmode" value="transparent" />\r\n';		
  html += '<param name="menu" value="false" />\r\n';  
  html += '<embed src="'+src+'" quality=high bgcolor="#ffffff" wmode="transparent" width="'+w+'" height="'+h+'" swliveconnect="true" name="fev1" swLiveConnect="true" align="center" allowScriptAccess="alway" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>\r\n'; 
  html += '</object>\r\n'; 

  document.write(html);
}



function flash_param(src,w,h,id,val) { 
  
  html = '';
  html += '<object type="application/x-shockwave-flash"  classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0 id="'+id+'" width="'+w+'" align="center" height="'+h+'">';  
  html += '<param name="movie" value="'+src+'" />'; 
  html += '<param name="quality" value="high" />'; 
  html += '<param name="flashvars" value="'+val+'" />'; 
  html += '<param name="bgcolor" value="#ffffff" />';
  html += '<param name="wmode" value="transparent" />';		
  html += '<param name="menu" value="false" />';  
  html += '<param name="allowScriptAccess" value="always" />';  
  html += '<param name="allowFullScreen" value="true" />';  
  html += '<embed src="'+src+'" quality=high bgcolor="#ffffff" menu="false" wmode="transparent" allowScriptAccess="always" showLiveConnect="true" allowFullScreen="true" width="'+w+'" height="'+h+'" flashVars="'+val+'" swliveconnect="true" id="'+id+'" name="param" align="center" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> <\/embed>'; 
  html += '<\/object>'; 


  document.write(html);

  eval("window." + id + " = document.getElementById('" + id + "');");

}



function flash_load(src,w,h,id,val,cp) { 
  
  html = '';
  html += '<object type="application/x-shockwave-flash"  classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"  codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0 id="'+id+'" width="'+w+'" align="center" height="'+h+'">';  
  html += '<param name="movie" value="'+src+'" />'; 
  html += '<param name="quality" value="high" />'; 
  html += '<param name="flashvars" value="'+val+'" />'; 
  html += '<param name="bgcolor" value="#ffffff" />';
  html += '<param name="wmode" value="transparent" />';		
  html += '<param name="menu" value="false" />';  
  html += '<param name="allowScriptAccess" value="always" />';  
  html += '<param name="allowFullScreen" value="true" />';  
  if (cp != "") html += '<p>'+cp+'</p>';  
  html += '<embed src="'+src+'" quality=high bgcolor="#ffffff" menu="false" wmode="transparent" allowScriptAccess="always" showLiveConnect="true" allowFullScreen="true" width="'+w+'" height="'+h+'" flashVars="'+val+'" swliveconnect="true" id="'+id+'" name="param" align="center" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"> <\/embed>'; 
  html += '<\/object>'; 
  
  document.write(html);

  eval("window." + id + " = document.getElementById('" + id + "');");

}



function thisMovie(movieName) {
  if (navigator.appName.indexOf("Microsoft") != -1)  return window[movieName];
  else return document[movieName];
}



// 상단네비 1차 메뉴 처리

function menuD2block(id) {
  for(num=1; num <= 5; num++) document.getElementById('D2MG'+num).style.display='none'; //D2MG1~D2MG5 까지 숨긴 다음
  document.getElementById(id).style.display='block'; //해당 ID만 보임

  //document.getElementById(id).style.zIndex = "99";
}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}


var sel_tab = '';

function MM_swapImgRestore2(gu) { //v3.0
  var i, x, a=document.MM_sr;

  for (i=0; a && i < a.length && (x=a[i]) && x.oSrc; i++) {
	if (sel_tab != gu) x.src = x.oSrc;
  }
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}


function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { 
	v = args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; 
  }
}

MM_reloadPage(true);



// 확대 이미지 출력 

function show_bimage(img, width, height) {

  document.myimg.src = img;
  document.myimg.width = width;
  document.myimg.height = height;
  
}


// 원도우 창 오픈

function winOpen (doc, wname, top, left, width, height) {
  window.open(doc, wname, 'scrollbars=no,resizable=no,top='+top+',left='+left+',width='+width+',height='+height);
}



// 원도우 최대창 오픈

function winOpenMax (doc, wname) {
  window.open(doc, wname, 'scrollbars=yes,toolbar=yes,location=yes,resizable=yes,status=yes,menubar=yes,resizable=yes,fullscreen=no');
}



// 원도우 창 오픈 (해상도에 따라 가운데로 열기)

function winOpenCenter (doc, wname, width, height) {

  var screenWidth  = window.screen.availWidth;
  var screenHeight = window.screen.availHeight;

  var intLeft = (screenWidth - width) / 2;
  var intTop  = (screenHeight - height) / 2

  window.open(doc, wname, 'scrollbars=no,resizable=no,top='+intTop+',left='+intLeft+',width='+width+',height='+height);

}



// 원도우 창 오픈 (스크롤, 해상도에 따라 가운데로 열기)

function winOpenCenterB (doc, wname, width, height) {

  var screenWidth  = window.screen.availWidth;
  var screenHeight = window.screen.availHeight;

  var intLeft = (screenWidth - width) / 2;
  var intTop  = (screenHeight - height) / 2;

  window.open(doc, wname, 'scrollbars=yes,resizable=no,top='+intTop+',left='+intLeft+',width='+width+',height='+height);

}






 /*--------------------------------------------------------------------------*
  * void cal_byte(aquery, f1, f2, maxStr) --- 
  * 바이트 체크
  *--------------------------------------------------------------------------*/


function cal_byte(aquery, f1, f2, maxStr) {

  var tmpStr;
  var temp=0;
  var onechar;
  var tcount;
  tcount = 0;
   
  if (aquery == '')  aquery = f1.value;

  tmpStr = new String(aquery);
  temp = tmpStr.length;

  for (k=0; k < temp; k++) {
    onechar = tmpStr.charAt(k);
    if (escape(onechar).length > 4) tcount += 2;
    else if (onechar != '\r')       tcount++;
  }

  f2.value = tcount;
  if (tcount > maxStr) {
      reserve = tcount - maxStr;
      alert("내용은 "+maxStr+" 바이트 이상은 입력 할 수 없습니다.\r\n입력한 내용은 "+reserve+"바이트가 초과되었습니다.\r\n 초과된 부분은 자동으로 삭제됩니다."); 
      nets_check(f1, f2, maxStr);
      return false;
  } 

}


function nets_check(f1, f2, maxStr) {

  var tmpStr;
  var temp = 0;
  var onechar;
  var tcount;
  tcount = 0;
    
  tmpStr = new String(f1.value);
  temp = tmpStr.length;

  for (k=0;k<temp;k++) {
    onechar = tmpStr.charAt(k);
        
    if (escape(onechar).length > 4)  tcount += 2;
    else if (onechar != '\r')        tcount++;

  if (tcount > maxStr) {
        tmpStr = tmpStr.substring(0, k); 
        break;
    }
  }
    
  f1.value = tmpStr;
  cal_byte(tmpStr, f1, f2, maxStr);
 
  return tmpStr;

}



// 전자우편 체크

function emailcheck(str) {

  var i;
  var strEmail = str;
  var strCheck1 = false;
  var strCheck2 = false;
  var result = true;

  for (i=0; i < strEmail.length; i++) {
    if ((strEmail.substring(i,i+1) == "~") || (strEmail.substring(i,i+1) == ".") ||
        (strEmail.substring(i,i+1) == "_") || (strEmail.substring(i,i+1) == "-") ||
        ((strEmail.substring(i,i+1) >= "0") && (strEmail.substring(i,i+1) <= "9")) ||
        ((strEmail.substring(i,i+1) >= "@") && (strEmail.substring(i,i+1) <= "Z")) ||
        ((strEmail.substring(i,i+1) >= "a") && (strEmail.substring(i,i+1) <= "z"))) {
        if (strEmail.substring(i,i+1) == ".")  strCheck1 = true;
	    if (strEmail.substring(i,i+1) == "@")  strCheck2 = true;  
    }
    else {
        result = false;  
	    break;
    }
  }

  if ((strCheck1 == false) || (strCheck2 == false)) {
        result = false;  
  }

  return result;
}



// 3자리 단위로 콤마 삽입하기전 폼값 체크
// onblur="comma(폼이름.폼필드)" 식으로 input 형식에 삽입

function comma(f) {
 
  if (IsEmpty(f.value) == true)  return  false;
	 
  if (!checkDigit_comma(f.value) == true) { 
      alert("숫자만 입력해 주세요.");
	  f.value = '';
      f.focus();
      return false; 
  }

  var price, tmp;
  price = f.value;
  tmp = price.replace(/,/g, "");
	
  f.value = commaNum(tmp);  

}




//3자리 단위로 콤마 삽입하기

function commaNum(num) {  
  if (num < 0) { num *= -1; var minus = true} 
  else var minus = false 
         
  var dotPos = (num+"").split(".") 
  var dotU = dotPos[0] 
  var dotD = dotPos[1] 
  var commaFlag = dotU.length%3 

  if (commaFlag) { 
      var out = dotU.substring(0, commaFlag)  
      if (dotU.length > 3) out += "," 
  } 
  else var out = "" 

  for (var i=commaFlag; i < dotU.length; i+=3) { 
       out += dotU.substring(i, i+3)  
       if( i < dotU.length-3) out += "," 
  } 

  if (minus) out = "-" + out 
  if (dotD) return out + "." + dotD 
  else return out  
} 


// 자료가 숫자, 콤마 인지 체크

function checkDigit_comma(tocheck) {
  var isnum = true;
  if ((tocheck ==null) || (tocheck == "")) {
       isnum = false;
       return isnum; 
  }

  for (var j= 0 ; j< tocheck.length; j++ ) {
       if ( ( tocheck.substring(j,j+1) != "0" ) &&
            ( tocheck.substring(j,j+1) != "1" ) &&
            ( tocheck.substring(j,j+1) != "2" ) &&
            ( tocheck.substring(j,j+1) != "3" ) &&
            ( tocheck.substring(j,j+1) != "4" ) &&
            ( tocheck.substring(j,j+1) != "5" ) &&
            ( tocheck.substring(j,j+1) != "6" ) &&
            ( tocheck.substring(j,j+1) != "7" ) &&
            ( tocheck.substring(j,j+1) != "8" ) &&
            ( tocheck.substring(j,j+1) != "9" ) &&
            ( tocheck.substring(j,j+1) != "," ) ) {
            isnum = false; }  
   }
   return isnum; 
}



function myLogOut() {

  result = confirm('로그아웃 하시겠습니까?');

  if (result == true) {   
      new ajax.xhr.Request("/ajax_script/LogOut.asp", null, logOutResult, "POST");
  }

}


function logOutResult(req) {

  if (req.readyState == 4) {
	  if (req.status == 200) {

	  top.window.location.href='/manager';

     }
  }

}




function dirLogOut() {

  new ajax.xhr.Request("/ajax_script/LogOut.asp", null, dirlogOutResult, "POST");

}


function dirlogOutResult(req) {

  if (req.readyState == 4) {
	  if (req.status == 200) {

		  var docXML = req.responseXML;
		  var code = docXML.getElementsByTagName("code").item(0).firstChild.nodeValue;      // 에러코드        

          if (code == '90') {
              window.alert('로그아웃 성공.');
			  top.window.location.href='/';
          }
		  else {
             window.alert('로그아웃 실패.');
		  }

     }
  }

}




// 체크된 회원에게 메일 전송

function c_semail () {

  var cnum = 0;
  cnum = ch_count();

  if (cnum < 1) {
      window.alert("메일전송할 회원을 한명 이상 선택해주세요.");
      return false; 
  }
  
  show_wait_showb();
  //document.bform2.s_gubun.value = 'B';
  document.bform2.action = "mail_send.asp";
  //document.bform2.target = "_self";
  document.bform2.submit();

}


// 체크된 메일링 메일 전송

function c_mailing () {

  var cnum = 0;
  cnum = ch_count();

  if (cnum < 1) {
      window.alert("메일전송할 회원을 한명 이상 선택해 주세요.");
      return false; 
  }
  
  show_wait_show();
  document.bform2.s_gubun.value = 'D';
  document.bform2.action = "mail_send.asp";
  document.bform2.target = "_self";
  document.bform2.submit();

}




// 검색된 회원에게 메일 전송

function s_semail() {
 
  show_wait_show();
  document.bform2.s_gubun.value = 'C';
  document.bform2.action = "mail_send.asp";
  document.bform2.target = "_self";
  document.bform2.submit();

}


// 검색된 메일링 메일 전송

function s_mailing() {
 
  show_wait_show();
  document.bform2.s_gubun.value = 'E';
  document.bform2.action = "mail_send.asp";
  document.bform2.target = "_self";
  document.bform2.submit();

}


// 확장자 체크

function chkExpansin(str) {
  var chk = str.indexOf(".");
  if (chk > -1) return true;              
  else  return false; 
}




// htmlarea 사용하는 폼에서 업로드된 이미지를 텍스트박스에 담아서 액션 페이지로 전송한다.

function get_image (objname) {

  var myimage = document.getElementById("id"+objname).contentWindow.document.images;

  for (i=0; i < myimage.length; i++) {

	var input = document.createElement('input');
	input.type = "hidden";
	input.name = "myimges";
	input.value = myimage[i].src;

	document.bform1.appendChild(input);

  } 

}




// 사용자 페이지 로그인 처리

function user_login () {
  
  if (IsEmpty(document.logForm.cid.value) == true) {
      alert("아이디를 입력해 주세요.");
      document.logForm.cid.focus();
      return false;  
  }

  if (IsEmpty(document.logForm.pwd.value) == true) {
      alert("비밀번호를 입력해 주세요.");
      document.logForm.pwd.focus();
      return false;  
  }

  document.getElementById('userLoginOrg').style.display='none';
  document.getElementById('userLoginmsg').style.display='block';

  var params  = "cid=" + escape_plus(document.logForm.cid.value) + "&pwd=" + escape_plus(document.logForm.pwd.value)
  params += "&returnUrl=" + document.logForm.returnUrl.value;
  
  new ajax.xhr.Request("/ajaxScript/loginProcess.asp", params, myloginResult, "POST");

  return false; 

}




function myloginResult(req) {

  if (req.readyState == 4) {
	  if (req.status == 200) {
			
		  var docXML = req.responseXML;

  	      var code = docXML.getElementsByTagName("code").item(0).firstChild.nodeValue;   // 에러코드
  	      var msg = docXML.getElementsByTagName("msg").item(0).firstChild.nodeValue;     // 에러상태
		  
          if (code != '90') {

			  document.getElementById('userLoginOrg').style.display='block';
			  document.getElementById('userLoginmsg').style.display='none';
              document.logForm.pwd.value= '';
			  window.alert(msg);
		  }
		  else {

			  var returnUrl = docXML.getElementsByTagName("returnUrl").item(0).firstChild.nodeValue;
			  window.location.href = returnUrl; 
			  
          }

     }

  }  

}





// 날짜 채우기

function sel_day(diff) {

  if (diff == '3')      bform1.csday.value =  vform.daypriv3.value;
  else if (diff == '5') bform1.csday.value =  vform.daypriv5.value;
  else                  bform1.csday.value =  vform.daypriv0.value;

}



function check_tag() {

  var cnt = 0;
  var frm = document.bform1;
  for (var i = 0; i < frm.elements.length; i++) {
    if (frm.elements[i].name == "chkDisplayMode" && frm.elements[i].type == "checkbox") {
        if (frm.elements[i].checked == true) cnt = cnt + 1;
    }
  }

  return cnt

}





// 로그인 페이지 이동 체크

function confirm_login () {
  
  if (confirm("로그인후 이용 하실 수 있습니다.\n확인을 클릭시 로그인 페이지로 이동 합니다.") == true) {
	  comForm.action = "/member/login.asp";
	  comForm.submit();
  }

}



// life menu open

function life_navi_open () {
  
  document.getElementById('life_navi').style.display='inline';
  return;

}



// life menu close

function life_navi_close () {
  
  document.getElementById('life_navi').style.display='none';
  return;

}



function sel_map_gugun (gu, sido, gugun) {

  alert(gu + '  |  ' + sido + '  |  ' + gugun);

}


function sel_tube (gu, cd) {

  alert(gu + '  |  ' + cd);

}



// 브라우저 판정

function chkBrowser () { 

  var ua = navigator.userAgent;
  var isbrowser = new Array(9);


  for (i=0; i < 9; i++)  isbrowser[i] = false;

  if (document.all)                  isbrowser[0] = true;
  if (ua.indexOf("Netscape") != -1)  isbrowser[1] = true;
  if (ua.indexOf("Safari") != -1)    isbrowser[2] = true;
  if (ua.indexOf("Firefox") != -1)   isbrowser[3] = true;
  if (ua.indexOf("Konqueror") != -1) isbrowser[4] = true;
  if (ua.indexOf("Galeon") != -1)    isbrowser[5] = true;
  if (ua.indexOf("K-Meleon") != -1)  isbrowser[6] = true;
  if (ua.indexOf("Sylera") != -1)    isbrowser[7] = true;
  if (window.opera != undefined)     isbrowser[8] = true;
	

  if (isbrowser[0] == true) isbrowser[9] = new RegExp('MSIE ([0-9.]+)','gi').exec(ua)[1];
  else isbrowser[9] = "1";

  return isbrowser;

}




//------ 팝업창 DIV ------//

/*** 팝업 레이어 팝업창 띄우기 ***/

function calLayer_show_popup (url, width, height,no,left,top) {
	
   var screenWidth  = screen.availwidth;
   var screenHeight = screen.availheight;
	
	if(left != "" && top != ""){
		var po_lef = parseInt(left);
		var po_top = parseInt(top);
	}
	else{
   var po_lef = (screenWidth - width) / 2;
   var po_top  = (screenHeight - height) / 2
	}


	w = parseInt(width);
	h = parseInt(height);

	var pixelBorder = 3;
	var titleHeight = 25;
	//w += pixelBorder * 2;
	h += pixelBorder * 2 + titleHeight;
	
	calhiddenselect('hidden');

	

	// 내용프레임
	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		left = parseInt(po_lef);
		top = parseInt(po_top);
		width = w;
		height = h - 7;
		backgroundColor = "#FFFFFF";
		border = "3px solid #DDDDDD";
		zIndex = "100";
	}
	obj.id = "popup_"+no;
	document.body.appendChild(obj);

	
	// 아이프레임
	var ifrm = document.createElement("iframe");
	with (ifrm.style){
		width = w+ "px";
		height = h - pixelBorder * 2 + "px";		
	}
	ifrm.frameBorder = 0;
	ifrm.marginwidth = 0;
	ifrm.marginheight = 0;
	ifrm.scrolling = "no";
	ifrm.src = url;   // 아이프레임 경로
	obj.appendChild(ifrm);


	x = (document.layers) ? loc.pageX : po_lef;
	y = (document.layers) ? loc.pageY : po_top;
	
	if (document.all) {
      document.getElementById("popup_"+no).style.pixelLeft = x;
      document.getElementById("popup_"+no).style.pixelTop = y;
  }
  else {
      document.getElementById("popup_"+no).style.left = x + "px";
      document.getElementById("popup_"+no).style.top =  y + "px";
			document.getElementById("popup_"+no).style.width = w + "px";
			document.getElementById("popup_"+no).style.height = h - 7 + "px";
  }
}



function calhiddenselect(mode) {
	var obj = document.getElementsByTagName('select');
	for (i=0;i<obj.length;i++){
		obj[i].style.visibility = mode;
	}
}

function calcloselayer_layer(no) {

	calhiddenselect('visible');

  var isb = chkBrowser();
	
	if (isb[0] == true) {
     parent.document.getElementById('popup_'+no).removeNode(true);
  }
  else {
     var obj1 = parent.document.getElementById('popup_'+no); 
	 obj1.parentNode.removeChild(obj1);
  }

}


function setPNG24(obj) { 
    obj.width=obj.height=1; 
    obj.className=obj.className.replace(/\bPNG24\b/i,''); 
    obj.style.filter = 
    "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
    obj.src=''; 
    return ''; 
} 



// html generate 함수
function navi(param) {
	if(!param) return;
	arrParam = param.split("|");
	var str  = "<div class=\"tar ff1 fc9\">";
	str += " <img src='/kr/images/common/icon_home.gif' /> <img src='/kr/images/common/icn_navi.gif' /> "
	for(var i=0;i<arrParam.length;i++) {
		if(i<arrParam.length-1) {
			str += getMnuNM(arrParam[i])+" <img src='/kr/images/common/icn_navi.gif' /> ";
		} else {
			str += "<span class=\"sel_title_navi\"'>"+getMnuNM(arrParam[i])+"</span>";
		}
	}
	str += "</div>";
	document.write(str);
}

// 이미지효과주기

function imgChang(Image) {
	var Preview = document.getElementById("ch_img");
		Preview.filters.blendTrans.apply();
		Preview.src = Image;
		Preview.filters.blendTrans.play();

}




//Top 메뉴
//arrMnu.push({ key: "home", txt: "메인", url: "/kr/index.asp" });
//arrMnu.push({ key:"introduction",	txt:"한불소개",	url:"#"});
//arrMnu.push({ key: "introduction1", txt: "한불소개", url: "#" });
