
/**
 * ÀÎ¼ö·Î ¹ÞÀº °´Ã¼ÀÇ À§Ä¡Á¤º¸(x, y)¸¦ °¡Áö´Â ±¸Á¶Ã¼¸¦ ¹ÝÈ¯ÇÑ´Ù.
 * 
 */
function getObjPos(id) {
	var xy = { x:-1, y:-1 };
	do { 
		xy.x += parseInt( id.offsetLeft );
		xy.y += parseInt( id.offsetTop );
		id = id.offsetParent;
	} while (id);
	return xy;
}


/**
 * ·¹ÀÌ¾î ½ºÅ©·Ñ ½ºÅ©¸³Æ® ½ÃÀÛ --------------------------------------------------
 */
var scrTgtObj, scrBaseObj, scrFX, scrFY, scrDivHeight, scrBottomPos;

// tgtObj : ½ºÅ©·Ñ ÇÏ·Á´Â °´Ã¼
// baseObj : tgtObjÀÇ À§Ä¡ÀÇ ±âÁØÀÌ µÇ´Â °´Ã¼
// fX : baseObj·ÎºÎÅÍ tgtObjÀÇ ÁÂÃøÀ§Ä¡
// fY : tgtObjÀÇ À§·ÎºÎÅÍÀÇ À§Ä¡
function initScrollingDivSimple(tgtObj, baseObj, fX, fY) {
	initScrollingDiv(tgtObj, baseObj, fX, fY, 0, 0);
}


// tgtObj : ½ºÅ©·Ñ ÇÏ·Á´Â °´Ã¼
// baseObj : tgtObjÀÇ À§Ä¡ÀÇ ±âÁØÀÌ µÇ´Â °´Ã¼
// fX : baseObj·ÎºÎÅÍ tgtObjÀÇ ÁÂÃøÀ§Ä¡
// fY : tgtObjÀÇ À§·ÎºÎÅÍÀÇ À§Ä¡
// divHeight : tgtObjÀÇ ±æÀÌ
// bottomPos : tgtObjÀÇ ¾Æ·¡ÂÊÀ¸·Î ½ºÅ©·Ñ ÇÒ ¶§ ¹Ù´ÚÀ¸·Î ºÎÅÍ bottomPos + divHeight ÀÌÇÏ´Â ³»·Á°¡Áö ¾Ê´Â´Ù!
function initScrollingDiv(tgtObj, baseObj, fX, fY, divHeight, bottomPos) {
	scrTgtObj = tgtObj;
	scrBaseObj = baseObj;
	scrFX = fX;
	scrFY = fY;
	scrDivHeight = divHeight;
	scrBottomPos = bottomPos;

	setInterval("scrollingDiv()",30);
}

// ·¹ÀÌ¾î ½ºÅ©·Ñ ½ºÅ©¸³Æ®
function scrollingDiv(){
	var tgtObj, baseObj;
	var fX, fY;
	var baseObjPos;
	var scrollTop, scrollHeight;

	tgtObj = scrTgtObj;
	baseObj = scrBaseObj;

	fX = scrFX;
	fY = scrFY;

	baseObjPos = getObjPos(baseObj);

	scrollTop = document.body.scrollTop;
	scrollHeight = document.body.scrollHeight;

	if (baseObjPos.x > -1 && baseObjPos.y > -1){
		if ( (scrollTop + fY + scrDivHeight) < (scrollHeight - scrBottomPos) ) {
			tgtObj.style.top = scrollTop + fY;
		}
		else {
			tgtObj.style.top = scrollHeight - scrDivHeight - scrBottomPos;
		}
		tgtObj.style.left = baseObjPos.x + fX;

		try{
			tgtObj.style.visibility = "visible";
		}catch (e){
			window.setTimeout("scrollingDiv()",30)
		}
	}
}

/**
 * ·¹ÀÌ¾î ½ºÅ©·Ñ ½ºÅ©¸³Æ® ³¡ --------------------------------------------------
 */

 

