/* ·¹ÀÌ¾î °ü·Ã ½ºÅ©¸³Æ® */
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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

/* ÇÃ·¡½Ã ½ºÅ©¸³Æ® */
function __tx__(id){
document.write(document.getElementById(id).value);
}

/* ÇÃ·¡½Ã ½ºÅ©¸³Æ® */
function __ws__(id){
document.write(id.text);id.id='';
}

/* ºê¶ó¿ìÁ® Å¸ÀÌÆ² */
document.title="°³³ä¿ø¸®";

/* ÀÚµ¿ ÀÌ¹ÌÁö Æ÷Ä¿½º ¾Æ¿ô */
function autoblur(){ 
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") 
	document.body.focus(); 
} 
//	document.onfocusin=autoblur;



function random_imglink(){

	var ry=Math.floor(Math.random()*2);

	if (ry==0){
		ry = ry+1;
		//ÀÌ¹ÌÁöº¯°æ
		document.getElementById('randomimg').style.backgroundImage='url(http://mid.imath.tv/images/with/with_pic_a_01_3.jpg)';
		//linkº¯°æ
		document.getElementById('randomlink').innerHTML="<a href='http://mid.imath.tv/with/teacher_read.aspx?School=H&T_Code=60' hidefocus><img src='../images/with/with_btn_03.gif' width='57' height='23' alt=''></a>";
	}else{
		document.getElementById('randomimg').style.backgroundImage='url(http://mid.imath.tv/images/with/with_pic_a_01_3.jpg)';
		document.getElementById('randomlink').innerHTML="<a href='http://mid.imath.tv/with/teacher_read.aspx?School=H&T_Code=60' hidefocus><img src='../images/with/with_btn_03.gif' width='57' height='23' alt=''></a>";
	}
}

//iframe auto resize
function iframe_autoresize(arg) {
    arg.height = eval(arg.name+".document.body.scrollHeight");
}

//Email Çü½Ä check
function Email_chk(Form_Name, Field_Name) {
	var t = eval("document." + Form_Name + "." + Field_Name + ".value");
	var ValidFlag = false;
	var atCount = 0;
	var SpecialFlag;
	var atLoop;
	var atChr;
	var BadFlag;
	var tAry1;
	var UserName;
	var DomainName;
	
	if(t.length > 0 && t.indexOf("@") > 0 && t.indexOf(".") > 0) {
		atCount = 0;
		SpecialFlag = false;
		
		for(atLoop=1; atLoop<=t.length; atLoop++) {
			atChr = t.substring(atLoop, atLoop+1);
			
			if(atChr == "@") atCount = atCount + 1;
			if((atChr >= 32) && (atChr <= 44)) SpecialFlag = true;
			if((atChr == 47) || (atChr == 96) || (atChr >= 123)) SpecialFlag = true;
			if((atChr >= 58) && (atChr <= 63)) SpecialFlag = true;
			if((atChr >= 91) && (atChr <= 94)) SpecialFlag = true;
		}
		
		if((atCount == 1) && (SpecialFlag == false)) {
			BadFlag = false;
			tAry1 = t.split("@");
			UserName = tAry1[0];
			DomainName = tAry1[1];
			
			if((UserName.length <= 0) || (DomainName.length <= 0 )) BadFlag = true;
			if(DomainName.substring(1, 2 ) == ".") BadFlag = true;
			if(DomainName.substring(DomainName.length-1, DomainName.length) == ".") BadFlag = true;
			
			ValidFlag = true;
		}
	}
	
	if(BadFlag == true) ValidFlag = false;
	
	return ValidFlag;
}

//ID Çü½Ä Check
function CheckChar(name) {
	strarr = new Array(name.value.length);
	
	if((name.value.charAt(0) < "a" || name.value.charAt(0) > "z") && (name.value.charAt(0) < "A" || name.value.charAt(0) > "Z")) {
		return true;
	}
	
	for(i = 0; i < name.value.length; i++) {
		strarr[i] = name.value.charAt(i)
		if((strarr[i] >= 0) && (strarr[i] <= 9))
			continue;
		else if((strarr[i] >= "a") && (strarr[i] <= "z"))
			continue;
		else if((strarr[i] >= "A") && (strarr[i] <= "Z"))
			continue;
		else {
			return true;
		}
	}  
	return false;
}

//±ÛÀÚ¼ö Á¦ÇÑ.
function in_ti(word, length) {
	if(word.length > length) {
		word = word.substring(0, length) + "..";
	}
	
	document.write(word);
}

/*
launchCenter(str1, str2, int1, int2, str3)
 - str1 : ÆË¾÷µÉ url 
 - str2 : ÆË¾÷Ã¢ ¸í
 - int1 : ÆË¾÷Ã¢ÀÇ °¡·Î±æÀÌ
 - int2 : ÆË¾÷Ã¢ÀÇ ¼¼·Î±æÀÌ
 - str3 : ±âÅ¸ ÆË¾÷Ã¢ÀÇ Attribute
 - ¼³¸í : ÆË¾÷Ã¢À» ¸ð´ÏÅÍÀÇ ÇÑ°¡¿îµ¥¿¡ À§Ä¡½ÃÅ´
 - ¹ÝÈ¯°ª : ¾øÀ½
*/

// launchCenter(url, name, width, height, att)
function launchCenter(url, name, width, height, att) 
{
  var str = "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
    str += "," + att
  }
  return window.open(url, name, str);
}

