/*
 * 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 + 'style="position:absolute" 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);
	}
}

/*
  ÄíÅ° »ý¼º ÇÔ¼ö
  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://cnedu/";
	  title = "Ãæ³²±³À°Ã»";
		window.external.AddFavorite(url ,title);
	}
}



/*
 * Æû¿¡ ÀÔ·ÂµÈ ÀÌ¸ÞÀÏÀÌ Á¤È®ÇÑ Çü½ÄÀÎÁö È®ÀÎÇÑ´Ù.
 * Á¶°Ç¿¡ ¸Â´Ù¸é true¸¦, Æ²¸®´Ù¸é false¸¦ ¹ÝÈ¯ÇÏ¸é¼­ fromÀÇ ¹®ÀÚ¿­À» Áö¿ì°í,
 * msg¸¦ Ãâ·ÂÇÑ´Ù.
 * Form.text frmObj : input typeÀÌ 'text'ÀÎ Æû ¿ÀºêÁ§Æ®
 */
function chkEmailForm(frmObj, msg) {
	if(!isEmail(frmObj.value)) {
		if(arguments[1] != null) {
			alert(msg + "ÀÌ¸ÞÀÏ Çü½ÄÀÌ ¸ÂÁö ¾Ê½À´Ï´Ù.");
		} else {
			alert("ÀÌ¸ÞÀÏ Çü½ÄÀÌ ¸ÂÁö ¾Ê½À´Ï´Ù.");
		}
		frmObj.focus();
		frmObj.select();
		return false;
	}
	return true;
}

/*
 * ÀÌ¸ÞÀÏ Á¡°Ë¿ë ½ºÅ©¸³Æ®
 * ÃâÃ³ : http://korea.internet.com/channel/content.asp?cid=189&nid=14730
 */
function isEmail(str) {
	//regular expression Áö¿ø ¿©ºÎ Á¡°Ë
	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";

		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}

	if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

/*
 * ÀüÈ­¹øÈ£ Á¡°Ë¿ë ½ºÅ©¸³Æ®
 * Á¡°ËÁ¶°Ç
 * 1. ¼¼°³ÀÇ ÀÎÀÚ°¡ ¸ðµÎ nullÀÌ¾Æ´Ï°í
 * 2. ¼¼°³ÀÇ ÀÎÀÚ°¡ ¸ðµÎ ¼ýÀÚ
 * 3. tel01Àº 0À¸·Î ½ÃÀÛÇÏ´Â 3ÀÚ¸®¼ýÀÚ
 * 4. tel02Àº 3¶Ç´Â 4ÀÚ¸® ¼ýÀÚ
 * 5. tel03Àº 4ÀÚ¸® ¼ýÀÚ
 */
function isTel(tel01, tel02, tel03) {
	if((arguments[0] == null) || (arguments[1] == null) || (arguments[2] == null)) return false;
	if(!isInt(arguments[0]) || !isInt(arguments[1]) || !isInt(arguments[2])) return false;
	if((arguments[0].length != 3) || (arguments[0].charAt(0) != '0')) return false;
	if((arguments[1].length != 3) && (arguments[1].length != 4)) return false;
	if(arguments[2].length != 4) return false;

	return true;
}

/*
 * ¹®ÀÚ¿­ÀÌ ºó°ø¹é¿­ÀÎÁö È®ÀÎÇÕ´Ï´Ù.
 * ¸Â´Ù¸é true¸¦, Æ²¸®´Ù¸é false¸¦ ¹ÝÈ¯ÇÕ´Ï´Ù.
 * String str : °ø¹éÀÎÁö ÆÇ´ÜÇÒ ¹®ÀÚ¿­
 * String msg : °ø¹é¹®ÀÚ¿­ÀÏ¶§ Ãâ·ÂÇÒ ¸Þ¼¼Áö msg + " ÀÔ·ÂÇÏ¼¼¿ä"ÀÇ Çü½ÄÀ¸·Î alertµÈ´Ù.
 */
