var isIE8 = (navigator.userAgent.indexOf("MSIE 8.0")!=-1) ? true:false;

function include_script (type, defer, src)
{
	var script = document.createElement("script") ;
	script.type = type, script.defer = defer ;
	document.getElementsByTagName('head')[0].appendChild(script) ;
	script.src = src ;
}

include_script("text/javascript", true, "/common/js/soobakc_xml.js") ;

/*****************************************************************************************************************************************
	popup
*****************************************************************************************************************************************/
function WinPopup(mypage,myname, w, h,scroll) { //v2.0

	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;

	var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',resizable=0,status=0,scrollbars='+scroll+'';
	var popWin = window.open(mypage, myname, winprops);
	if (parseInt(navigator.appVersion) >= 4) { popWin.window.focus(); }
}

function eventPopup(mypage, w, h, scroll, leftP, topP) { //v2.0

	if (leftP == '' )
		leftP = (screen.width - w) / 2;

	if (topP == '')
		topP = (screen.height - h) / 2;

	var winprops = 'height='+h+',width='+w+',top='+topP+',left='+leftP+',resizable=0,status=0,scrollbars='+scroll+'';
	var popWin = window.open(mypage, 'eventPop'+leftP+w, winprops);
	/**********************************************
	¼öÁ¤ÀÚ : ±è³²¹è
	¼öÁ¤ÀÏ : 2009.11.13
	³»  ¿ë : ÆË¾÷Â÷´Ü µÇ¾úÀ» °æ¿ì ¿À·ù ¹ß»ýÇÏ´Â°Í ¹æÁö
	***********************************************/
//	if (popWin != "") {
//		popWin.window.focus();
//	};
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  var win = window.open(theURL,winName,features);
  win.focus();
}


/*****************************************************************************************************************************************
	image rollover
*****************************************************************************************************************************************/

function imgOn(imgEl) {
	imgEl.src = imgEl.src.replace("_off.gif", "_on.gif");
}

function imgOff(imgEl) {
	imgEl.src = imgEl.src.replace("_on.gif", "_off.gif");
}


function imgOn(imgEl) {
	imgEl.src = imgEl.src.replace("_off.jpg", "_on.jpg");
}

function imgOff(imgEl) {
	imgEl.src = imgEl.src.replace("_on.jpg", "_off.jpg");
}

/*****************************************************************************************************************************************
	Tab_image
*****************************************************************************************************************************************/
function initTabMenu(tabContainerID, tabDefaultTabId) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("ul")[0].getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onclick = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", "_off.gif");
				} else {
					currentmenu.className = currentmenu.className.replace("on", "");
				}
			}

			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace("_off.gif", "_on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		/***********************************************************************
		¼öÁ¤ÀÚ : ±è³²¹è
		¼öÁ¤ÀÏ : 2009.02.12
		³»  ¿ë : ¼³Á¤µÈ ÅÇ¿¡ ÃÊ±â°ª ÁöÁ¤ °¡´ÉÇÏµµ·Ï ¼öÁ¤
		************************************************************************/
		if (tabAnchor.item(i).href.split("#")[1] == tabDefaultTabId) {
			thismenu.container.first = thismenu;
		} else if (!thismenu.container.first) {
			thismenu.container.first = thismenu;
		};
	}
	if (tabContainer.first)
		tabContainer.first.onclick();
}


/*****************************************************************************************************************************************
	Tab Over
*****************************************************************************************************************************************/
function TabMenuOver(tabContainerID) {
	var tabContainer = document.getElementById(tabContainerID);
	var tabAnchor = tabContainer.getElementsByTagName("ul")[0].getElementsByTagName("a");
	var i = 0;

	for(i=0; i<tabAnchor.length; i++) {
		if (tabAnchor.item(i).className == "tab")
			thismenu = tabAnchor.item(i);
		else
			continue;

		thismenu.container = tabContainer;
		thismenu.targetEl = document.getElementById(tabAnchor.item(i).href.split("#")[1]);
		thismenu.targetEl.style.display = "none";
		thismenu.imgEl = thismenu.getElementsByTagName("img").item(0);
		thismenu.onmouseover = function tabMenuClick() {
			currentmenu = this.container.current;
			if (currentmenu == this)
				return;

			if (currentmenu) {
				currentmenu.targetEl.style.display = "none";
				if (currentmenu.imgEl) {
					currentmenu.imgEl.src = currentmenu.imgEl.src.replace("_on.gif", "_off.gif");
				} else {
					currentmenu.className = currentmenu.className.replace("on", "");
				}
			}

			this.targetEl.style.display = "";
			if (this.imgEl) {
				this.imgEl.src = this.imgEl.src.replace("_off.gif", "_on.gif");
			} else {
				this.className += " on";
			}
			this.container.current = this;

			return false;
		};

		if (!thismenu.container.first)
			thismenu.container.first = thismenu;
	}
	if (tabContainer.first)
		tabContainer.first.onmouseover();
}
/*****************************************************************************************************************************************
	Tab_text
*****************************************************************************************************************************************/

