
/*--------------------------------------------------------------------------*
 * 소스설명 : 공통으로 사용 하는 자바스크립트 함수 모음
 * 작성자 : 안병권
 * 작성일 : 2006.10.30 (월) 
 * 개정자 : 박성주
 * 개정일 : 2007.09.15 (토)
 *---------------------------------------------------------------------------*/

function nocontextmenu() // IE에서만 적용, 다른 브라우저는 무시
{
   event.cancelBubble = true;
   event.returnValue = false;

   return false;
}

function nodrag(){
 
 event.cancelBubble = true;
 event.returnValue = false;
 return false;
}

//document.oncontextmenu = nocontextmenu;    
//document.onselectstart=nodrag;
//document.ondragstart=nodrag; 

/*--------------------------------------------------------------------------*
 *
 * 문자열 함수 모음
 *
 *---------------------------------------------------------------------------*/

  var NUM = "0123456789";
  var SALPHA = "abcdefghijklmnopqrstuvwxyz";
  var ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"+SALPHA;
  var ERRORMSG = ""; 

/*--------------------------------------------------------------------------*
 * string trim(str)
 * 왼쪽과 오른쪽 공백을 제거한 문자열 리턴
 *--------------------------------------------------------------------------*/
 function trim(str) {
  
	var str = str.replace(/^\s*/,'').replace(/\s*$/, ''); 
	return str;
 } 

 /*--------------------------------------------------------------------------*
  * int strLen(str)
  * 문자열의 길이를 리턴 (한글을 2자리로 계산)
  *--------------------------------------------------------------------------*/
  function strLen (s) {

	  var i;
      var len = 0;

	  for ( i=0 ; i<s.length; i++) {
		  if ( s.charCodeAt(i) > 255 ) {
			  len += 2;
       	  } else {
			  len ++;
		  }
	  }
      return len;
  }

 /*--------------------------------------------------------------------------*
  * 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; 
  }

 /*--------------------------------------------------------------------------*
  * 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;
  }

 /*--------------------------------------------------------------------------*
  * boolean IsAlpha(str)
  * 문자열이 알파벳으로만 이루어져 있으면 True, 아니면 False
  *--------------------------------------------------------------------------*/
  function IsAlpha(str) {
    return IsOnlySpcialString(str, ALPHA);
  }

 /*--------------------------------------------------------------------------*
  * boolean IsNumber(str)
  * 문자열이 숫자로만 이루어져 있으면 True, 아니면 False
  *--------------------------------------------------------------------------*/
  function IsNumber(str) {
    return IsOnlySpcialString(str, NUM);
  }

 /*--------------------------------------------------------------------------*
  * boolean IsNumberDot(str)
  * 문자열이 숫자로만 이루어져 있으면 True, 아니면 False
  *--------------------------------------------------------------------------*/
  function IsNumberDot(str) {
    return IsOnlySpcialString(str, NUM+".");
  }

 /*--------------------------------------------------------------------------*
  * boolean IsAlphaNumber(str)
  * 문자열이 알파벳과 숫자으로만 이루어져 있으면 True, 아니면 False
  *--------------------------------------------------------------------------*/
  function IsAlphaNumber(str) {
    return IsOnlySpcialString(str, ALPHA+NUM);
  }

 /*--------------------------------------------------------------------------*
  * string strReverse(str)
  * 문자열을 뒤집는다.
  *--------------------------------------------------------------------------*/
  function strReverse(str) {

	  var temp="";

	  for(i=str.length-1;i>=0;i--) {
		  temp += str.charAt(i);
	  }
	  return temp;
  }

 /*--------------------------------------------------------------------------*
  * string strFormat(str, ch, pos, rev)
  * 문자열에 pos 자릿수마다 ch 문자를 덧붙인다.
  * rev 가 1 이면 뒤에서 부터 ch 문자를 덧붙인다.
  *--------------------------------------------------------------------------*/
  function strFormat(str, ch, pos, rev) {

	  var len = str.length;
	  var result = "";

	  if(rev == 1) str = strReverse(str);

	  for(i=0;i<len;i=i+pos) {
		  if(i+pos < len) {
			  result += str.substring(i, i+pos) + ch;
		  } else {
			  result += str.substring(i, len);
		  }
	  }

	  if(rev == 1) result = strReverse(result);

	  return result;
  }

 /*--------------------------------------------------------------------------*
  * string makeMoney(str)
  * 숫자를 3자리마다 콤마가 찍힌 화폐형식으로 변환
  *--------------------------------------------------------------------------*/
  function makeMoney(str) {
	  var result = strFormat(str, ",", 3, 1);
	  return result;
  }


 /*--------------------------------------------------------------------------*
  * string checkDigit(tocheck)
  * 자료가 숫자인지 체크
  *--------------------------------------------------------------------------*/
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; 
}