// comma »ðÀÔ
function comma_In(number) {
	len = number.length;
	s = Math.floor(len / 3);
	t = len % 3;
 
	if(t == 0) {
		t = 3;
		s--;
	}
 
	r =	number.substr(0, t);
 
	for(i = 0; i < s; i++) {
		r += "," + number.substr(3 * i + t, 3);
	}
	return r;
}
// comma Á¦°Å
function comma_Del(str) {
	var index, len
           
	while(true) {
		index = str.indexOf(",")
		// ,(Comma)°¡ ¾øÀ¸¸é Á¾·áÇÕ´Ï´Ù.
		if (index == -1) break
			// ¹®ÀÚ¿­ ±æÀÌ¸¦ ±¸ÇÕ´Ï´Ù.
			len = str.length
			// ,(Comma)¸¦ Àß¶ó³À´Ï´Ù.
			str = str.substring(0, index) + str.substring((index+1),len)
	}
	return str;
}

// html tag Á¦°Å
function removeTag(val) {
    var rmvExp = new RegExp();
    rmvExp = /[<][^>]*[>]/gi;
    return val.replace(rmvExp, "");
}
//----------------------------------------------------------------------------//

/* ÁØºñÁß */
function ready(){
	window.alert("ÇØ´ç¸Þ´º´Â ¼­ºñ½º ÁØºñÁßÀÔ´Ï´Ù.");
}


/* Main */
function main() {
	window.location.href = "../main/main.aspx";
}

/* intro : °­ÀÇ¼Ò°³ */
function intro_01() {
	window.location.href = "../intro/intro_01.aspx";
}

/* support : °í°´Áö¿ø */
function support_01() {
	window.location.href = "../support/support_01.aspx";
}

/* book : ±³Àç¼Ò°³ */
function book_01() {
	window.location.href = "../book/book_01.aspx";
}

/* room : ³» °øºÎ¹æ */
function room_01() {
	window.location.href = "../room/room_01.aspx";
}

/* with : ¼±»ý´Ô°ú ÇÔ²² */
function with_01() {
	window.location.href = "../with/with_01.aspx";
}

/* comm : Ä¿¹Â´ÏÆ¼ */
function comm_01() {
	window.location.href = "../comm/comm_01.aspx";
}


/* ÇÃ·¹ÀÌ¾î */
function player_win(ld_code, path, lm_code) {
	if(lm_code == null) {
		if(path.toLowerCase() == "high_path") {
			//window.open("../player/player.aspx?LD_Code=" + ld_code + "&path=" + path, "player", "width=949,height=592,left=0,top=0,scrollbarsy=yes");
			window.open("../player/player.aspx?LD_Code=" + ld_code + "&path=" + path, "player", "width=671,height=450,left=0,top=0,scrollbarsy=yes");
		} else {
			window.open("../player/player.aspx?LD_Code=" + ld_code + "&path=" + path, "player", "width=671,height=450,left=0,top=0,scrollbarsy=yes");
		}
	} else {
		if(path.toLowerCase() == "high_path") {
			//window.open("../player/player.aspx?LM_Code=" + lm_code + "&path=" + path, "player", "width=949,height=592,left=0,top=0,scrollbarsy=yes");
			window.open("../player/player.aspx?LM_Code=" + lm_code + "&path=" + path, "player", "width=671,height=450,left=0,top=0,scrollbarsy=yes");
		} else {
			window.open("../player/player.aspx?LM_Code=" + lm_code + "&path=" + path, "player", "width=671,height=450,left=0,top=0,scrollbarsy=yes");
		}
	}
}

//³¯Â¥Ã¼Å©
function isJDate(ymd) {
	if(ymd.split("-").length != 3) {
		return true;
	}
	
	yy = ymd.split("-")[0];
	mm = ymd.split("-")[1];
	dd = ymd.split("-")[2];
	
	if(isNaN(yy)) {
		return true;
	}
	
	if((yy < 1901) || (yy > 2078)) {
		return true;
	}
	
	if(isNaN(mm)) {
		return true;
	}
	
	if((mm < 1) || (mm > 12)) {
		return true;
	}
	
	if(isNaN(dd)) {
		return true;
	}
	
	if(mm == 1 || mm == 3 || mm == 5 || mm == 7 || mm == 8 || mm == 10 || mm == 12) {
		kk = 31;
	} else if(mm == 4 || mm == 6 || mm == 9 || mm == 11) {
		kk = 30;
	} else if((yy % 4 == 0 && yy % 100 != 0) || (yy % 400 == 0)) {
		kk = 29;
	} else {
		kk = 28;
	}
	
	if((dd < 1) || (dd > kk)) {
		return true;
	}
	
	return false;
}

/* È¸»ç¼Ò°³ */
function company(){ //È¸»ç¼Ò°³
    window.open("http://home.imath.tv/", "_blank");
}

/* ÇÐ³âº° ÁýÁß ÇÐ½À¹ý ÆË¾÷ */
function oncl(url) {
    window.open("../stu_system/" + url + ".htm", "study_system", "status=no,resizable=no,width=700,height=550,scrollbars=yes,top=0,left=50");
}

function LeftBanner() {
    window.open('../etc/etc_01.aspx', 'etc_01', 'status=no,resizable=no,width=764,height=550,scrollbars=yes,top=0,left=50');
}
