function strReplace(szFind, szReplace, szAll) {
	var i;
	var length;

	length = szReplace.length - szFind.length;

	for (i=0; i < szAll.length; i++) {
		if (szAll.substr(i,szFind.length) == szFind) {
			if ( i > 0 ) {
				if (szFind == "\n") {
					szAll = szAll.substr(0, i-1) + szReplace + szAll.substr(i+szFind.length,szAll.length - (i+szFind.length));
				} else {
					szAll = szAll.substr(0, i) + szReplace + szAll.substr(i+szFind.length,szAll.length - (i+szFind.length));
				}
			} else { 
				szAll = szReplace + szAll.substr(i+szFind.length,szAll.length - (i+szFind.length));
			}
			i = i + length;
		}
	}
	return szAll;
}

function withdrawal(){
	if(confirm("are you really?")){
		location.href="/member/withdrawal.jsp?delkey=ok";
	}
}
function lec_fullscreen(url) {
    var larg_schermo = screen.availWidth - 10;
    var altez_schermo = screen.availHeight - 15;
    window.open(url, "WindowName", "width=" + larg_schermo + ",height=" + altez_schermo + ",top=0,left=0");
}

//마우스이벤트
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_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_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/**********************************************************************************
	popupwindow (스크롤바 no)
***********************************************************************************/
function popwindow(pop,width,height,top,left)
{
	var url = pop;  
	var wd = width;
	var he = height;
	var to = top;
	var le = left;	
	
	window.open(url,"","toolbar=0,menubar=0,scrollbars=no,resizable=no,width=" + wd +",height=" + he + ",top=" + to + ",left=" + le + ";")
}

/**********************************************************************************
	openPopup (스크롤바 no)
***********************************************************************************/
function openPopup(url, wt, ht, winName)
{
  if(winName==null)
    winName = 'no_name';
  
  if(wt==null) wt='800px';  
  if(ht==null) ht='600px';

    if (self.winName && !winName.closed)
    {
        winName.close();
        winName = null;
    }
    
    var wObj = window.open( url, winName,
            "width=" + wt + ",height=" + ht + ",scrollbars=no");
            
    wObj.focus();
    return wObj;            
}	


/**********************************************************************************
	popupwindow01(스크롤바 yes)
***********************************************************************************/
function popwindow01(win,pop,width,height,top,left)
{
	var wname = win;  
	var url = pop;  
	var wd = width;
	var he = height;
	var to = top;
	var le = left;
	
	window.open(url,"wname","toolbar=0,menubar=0,scrollbars=yes,resizable=no,width=" + wd +",height=" + he + ",top=" + to + ",left=" + le + ";")
}



/************************************************************** 
* 팝업창 Function
* @param sturl  이동하고자하는 URL
* @param stname 팝업창 title
* @param height 팝업창 height
* @param width  팝업창 중앙정렬(center) Default는 left정렬
* @param scroll 팝업창 스크롤 유무(Y, N)
**************************************************************/
var arWinName = Array();
function openWin(sturl, stname, height,width ,opt, scroll)
{
  if (opt == "center") {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;
    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;
    var par = ",left=" + xc + ",screenX=" + xc;
    par += ",top=" + yc + ",screenY=" + yc;
    par += ",height=" + height + ",innerHeight=" + height;
    par += ",width=" + width + ",innerWidth=" + width;
  } else {
    var par = ",left=" + 1 + ",screenX=" + 1;
    par += ",top=" + 1 + ",screenY=" + 1;
    par += ",height=" + height + ",innerHeight=" + height;
    par += ",width=" + width + ",innerWidth=" + width;
  }
  if (scroll == "Y")
  {
    par += ",scrollbars=1";
  }  
  if (!arWinName[stname] || arWinName[stname].closed ) {
    arWinName[stname] = window.open( sturl , stname , par);    
  }else {
    arWinName[stname].focus();
  }
}

/**********************************************************************************
	메뉴링크
***********************************************************************************/

