// Àü¸Þ´º °øÅëÀûÀÎ ½ºÅ©¸³Æ®
// ·¹ÀÌ¾î °ü·Ã ½ºÅ©¸³Æ®
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();
}
MM_reloadPage(true);

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_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; 
	if(v == 'visible') obj.display='block';
	else obj.display='none';
  }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var MM_SlideLayer;
var MM_SlideLayerWidth;
var MM_SlideLayerHieght;
var MM_SlideLayerDistance;
function MM_showHideSlideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideSlideLayers.arguments;
  MM_SlideLayerWidth = args[0];
  MM_SlideLayerHieght = args[1];
  MM_SlideLayerDistance = args[2];
  for (i=3; i<(args.length-2); i+=3) {
  	if ((obj=MM_findObj(args[i]))!=null) { 
  		v = args[i+2];
    	if (obj.style) { 
    		obj = obj.style; 
    		if(v == 'show') {
    			obj.height=0;
    			obj.overflow = 'hidden';
	  			obj.visibility='visible';	
				obj.display='block';
	  			MM_SlideLayer = MM_findObj(args[i]);
    			MM_showHideSlideInterval();
    		} else {
    			obj.visibility='hidden';
				obj.display='none';
    		}
    	}
    }
  }  
}

function MM_showHideSlideInterval() {
	var obj = MM_SlideLayer.style;
	var ih = parseInt(obj.height);
	if(ih < MM_SlideLayerHieght) {
		ih = ih + MM_SlideLayerDistance;
		obj.height = ih;
	  setTimeout("MM_showHideSlideInterval()",1);
	}
}

/*
 * IEÀÇ »õ·Î¿î ActiveXÁ¤Ã¥¿¡ ÀÇÇØ Object´Â document.write½ºÅ©¸³Æ®¸¦ È°¿ëÇÏ¿©¾ß ÇÑ´Ù.
 * ÀÛ¼ºÀÚ : 2006.04.18 ÇöÁØ¾Æºü
 * 
 * String src : ÇÃ·¡½¬ ÁÖ¼Ò [ÇÊ¼ö]
 * int w : ÇÃ·¡½¬ Æø [ÇÊ¼ö]
 * int h : ÇÃ·¡½¬ ³ôÀÌ [ÇÊ¼ö]
 * wmode : [¼±ÅÃ]
 * menu : [¼±ÅÃ]
 */
function writeFlash(src,width,height,wmode,menu) {
	html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	html = html + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ width + '" height="' + height + '">';
	html = html + '<param name="movie" value="' + src + '">';
	if(wmode != null) {	html = html + '<param name="wmode" value="' + wmode + '">';	}
	if(menu != null) {	html = html + '<param name="menu" value="' + menu+ '">';	}
	html = html + '<param name="quality" value="high">';
	html = html + '<embed src="' + src + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>';
	html = html + '</object>';

	document.write(html);		
}

/*
 * IEÀÇ »õ·Î¿î ActiveXÁ¤Ã¥¿¡ ÀÇÇØ Object´Â document.write½ºÅ©¸³Æ®¸¦ È°¿ëÇÏ¿©¾ß ÇÑ´Ù.
 * ÀÛ¼ºÀÚ : 2006.04.18 ÇöÁØ¾Æºü
 * 
 * String classid : ÅÂ±×ÇÁ¸® ID [ÇÊ¼ö]
 * String version : ÅÂ±×ÇÁ¸® ¹öÀü[ÇÊ¼ö]
 */
function writeTagfree(classid, version) {
	html = '<object classid="' + classid + '" id="twe"  ';
	html = html + ' width="100%" height="100%" ';
	html = html + 'codebase="/assist/tagfree/tweditor.cab#version=' + version + '" >';
	html = html + '<param name="InitFile" value="/assist/tagfree/env.xml">';
	html = html + '<param name="ApplyInitData" value="1"><param name="Mode" value="0">';
	html = html + '</object>';

	document.write(html);		
}

