﻿//롤오버 드림위버 코드

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.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_openBrWindow(theURL,winName,features) { //v2.0
   window.open(theURL,winName,features);
  }
  
//플래쉬 삽입 코드
// flash swf active 
function FlashMainbody(Ftrans,wid,hei) {
	mainbody = "<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='"+ wid +"' height='"+ hei +"'>";
	mainbody += "<param name='movie' value='"+ Ftrans +"'>";
	mainbody += "<param name='quality' value='high'>";
	mainbody += "<param name='wmode' value='transparent'>";
	mainbody += "<param name='menu' value='false'>";
	mainbody += "<embed src='"+ Ftrans +"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+ wid +"' height='"+ hei +"'></embed>"
	mainbody += "</object>";

	//document.body.innerHTML = mainbody;
	document.write(mainbody);
	return;
}
function popurl(turl)
{
	window.open(turl,'lecture','width=800,height=700,top=20,left=210,status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}
function selfurl(turl)
{
	self.location = turl;
}
function hiddenurl(turl)
{
	hframe.location = turl;
}
function self_url(turl)
{
	self.location = turl;
}
function target_url(turl)
{
	tab_result.location = turl;
}
function hidden_url(turl)
{
	hframe.location = turl;
}

/* @id $ */
function $() {
	var ret = [];
	for(var i=0; i < arguments.length; i++) {
		if (typeof arguments[i] == 'string') {
			ret[ret.length] = document.getElementById(arguments[i]);
		} else {
			ret[ret.length] = arguments[i];
		}
	}
	return ret[1]?ret:ret[0];
}
function Media_Off(obj) {  
  $(obj).stop(); 
} 
 
function Media_On(obj) {  
  $(obj).play();
}

function Start_Fun(student_workbook_no,unit_idx,section_idx)
{	
	var turl = program_url + "/fun_v2/index.asp?student_workbook_no="+student_workbook_no+"&unit_idx="+unit_idx+"&section_idx="+section_idx;
	window.open(turl,'Fun','status=yes,channelmode=yes,fullscreen,scrollbars=no,resizable');
	//self_url(turl);
}
function Start_Fun2(student_workbook_no,unit_idx,section_idx)
{	
	var turl = program_url + "/fun_v2/index.asp?student_workbook_no="+student_workbook_no+"&unit_idx="+unit_idx+"&section_idx="+section_idx;
	window.open(turl,'Fun','status=yes,channelmode=yes,fullscreen,scrollbars=no,resizable');
	//self_url(turl);
}

function EBook_Start(ebook_no,student_workbook_no)
{	
	var turl = data_url + "/EBook/index.asp?ebook_no="+ebook_no+"&student_workbook_no="+student_workbook_no;
	window.open(turl,'EBook','status=yes,channelmode=yes,fullscreen,scrollbars=no,resizable');
	//self_url(turl);
}

function Writing_Start(myno,student_workbook_no,workbook_contents_no)
{	
	var turl = program_url + "/writing_v1/index.asp?myno="+myno+"&student_workbook_no="+student_workbook_no+"&workbook_contents_no="+workbook_contents_no;
	window.open(turl,'lecture','status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}

function Writing_Start_V3(linked_no,course_writing_contents_no)
{	
	var turl = program_url + "/writing_v5/index.asp?linked_no="+linked_no+"&course_writing_contents_no="+course_writing_contents_no;
	window.open(turl,'writing','status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}
function Writing_Start_V4(student_no,course_writing_contents_no)
{	
	var turl = program_url + "/writing_v5/index_normal.asp?student_no="+student_no+"&course_writing_contents_no="+course_writing_contents_no;
	window.open(turl,'writing','status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}
function Writing_Start_V5(linked_no,course_writing_contents_no)
{	
	var turl = program_url + "/writing_v5/index.asp?linked_no="+linked_no+"&course_writing_contents_no="+course_writing_contents_no;
	window.open(turl,'writing','status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}
function Writing_Done_V3(linked_no,course_writing_contents_no)
{	
	var turl = program_url + "/writing_v5/index_correction.asp?linked_no="+linked_no+"&course_writing_contents_no="+course_writing_contents_no;
	window.open(turl,'writing','status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}
function Writing_Done_V4(student_no,course_writing_contents_no)
{	
	var turl = program_url + "/writing_v5/index_normal_correction.asp?student_no="+student_no+"&course_writing_contents_no="+course_writing_contents_no;
	window.open(turl,'writing','status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}
function Writing_Done_V5(linked_no,course_writing_contents_no)
{	
	var turl = program_url + "/writing_v5/index_correction.asp?linked_no="+linked_no+"&course_writing_contents_no="+course_writing_contents_no;
	window.open(turl,'writing','status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}

// Low Level Essay

function Fun_LowEssayHelp(student_lowessay_topic_no)
{
	var turl = program_url + "/LowEssay_v1/index_help.asp?student_lowessay_topic_no="+student_lowessay_topic_no+"&student_no="+student_no;
	window.open(turl,'LowessayHelp','status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}
function Fun_LowEssay(student_lowessay_topic_no)
{
	var turl = program_url + "/LowEssay_v1/index_essay.asp?student_lowessay_topic_no="+student_lowessay_topic_no+"&student_no="+student_no;
	window.open(turl,'LowessayHelp','status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}

function Fun_LowWord(student_lowessay_topic_no)
{
	var turl = program_url + "/LowEssay_v1/index_word.asp?student_lowessay_topic_no="+student_lowessay_topic_no+"&student_no="+student_no;
	window.open(turl,'LowessayHelp','status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}
// Inspire V2
function Inspire_V2(student_Inspire_V2_Seq_no){
	//var program_url = "http://192.168.10.199:5550";
	var turl = program_url + "/LowEssay_v2/index.asp?student_Inspire_V2_Seq_no="+student_Inspire_V2_Seq_no;
	if(screen.width>=1280){
		centerwin(turl,'LowEssay_v2','width=1240,height=850,status=yes,scrollbars=yes,resizable=no');
	}else{
		centerwin(turl,'LowEssay_v2','width='+(screen.width-20)+',height='+(screen.height-50)+',status=yes,channelmode=yes,fullscreen,scrollbars=yes,resizable=no');
	}
}
// Report
function LowWriting_Report(student_lowessay_no,student_lowessay_topic_no)
{
	var turl = program_url + "/report/lowwriting.asp?student_lowessay_no="+student_lowessay_no+"&student_lowessay_topic_no="+student_lowessay_topic_no;
	window.open(turl,'LowWriting_Report','status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}
function Inspire_V2_Report(student_Inspire_V2_Seq_no)
{
	var turl = program_url + "/report/Inspire_V2.asp?student_Inspire_V2_Seq_no="+student_Inspire_V2_Seq_no;
	window.open(turl,'Inspire_V2_Report','status=yes,channelmode=yes,fullscreen,scrollbars,resizable');
}

function centerwin(url,winname,features)
{	
	features = features.toLowerCase();
	len = features.length;
	sumchar= "";
	for (i=1; i <= len; i++) 
	{ 
		onechar = features.substr(i-1, 1);
		if (onechar != " ") sumchar += onechar;
	}
	
	features = sumchar; 
	sp = new Array();
	sp = features.split(',', 10);
	splen = sp.length;
	for (i=0; i < splen; i++) 
	{ 
	if (sp[i].indexOf("width=") == 0)
	{ 
	width = Number(sp[i].substring(6)); 
	} else if (sp[i].indexOf("height=") == 0) 
	{
	height = Number(sp[i].substring(7)); 
	}
	}
	sleft = (screen.width - width) / 2;
	stop = (screen.height - height) / 2;
	features = features + ",left=" + sleft + ",top=" + stop;
	popwin = window.open(url,winname,features); 
}


// 학교검색
var Selected_Fld;
var Selected_Fld_No;
function Search_School(fld_obj,fld_name)
{
	Selected_Fld = fld_obj;
	Selected_Fld_No = fld_name;
	sendRequest(ajax_Search_School,'&sword='+fld_obj.value,'GET','/common/Search_School.asp',true,true);	
}
function ajax_Search_School(oj)
{
	//var res = uriEncode(oj.responseText);
	var res = decodeURIComponent(oj.responseText);
	if(res!="NO"){
		AjaxLayer(Selected_Fld,res,150,100);
		
	}else{
		hiddenAjaxLayer();
	}
	//alert(Selected_Fld.clientX);
	//$('CP_List').innerHTML = res;
}
function Choice_School(tidx,tname)
{
	Selected_Fld.value = tname;
	$(Selected_Fld_No).value = tidx;
	hiddenAjaxLayer();
}

function roundTable(objID) {
	var obj = document.getElementById(objID);
	var Parent, objTmp, Table, TBody, TR, TD;
	var bdcolor, bgcolor, Space;
	var trIDX, tdIDX, MAX;
	var styleWidth, styleHeight;
	
	// get parent node
	Parent = obj.parentNode;
	objTmp = document.createElement('SPAN');
	Parent.insertBefore(objTmp, obj);
	Parent.removeChild(obj);
	
	// get attribute
	bdcolor = obj.getAttribute('rborder');
	bgcolor = obj.getAttribute('rbgcolor');
	radius = parseInt(obj.getAttribute('radius'));
	if (radius == null || radius < 1) radius = 1;
	else if (radius > 6) radius = 6;
	
	MAX = radius * 2 + 1;
	
	/*
	create table {{
	*/
	Table = document.createElement('TABLE');
	TBody = document.createElement('TBODY');
	
	Table.cellSpacing = 0;
	Table.cellPadding = 0;
	
	for (trIDX=0; trIDX < MAX; trIDX++) {
	TR = document.createElement('TR');
	Space = Math.abs(trIDX - parseInt(radius));
	for (tdIDX=0; tdIDX < MAX; tdIDX++) {
	TD = document.createElement('TD');
	
	styleWidth = '1px'; styleHeight = '1px';
	if (tdIDX == 0 || tdIDX == MAX - 1) styleHeight = null;
	else if (trIDX == 0 || trIDX == MAX - 1) styleWidth = null;
	else if (radius > 2) {
		if (Math.abs(tdIDX - radius) == 1) styleWidth = '2px';
		if (Math.abs(trIDX - radius) == 1) styleHeight = '2px';
	}
	
	if (styleWidth != null) TD.style.width = styleWidth;
	if (styleHeight != null) TD.style.height = styleHeight;
	
	if (Space == tdIDX || Space == MAX - tdIDX - 1) TD.style.backgroundColor = bdcolor;
	else if (tdIDX > Space && Space < MAX - tdIDX - 1) TD.style.backgroundColor = bgcolor;
	
	if (Space == 0 && tdIDX == radius) TD.appendChild(obj);
		TR.appendChild(TD);
	}
		TBody.appendChild(TR);
	}
	
	/*
	}}
	*/
	
	Table.appendChild(TBody);
	
	// insert table and remove original table
	Parent.insertBefore(Table, objTmp);
}

/* textarea 글자 입력수 제한 */
function updateChar(length_limit)
{
   var form1 = document.memoform;
   var length = calculate_msglen(form1.content.value);
   textlimit.innerText = length;
   if (length > length_limit) {
       alert("최대 " + length_limit + "byte이므로 초과된 글자수는 자동으로 삭제됩니다.");
       form1.content.value = form1.content.value.replace(/\r\n$/, "");
       form1.content.value = assert_msglen(form1.content.value, length_limit);
   }
}

function calculate_msglen(message)
{
   var nbytes = 0;

   for (i=0; i<message.length; i++) {
       var ch = message.charAt(i);
       if(escape(ch).length > 4) {
           nbytes += 2;
       } else if (ch == '\n') {
           if (message.charAt(i-1) != '\r') {
               nbytes += 1;
           }
       } else if (ch == '<' || ch == '>') {
           nbytes += 4;
       } else {
           nbytes += 1;
       }
   }

   return nbytes;
}

function assert_msglen(message, maximum)
{
   var inc = 0;
   var nbytes = 0;
   var msg = "";
   var msglen = message.length;

   for (i=0; i<msglen; i++) {
       var ch = message.charAt(i);
       if (escape(ch).length > 4) {
           inc = 2;
       } else if (ch == '\n') {
           if (message.charAt(i-1) != '\r') {
               inc = 1;
           }
       } else if (ch == '<' || ch == '>') {
           inc = 4;
       } else {
           inc = 1;
       }
       if ((nbytes + inc) > maximum) {
           break;
       }
       nbytes += inc;
       msg += ch;
   }
   textlimit.innerText = nbytes;
   return msg;
}

function setDate(obj,from,to)
{
	var obj = document.getElementsByName(obj);
	obj[0].value = (from) ? from : "";
	obj[1].value = (from) ? to : "";
}

/**
 * chkBox(El,mode)
 *
 * 동일한 이름의 체크박스의 체크 상황 컨트롤
 *
 * -mode	true	전체선택
 *			false	선택해제
 *			'rev'	선택반전
 * @Usage	<input type=checkbox name=chk[]>
 *			<a href="javascript:void(0)" onClick="chkBox(document.getElementsByName('chk[]'),true|false|'rev')">chk</a>
 */

function chkBox(El,mode)
{
	if (!El) return;
	for (i=0;i<El.length;i++) El[i].checked = (mode=='rev') ? !El[i].checked : mode;
}

/**
 * isChked(El,msg)
 *
 * 체크박스의 체크 유무 판별
 *
 * -msg		null	바로 진행
 *			msg		confirm창을 띄어 실행 유무 체크 (msg - confirm창의 질의 내용)
 * @Usage	<input type=checkbox name=chk[]>
 *			<a href="javascript:void(0)" onClick="return isChked(document.getElementsByName('chk[]'),null|msg)">del</a>
 */
function isChked(El,msg)
{
	if (!El) return;
	if (typeof(El)!="object") El = document.getElementsByName(El);
	if (El) for (i=0;i<El.length;i++) if (El[i].checked) var isChked = true;
	if (isChked){
		return (msg) ? confirm(msg) : true;
	} else {
		alert ("선택된 사항이 없습니다");
		return false;
	}
}