function menuGo(a, b) {
	if (a == 1) {//about okf
			parent.location.href="/teen/aboutokf/aboutokf.jsp?linkType=okf1.htm";
		if (b == 1){//
			parent.location.href="/teen/aboutokf/aboutokf.jsp?linkType=okf1.htm";
		} else if (b == 2){//
			parent.location.href="/teen/aboutokf/aboutokf.jsp?linkType=okf2.htm";
		} else if (b == 3){//
			parent.location.href="/teen/aboutokf/aboutokf.jsp?linkType=okf3.htm";
		} else if (b == 4){//
			parent.location.href="/teen/aboutokf/aboutokf.jsp?linkType=okf4.htm";
		} else if (b == 5){//
			parent.location.href="/teen/aboutokf/aboutokf.jsp?linkType=okf5.htm";
		} else if (b == 6){//
			parent.location.href="/teen/aboutokf/aboutokf.jsp?linkType=okf6.htm";
		} 
	}else if (a == 2){//StudyKorean
			location.href="/lecture/list.jsp?lec_theme=Basic&lec_chapter=hg";
		if (b == 1){//
			parent.location.href="/lecture/list.jsp?lec_theme=Basic&lec_chapter=hg";
		} else if (b == 2){//
			parent.location.href="/lecture/list.jsp?lec_theme=Plus&lec_chapter=fz";
		}else if (b == 3){//
			location.href="/lecture/list.jsp?lec_theme=Super&lec_chapter=hu";
		}
	}else if (a == 3){//edu info cener
			parent.location.href="/teen/edu/template.jsp?linkType=center_main.jsp";
		if (b == 1){//
			parent.location.href="/teen/edu/template.jsp?linkType=/teen/edu/kortest/board.jsp?tablename=teen_edu_kortest";
		} else if (b == 2){//
			parent.location.href="/teen/edu/template.jsp?linkType=/teen/edu/korinfo/board.jsp?tablename=teen_edu_korinfo";
		}else if (b == 3){//
			parent.location.href="/teen/edu/template.jsp?linkType=/teen/edu/visa/entrance_eng.jsp";
		}else if (b == 4){//
			parent.location.href="/teen/edu/template.jsp?linkType=/teen/edu/visa/issuingvisa_eng.jsp";
		}else if (b == 5){//
			location.href="/teen/edu/template.jsp?linkType=/teen/edu/korlife/board.jsp?tablename=teen_edu_korlife";
		}else if (b == 6){//
			parent.location.href="/teen/edu/template.jsp?linkType=/teen/edu/korexp/board.jsp?tablename=teen_edu_korexp";
		}else if (b == 7){//
			parent.location.href="/teen/edu/template.jsp?linkType=/teen/edu/yuhak/board.jsp?tablename=teen_edu_yuhak";
		}
	}else if (a == 4){//StudyClub
			parent.location.href="/teen/club_new/club_main.jsp";
		if (b == 1){//
			parent.location.href="/teen/club_new/club_main.jsp";
		} else if (b == 2){//
			parent.location.href="/teen/club_new/club_main.jsp";
		} else if (b == 3){//
			parent.location.href="/teen/club_new/club_main.jsp";
		} else if (b == 4){//
			parent.location.href="/teen/club_new/club_main.jsp";
		} else if (b == 5){//
			parent.location.href="/teen/club_new/club_main.jsp";
		} else if (b == 6){//
			parent.location.href="/teen/club_new/club_main.jsp";
		}		
	}else if (a == 5){//Zoom-in World
			parent.location.href="/teen/zoom/list.jsp";
		if (b == 1){//
			parent.location.href="/teen/zoom/list.jsp";
		} else if (b == 2){//
			parent.location.href="/teen/zoom/zoom_africa.jsp?tbN=teen_world_africa";
		}
	}else if( a == 6){//Pen-pal
				parent.location.href="/teen/penpal/list.jsp";
			if (b == 1){
				parent.location.href="/teen/penpal/list.jsp";
			}else if(b == 2){ 
				parent.location.href="/teen/penpal/input_penpal.jsp";
			}else if(b == 3){ 
				parent.location.href="/teen/penpal/openletter.jsp?tbN=teen_openletter";
			}
	}else if (a ==7){//Edutainment
			parent.location.href="/teen/edu/index.jsp";
		 if (b == 1){ 
				parent.location.href="/teen/edu/wow/board.jsp";
			}else if (b == 2){
				parent.location.href="/teen/edu/song/song.jsp";
			}else if (b == 3){
				parent.location.href="/teen/edu/fairy/fairy.jsp";
			}else if (b == 4){
				parent.location.href="/teen/edu/comic/comic.jsp";
			}else if (b == 5){
				parent.location.href="/teen/edu/game/game.jsp";
			}else if (b == 6){
				parent.location.href="/teen/edu/quiz/quiz.jsp";
			}else if (b == 7){
				parent.location.href="/teen/edu/drama/drama.jsp";
			}
	}
}

/**********************************************************************************
	onfocus="this.blur();"		// by postcorea (06/05/18)
***********************************************************************************/
function bluring(){ 
    if(event.srcElement==null)return;
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") 
	document.body.focus(); 
} 
document.onfocusin=bluring; 

/**********************************************************************************
	js import		// by postcorea (06/05/18)
***********************************************************************************/
var script=document.createElement("script");
script.src = "/common/js/selectBox.js";
document.getElementsByTagName("head")[0].appendChild(script);