/*
 * IEÀÇ »õ·Î¿î ActiveXÁ¤Ã¥¿¡ ÀÇÇØ Object´Â document.write½ºÅ©¸³Æ®¸¦ È°¿ëÇÏ¿©¾ß ÇÑ´Ù.
 * ÀÛ¼ºÀÚ : 2006.04.18 ÇöÁØ¾Æºü
 * 
 * String html : ¼Ò½º
 */
function writeObject(html) {
	document.write(html);		
}


/*
 * »õ·Î¿î ÆË¾÷Ã¢À» ¶ç¿ó´Ï´Ù.
 * String url : ÆË¾÷¹®¼­ÀÇ °æ·Î [ÇÊ¼ö]
 * String name : ÆË¾÷Ã¢ÀÇ ÀÌ¸§ [default:"nWin"]
 * int w : ÆË¾÷Ã¢ÀÇ Æø [default:300]
 * int h : ÆË¾÷Ã¢ÀÇ ³ôÀÌ [default:300]
 * int x : ÆË¾÷Ã¢ÀÇ ÁÂÃø »ó´ÜÀÇ xÁÂÇ¥ [default:10]
 * int y : ÆË¾÷Ã¢ÀÇ ÁÂÃø »ó´ÜÀÇ yÁÂÇ¥ [default:10]
 * String s : ÆË¾÷Ã¢¿¡ ½ºÅ¬·Î¹Ù Ç¥½Ã¿©ºÎ('no' : Ç¥½Ã¾ÈÇÔ, 'yes' : Ç¥½ÃÇÔ, [default:"no"])
 */
function popup(url, name, w, h, x, y, s) {
	if(url == null) return;
	_name = arguments[1] != null ? arguments[1] : "nWin";
	_w = arguments[2] != null ? arguments[2] : "300";
	_h = arguments[3] != null ? arguments[3] : "300";
	_x = arguments[4] != null ? arguments[4] : "10";
	_y = arguments[5] != null ? arguments[5] : "10";
	_s = arguments[6] != "yes" ? "no" : "yes";
	var opt = ',menubar=0,status=0,resizable=0,directories=0,toolbar=0,location=0,';
	p_win = window.open(url, _name, 'width=' + _w + ',height=' + _h + ',left=' + _x + ',top=' + _y + ',scrollbars=' + _s + opt);
	p_win.focus();
	this.name = 'cnedu';
	return p_win;
}

/*
 * È­¸éÀÇ Áß¾Ó¿¡ ÆË¾÷Ã¢À» ¶ç¿ó´Ï´Ù.
 *
 * String url : ÆË¾÷¹®¼­ÀÇ °æ·Î [ÇÊ¼ö]
 * String name : ÆË¾÷Ã¢ÀÇ ÀÌ¸§ [default:"nWin"]
 * int w : ÆË¾÷Ã¢ÀÇ Æø [default:300]
 * int h : ÆË¾÷Ã¢ÀÇ ³ôÀÌ [default:300]
 * String s : ÆË¾÷Ã¢¿¡ ½ºÅ¬·Î¹Ù Ç¥½Ã¿©ºÎ('no' : Ç¥½Ã¾ÈÇÔ, 'yes' : Ç¥½ÃÇÔ, [default:"no"])
 */
function popupCenter(url, name, w, h, s) {
	if(url == null) return;
	_name = arguments[1] != null ? arguments[1] : "nWin";
	_w = arguments[2] != null ? arguments[2] : "300";
	_h = arguments[3] != null ? arguments[3] : "300";
	_x = (screen.width / 2) - (_w / 2);
	_y = (screen.height / 2) - (_h / 2);
	_s = arguments[4] == "yes" ? "yes" : "no";
	var opt = ',menubar=no,status=no,resizable=no,directories=0,toolbar=0,location=0,';
	p_win = window.open(url, _name,
			'width=' + _w + ',height=' + _h + ',left=' + _x + ',top=' + _y + ',scrollbars=' + _s + opt);
	p_win.focus();
	this.name = 'cnedu';
	return p_win;
}