/*------------------------------------------------------------------------------------------------
	resizeIF(¾ÆÀÌµð°ª)
	iframe ³ôÀÌ µ¿Àû Á¶Àý.
 ------------------------------------------------------------------------------------------------*/
function resizeIF(Id) {
	var obj = document.getElementById(Id);
	var Body;
	var H, Min;

	// ÃÖ¼Ò ³ôÀÌ ¼³Á¤ (³Ê¹« ÀÛ¾ÆÁö´Â °ÍÀ» ¹æÁö)
	Min = 100;

	// DOM °´Ã¼ ÇÒ´ç
	try {
		if (!document.all && obj.contentWindow.document.location.href == 'about:blank') {
			setTimeout("resizeIF('"+Id+"')", 10);
			return;
		}

		Body = obj.contentWindow.document.getElementsByTagName('BODY');
		Body = Body[0];

		if (this.Location != obj.contentWindow.document.location.href) {
			H = Body.scrollHeight + 5;
			obj.style.height =  (H<Min?Min:H) + 'px';

			this.Location = obj.contentWindow.document.location.href;
		}
	}
	catch(e) {
		setTimeout("resizeIF('"+Id+"')", 10);
		return;
	}

	setTimeout("resizeIF('"+Id+"')", 100);
}


 function GoPageLink(golink) {
	document.location.href=golink;
}


/**
 * ÁöÁ¤µÈ form³»ÀÇ checkbox nameÀÌ objNameÀÎ°ÍµéÀ» ¸ðµÎ checked»óÅÂ·Î ¸¸µç´Ù.
 */
function selectAll(form, objName) {
	for( var i=0; i<form.elements.length; i++) {
		var ele = form.elements[i];
		if(ele.name == objName)
			ele.checked = true;
	}
	return;
}

/**
 * ÁöÁ¤µÈ form³»ÀÇ checkbox nameÀÌ objNameÀÎ°ÍµéÀ» ¸ðµÎ unchecked»óÅÂ·Î ¸¸µç´Ù.
 */
function deselectAll(form, objName) {
	for( var i=0; i<form.elements.length; i++) {
		var ele = form.elements[i];
		if(ele.name == objName)
			ele.checked = false;
	}
	return;
}

/**
 * ÁöÁ¤µÈ form³»ÀÇ »óÀ§ chkbox Å¬¸¯½Ã ÇÏÀ§ chkbox »óÅÂ º¯È­
 * »óÀ§ chkbox nameÀº top+ÇÏÀ§chkbox name Çü½ÄÀ» °¡Á®¾ß ÇÑ´Ù.
 */
function setChkBox(form, obj) {
	var subObjName = obj.name.substring(3);
	if (obj.checked) {
		selectAll(form, subObjName);
	}
	else {
		deselectAll(form, subObjName);
	}
}

/**
 * ÁöÁ¤µÈ form³»ÀÇ checkbox nameÀÌ objNameÀÎ°ÍµéÁß checkedµÈ°ÍµéÀÇ ÃÑ °¹¼ö¸¦ ¹ÝÈ¯ÇÑ´Ù.
 */
function cntChkBox(form, objName) {
	var rtnValue;
	rtnValue = 0;
	for( var i=0; i<form.elements.length; i++) {
		var ele = form.elements[i];
		if(ele.name == objName) {
			if (ele.checked) {
				++rtnValue;
			}
		}
	}
	return rtnValue;
}

function getStringByte(thisStrvalue){	//byte ±æÀÌ¸¦ ¸®ÅÏÇØÁÖ´Â ÇÔ¼ö
	var strLen = 0;

	for(i = 0; i < thisStrvalue.length;i++){
		if(escape(thisStrvalue.charAt(i)).length >= 4){
			strLen +=2;
		}
		else{
			if(escape(thisStrvalue.charAt(i)) !="%0D")
				strLen++;
		}
	}
	return strLen;
}