/*--------------------------------------------------------------------------*
 *
 * 폼처리 함수
 *
 *---------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------*
 * 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;
 }

 /*--------------------------------------------------------------------------*
 * int is_selected()
 * 선택상자에서 선택된것이 하나라도 있으면 true 를 리턴
 *--------------------------------------------------------------------------*/
 function is_selected(field) {

	var obj = eval(field);

	for (var i=0;i<obj.length;i++) {
		if ( obj[i].selected == true) {
			return true;
		}
	}
	return false;
 }

 /*--------------------------------------------------------------------------*
  * void all_textForm_trim(form)
  * 왼쪽과 오른쪽 공백을 제거한 문자열 리턴
  *--------------------------------------------------------------------------*/
  function all_textForm_trim(form) {

	for (var i = 0; i < form.elements.length; i++) {
		if (form.elements[i].type == "text") {
			form.elements[i].value = trim(form.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 date_range_select (form, syear, smonth, sday, eyear, emonth, eday)
  * 날짜 셀렉트박스를 원하는 값으로 선택하도록 한다.
  *--------------------------------------------------------------------------*/
  function date_range_select(form, syear, smonth, sday, eyear, emonth, eday) {

	  setSelect(form.syear, syear);
	  setSelect(form.smonth, smonth);
	  setSelect(form.sday, sday);

	  setSelect(form.eyear, eyear);
	  setSelect(form.emonth, emonth);
	  setSelect(form.eday, eday);
 }


 /*--------------------------------------------------------------------------*
  * void getSelectValue (obj)
  * 셀렉트폼의 선택상태를 해제한다.
  *--------------------------------------------------------------------------*/
  function getSelectedOption (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;        	    	
  }

 /*--------------------------------------------------------------------------*
  * 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;
  }





// 사업자번호 체크 형식

function cnum_check(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 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) {

	  var w = screen.availwidth;
	  var h = screen.availheight;

	  window.open(url, wname, 'scrollbars=yes,toolbar=yes,location=yes,resizable=yes,status=yes,menubar=yes,resizable=yes,fullscreen=no,width='+w+',height='+h);
  }

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 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; 
      }
  }


/*--------------------------------------------------------------------------*
 *
 * 쿠키 처리 함수
 *
 *---------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*
  * void setCookie(name, value, expiredays)
  * 쿠키 생성
  *--------------------------------------------------------------------------*/
  function setCookie(name, value, expiredays) {
	  
	  var todayDate = new Date();

	  todayDate.setDate(todayDate.getDate() + expiredays);   
	  document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
  }

 /*--------------------------------------------------------------------------*
  * string getCookie(name)
  * 쿠키 리턴
  *--------------------------------------------------------------------------*/
  function getCookie(name) {

	  var nameOfCookie = name + "=";
	  var x = 0;
	  
	  while(x <= document.cookie.length) {
		  var y = (x + nameOfCookie.length);
		  
		  if(document.cookie.substring(x,y) == nameOfCookie) {
			  if((endOfCookie = document.cookie.indexOf(";",y)) == -1) endOfCookie = document.cookie.length;
			  return unescape(document.cookie.substring(y,endOfCookie));
		  }
		  x = document.cookie.indexOf(" ",x) + 1;
		  
		  if(x == 0) break;
	  }
	  return "";
  }


/*--------------------------------------------------------------------------*
 *
 * 날짜 처리 함수
 *
 *---------------------------------------------------------------------------*/
 /*--------------------------------------------------------------------------*
  * 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=8,0,0,0 id="'+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" menu="false" width="'+w+'"  height="'+h+'" swliveconnect="true" id="'+id+'" name="param" 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 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;
}

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 fillaccount(f1, f2) {

  if (f1.value != '') {
      f2.value = f1.value;  
  }

}

function openCal(e, obj) {

  var isb = chkBrowser();

  var top = isb[0] ? event.clientY - 120 : e.clientY - 120;
  var left = isb[0] ? event.clientX - 120 : e.clientX - 120;

  calLayer_show('/myclass/mycalendar.php?obj='+obj,top,left);
  
}


// 배열 생성자

function makeArray(n) {
  
  this.length = n;
  for (var i=1; i <= n; i++) this[i] = "";
  return this;

}

// 브라우저 판정

function chkBrowser () { 

  var ua = navigator.userAgent;
  var isbrowser = new makeArray(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;

}

/*** 달력 레이어 팝업창 띄우기 ***/

function calLayer_show(url, po_top, po_lef) {
	
	w = 210;
	h = 160;

	var pixelBorder = 3;
	var titleHeight = 25;
	w += pixelBorder * 2;
	h += pixelBorder * 2 + titleHeight;

	var bodyW = document.body.clientWidth;
	var bodyH = document.body.clientHeight;

	var posX = (bodyW - w) / 2;
	var posY = (bodyH - h) / 2;

	calhiddenselect('hidden');

	// 백그라운드 
	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		left = 0;
		top = 0;
		width = "100%";
		height = document.body.scrollHeight;
		//backgroundColor = "#000000";
		filter = "Alpha(Opacity=50)";
	}
	obj.id = "objPopupLayerBg";
	document.body.appendChild(obj);

	// 내용프레임
	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		left = po_lef;
		top = po_top;
		width = w;
		height = h;
		border = "3px solid #5BB9CE";
	}
	obj.id = "objPopupLayer";
	document.body.appendChild(obj);

	// close 바 레이어 
	var bottom = document.createElement("div");
	
	with (bottom.style){
		position = "absolute";
		width = w - pixelBorder * 2;
		height = titleHeight + 3;		
		left = 0;
		top = h - titleHeight - pixelBorder * 3;	
		padding = "7px 0 0 0";
		textAlign = "right";
		backgroundColor = "#EBEBEB";
		font = "bold 12px 돋움";
	}
	
	bottom.innerHTML = "<a href='javascript:calcloselayer()'><font color='#000000'>close</font></a>";
	obj.appendChild(bottom);

	// 아이프레임
	var ifrm = document.createElement("iframe");
	with (ifrm.style){
		width = w - 6;
		height = h - pixelBorder * 2 - titleHeight - 3;		
	}
	ifrm.frameBorder = 0;
	ifrm.marginwidth = 0;
	ifrm.marginheight = 0;
	ifrm.scrolling="no";
	ifrm.src = url;   // 아이프레임 경로
	obj.appendChild(ifrm);
}


function calcloselayer() {
  calhiddenselect('visible');

  var isb = chkBrowser();

  if (isb[0] == true) {
     document.getElementById('objPopupLayer').removeNode(true);
     document.getElementById('objPopupLayerBg').removeNode(true);
  }
  else {
     var obj1 = document.getElementById('objPopupLayer'); 
     var obj2 = document.getElementById('objPopupLayerBg'); 

	 obj1.parentNode.removeChild(obj1);
	 obj2.parentNode.removeChild(obj2);
  }

}


function calhiddenselect(mode) {
	var obj = document.getElementsByTagName('select');
	for (i=0;i<obj.length;i++){
		obj[i].style.visibility = mode;
	}
}





/*** 팝업 레이어 팝업창 띄우기 ***/

function calLayer_show_popup(url, po_top, po_lef,no,width,height) {
	
	w = parseInt(width);
	h = parseInt(height);

	var pixelBorder = 3;
	var titleHeight = 25;
	w += pixelBorder * 2;
	h += pixelBorder * 2 + titleHeight;

	var bodyW = document.body.clientWidth;
	var bodyH = document.body.clientHeight;

	var posX = (bodyW - w) / 2;
	var posY = (bodyH - h) / 2;

	calhiddenselect('hidden');

	// 백그라운드 
	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		left = 0;
		top = 0;
		width = "100%";
		height = document.body.scrollHeight;
		//backgroundColor = "#000000";
		filter = "Alpha(Opacity=50)";
	}
	obj.id = "objPopupLayerBg";
	document.body.appendChild(obj);

	// 내용프레임
	var obj = document.createElement("div");
	with (obj.style){
		position = "absolute";
		left = po_lef;
		top = po_top;
		width = w;
		height = h;
		backgroundColor = "#dddddd";
		border = "3px solid #DDDDDD";
	}
	obj.id = "objPopupLayer";
	document.body.appendChild(obj);

	// close 바 레이어 

	var bottom = document.createElement("div");
	
	with (bottom.style){
		position = "absolute";
		width = w - pixelBorder * 2;
		height = titleHeight + 3;		
		left = 0;
		top = h - titleHeight - pixelBorder * 3;	
		padding = "0 0 0 0";
		textAlign = "left";
		backgroundColor = "#EBEBEB";
		font = "bold 12px 돋움";
	}
	
	bottom.innerHTML = "<body style='margin-left:0px;margin-right:0px;margin-top:0px;margin-bottom:0px;'><table border='0' width=100%'><tr><td align='left' valign='top' class='common'><div id='today'><input type='checkbox' name='view_check' value='1' onClick='setclose("+no+");'> 오늘하루 팝업창 열지 않기 </div></td><td align='right'><a href='javascript:calcloselayer()'><font color='#000000'>close</font></a></td></tr></table></body>";
	obj.appendChild(bottom);

	// 아이프레임
	var ifrm = document.createElement("iframe");
	with (ifrm.style){
		width = w - 6;
		height = h - pixelBorder * 2 - titleHeight - 3;		
	}
	ifrm.frameBorder = 0;
	ifrm.marginwidth = 0;
	ifrm.marginheight = 0;
	ifrm.scrolling="no";
	ifrm.src = url;   // 아이프레임 경로
	obj.appendChild(ifrm);
}

function setclose(no) {
	co_no="popup_"+no
	setCookie_po(co_no, 'N', 1);
	calcloselayer();  
}

// 글자 수 세기
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;

}

