//***********************************************************************************
// Author      : seo.h.y
// Create Date : 2009-11-20
// Description : °øÅë À¯Æ¿ÇÔ¼ö ¹× °øÅë º¯¼ö (ÀÚ¹Ù½ºÅ©¸³Æ®¿ë)
//***********************************************************************************


//#####  °øÅë Function  ################################################################################################

//menu
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 reloadHeight(frm){
	var objBody = eval(frm + ".document.body");
	var objFrame = document.all[frm];

	objFrame.style.height = objBody.scrollHeight + (objBody.offsetHeight - objBody.clientHeight);
}

//±ÛÀÚ ±æÀÌ ¾ò±â
function getlength(item){
	var onchar
	var ochar
	var tcount=0
	onechar	=	document.getElementById(item).value;
	leng	=	onechar.length;

	for(i=0 ; i< leng ;i++){
		ochar=onechar.charAt(i)
		if(escape(ochar).length > 4){
			tcount+=2;
		}else if (ochar!='\r') {
			tcount++;
		}

	}
	return tcount
}

//window open
function open_pop(url,name,width,height){	
	window.open(url,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height+',top=200,left=200');
}

//delete check
function ComDelCheck(val){
	sure = confirm("Delete?")
	if(sure){
		location.href = val
	}
}

//login check
function loginCheck(user_id){
	if(user_id == "" || user_id == undefined){
		alert("Left login");
		parent.form_login.id.focus();
	}
}

//ÄíÅ°¿¡ ÀúÀå
function setCookie(name, value, expiredays){ 
	if(typeof expiredays == "undefined" || expiredays == null){
		var expiredays = 1; //±âº» ÇÏ·ç
	}
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

//ÄíÅ°°ª °¡Á®¿À±â
function getCookie(name) {
   var key = name + "=" ;
   var key_len = key.length ;
   var cookie_len = document.cookie.length;
   var i = 0;
   while (i < cookie_len ) {
	  var j = i + key_len;
	  if ( document.cookie.substring( i, j ) == key ) {
		 var cookie_end = document.cookie.indexOf(";",j);
		 if (cookie_end == -1) {
			cookie_end = document.cookie.length;
		 }
		 return document.cookie.substring(j,cookie_end );
	  }
	  i++
   }
   return ""
}


//ÀÔ·Â°ª Ã¼Å©1
function inputCheck(name, msg){		
	if(document.getElementById(name).value == ""){
		alert(msg);
		document.getElementById(name).focus();
		return true;
	}
}

//ÀÔ·Â°ª Ã¼Å©2 (Æ÷Ä¿½º X)
function inputCheck2(name, msg){		
	if(document.getElementById(name).value == ""){
		alert(msg);
		return true;
	}
}

//±æÀÌ Ã¼Å©
var temp00 = "";
function checkLength(field, field2, limit) {
	f = document.getElementById(field)
	f2= document.getElementById(field2)
	
	if ( countBytes(f.value) > limit) {
		alert('Please write the subject up to ' + limit + ' letters.');
		f.value = temp00;
	}else{
		f2.innerHTML = countBytes(f.value);
		temp00 = f.value;
	}
}

//±æÀÌ Ä«¿îÆ®
function countBytes(field) {
	var tcount   = 0;
	var tmpStr   = new String(field);
	var tmpCount = tmpStr.length;
	var onechar;

	for ( k=0; k<tmpCount; k++ ) {
		oneChar = tmpStr.charAt(k);
		if (escape(oneChar).length > 4) {
			tcount += 2;
		} else {
			tcount += 1;
		}
	}
	return tcount;
}



//#####  Wbaduk ³» Function  ################################################################################################

//gibo
function gibo_load(gibonum) {
	window.open('/gibo/gibo_view.asp?gb_no='+gibonum,'gibo','toolbar=no,location=no,diectories=yes,status=yes,scrollbars=no,menubar=no,resizable=yes,width=915,height=710');
}

function Lecture_load(lectnum) {
	window.open('/lecture/lecture_view.asp?lecture_no='+lectnum,'gibo','toolbar=no,location=no,diectories=yes,status=yes,scrollbars=no,menubar=no,resizable=yes,width=915,height=710');
}


//°ÔÀÓ ½ÇÇà

//function IsInstall() {
//	delayTime();
//}

//function delayTime() {   
//	waitTime = window.setTimeout("oro2000()", 100);	  
//}

function gameRun(COM_PROGRAM_FILE) {
	var check;
	
	check = SChecker.IsOro("Cyberoro\\English","Dirpath Info","oropath","upcheck");

	if(check == 2) {
		if(confirm("Program is not installed. Setup Thist Program ?")) {
		   location.href = COM_PROGRAM_FILE ;
		}
	} else {
		SChecker.ExeOro("Cyberoro\\English","Dirpath Info","oropath","upcheck");
	}
}