/*
 * »õ·Î¿î À©µµ¿ì¸¦ ¶ç¿ó´Ï´Ù.
 */
function openWin(url, name) {
	if(url == null) return;
	_name = arguments[1] != null ? arguments[1] : "nWin";
	p_win = window.open(url, _name);
	p_win.focus();
	this.name = 'cnedu';
	return p_win;
}


/*

  ÄíÅ°ÀÇ Á¸Àç¿©ºÎ¿¡ µû¶ó popupÃ¢À» ¶ç¿ó´Ï´Ù.
  String c_name : ÄíÅ°¸í
  String url : ÆË¾÷¹®¼­ÀÇ °æ·Î
  String name : ÆË¾÷Ã¢ÀÇ ÀÌ¸§
  int w : ÆË¾÷Ã¢À» Æø
  int h : ÆË¾÷Ã¢ÀÇ ³ôÀÌ
  int x : ÆË¾÷Ã¢ÀÇ ÁÂÃø »ó´ÜÀÇ xÁÂÇ¥
  int y : ÆË¾÷Ã¢ÀÇ ÁÂÃø »ó´ÜÀÇ yÇ¥Ç¥
  String s : ÆË¾÷Ã¢¿¡ ½ºÅ¬·Î¹Ù Ç¥½Ã¿©ºÎ('no' : Ç¥½Ã¾ÈÇÔ, 'yes' : Ç¥½ÃÇÔ)

  #2003.11.18 silver_star
  String s_date : ½ÃÀÛÀÏ½Ã
  String e_date : Á¾·áÀÏ½Ã

  ½ÃÀÛÀÏ½Ã <= °Ô½ÃÀÏ < Á¾·áÀÏ½Ã
*/

function popupByCookie(c_name, url, name, w, h, x, y, s,s_date,e_date) {
	var cookie = getCookie(c_name);
	if(s_date != null && e_date != null) {
		var day = new Date();
			year = day.getYear();
			month = day.getMonth() + 1;
			date = day.getDate();
			hour = day.getHours();
			if(month < 10) month = "0" + month;
			if(date < 10) date = "0" + date;
			if(hour < 10) hour = "0" + hour;
    

		var c_date = year + "" + month + "" + date + "" + hour;
		c_date = parseInt(c_date);
		s_date = parseInt(s_date);
		e_date = parseInt(e_date);

		if((c_date >= s_date) && (c_date < e_date)) {
			if(!cookie) popup(url, name, w, h, x, y, s);
		}
	} else {
		if(!cookie) popup(url, name, w, h, x, y, s);
	}
}

function popupByServerCookie(c_name, url, name, w, h, x, y, s,s_date,e_date,c_date) {
	var cookie = getCookie(c_name);
	if(s_date != null && e_date != null) {
		c_date = parseInt(c_date);
		s_date = parseInt(s_date);
		e_date = parseInt(e_date);

		if((c_date >= s_date) && (c_date < e_date)) {
			if(!cookie) popup(url, name, w, h, x, y, s);
		}
	} else {
		if(!cookie) popup(url, name, w, h, x, y, s);
	}
}

/*
  ÄíÅ° »ý¼º ÇÔ¼ö
  String name : ÄíÅ°¸í
  String value : ÄíÅ° °ª
  int day : ÄíÅ°¸¸·á ±â°£(ÀÏ ´ÜÀ§)
*/
function setCookie(name, value, day) {
	if(day != null) {
	    var expDays = day;                // ¸¸·á ³¯Â¥ ¼ÂÆÃ
    	var exp = new Date();
    	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
    	var expire_date = new Date(exp);
	    //document.cookie = name + "=" + value + "; domain=.chungnam.net ; expires=" + expire_date.toGMTString()+ "; path=/";
	    document.cookie = name + "=" + value + " ; expires=" + expire_date.toGMTString()+ "; path=/";
	} else {
		//document.cookie = name + "=" + value + "; domain=.chungnam.net ; path=/";
		document.cookie = name + "=" + value + "; path=/";
	}
}