function tabview_aux(TabViewId, id) {
	var TabView = document.getElementById(TabViewId);
	// ----- Tabs -----
	var Tabs = TabView.firstChild;
	while (Tabs.className != "tabs" ) Tabs = Tabs.nextSibling;

	var Tab = Tabs.firstChild;
	var i = 0;

	do {
		if (Tab.tagName == "A") {
			i++;
			Tab.href = "javascript:tabview_switch('"+TabViewId+"', "+i+");";
			Tab.className = (i == id) ? "Active" : "";
			Tab.blur();
		}
	}
	while (Tab = Tab.nextSibling);

	// ----- Pages -----

	var Pages = TabView.firstChild;
	while (Pages.className != 'pages') Pages = Pages.nextSibling;

	var Page = Pages.firstChild;
	var i = 0;

	do {
		if (Page.className == 'page') {
			i++;
			if (Pages.offsetHeight) Page.style.height = (Pages.offsetHeight-2)+"px";
				Page.style.overflow = "auto";
				Page.style.display = (i == id) ? '' : 'none';
		}
	}
	while (Page = Page.nextSibling);
}
function tabview_switch(TabViewId, id) { tabview_aux(TabViewId, id); }
function tabview_initialize(TabViewId) { tabview_aux(TabViewId, 1); }

/*****************************************************************************************************************************************
	input text delete
*****************************************************************************************************************************************/

function clearText(thefield)
{
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}

/*****************************************************************************************************************************************
	Layer
*****************************************************************************************************************************************/
function layerShow(layerId) {
	document.getElementById(layerId).style.display = "block";

}
function layerHide(layerId) {
	document.getElementById(layerId).style.display = "none";
}

function layerToggle(layerId) {
	if (document.getElementById(layerId).style.display=='none')
		document.getElementById(layerId).style.display = "";
	else
		document.getElementById(layerId).style.display = "none";
}

/*****************************************************************************************************************************************
	·¹ÀÌ¾î·Ñ¸µ
*****************************************************************************************************************************************/

var banner_1_mouseEvent = 1;
var banner_2_mouseEvent = 1;


// banner_roll("divÅÂ±× id", ¹è³Ê1°³³ôÀÌ, µô·¹ÀÌ, 1Ä­ÀÌµ¿¼Óµµ, 0);
function banner_roll(div_id, banner_height, banner_delay, banner_speed, this_height)
{

	if(eval(div_id + "_mouseEvent"))
	{
		var div_tag = document.getElementById(div_id);
		var a_tag, i;

		this_height++;

		if(this_height < banner_height)
		{
			div_tag.style.top = -this_height;
			setTimeout("banner_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", " + this_height + ");", banner_speed);
		}
		else
		{
			a_tag = div_tag.getElementsByTagName("TABLE");
			div_tag.appendChild(a_tag[0]);
			div_tag.style.top = 0;
			setTimeout("banner_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", 0);", banner_delay);
		}
	}
	else
	{
		setTimeout("banner_roll('" + div_id + "', " + banner_height + ", " + banner_delay + ", " + banner_speed + ", " + this_height + ");", banner_speed);
	}

	return true;
}

/*****************************************************************************************************************************************
	Faq style
*****************************************************************************************************************************************/
function stylecorn(id, idx) {
        var obj_div = document.getElementById(id).getElementsByTagName('td');

        var faq_list = new Array();
        var faq_detail = new Array();

        for (var i=0; i<obj_div.length; i++ ){
            if( obj_div[i].className.indexOf("study_list") > -1 ){
                faq_list[faq_list.length] = obj_div[i];
            }else if( obj_div[i].className.indexOf("study_view") > -1 ){
                faq_detail[faq_detail.length] = obj_div[i];
            }
        }

        for (var i=0; i<faq_list.length ; i++ ){
            if (idx == i){
                if( faq_detail[i].style.display == '' ){

                    faq_detail[i].style.display = 'none';
                }else{

                    faq_detail[i].style.display = '';
                }
            } else {

                faq_detail[i].style.display = 'none';
            }
        }
    }

function stylecorn01(id, idx) {
        var obj_div = document.getElementById(id).getElementsByTagName('div');

        var faq_list = new Array();
        var faq_detail = new Array();

        for (var i=0; i<obj_div.length; i++ ){
            if( obj_div[i].className.indexOf("search_lc") > -1 ){
                faq_list[faq_list.length] = obj_div[i];
            }else if( obj_div[i].className.indexOf("search_view") > -1 ){
                faq_detail[faq_detail.length] = obj_div[i];
            }
        }

        for (var i=0; i<faq_list.length ; i++ ){
            if (idx == i){
                if( faq_detail[i].style.display == '' ){

                    faq_detail[i].style.display = 'none';
                }else{

                    faq_detail[i].style.display = '';
                }
            } else {

                faq_detail[i].style.display = 'none';
            }
        }
    }



