
/*--------------------------------------------------------------------------*
 *
 * 문자열 함수 모음
 *
 *---------------------------------------------------------------------------*/

  var NUM = "0123456789";
  var SALPHA = "abcdefghijklmnopqrstuvwxyz";
  var ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"+SALPHA;
  var ERRORMSG = ""; 






 /*--------------------------------------------------------------------------*
  * 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; 
  }

 /*--------------------------------------------------------------------------*
  * 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;
		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.bform1;

  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;
  }

 /*--------------------------------------------------------------------------*
  * void nextForm_Focus(f1, f2, len)
  * f1 폼필드값이 len의 길이만큼 채워지면 f2 폼필드를 focus가 이동한다.
  *--------------------------------------------------------------------------*/
  function nextForm_Focus (f1, f2, len) {
	
	if (f1.value.length == len)  f2.focus();

  }

 /*--------------------------------------------------------------------------*
  * int CheckRID (sRIDFirst, sRIDLast)
  * 주민등록번호가 유효한 형식이면 0, 앞자리가 잘못됐으면 -1, 뒷자리가 -2
  *--------------------------------------------------------------------------*/
  function CheckRID (sRIDFirst, sRIDLast) {

	  var i;
	  var chk = 0;
	  var nYear = sRIDFirst.substring(0,2);
	  var nMondth = sRIDFirst.substring(2,4);
	  var nDay = sRIDFirst.substring(4,6);
	  var nSex = sRIDLast.charAt(0);

	  if (!IsNumber(sRIDFirst, NUM)) {
		  ERRORMSG = "주민등록번호 앞자리에 잘못된 문자가 있습니다.";
		  return -1;
	  }
	  
	  if ( sRIDFirst.length!=6 ||  nMondth<1 || nMondth>12 || nDay<1 || nDay>31) {
		  ERRORMSG = "주민등록번호 앞자리가 유효한 형식이 아닙니다.";
		  return -1;
	  }
	  
	  if (!IsNumber(sRIDLast, NUM)) {
		  ERRORMSG = "주민등록번호 뒷자리에 잘못된 문자가 있습니다.";
		  return -2;
	  }
	
      if ( sRIDLast.length!=7 || (nSex!=1 && nSex!=2 && nSex!=3 && nSex!=4) ) {
		  ERRORMSG = "주민등록번호 뒷자리가 유효한 형식이 아닙니다.";
		  return -2;
	  }
	
      for (i=0; i<6; i++) {
		  chk += ( (i+2) * parseInt( sRIDFirst.charAt(i) ));
      }
	
      for (i=6; i<12; i++) {
		  chk += ( (i%8+2) * parseInt( sRIDLast.charAt(i-6) ));
      }
	
      chk = 11 - (chk%11);
      chk %= 10;
	
      if (chk != parseInt( sRIDLast.charAt(6))) {
		  ERRORMSG = "유효하지 않은 주민등록번호입니다.";
          return -1;
      }
	  return 0;        	    	
  }

/*--------------------------------------------------------------------------*
 * 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(tmp_a, tmp_b) {

  var screenWidth  = screen.availwidth;
  var screenHeight = screen.availheight;

  var intLeft = (screenWidth - 370) / 2;
  var intTop  = (screenHeight - 302) / 2

  window.open('/post_list.asp?tmp_a='+tmp_a+'&tmp_b='+tmp_b, 'post_list', ('scrollbars=no,resizable=no,top='+intTop+',left='+intLeft+',width=370,height=302'));

} 



// 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 frameResize(obj) {
  
  try {
    
	 parent.document.getElementById(frames.name).style.height = this.document.body.scrollHeight;
    window.scrollTo(0,0);
  }
  catch (e) {}

}



function show_Iframe (posid, myid, width, src) {

  var str = "";

  str += "<iframe id=\"" + myid + "\" name=\"" + myid + "\" frameborder=\"0\" width=\"" + width + "\" height=\"0\" hspace=\"0\" vspace=\"0\" "
  str += "marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" onload=\"resizeIframe(this, " + myid + ")\" src=\"" + src + "\" allowTransparency='true'></iframe>\n"


  document.getElementById(posid).innerHTML = str;

}



function toggle_Iframe (posid, myid, gu, src) {


    if (document.getElementById(myid) && toggleForm.gu.value == gu) {

        document.getElementById(posid).innerHTML = '';
	
	}
	else {

		 var str = "";

	    str += "<iframe id=\"" + myid + "\" name=\"" + myid + "\" frameborder=\"0\" width=\"570\" height=\"0\" hspace=\"0\" vspace=\"0\" "
	    str += "marginheight=\"0\" marginwidth=\"0\" scrolling=\"no\" onload=\"resizeIframe(this, " + myid + ")\" src=\"" + src + "\"></iframe>\n"

	    document.getElementById(posid).innerHTML = str;

    }

	toggleForm.gu.value = gu;

}



function resizeIframe(ifrm, myid) {
  obj = eval(myid);
  ifrm.setExpression('height', obj.document.body.scrollHeight+70);
  //ifrm.setExpression('width',myid.document.body.scrollWidth);

  //ifrm.setExpression('height',myid.document.body.scrollHeight + (myid.document.body.offsetHeight - myid.document.body.clientHeight));

}



function init_iframe(height) {
  reSize(height);
  setTimeout('init_iframe('+height+')', 200)
}


function reSize(height) {
  try {
    var objBody = ifrm.document.body;
    var objFrame = document.all["ifrm"];
    ifrmHeight = objBody.scrollHeight + (objBody.offsetHeight - objBody.clientHeight);

    if (ifrmHeight > height)  ifrmHeight = height;
		
    if (ifrmHeight > 0)  objFrame.style.height = ifrmHeight
    else  objFrame.style.height = 0;
    objFrame.style.width = '100%';
  }
  catch(e) {}
}






/*--------------------------------------------------------------------------*
 *
 * 날짜 처리 함수
 *
 *---------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*
  * 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 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+'" name="'+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 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+'" name="'+id+'" width="'+w+'" align="center" height="'+h+'">\r\n';  
  html += '<param name="allowScriptAccess" value="alway">\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="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 <= 6; 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='/kor/default.asp';
          }
		  else {
             window.alert('로그아웃 실패.');
		  }

     }
  }

}




// 체크된 회원에게 메일 전송

function c_semail () {

  var cnum = 0;
  cnum = ch_count();

  if (cnum < 1) {
      window.alert("메일전송할 회원을 한명 이상 선택해 주세요.");
      return false; 
  }
  
  show_wait_show();
  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; 
}



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 ''; 
} 




// 브라우저 판정

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 abc(){
alert("연결이대??????");
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}