/*
  ÄíÅ° ¼Ò¸ê ÇÔ¼ö
  String name : ¼Ò¸ê½ÃÅ³ ÄíÅ°¸í
*/
function clearCookie(name) {
    var today = new Date()
    //¾îÁ¦ ³¯Â¥¸¦ ÄíÅ° ¼Ò¸ê ³¯Â¥·Î ¼³Á¤ÇÑ´Ù.
    var expire_date = new Date(today.getTime() - 60*60*24*1000)
    //document.cookie = name + "= " + "; expires=" + expire_date.toGMTString() + "; path=/";
    //document.cookie = name + "= " + "; domain=.chungnam.net ; path=/";
    document.cookie = name + "= " + "; path=/";
}

/*
  ÄíÅ°¸¦ °¡Á®¿À´Â ÇÔ¼ö
  String name : ÄíÅ°¸í
*/
function getCookie(name) {
   var from_idx = document.cookie.indexOf(name+'=');
   if (from_idx != -1) {
      from_idx += name.length + 1
      to_idx = document.cookie.indexOf(';', from_idx)

      if (to_idx == -1) {
            to_idx = document.cookie.length
      }
      return unescape(document.cookie.substring(from_idx, to_idx))
   }
}

/*
  Ã¼Å© »óÅÂ¿¡ µû¶ó ÄíÅ° »ý¼º°ú ¼Ò¸êÀ» Á¦¾îÇÏ´Â ÇÔ¼ö
  checkboxÀÇ Event HandlerÀÎ onClickÀÌº¥Æ®¿¡ µî·ÏÇØ¼­ »ç¿ëÇÕ´Ï´Ù.
  ex) <input type="checkbox" onClick="controlCookie(this, 'cName')">
  Form.checkbox frmObj : input typeÀÌ 'checkbox'ÀÎ Form Object
  ex) checkbox¸¦ »ç¿ëÇÏÁö ¾Ê´Â°æ¿ì use¿¡ °ªÀ» ºÎ¿©ÇÑ´Ù.
*/
function controlCookie(frmObj, name, day,use) {
	  if ((frmObj.checked) || (use != null)) {
        //Ã¼Å© ¹Ú½º¸¦ ¼±ÅÃÇßÀ» °æ¿ì ÄíÅ° »ý¼º ÇÔ¼ö È£Ãâ
        setCookie(name,"true", day);
        self.close();
    }
    else {
        //Ã¼Å© ¹Ú½º¸¦ ÇØÁ¦ÇßÀ» °æ¿ì ÄíÅ° ¼Ò¸ê ÇÔ¼ö È£Ãâ
        clearCookie(name);
    } 
    return
}


/*
 Áñ°ÜÃ£±â Ãß°¡
*/
 function Bookmark(){
  if (document.all){
	  url="http://www.boryeohg.go.kr/";
	  title = "º¸·É½ÃÃ»";
		window.external.AddFavorite(url ,title);
	}
}


/*
 ÀÎ¼â ±â´É
*/
function popPrint() {
	//pUrl = getPostPathString(document.location.pathname + document.location.search, 2);
	//popupCenter("/ctnt/prnt." + pUrl.substring(1, pUrl.length), "nWin", 685, 600, "yes");
	
	pUrl = getPostPathString(document.location.pathname, 2);
  var frm = document.all.frmPrintMail;
  if(frm != null) {
      popupCenter("", "wPrintWindow", 685, 600, "yes");
      frm.target = "wPrintWindow";
      frm.action = "/ctnt/prnt." + pUrl.substring(1, pUrl.length);
      frm.submit();
  }
}