/* onfocus-='this.blur()'*/
function bluring(){
if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin=bluring;


/*****************************************************************************************************************************************
	ÇÃ·¡½Ã°øÅë
*****************************************************************************************************************************************/

function common_object(width,height,dir){
	if (dir.indexOf("swf") > 0) {
		document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"+width+"' height='"+height+"'><param name='movie' value='"+dir+"'><param name='quality' value='high'><param name='allowScriptAccess' value='sameDomain'><param name='wmode' value='transparent'><embed src='"+dir+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+width+"' height='"+height+"'></embed></object>");
	} else {
		document.write("<img src='"+dir+"' width='"+width+"' height='"+height+"'  border='0'>");
	}
}

/*****************************************************************************************************************************************
	ÃÊµî¿¡ ¾²ÀÎ½ºÅ©¸³Æ®
*****************************************************************************************************************************************/

function MM_preloadImages() { //v3.0f
  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];}}f
}

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 ConView(kind){
	var ConLayer = eval("document.all.layer"+kind+"");
	if (ConLayer.style.display == "")
	{
		ConLayer.style.display = "none";
	}else{
		ConLayer.style.display = "";
	}

	for (i=1;i<3;i++)
	{
		if (i != kind)
		{
			var ConLayer2 = eval("document.all.layer"+i+"");
			ConLayer2.style.display = "none";
		}
	}
}


/*****************************************************************************************************************************************
	ie 6.0 ·¹ÀÌ¾î ¼¿·ºÆ®¹Ú½º ¼û±â±â
*****************************************************************************************************************************************/
	function fnLayerShow(){
		var objLayer = document.getElementById("Layer");
		var objLayerContents = document.getElementById("Layer-Contents");
		objLayer.style.display = "block";

		//ie6¿¡¼­ ¼¿·ºÆ® ¹Ú½º À§·Î º¸ÀÌ±â
		if(navigator.userAgent.indexOf("MSIE 6")>-1 && navigator.userAgent.indexOf("MSIE 7")<0){
			if (!document.getElementById("IE6Iframe")){
				var ie6_ifm = document.createElement("iframe");
				ie6_ifm.setAttribute("id","IE6Iframe");
				ie6_ifm.style.position = "absolute";
				ie6_ifm.style.opacity = "0";
				ie6_ifm.style.filter = "alpha(opacity=0)";
				ie6_ifm.style.zindex = "-1";
				ie6_ifm.style.left = "0";
				ie6_ifm.style.top = "0";
				ie6_ifm.style.width = objLayerContents.offsetWidth;
				ie6_ifm.style.height = objLayerContents.offsetHeight;
				objLayer.appendChild(ie6_ifm);
			}
		}
	}


	function fnLayerClose(){
		var objLayer = document.getElementById("Layer");
		objLayer.style.display = "none";
	}


/*****************************************************************************************************************************************
	¾Æ·¡´Â ±âÁ¸ ¼Ò½º
*****************************************************************************************************************************************/


function selectBox(start,end,inpt,adds,strd) {

	var i=0,iinput=0;
	var t = eval(adds);
	var sTemp="";
	var strString="";

	//if(inpt !=""){
	    iinput=inpt;
		for(i=start ; i<=end ; i+=t){
			if(i==iinput){
				if(i<10){
					sTemp="0"+ i;
				}
				else{
					sTemp= i;
				}
				strString+=" <option value='"+sTemp+"' selected>"+i+" "+strd+"</option>";
			}
			else{
				if(i<10){
					sTemp="0"+ i;
				}
				else{
					sTemp= i;
				}
				strString+=" <option value='"+sTemp+"'>"+i+" "+strd +"</option>";
			}
		}
	//}
	return strString;

}

function selectSchool(colName){
	MM_openBrWindow('/member/popup_school.asp?colName='+colName,'school','width=500,height=160')
}