function isEmptyString(str, msg) {
	var len = str.length;
	//var result = 0;

	for(i = 0 ; i < len ; i++) {
		achar = str.substring(i, i+1);
		if(achar != ' ') {
			//result = 1;
			return false;
		}
	}
	if(arguments[1] != null) alert(msg + " ÀÔ·ÂÇÏ¼¼¿ä!");
	return true;
}

/*
 * Æû¿¡ ÀÔ·ÂµÈ °ªÀÌ NULL °ªÀÌ°Å³ª, °ø¹é¸¸ Á¸ÀçÇÏ´Â ºó ¹®ÀÚ¿­ÀÎÁö È®ÀÎÇÑ´Ù.
 * Á¶°Ç¿¡ ¸Â´Ù¸é true¸¦, Æ²¸®´Ù¸é false¸¦ ¹ÝÈ¯ÇÏ¸é¼­ fromÀÇ ¹®ÀÚ¿­À» Áö¿ì°í,
 * msg¸¦ Ãâ·ÂÇÑ´Ù.
 * Form.text frmObj : input typeÀÌ 'text'ÀÎ Æû ¿ÀºêÁ§Æ®
 */
function isEmptyForm(frmObj, msg) {
	try {
		if(isEmptyString(frmObj.value, msg)) {
			frmObj.value = "";
			if(frmObj.style.display != "none") {
				frmObj.focus();
			}
			return true;
		}
	} catch (Everything) {
		alert("[DEBUG] : " + Everything.message);
		return true;
	} 

	return false;
}

/*
 * Á¦ÇÑµÈ ±æÀÌÀÇ ÀÔ·ÂÀÌ ¿Ï·á µÇ¾úÀ» °æ¿ì. ´ÙÀ½ ÀÔ·ÂÇÊµå·Î ³Ñ¾î°£´Ù.
 * FormObjectÀÇ EventHandlerÀÎ 'onKeyUp'¿¡ ´ÙÀ½ ÇÔ¼ö¸¦ µî·ÏÇÑ´Ù.
 * int cnt : ¹®ÀÚ¿­ ±æÀÌ
 * Form.object frmObj2 : Á¦ÇÑµÈ ÀÔ·ÂÀÌ ¿Ï·áµÇ¾úÀ»°æ¿ì focus¸¦ ³Ñ°ÜÁÙ ÀÓÀÇÀÇ form object
 */
function moveNext(cnt, frmObj2, e) {
	if(!e) { var e = window.event; } // FFÁö¿ø

	if(e.srcElement) {
		value = e.srcElement.value;
	} else if(e.target) {
		value = e.target.value;  // FFÁö¿ø
	}

	if ((value.length >= cnt) && frmObj2) {
		frmObj2.focus();
	}
	return;
}


/*
 * numÀÌ Á¤¼öÀÎÁö ¾Æ´ÑÁö¸¦ ÆÇ´Ü
 * String num : Á¤¼öÆÇ´Ü¿¡ »ç¿ëÇÒ ¹®ÀÚ¿­
 */
function isInt(num) {
	if(arguments[0] == null) return false;
	for(i = 0 ; i < num.length ; ++i) {
		if((48 > num.charCodeAt(i)) || (num.charCodeAt(i) > 57)) {
			return false;
		}
	}
	return true;
}

/*
 * 0~9 ±îÁö ¿ÀÁ÷ ¼ýÀÚ¸¸ ÀÔ·Â°¡´ÉÇÏ°ÔÇÔ
 * key°ªÀÌ ÀÖ´Â °æ¿ì key°ªÀº ÀÔ·Â °¡´É
 */
function eventCheckNumber(key) {
	if ((key != null && event.keyCode == key) || (event.keyCode >= 48 && event.keyCode <= 57) ) {
	    	
	} else {
		event.returnValue = false;
	}	  
}

/* 
 * radio ¹øÆ° ¼±ÅÃ ¿©ºÎ ÆÇ´Ü
 */