/**
 * ¼¼ÀÚ¸®¸¶´Ù , Âï±â!!
 * ÀÛ¼ºÀÏ : 2008-11-08 ÀÌ¿ëÈÆ
 */
function getFormatNumber(pString) {
	var totCnt;
	var rtnValue;

	totCnt = Number(pString.length) / 3;
	rtnValue = '';

	pString = getRevString(pString);

	for (cnti=0; cnti<totCnt; cnti++) {
		rtnValue += pString.substring(cnti*3, cnti*3+3) + ',';
	}
	rtnValue = rtnValue.substring(0, rtnValue.length-1);
	rtnValue = getRevString(rtnValue);

	return rtnValue;
}

/**
 * ¹®ÀÚ¿­ µÚÁý±â~
 * ÀÛ¼ºÀÏ : 2008-11-08 ÀÌ¿ëÈÆ
 */
function getRevString(pString) {
	var totCnt;
	var rtnValue;

	totCnt = Number(pString.length);
	rtnValue = '';

	for (cnti=0; cnti<totCnt; cnti++) {
		dmy = pString.substring(pString.length-cnti-1, pString.length-cnti);
		rtnValue += dmy;
	}

	return rtnValue;
}

/**
 * ³¯Â¥°è»ê
 * ÀÛ¼ºÀÏ : 2008-11-08 ÀÌ¿ëÈÆ
 */
function addDay(pDate, pDay) {
	var rtnValue; 

	yyyy = Number(pDate.substring(0, 4));
	mm = Number(pDate.substring(5, 7));
	dd = Number(pDate.substring(8, 10));

	rtnValue = shiftTime(pDate.replace('-', '').replace('-', '') + '0000', 0, 0, Number(pDay), 0);

	return rtnValue;
}	

function shiftTime(time,y,m,d,h) { //moveTime(time,y,m,d,h)
    var date = toTimeObject(time);
    date.setFullYear(date.getFullYear() + y); //y³âÀ» ´õÇÔ
    date.setMonth(date.getMonth() + m);       //m¿ùÀ» ´õÇÔ
    date.setDate(date.getDate() + d);         //dÀÏÀ» ´õÇÔ
    date.setHours(date.getHours() + h);       //h½Ã¸¦ ´õÇÔ
    return toTimeString(date);
}

function toTimeObject(time) { //parseTime(time)
    var year  = time.substr(0,4);
    var month = time.substr(4,2) - 1; // 1¿ù=0,12¿ù=11
    var day   = time.substr(6,2);
    var hour  = time.substr(8,2);
    var min   = time.substr(10,2);
    return new Date(year,month,day,hour,min);
}

function toTimeString(date) { //formatTime(date)
    var year  = date.getFullYear();
    var month = date.getMonth() + 1; // 1¿ù=0,12¿ù=11ÀÌ¹Ç·Î 1 ´õÇÔ
    var day   = date.getDate();
    var hour  = date.getHours();
    var min   = date.getMinutes();
    if (("" + month).length == 1) { month = "0" + month; }
    if (("" + day).length   == 1) { day   = "0" + day;   }
    if (("" + hour).length  == 1) { hour  = "0" + hour;  }
    if (("" + min).length   == 1) { min   = "0" + min;   }
    return ("" + year + "-" + month + "-" + day)
}

function chkSearch(dest, form, obj, value) {
	obj.value = value;

	form.action = dest;
	form.submit();
}


/**
 * °­ÁÂº¸±â¿¡¼­ °­ÁÂ¸ñ·ÏÀ¸·Î µîµî~ ±×³É Æû°ªÀ» °¡Áö°í À§Ä¡ÀÌµ¿ÇÏ°í ½ÍÀ»¶§!!!
 * ÀÛ¼ºÀÏ : 2008-11-07 ÀÌ¿ëÈÆ
 */
function moveList(form, pDest) {
	form.action = pDest;
	form.submit();
}