function Mail_Chk(mail){

	if (mail.indexOf("@") == -1 ){
		alert("E-MailÀº '@'¸¦ Æ÷ÇÔÇØ¾ß ÇÕ´Ï´Ù.");
		return false;
	}
	if (mail.indexOf(".") == -1 ){
		alert("E-MailÁÖ¼Ò°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
		return false;
	}
	return true;
}







function LoginStateCheck(flag){
	var xmlHttpLoginState = Ajax.getTransport();
	xmlHttpLoginState.open("GET", "/common/asp/login_state_xml.asp?flag="+flag, false);
	xmlHttpLoginState.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpLoginState.send(null);
	return xmlHttpLoginState.responseText;
}

//------------------------------------------------------------------------------
// Footer ¿¡ ÀÖ´Â ÀÚÁÖ ¾²´Â ¸Þ´º ¼³Á¤ÇÏ±â
// 2009-01-29 ÇÏ¿ø¼®
//------------------------------------------------------------------------------
function setFooterMyMenu(){
	if (LoginStateCheck("state") == ""){
		alert('\n È¸¿øÀ¸·Î ·Î±×ÀÎ ÇÏ½Ê½Ã¿À.');
		return;
	}

	var chkMenunum = 0;
	var f = document.footerMyMenu;
	for(i=0;i<f.my_menu.length;i++){
		if(f.my_menu[i].checked){
			chkMenunum++;
		}
	}

	if (!chkMenunum) {
		alert("ÀÚÁÖ ¾²´Â ¸Þ´º¸¦ ¼±ÅÃÇØ ÁÖ¼¼¿ä");
		return;
	}

	if (chkMenunum > 4) {
		alert("ÃÖ´ë 4°³ ±îÁö¸¸ ¼±ÅÃÇÒ ¼ö ÀÖ½À´Ï´Ù.");
		return;
	}
	if (confirm("Àû¿ëÇÏ½Ã°Ú½À´Ï±î?")){
		f.submit();
	}
}

function CheckStrLen1(chkfrm,remainfrm,maxlen)
{
	var temp; //µé¾î¿À´Â ¹®ÀÚ°ª...
	var msglen;
	msglen = maxlen*1;

	l = chkfrm.value.length;
	tmpstr = "" ;

	if (l == 0)
		remainfrm.value = maxlen*1;
	else
	{
		for(k=0;k<l;k++)
		{
			temp = chkfrm.value.charAt(k);

			if (escape(temp).length > 4)
			msglen -= 1;
			else
			msglen--;

			if(msglen < 0)
			{
				alert("ÃÑ ¿µ¹® "+(maxlen*1)+"ÀÚ ÇÑ±Û " + maxlen + "ÀÚ ±îÁö µî·Ï °¡´ÉÇÕ´Ï´Ù.");
				chkfrm.value = tmpstr;
				break;
			}
			else
			{
				remainfrm.value = msglen;
				tmpstr += temp;
			}
		}
	}
}


function CheckStrLen(chkfrm,remainfrm,maxlen)
{
	var temp; //µé¾î¿À´Â ¹®ÀÚ°ª...
	var msglen;
	msglen = maxlen*1;

	l = chkfrm.value.length;
	tmpstr = "" ;

	if (l == 0)
		remainfrm.value = maxlen*1;
	else
	{
		for(k=0;k<l;k++)
		{
			temp = chkfrm.value.charAt(k);

			if (escape(temp).length > 4)
			msglen -= 2;
			else
			msglen--;

			if(msglen < 0)
			{
				alert("ÃÑ ¿µ¹® "+(maxlen*1)+"ÀÚ ÇÑ±Û " + maxlen + "ÀÚ ±îÁö µî·Ï °¡´ÉÇÕ´Ï´Ù.");
				chkfrm.value = tmpstr;
				break;
			}
			else
			{
				remainfrm.value = msglen;
				tmpstr += temp;
			}
		}
	}
}


function setAllMenuLayer(show_type){
	//alert(show_type)
	if (show_type=="h"){
		if(document.getElementById("new_teacher")){
			layerHide('new_teacher');
		}
		if(document.getElementById("ing_study")){
			layerHide('ing_study');
		}
		if(document.getElementById("tc_btn")){
			layerHide('tc_btn');
		}
	}else if (show_type=="s"){
		if(document.getElementById("new_teacher")){
			layerShow('new_teacher');
		}
		if(document.getElementById("ing_study")){
			layerShow('ing_study');
		}
		if(document.getElementById("tc_btn")){
			layerShow('tc_btn');
		}
	}
}

function setCookie(name, value, expiredays) {
	var expire_date = new Date();
	expire_date.setDate(expire_date.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; expires=" + expire_date.toGMTString() + "; path=/";
}





//--------------------------------------------------------
// ÇØ´ç °´Ã¼°¡ ¹è¿­ÀÎÁöÃ¼Å©
// objName : input,checkbox,radioµî, ¶Ç´Â id·Î Á¤ÀÇµÈ °´Ã¼µé
// »ùÇÃ
//	if(isArray(document.test.aaa))
//		alert('¹è¿­ÀÔ´Ï´Ù.');
//	else
//		alert('¹è¿­ÀÌ ¾Æ´Õ´Ï´Ù.');
//--------------------------------------------------------
function isArray(objName, objType)
{
	if (objType=='id')
	{
		var obj=document.getElementById(objName);

		if(typeof(obj.length)=='undefined')
			return false;
		else
			return true;
	}
	else
	{
		if(typeof(objName.length)=='undefined')
			return false;
		else
			return true;
	}
}



//--------------------------------------------------------------------------------------------------------------------
// Æû¿¡¼­ Ã¼Å©¹Ú½º ÀüÃ¼ ¼±ÅÃÇÏ±â
//--------------------------------------------------------------------------------------------------------------------
// ¼³  ¸í : °Ô½ÃÆÇ°°Àº ¸ñ·Ï È­¸é¿¡¼­ Ã¼Å©¹Ú½º·Î ¿©·¯°³ ¼±ÅÃÇÒ¶§
// ÀÏ¹ÝÇü : checkAll(formÀÌ¸§, Ã¼Å©¹Ú½º¸ñ·ÏÀÌ¸§(°°ÀºÀÌ¸§À¸·ÎµÈ°Íµé), ÀüÃ¼¼±ÅÃ¿ë Ã¼Å©¹Ú½ºÀÌ¸§)
// ¿¹  Á¦ : checkAll('frmList', 'idx', 'chkAll');
//--------------------------------------------------------------------------------------------------------------------

function checkAll(frmName, checkboxObj, allObj)
{
	var objForm		= eval('document.' + frmName); //Æû°´Ã¼
	var arrCheckBox	= eval('document.' + frmName + '.' + checkboxObj); //Ã¼Å©¹Ú½º¸ñ·Ï
	var checkboxAll	= eval('document.' + frmName + '.' + allObj); //ÀüÃ¼¼±ÅÃÇÏ´Â Ã¼Å©¹Ú½º


	if(typeof(arrCheckBox) != 'object')
	{
		alert('¼±ÅÃÇ×¸ñÀÌ ¾ø½À´Ï´Ù.');
		return false;
	}


	if (checkboxAll.checked)
	{
		//Ã¼Å©
		if(!isArray(arrCheckBox)) //if(typeof(arrCheckBox.length)=='undefined')
		{
			if (!arrCheckBox.disabled) {
				arrCheckBox.checked=true;
			};
		}
		else
		{
			for(i=0;i < arrCheckBox.length;i++){
				if (!arrCheckBox[i].disabled) {
					arrCheckBox[i].checked=true;
				};
			}
		}
	}
	else
	{
		//ÇØÁ¦
		if(!isArray(arrCheckBox)) //if(typeof(arrCheckBox.length)=='undefined')
		{
			arrCheckBox.checked=false;
		}
		else
		{
			for(i=0;i < arrCheckBox.length;i++){
				arrCheckBox[i].checked=false;
			}
		}
	}
}





//--------------------------------------------------------------------------------------------------------------------
// aspÀÇ left¿Í right
//--------------------------------------------------------------------------------------------------------------------
// ¼³  ¸í : ÁöÁ¤ÇÑ °¹¼ö¸¸Å­ ¹®ÀÚ °¡Á®¿À±â  (ÇÑ¿µ°¹¼ö ±¸ºÐ¾øÀÌ)
// ÀÏ¹ÝÇü : left(¹®ÀÚ¿­, °¹¼ö);
//			right(¹®ÀÚ¿­, °¹¼ö);
// ¿¹  Á¦ : left(strVal, 7);
//			right(strVal, 7);
// ·Î  ±× : 2009-05-18 ¹Ú¹üÀÏ ÁÖ¼®Ãß°¡
//--------------------------------------------------------------------------------------------------------------------

function left(str, n)
{
	if (n <= 0)
		return "";
	else if (n > String(str).length)
		return str;
	else
		return String(str).substring(0,n);
}




function right(str, n)
{
	if (n <= 0)
	{
		return "";
	}
	else if(n > String(str).length)
	{
		return str;
	}
	else
	{
		var iLen = String(str).length;
		return String(str).substring(iLen, iLen - n);
	}
}



//-----------------------------------------------------------------------------
// 3ÀÚ¸®¸¶´Ù ÄÞ¸¶Âï±â(¹®ÀÚº¯¼öÀÏ¶§)
// @return : String
//-----------------------------------------------------------------------------
String.prototype.setComma=function(){
	return this.replace(/(\d)(?=(?:\d{3})+(?!\d))/g,'$1,');
}


//-----------------------------------------------------------------------------
// 3ÀÚ¸®¸¶´Ù ÄÞ¸¶Âï±â(¼ýÀÚ°ªÀÏ¶§_)
// @return : String
//-----------------------------------------------------------------------------
Number.prototype.setComma=function(){
	return this.toString().replace(/(\d)(?=(?:\d{3})+(?!\d))/g,'$1,');
}



//-----------------------------------------------------------------------------
// ¼ýÀÚ¸¸ °¡Á®¿Ã¶§
// @return : String
//-----------------------------------------------------------------------------
String.prototype.getNumber = function() {
	return this.replace(/[^0-9]/g,'');
}





//-----------------------------------------------------------------------------
// ¹®ÀÚÀÇ ÁÂ, ¿ì °ø¹é Á¦°Å
// @return : String
//-----------------------------------------------------------------------------
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/gi, "");
}
//-----------------------------------------------------------------------------
// ¹®ÀÚÀÇ ÁÂ °ø¹é Á¦°Å
// @return : String
//-----------------------------------------------------------------------------
String.prototype.ltrim = function() {
    return this.replace(/(^\s*)/, "");
}
//-----------------------------------------------------------------------------
// ¹®ÀÚÀÇ ¿ì °ø¹é Á¦°Å
// @return : String
//-----------------------------------------------------------------------------
String.prototype.rtrim = function() {
    return this.replace(/(\s*$)/, "");
}
//-----------------------------------------------------------------------------
// ¼ýÀÚ·Î ±¸¼ºµÈ ¹®ÀÚ¿­ÀÎ°¡ Ã¼Å©
// @return : True Or False
//
// »ç¿ë¿¹
// var strCheckData = " 123456 ";
// alert( strCheckData.isNumeric() );
//-----------------------------------------------------------------------------
String.prototype.isNumeric = function() {
    var isRtnValue = null;
    if (this.length == 0 || isNaN(this)){
        isRtnValue = false;
    } else {
        isRtnValue = true;
    };

    return isRtnValue;
};