function isNullRadio(obj,info) {
	for(var i = 0; i < obj.length; i++)	{
		if(obj(i).checked == true) {
			return false;
			break;
		} 
	}
	alert(info + "¼±ÅÃÇÏ¼¼¿ä");
	return true;
}
/*
 * ÁÖ¹Î¹øÈ£ Ã¼Å©
 * ÁÖ¹Î¹øÈ£°¡ ¸Â´Ù¸é true¸¦, Æ²¸®´Ù¸é false¸¦ ¹ÝÈ¯
 * String jumin1 : ÁÖ¹Î¹øÈ£ ¾ÕÀÚ¸® 6ÀÚ¸®
 * String jumin2 : ÁÖ¹Î¹øÈ£ µÞÀÚ¸® 7ÀÚ¸®
 */
function chkJumin1(jumin1, jumin2) {
	var str_jumin1 = jumin1 ;
	var str_jumin2 = jumin2 ;

	if((str_jumin1.length != 6) || (str_jumin2.length != 7)
			|| !isInt(str_jumin1) || !isInt(str_jumin2)) return false;


	var f1 = str_jumin1.substring(0,1);
	var f2 = str_jumin1.substring(1,2);
	var f3 = str_jumin1.substring(2,3);
	var f4 = str_jumin1.substring(3,4);
	var f5 = str_jumin1.substring(4,5);
	var f6 = str_jumin1.substring(5,6);
	var hap = f1*2 + f2*3 + f3*4 + f4*5 + f5*6 + f6*7;
	var l1 = str_jumin2.substring(0,1);
	var l2 = str_jumin2.substring(1,2);
	var l3 = str_jumin2.substring(2,3);
	var l4 = str_jumin2.substring(3,4);
	var l5 = str_jumin2.substring(4,5);
	var l6 = str_jumin2.substring(5,6);
	var l7 = str_jumin2.substring(6,7);
	hap = hap + l1*8 + l2*9 + l3*2 + l4*3 + l5*4 + l6*5;
	hap = 11 - hap % 11;
	hap = hap % 10;

	if (hap != l7) return false;
	return true;
}

/*
 * '-'±âÈ£¾øÀÌ ¿¬¼ÓµÈ 13ÀÚ¸® ÁÖ¹Î¹øÈ£¸¦ Ã¼Å©
 * ¿Ã¹Ù¸¥ ÁÖ¹Î¹øÈ£ÀÌ¸é true¸¦, ±×·¸Áö ¾Ê´Ù¸é false¸¦ ¹ÝÈ¯ÇÕ´Ï´Ù.
 * String jumin : 13ÀÚ¸® ÁÖ¹Î¹øÈ£
 */
function chkJumin2(jumin) {
	if(jumin.length != 13) return false;
	return chkJumin1(jumin.substring(0, 6), jumin.substring(6, 13));
}

/*
 * ¸¶Áö¸· '/'¹®ÀÚ ÀÌÈÄÀÇ ¹®ÀÚ¿­À» ¹ÝÈ¯ÇÕ´Ï´Ù.
 * '/'¹®ÀÚ°¡ ¾ø´Â°æ¿ì´Â ÁÖ¾îÁø ¸ðµç ¹®ÀÚ¿­À»,
 * ¹®ÀÚ¿­ ¸¶Áö¸·ÀÌ '/'·Î ³¡³­ °æ¿ì¿¡´Â 0-length stringÀ» ¹ÝÈ¯ÇÕ´Ï´Ù.
 */
function getLastPathString(str) {
	idx = str.lastIndexOf('/');
	if(idx < 0) {
		return "";
	} else {
		return str.substring(idx, str.length);
	}
}

/*
 * idx¹øÂ° '/'¹®ÀÚ ÀÌÈÄÀÇ ¹®ÀÚ¿­À» ¹ÝÈ¯ÇÕ´Ï´Ù.
 */
function getPostPathString(str, idx) {
	if((str == null) || (idx <= 0)) return null;
	pos = 0; 
	iCnt = 0;
	while((pos = str.indexOf('/', pos)) != -1) {
		if((++iCnt) == idx) {
			return str.substring(pos, str.length);
		}
		++pos;
	}
}