/**
 * ¹ü¿ë Æû ÀÌµ¿¿ë~
 * ÀÛ¼ºÀÏ : 2009-02-19 ÀÌ¿ëÈÆ
 */
function submitForm(form, pDest, evalValue, args) {
	form.action = pDest + args;
	eval(evalValue);
	form.submit();
}

function jfExamPreview(v_examfile,v_examcode,v_answerfile) {

	window.open("/public/Teams/mv_exam_preview.asp?examfile="+v_examfile+"&testcode="+v_examcode+"&answerfile="+v_answerfile,"PreviewFrame","width=1000, height=700")
}
function jfNoteOpenNon(v_examcode){
	noteopen = window.open("","noteopen","top=0, left=0, width=1100, height=700")
	with(frmNoteOpen){
		examcode.value = v_examcode
		target = "noteopen"
		submit()
		}
}

function jfNoteOpen(v_examcode, v_examname, v_examsubject){
	noteopen = window.open("","noteopen","top=0, left=0, width=1100, height=750")
	with(frmNoteOpen1){
		examcode.value = v_examcode
		examname.value = v_examname
		examsubject.value = v_examsubject
		target = "noteopen"
		submit()
		}
}

function _ws_(id) 
{ 
        var _object = id.innerHTML; 
        _object = _object.replace("<!--", ""); 
        _object = _object.replace("-->" , ""); 
        document.write(_object); id.id=""; 
}
 
function open_obj(id)
{
	if (id == 'note')
	{
		document.write ('<object classid="clsid:254176EC-7C0A-4C9E-AD15-6184E3ABC225" width="615" height="420" id="idExamOCX" VIEWASTEXT style="border: 2 gray;">');
	}else if (id == 'exam'){
		document.write ('<object classid="clsid:254176EC-7C0A-4C9E-AD15-6184E3ABC225" name="idExamOCX" width="808" height="530"  VIEWASTEXT>');
	}else if (id == 'vod'){
		document.write ('<object width="640" height="480" id="MPlayer" name="MPlayer" classid="CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" viewastext declare>');
	}
}


function close_obj()
{
	document.write ('</object>');
}

function textareabox(code)
{
	document.write(document.getElementById(code).value);
}



function commonPopup(pLocation, pWidth, pHeight) {
	open(pLocation, 'pop' + pWidth + '_' + pHeight, 'width=' + pWidth + ', height=' + pHeight + ', left=500, top=300, scrollbars=no');
}


function UpdateLink(){
	//alert('ÇöÀç º£Å¸ Å×½ºÆ® ÁøÇàÁßÀÎ ¾÷µ¥ÀÌÆ® ¹öÁ¯ÀÌ ¾ø½À´Ï´Ù.');
	//location.href='http://download.inet-school.co.kr/InetFiles/MRClient/NUpdate/VMediarose2/MRSetup091013.exe'; // ³»ºÎ¼­¹ö »ç¿ë
	//location.href='http://update.mediaroz.com/MRClient/NUpdate/VMediarose2/MRSetup091013.exe';
	location.href = 'http://dist.cdnetworks.co.kr/cdndist/aquaplayer/AquaPlayerSETUP13120.EXE';
}

/**
 * °­»çÁ¤º¸º¸±â
 */
function openTeacherProfile(pTMSeq) {
	open('/public/Popup/TeacherProfile.asp?tmseq=' + pTMSeq, 'TeacherProfile', 'width=317, height=400, left=100, top=100, scrollbars=yes');
}

/**
 * °­»çÁ¤º¸º¸±â
 */
function moveHighTeacherHome(pTMSeq) {
	if (confirm('¼±»ý´Ô ¼Ò°³ÆäÀÌÁö·Î ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î?')) {
		location.href = '/high/Teacher/Introduction/N_Introduction_L.asp?tmseq=' + pTMSeq;
	}
}

/**
 * °­»çÁ¤º¸º¸±â ¸Þ´º ÁöÁ¤
 */