//¹ÙÀÌÆ®´ÜÀ§ ¹®ÀÚ°è»ê
function getByteLength_Form(chkfrm,remainfrm,maxlen)
{
	var temp; //µé¾î¿À´Â ¹®ÀÚ°ª...
	var msglen;
	msglen = maxlen*1;

	l = chkfrm.value.length;
	tmpstr = "" ;

	if (l == 0)
		remainfrm.value = maxlen*1;
	else
	{
		for(k=0;k<l;k++)
		{
			temp = chkfrm.value.charAt(k);

			if (escape(temp).length > 4)
			msglen -= 2;
			else
			msglen--;

			if(msglen < 0)
			{
				alert("ÃÑ ¿µ¹® "+(maxlen*1)+"ÀÚ ÇÑ±Û " + maxlen + "ÀÚ ±îÁö µî·Ï °¡´ÉÇÕ´Ï´Ù.");
				chkfrm.value = tmpstr;
				break;
			}
			else
			{
				if(typeof(document.getElementById(remainfrm)) == 'object')
					document.getElementById(remainfrm).innerText = msglen.setComma();
				else
					remainfrm.value = msglen;
				tmpstr += temp;
			}
		}
	}
}





//ID ¹®ÀÚ¿­±æÀÌ°è»ê(ÅØ½ºÆ®ÇÊµåÂüÁ¶, ³²Àº±ÛÀÚÁý¾î³ÖÀ»idÀÌ¸§, ÃÖ´ë°ª)
function getByteLength(inputField, remainField, maxlen)
{
	var temp; //µé¾î¿À´Â ¹®ÀÚ°ª...
	var msglen;
	var objRemain = document.getElementById(remainField);

	msglen = maxlen*1;

	l = inputField.value.length;
	tmpstr = "" ;

	if (l == 0)
		objRemain.innerHTML = maxlen*1;
	else
	{
		for(k=0;k<l;k++)
		{
			temp = inputField.value.charAt(k);

			if (escape(temp).length > 4)
				msglen -= 2; //¹ÙÀÌÆ®°è»ê, ´Ü¼ø±ÛÀÚ¼ö·Î¸¸ ÇÏ·Á¸é 1
			else
				msglen--;

			if(msglen < 0)
			{
				alert("ÃÑ ¿µ¹® "+(maxlen*1)+"ÀÚ ÇÑ±Û " + maxlen + "ÀÚ ±îÁö µî·Ï °¡´ÉÇÕ´Ï´Ù.");
				inputField.value = tmpstr;
				break;
			}
			else
			{
				objRemain.innerHTML = msglen;
				tmpstr += temp;
			}
		}
	}
}