/*
 * È®ÀåÀÚ¸¦ Á¦°ÅÇÑ ¹®ÀÚ¿­À» ¹ÝÈ¯
 */
function removePostfix(str) {
	if((str == null)) return null;
	idx = str.lastIndexOf(".");
	return str.substring(0, idx);
}

/**
 * ¿øÇÏ´Â ÆÄÀÏÅ¸ÀÔÀÎÁö¸¦ È®ÀÎ
 */
function isFileType(frmObj,msg,type) {
  if(frmObj == null) return true;
  var filename = frmObj.value;
  filename = filename.toLowerCase();
  var filesize = filename.length;
  if(filesize == 0) return true;
  var file_point_loc = filename.lastIndexOf(".");
  if(file_point_loc == -1) {
      alert(msg);
      return false;
  }

  var file_ext = filename.substring(file_point_loc+1,filesize);
  var typelist = type.split(",");
  for( var i=0; i<typelist.length; i++) {
      if(file_ext == typelist[i]) {
          return true;
      }
  }

  alert(msg);
  return false;
}

/**
 * ¿øÄ¡¾Ê´Â ÆÄÀÏÅ¸ÀÔÀÎÁö¸¦ È®ÀÎ
 */
function isNotFileType(frmObj,msg,type) {
  if(frmObj == null) return true;
  var filename = frmObj.value;
  filename = filename.toLowerCase();
  var filesize = filename.length;
  if(filesize == 0) return true;
  var file_point_loc = filename.lastIndexOf(".");
  if(file_point_loc == -1) {
      return false;
  }

  var file_ext = filename.substring(file_point_loc+1,filesize);
  var typelist = type.split(",");
  for( var i=0; i<typelist.length; i++) {
      if(file_ext == typelist[i]) {
      		alert(msg);
          return true;
      }
  }
  return false;
}

/**
 * Æû Ã¼Å©¹Ú½º Ç×¸ñÀÌ ¼±ÅÃµÇ¾ú´ÂÁö È®ÀÎ
 * ¼±ÅÃµÇ¾úÀ» °æ¿ì ','·Î ±¸ºÐµÈ ¹®ÀÚ¿­À» ³Ñ±ä´Ù.
 */
function getChecked(obj,title,tag)
{
	if(obj == null) return "";
	var stype = "";
	var ids = "";
	var tags = "";
	var icount;
	if (obj.length != null)
	{
		icount = obj.length;
		stype = obj.tag;
		for(i=0; i < icount; i++)
		{
			if (obj(i).checked == true)
			{
				ids = ids + "" + obj(i).value + ","; 
				if(tag != null)	tags = tags + "" + obj(i).tag + ",";
			}
		}
		ids = ids.substring(0,ids.length-1);
		if(tag != null) tags = tags.substring(0,tags.length-1);
	}
	else
	{
		if(obj.checked == true)
		{
			ids = obj.value;
			if(tag != null) tags = obj.tag;
		}	
	}

	if(tag != null) return new Array(ids,tags);
	else return ids;
}

// ########################################################################## //
//                                                                            //
//                              ³¯ÀÚ°ü·Ã À¯Æ¿¼º ÇÔ¼öµé                        //
//                                                                            //
// ########################################################################## //
// ¿ùº° ¸¶Áö¸· ÀÏÀÚ
var lastdays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

/**
 * °¢ ´ÞÀÇ ¸¶Áö¸· ÀÏÀÚ¸¦ ¹ÝÈ¯ÇÕ´Ï´Ù.
 * theDate°¡ Æ÷ÇÔµÇ´Â ³¯ÀÚÀÇ ¸¶Áö¸· ÀÏÀÚ¸¦ ±¸ÇÕ´Ï´Ù.
 * theDateÀÇ Çü½ÄÀÌ ¿Ã¹Ù¸£Áö ¾Ê´Ù¸é ÀÌ¹ø´ÞÀÇ ¸¶Áö¸· ³¯ÀÚ¸¦ Ç¥½ÃÇÏ´Â Date°´Ã¼¸¦ ¹ÝÈ¯ÇÕ´Ï´Ù.
 */