function moveHighTeacherHomeArea(pTMSeq, pLeft) {
	if (confirm('¼±»ý´Ô ¼Ò°³ÆäÀÌÁö·Î ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î?')) {
		location.href = '/high/Teacher/Introduction/N_Introduction_L.asp?tmseq=' + pTMSeq + '&leftarea=' + pLeft;
	}
}


// XMLHTTP °´Ã¼ ¹ÝÈ¯
function getXMLHTTP() {
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		}

		var versions = [
			'MSXML2.XMLHTTP.6.0',
			'MSXML2.XMLHTTP.4.0',
			'MSXML2.XMLHTTP.3.0',
			'MSXML2.XMLHTTP',
			'Microsoft.XMLHTTP'
		];

		for (var i=0; i<versions.length; i++) {
			try {
				var oXMLHTTP = new ActiveXObject(versions[i]);
				return oXMLHTTP;
			}
			catch (e) {}
		}
		throw new Error('No XMLHTTP');
}


/**
  * objString : obj1, obj2 Çü½ÄÀ¸·Î ¸¸µé¾îÁø °´Ã¼µéÀÇ ÀÌ¸§ Áß ¼øÂ÷ÀûÀ¸·Î ¿Ã¶ó°¡´Â ¼ýÀÚºÎºÐÀ» Á¦¿ÜÇÑ ¾ÕºÎºÐ ±ÛÀÚ obj
  * idx : ÇöÀç º¸¿©ÁÖ°íÀÚ ÇÏ´Â obj¼ýÀÚ
  * totCnt : ÀüÃ¼ obj °¹¼ö ÁöÁ¤
  */
function toggleDivs(objString, idx, totCnt) {
	for (cnti=1; cnti<=totCnt; cnti++) {
		if (cnti == idx) {
			document.getElementById(objString + '' + cnti).style.display = 'block';
			document.getElementById(objString + '' + cnti).focus();
		}
		else {
			document.getElementById(objString + '' + cnti).style.display = 'none';
		}
	}
}

//¹®ÀÚ¿­ ÁöÁ¤¹®ÀÚ ±¸ºÐÀ¸·Î ¹è¿­°ª ¹ÝÈ¯
var returnArrValue = function(sValue, sString, arrNo) {
	var buffer = "";
	if (sString != "") {
		var arrList = sValue.split(sString);

		if (arrNo > arrList.length)	{
			buffer = "";
		}

		for (var i=0;i<arrList.length;i++)	{
			if (arrNo == i) {
				buffer = arrList[i];
				break;
			}
		}
	}

	return buffer;
}