//¶óµð¿À¹öÆ° Ã¼Å©µÇ¾îÀÖ´ÂÁö È®ÀÎÇÏ±â
function checkRadio(radioObj)
{
	var chkValue = false;

	for (radioLoop=0; radioLoop < radioObj.length; radioLoop++)
	{
		if (radioObj[radioLoop].checked)
		{
			chkValue=true;
			break;
		}
	}

	return chkValue;
}


/*-------------------------------------------------------------------------------*
*  ÀÛ¼ºÀÚ : ±è³²¹è
*  ÀÛ¼ºÀÏ : 2009.03.11
*  ³»  ¿ë : ÀÔ·Â°ª¿¡¼­ ¼ýÀÚ¸¸ ÀÔ·Â¹Þ¾Æ 3ÀÚ¸®¸¶´Ù ,[ÄÞ¸¶]·Î ±¸ºÐÇÏ¿© º¸¿©ÁÜ
*  »ç¿ë¹ý : ÀÔ·ÂºÎºÐ¿¡ onkeyup="javascript:getNumericWithComma(this)" »ðÀÔ
*--------------------------------------------------------------------------------*/
var prev = '';
function getNumericWithComma(obj) {
	var regexp = /^(-)?((?:[1-9]\d*)|(?:0))?(\.\d*)?$/;

	if(obj.value == prev){
		return;
	};

	num = obj.value.replace(/,/g,'');

	if(num.search(regexp)!= -1){
		new_num = num.match(regexp)[1];
		integer = num.match(regexp)[2];
		for(i=0, len=integer.length ; i<len ; i++){
				new_num += integer.charAt(i);
				if(i!=len-1 && (len-i)%3==1)
				{
						new_num += ',';
				}
		}
		new_num += num.match(regexp)[3];

		obj.value = new_num;
		prev = new_num;
	}
	else obj.value = prev;
};
/*-------------------------------------------------------------------------------*/