function getLastDay(theDate) {
	if((theDate.getMonth() < 0) || (theDate.getMonth() > 11)) {
		return getLastDay(new Date());
	} else if(theDate.getMonth() == 1) {
		if((((theDate.getYear() % 4) == 0) && ((theDate.getYear() % 100) != 0)) ||
				((theDate.getYear() % 400) == 0)) {
			return 29;
		} else {
			return 28;
		}
	} else {
		return lastdays[theDate.getMonth()];
	}
}

/**
 * ÁÖ¾îÁø Date°´Ã¼ÀÇ num_day¸¸Å­ÀÇ ÀÌÀü ³¯ÀÚÀÇ Date°´Ã¼¸¦ ¹ÝÈ¯ÇÕ´Ï´Ù.
 * theDate : Date°´Ã¼
 * num_day : ¾çÀÇ Á¤¼ö
 */
function theDayBefore(theDate, num_day) {
	r_date = new Date();
	r_date.setTime(theDate.getTime() - (num_day * 1000 * 60 * 60 * 24));
	return r_date;
}

/**
 * ÁÖ¾îÁø Date°´Ã¼ÀÇ num_day¸¸Å­ÀÇ ÀÌÈÄ ³¯ÀÚÀÇ Date°´Ã¼¸¦ ¹ÝÈ¯ÇÕ´Ï´Ù.
 * theDate : Date°´Ã¼
 * num_day : ¾çÀÇ Á¤¼ö
 */
function theDayAfter(theDate, num_day) {
	r_date = new Date();
	r_date.setTime(theDate.getTime() + (num_day * 1000 * 60 * 60 * 24));
	return r_date;
}

/**
 * ÁÖ¾îÁø Date°´Ã¼°¡ Æ÷ÇÔµÈ ÁÖÀÇ ÇØ´ç ¿äÀÏÀÇ Date°´Ã¼¸¦ ±¸ÇÕ´Ï´Ù.
 * ¿äÀÏÀº ÀÏ,¿ù,È­,¼ö,¸ñ,±Ý,ÅäÀÇ ¼øÀ¸·Î °¢°¢ 0~6±îÁöÀÇ ¼ýÀÚ·Î Ç¥ÇöÇÕ´Ï´Ù.
 */
function theDayWeek(theDate, week) {
	r_date = new Date();
	r_date.setTime(theDate.getTime());
	if(r_date.getDay() > week) {
		return theDayBefore(r_date, r_date.getDay() - week);
	} else if(r_date.getDay() < week) {
		return theDayAfter(r_date, week - r_date.getDay());
	} else {
		return r_date;
	}
}

/**
 * °ü¸®ÀÚ¿¡°Ô ¸ÞÀÏ º¸³»±â
 * mailTEmail : °ü¸®ÀÚÀÌ¸ÞÀÏÁÖ¼Ò
 * mailTName : °ü¸®ÀÚÀÌ¸§
 */
function sendAdminMail(mailTEmail, mailTName) {
	popupCenter("/ctnt/mail.ptal/ttop/04/ttop.04.002.html?mailTEmail="+mailTEmail+"&mailTName="+mailTName,"winSendAdminMail",670,597,"no");
}

/**
 * ±ÇÇÑ°ü¸®
 */
function priManager(priCd) {
	popupCenter('/ctnt/ppop.ptal/ttop/05/ttop.05.001.jsp?priCd=' + priCd,'winPriManager','650','450','no')
}

/**
 * ±ÇÇÑ½ÅÃ»ÀÚ°ü¸®
 */
function priManagerMng() {
	popupCenter('/ctnt/ppop.ptal/ttop/05/ttop.05.002.jsp','winPriManagerMng','670','450','yes')
}

/**
 * Á¢¼ÓÅë°è
 */
function goCounter(cnt_div) {
	popupCenter('/ctnt/ppop.ptal/ttop/05/ttop.05.003.jsp?cnt_div=' + cnt_div,'winCounter','650','640','yes')
}