//---------------------------------------------------------------------------------------------------
// µî·Ï½Ã ±ÛÀÚ¼ö Ã¼Å©
//---------------------------------------------------------------------------------------------------
function FC_ChkTextLen(form, maxLen) {
	var f = form;
	var text = f.value;
	
	var i = 0;
	var li_byte = 0;
	var li_len = 0; 
	var ls_one_char = "";
	var text2 = "";
 
	for (i=0; i< text.length; i++) {
		ls_one_char = text.charAt(i);

		if (escape(ls_one_char).length > 4) {
			li_byte += 2;
		} else {
			li_byte++;
		}

		if(li_byte <= maxLen) {
			li_len = i + 1;
		}
	}

	if (li_byte > maxLen) {
		alert( maxLen + " ±ÛÀÚ¸¦ ÃÊ°ú ÀÔ·ÂÇÒ¼ö ¾ø½À´Ï´Ù. \n ÃÊ°úµÈ ³»¿ëÀº ÀÚµ¿À¸·Î »èÁ¦ µË´Ï´Ù. ");
		text2 = text.substr(0, li_len);
		f.value = text2;
	}

	f.focus();
}


	/*
		¼ýÀÚ¿Í¿µ¹®¸¸ ÀÔ·Â¹Þ±â
		obj = ÀÎÇ²¹Ú½º
		return = void
		Å° ÀÌº¥Æ® »ç¿ë
	*/
	function NumEngCheck(obj){ 
		temp_value = obj.value.toString(); 
		regexp = /[^0-9a-zA-Z]/g; 
		repexp = ''; 
		temp_value = temp_value.replace(regexp,repexp); 
		obj.value = temp_value; 
	} 

	/*
		¼ýÀÚ¸¸ ÀÔ·Â¹Þ±â
		obj = ÀÎÇ²¹Ú½º
		type = ÀÔ·ÂÇüÅÂ
			'int' : ¾çÀÇ Á¤¼ö 
			'float' : ¾çÀÇ ½Ç¼ö 
			'-int' : À½ÀÇ Á¤¼ö Æ÷ÇÔ 
			'-float' : À½ÀÇ ½Ç¼ö Æ÷ÇÔ 
		return = void
		Å° ÀÌº¥Æ® »ç¿ë
	*/
	function numCheck(obj, type){ 
		temp_value = obj.value.toString(); 
		regexp = /[^-\.0-9]/g; 
		repexp = ''; 
		temp_value = temp_value.replace(regexp,repexp); 
		regexp = ''; 
		repexp = ''; 
		switch(type){ 
			case 'int':
				regexp = /[^0-9]/g;
				repexp = '';
				break; 
			case 'float':
				regexp = /^(-?)([0-9]*)(\.?)([^0-9]*)([0-9]*)([^0-9]*)/;
				repexp = '$2$3$5';
				break;
			case '-int':
				regexp = /^(-?)([0-9]*)([^0-9]*)([0-9]*)([^0-9]*)/;
				repexp = '$1$2$4';
				break;
			case '-float':
				regexp = /^(-?)([0-9]*)(\.?)([^0-9]*)([0-9]*)([^0-9]*)/;
				repexp = '$1$2$3$5';
				break; 
			default :
				regexp = /[^0-9]/g;
				repexp = '';
				break; 
		} 

		temp_value = temp_value.replace(regexp,repexp); 
		obj.value = temp_value; 
	} 

	/*
		¿µ¾î¸¸ ÀÔ·Â¹Þ±â  (´ë¼Ò¹®ÀÚ)
		obj = ÀÎÇ²¹Ú½º
		type = ÀÔ·ÂÇüÅÂ
			'small' : ¼Ò¹®ÀÚ
			'big' : ´ë¹®ÀÚ
			'all' : ÀüÃ¼
		return = void
		Å° ÀÌº¥Æ® »ç¿ë
	*/
	function engCheck(obj, type){ 
		temp_value = obj.value.toString(); 
		regexp = ''; 
		repexp = ''; 
		switch(type){ 
			case 'small':
				regexp = /[^a-z]/g;
				break; 
			case 'big':
				regexp = /[^A-Z]/g;
				break; 
			case 'all':
				regexp = /[^a-z]/i;
				break; 
			default :
				regexp = /[^a-z]/i;
				break;
		}

		temp_value = temp_value.replace(regexp,repexp); 
		obj.value = temp_value; 
	} 

	function colorCheck(chr){
		var varCheck = 0;

		chr = chr.replace("#","")

		for(var i=0; i < chr.length; i++) {
			if(chr.charAt(i) >= '0' && chr.charAt(i) <= '9'){
			}else if ((chr.charAt(i) >= 'a' && chr.charAt(i) <= 'f') || (chr.charAt(i) >= 'A' && chr.charAt(i) <= 'F')){
			}else{
				varCheck = 1;
			}
		}

		if(varCheck == 1 || chr.length != 6) {
			alert("±ÛÀÚ»ö Á¤º¸°¡ Àß¸ø ÀÔ·ÂµÇ¾ú½À´Ï´Ù.");
			return false;
		}else{
			return true;
		}
	}



function needLogin() {
	alert('·Î±×ÀÎ ÇÏ¼Å¾ßÇÕ´Ï´Ù.');

	login_form.userid.focus();
	return;
}