//--------------------------------------------------------------------------------------------------------------------
// select¹Ú½º ³»¿ëÃÊ±âÈ­
//--------------------------------------------------------------------------------------------------------------------
// ¼³  ¸í : select ¹Ú½ºÀÇ ³»¿ëÀ» ÃÊ±âÈ­ÇÑ´Ù(»èÁ¦)
// ÀÏ¹ÝÇü : initSelectBox(ÆûÀÌ¸§, ¼¿·ºÆ®¹Ú½ºÀÌ¸§);
// ¿¹  Á¦ : initSelectBox('frmInput', 'teacherId');
// ·Î  ±× : 2009-08-01 ¹Ú¹üÀÏ
//--------------------------------------------------------------------------------------------------------------------

function initSelectBox(frmName, selectName)
{
	var selectboxObj = eval('document.'+frmName+'.'+selectName);
	var optionCount = selectboxObj.options.length++;


	for (var i = 0; i < optionCount ; i++)
	{
		selectboxObj.options[1]=null;
	}

	//¶Ç´Â ¾Æ·¡Ã³·³ ÇØµµµ©

	//for (var i = 0; i < optionCount ; i++)
	//{
	// selectboxObj.options[optionCount - i]=null; //µÚ¿¡°ÍºÎÅÍ Áö¿ö³ª¿Â´Ù
	// }


}




//--------------------------------------------------------------------------------------------------------------------
// select¹Ú½º ³»¿ë»ðÀÔ
//--------------------------------------------------------------------------------------------------------------------
// ¼³  ¸í : select ¹Ú½ºÀÇ ³»¿ëÀ» ÃÊ±âÈ­ÇÑ´Ù(»èÁ¦)
// ÀÏ¹ÝÇü : insertSelectBox(ÆûÀÌ¸§, ¼¿·ºÆ®¹Ú½ºÀÌ¸§, ¿É¼Ç°ª, ¿É¼ÇÅØ½ºÆ®, ¼±ÅÃ°ª);
// ¿¹  Á¦ : insertSelectBox('frmInput', 'teacherId', 'mteach023', 'À°Áø¼÷', 'selected');
// ·Î  ±× : 2009-08-01 ¹Ú¹üÀÏ
//--------------------------------------------------------------------------------------------------------------------

function insertSelectBox(frmName, selectName, value, text, selflag)
{
	var selectboxObj = eval('document.'+frmName+'.'+selectName);
	var optionCount = selectboxObj.options.length++;



	selectboxObj.options[optionCount] = new Option(text, value);

	if(selflag=='selected')
		selectboxObj.options[optionCount].selected=true;

//	selectboxObj.options[optionCount].value=value;
//	selectboxObj.options[optionCount].text=text;

}




//--------------------------------------------------------------------------------------------------------------------
// select¹Ú½º ³»¿ë»ðÀÔ
//--------------------------------------------------------------------------------------------------------------------
// ¼³  ¸í : Å¸ÀÌÆ² ¸¸µé±â Âü°í(http://test.soobakc.com/Knowledge/study_infor/si_07.asp?s_idx=2)
// ÀÏ¹ÝÇü : createTitle(³»¿ë);
// ¿¹  Á¦ : createTitle('Á¦¸ñÀÔ´Ï´Ù.');
// ·Î  ±× : 2009-09-28 ¹Ú¹üÀÏ
//--------------------------------------------------------------------------------------------------------------------

function createTitle(msg)
{
	document.write ('<table width="730">');
	document.write ('<colgroup><col width="19"><col width="*"><col width="*"></colgroup>');
	document.write ('<tr>');
	document.write ('<td><img src="/images/knowledge/tit_lt.gif" width="19" height="33"></td>');
	document.write ('<td class="f14 mg_t10" background="/images/knowledge/tit_bg1.gif" style="padding-top:3px !important;">'+msg+'</td>');
	document.write ('<td background="/images/knowledge/tit_rt.gif"></td>');
	document.write ('</tr>');
	document.write ('</table>');
}