/*
 ¸ÞÀÏº¸³»±â ±â´É
*/
function popMail() {
	//pUrl = getPostPathString(document.location.pathname + document.location.search, 2);
	//popupCenter("/ctnt/mail." + pUrl.substring(1, pUrl.length), "nWin", 685, 600, "yes");
	pUrl = getPostPathString(document.location.pathname, 2);
  var frm = document.all.frmPrintMail;
  if(frm != null) {
      popupCenter("", "wMailWindow", 685, 600, "yes");
      frm.target = "wMailWindow";
      frm.action = "/ctnt/mail." + pUrl.substring(1, pUrl.length);
      frm.submit();
  }
}

/*
 ´Þ·ÂÃ¢¿­±â
*/
function openCal(pName) {
	popupCenter("/assist/calendar/calendar.jsp?pName=" + pName, "nCal", 200, 213, "no");
}

/**
 * IEÀÇ »õ·Î¿î ActiveXÁ¤Ã¥¿¡ ÀÇÇØ Object´Â document.write½ºÅ©¸³Æ®¸¦ È°¿ëÇÏ¿©¾ß ÇÑ´Ù.
 * ÀÛ¼ºÀÚ : 2006.10.12 ÇöÁØ¾Æºü
 *
 * String src : µ¿¿µ»ó ÁÖ¼Ò [ÇÊ¼ö]
 * int w : µ¿¿µ»ó Æø [ÇÊ¼ö]
 * int h : µ¿¿µ»ó ³ôÀÌ [ÇÊ¼ö]
 */
function writeVod(src,width,height,start) {
	if(start == null) start = "false";
  var html = "<OBJECT ID='MediaPlayer' classid='clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6' width='" + width + "' height='" + height + "' style='filter: gray()'>";
  var html = "<EMBED style='FILTER: gray()' ";
  html = html + " src='" + src + "' width=" + width + " height=" + height;
  html = html + " type=audio/x-ms-wax AUTOSTART='" + start + "'  ";
  html = html + " playCount='0' volume='0'  ";
  html = html + " showstatusbar='1' showaudiocontrols='1' showtracker='0'  ";
  html = html + " ShowControls='1' showpositioncontrols='0' showdisplay='0'  ";
  html = html + " ShowGotoBar='0' enablecontextmenu='0'> ";
  document.write(html);
}

/*
 °Ë»ö¾î È®ÀÎ ÈÄ °Ë»öÀ¸·Î Àü´Þ
*/
function chkSearchForm(frm) {
	if(frm != null) {
		if(frm.qt != null && frm.qt.value != "") {
			return true;
		} else {
			alert("°Ë»ö¾î°¡ Á¤È®ÇÏÁö ¾Ê½À´Ï´Ù.");
		}
	}
	return false;	
}


/*
 °ü¸® ´ë»ó ÄÁÅÙÃ÷ ¸ñ·Ï º¸±â
*/
function openContentMngList() {
	popupCenter("/ctnt/ppop.ptal/ttop/02/ttop.02.003.jsp", "winContentMngList", 600, 500, "yes");
}

/*
 °ü¸® ´ë»ó ÄÁÅÙÃ÷ °ü¸® ¸ñ·Ï º¸±â
*/
function openContentLogList(menuSeq) {
	popupCenter("/ctnt/ppop.ptal/ttop/02/ttop.02.003.02.jsp?menuSeq=" + menuSeq, "winContentLogList", 600, 500, "yes");
}

/*
 ¿î¿µÀÚ ¿äÃ»°Ô½ÃÆÇ ¸ñ·Ï º¸±â
*/
function openMngRequest() {
	popupCenter("/ctnt/ppop.ptal/ttop/02/ttop.02.004.jsp", "winMngRequest", 690, 570, "yes");
}

/*
 °ü·Ã»çÀÌÆ®·Î ÀÌµ¿
*/
function moveRelSite(obj) {
	if(obj != null) {
		if(obj.value != '') {
			openWin(obj.value, "_new");
		}
	}
}