//--------------------------------------------------------------------------------------------------------------------
// form °ªÀ» querystringÀ¸·Î ¿¬°áÇÏ±â
//--------------------------------------------------------------------------------------------------------------------
// ¼³  ¸í : Æû°ªÀ» querystringÀ¸·Î Á×~ ¿¬°áÇØ¼­ ¸®ÅÏÇÑ´Ù.
// ÀÏ¹ÝÇü : getSerialize(form Object);
// ¿¹  Á¦ : getSerialize(document.theFrom);
// ·Î  ±× : 2009-09-28 ¹Ú¹üÀÏ
//--------------------------------------------------------------------------------------------------------------------

function getSerialize(docForm)
{
	var submitContent = '';
	var formElem;
	var lastElemName = '';

	for (i = 0; i < docForm.elements.length; i++)
	{

		formElem = docForm.elements[i];
		switch (formElem.type)
		{
			// Text fields, hidden form elements
			case 'text':
			case 'hidden':
			case 'password':
			case 'textarea':
			case 'select-one':
				submitContent += formElem.name + '=' + escape(formElem.value) + '&'
				break;

			// Radio buttons
			case 'radio':
				if (formElem.checked)
				{
					submitContent += formElem.name + '=' + escape(formElem.value) + '&'
				}
				break;

			// Checkboxes
			case 'checkbox':
				if (formElem.checked)
				{
					submitContent += formElem.name + '=' + escape(formElem.value) + '&'
				}
				break;
		}
	}
	// Remove trailing separator
	submitContent = submitContent.substring(0, submitContent.length - 1);
	return submitContent;
}












//ÇÑ±Û¸¸
function KorCheck(str){
  if((/[^(°¡-ÆR)]/).test(str)) {
    return false;
  }else{
    return true;
  }
}


//¿µ¹®¸¸
function EngCheck(str){
  if((/[^(A-Z)^(a-z)]/).test(str)){
    return false;
  }else{
    return true;
  }
}

//¼ýÀÚ¸¸
function NumCheck(str){
  if((/[^(0-9)]/).test(str)){
    return false;
  }else{
    return true;
  }
}


//¿µ¹®,¼ýÀÚ¸¸
function EngNumCheck(str){
  if((/[^(A-Z)^(a-z)^(0-9)]/).test(str)){
    return false;
  }else{
    return true;
  }
}


//¿µ¹®,¼ýÀÚ,ÇÑ±Û¸¸
function KorEngNumCheck(str){
  if((/[^(A-Z)^(a-z)^(°¡-ÆR)^(0-9)]/).test(str)){
    return false;
  }else{
    return true;
  }
}



//¿Â·Îµå ÀÌº¥Æ® ÇÔ¼ö Ãß°¡
function addLoadEvent(func) {
	 var oldonload = window.onload;
	 if (typeof window.onload != "function") {
		  window.onload = func;
	 } else {
		  window.onload = function() {
				if(oldonload){
					 oldonload();
				}
				func();
		  }
	 }
}

//¼ö°­ÁßÀÎ °­ÁÂ ÀÖ´ÂÁö Ã¼Å© ÇÁ·Î¼¼½º , ¼ö°­ÁßÀÎ °­ÁÂ Ä«¿îÆ® ¸®ÅÏÇÔ
//2010-03-30 ÇÏ¾ð¼®
function SugangStateCheck(state,lp_idx){
	var xmlHttpLoginState = Ajax.getTransport();
	xmlHttpLoginState.open("GET", "/common/asp/Sugang_state_xml.asp?lp_idx="+lp_idx+"&state="+state, false);
	xmlHttpLoginState.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttpLoginState.send(null);
	return xmlHttpLoginState.responseText;
}

//°­ÁÂÀüÃ¼º¸±â »ó¼¼ ÆäÀÌÁö ÀÌµ¿
//2010-06-10 ÇÏ¾ð¼®
function goLecDetail(Menu_Depth,lp_idx){
	if(parent.opener.closed){
		window.open("/lecture/lecture_view_info.asp?menu_Depth="+Menu_Depth+"&lp_idx="+lp_idx);
	}else{

		parent.opener.location.href = "/lecture/lecture_view_info.asp?menu_Depth="+Menu_Depth+"&lp_idx="+lp_idx
		parent.opener.focus();
	}
}

function viewEBook(b_code)
{
	//window.open("http://www.soobakc.com/BookStore/Ebook_View.asp?b_code="+b_code, "blank");
	window.open("http://www.soobakc.com/BookStore/Ebook_View.asp?b_code="+b_code, 'ebook', 'menuBar=false; toolbar=false; width=' + screen.width + '; height=' + screen.height + ';  scrollbars=no;');
}

function viewBIndex(b_code)
{
	MM_openBrWindow('/Lecture/popup_book_cnt.asp?b_code='+b_code,'viewBookIndex','width=550,height=570,resizable=no ')
}

