////////////////////////////////////////////////////////////////////////////////
//	°øÅë javascript
//	ÀÛ¼º : ÃÖÀº±Í
////////////////////////////////////////////////////////////////////////////////

var IE_Version = new Number(((window.navigator.appVersion.split('; '))[1].split(' '))[1]); //ºê¶ó¿ìÀú ¹öÁ¯

//ºê¶ó¿ìÀú Ã¼Å©
if (navigator.appName != "Microsoft Internet Explorer" || IE_Version < 5.0)
{
//	document.location.href = "/common/oldbrowseris.php";
}


// ÀÌ¹ÌÁö ¹öÆ° ¸¸µé±â
// showButton(¹öÆ°width, ½ÇÇàµÉÇÔ¼ö,¹öÆ°TEXT, ¹öÆ°icon)
function showButton(width,func,txt,icon)
{
	var btn = "";
	if(icon)
	{
		icon = "<img src='"+icon+"'><br>";
	}
	else
	{
		icon = "";
	}
	btn += "<button class=bbtn onfocus='this.blur()' ";
	btn += "style='width:"+width+"' onClick=\""+func+"\" >";
	btn += "<table width=99% cellspacing=0 cellpadding=0><tr>";
	btn += "<td></td>";
	btn += "<td><table border='0' cellspacing='0' cellpadding='0'><tr><td>"+icon+"</td><td>"+txt+"</td></tr></table></td>";
	btn += "<td></td></tr></table></button>";
	document.write(btn);
}

// ÀÌ¹ÌÁö ¹öÆ° ¸¸µé±â2
function showButton2(width,func,txt,icon)
{
	var btn = "";
	if(icon)
	{
		icon = "<td><img src='"+icon+"'><br></td>";
	}
	else
	{
		icon = "";
	}
	btn += "<button class=bbtn onfocus='this.blur()' ";
	btn += "style='width:"+width+"' onClick=\""+func+"\">";
	btn += "<table width=100% cellspacing=0 cellpadding=0 border=0 align='absmiddle'><tr>";
	btn += "<td class=ltd2></td>";
	btn += "<td class=ctd2><table border='0' cellspacing='0' cellpadding='0' border=0 width=100%><tr>"+icon+"<td align=center><img src='/common/images/blank.gif' height=3><br>"+txt+"</td></tr></table></td>";
	btn += "<td class=rtd2></td></tr></table></button>";
	document.write(btn);
}
function showButton4(width,func,txt,icon)
{
	var btn = "";
	if(icon)
	{
		icon = "<td><img src='"+icon+"'><br></td>";
	}
	else
	{
		icon = "";
	}
	btn += "<button class=bbtn onfocus='this.blur()' ";
	btn += "style='width:"+width+"' onClick=\""+func+"\">";
	btn += "<table width=100% cellspacing=0 cellpadding=0 border=0 align='absmiddle'><tr>";
	btn += "<td></td>";
	btn += "<td><table border='0' cellspacing='0' cellpadding='0' border=0 width=100%><tr>"+icon+"<td align=center><img src='/common/images/blank.gif' height=3><br><font class=text_small>"+txt+"</td></tr></table></td>";
	btn += "<td></td></tr></table></button>";
	document.write(btn);
}
function showButton3(width,func,txt,icon)
{
	var btn = "";
	if(icon)
	{
		icon = "<td><img src='"+icon+"'><br></td>";
	}
	else
	{
		icon = "";
	}
	btn += "<button class=bbtn onfocus='this.blur()' ";
	btn += "style='width:"+width+"' onClick=\""+func+"\">";
	btn += "<table width=100% cellspacing=0 cellpadding=0 border=0 align='absmiddle'><tr>";
	btn += "<td class=ltd2></td>";
	btn += "<td><table border='0' cellspacing='0' cellpadding='0' border=0 width=100%><tr>"+icon+"<td align=center><img src='/common/images/blank.gif' height=3><br><font class=text_small>"+txt+"</td></tr></table></td>";
	btn += "<td class=rtd2></td></tr></table></button>";
	document.write(btn);
}

// ÀÌ¹ÌÁö ¹öÆ° ¸¸µé±â
// imgButton(½ÇÇàµÉÇÔ¼ö, ¹öÆ°icon)
function imgButton(func,icon)
{


	btn = "<input type='image' src='"+icon+"'\" onClick=\""+func+"\" onfocus='this.blur()'> ";

	document.write(btn);
}

////////////////////////////////////////////////////////////////////////////////
// ¸ð´Þ Ã¢
//function alertPage(Ã¢ÇüÅÂ,URL,WIDTH,HEIGHT)
function alertPage(modal,url,sizeX,sizeY)
{
	var url = url + "&modal=ok";
	var LEFT = (screen.width-sizeX)/2;
	var LTOP = (screen.height-sizeY)/2 - 50;
	if(modal==0) window.showModelessDialog(url,window,'dialogWidth:'+sizeX+'px;dialogHeight:'+sizeY+'px;dialogTop:'+LTOP+';dialogLeft:'+LEFT+';help:no;status:no;scroll:yes');
	if(modal==1) window.showModalDialog(url,window,'dialogWidth:'+sizeX+'px;dialogHeight:'+sizeY+'px;dialogTop:'+LTOP+';dialogLeft:'+LEFT+';help:no;status:no;scroll:yes');
	if(modal==2) window.open(url, '', 'scrollbars=yes,resizable=yes,width='+sizeX+',height='+sizeY+',top='+LTOP+',left='+LEFT);
}
//¾È³»¸Þ½ÃÁö Ã¢
function alertMsg(modal,msg,sizeX,sizeY)
{
	//Ã¢ÇüÅÂ,¸Þ½ÃÁö,WIDTH,HEIGHT
	var url = "/common/alert.php?message="+msg;
	var x = (window.screen.Width - sizeX)/2;
	var y = (window.screen.Height - sizeY)/2;
	if(modal==0) return window.showModelessDialog(url,window,"dialogWidth:"+sizeX+"px;dialogHeight:"+sizeY+"px;top:"+x+";left:"+y+";help:no;status:no;scroll:no");
	if(modal==1) return window.showModalDialog(url,window,"dialogWidth:"+sizeX+"px;dialogHeight:"+sizeY+"px;top:"+x+";left:"+y+";help:no;status:no;scroll:no");
	if(modal==2) return window.open(url, "", "scrollbars=yes,width="+sizeX+",height="+sizeY+",top="+x+",left="+y+"");
}

////////////////////////////////////////////////////////////////////////////////
// ±¸¸Å°ü·Ã ÇÔ¼öµé
////////////////////////////////////////////////////////////////////////////////


//±¸¸Å Ã¼Å©¹Ú½º ÇÔ¼ö
var checkflag = false;
function checkBoxAllCheck(obj)
{
	//if(typeof( chkBox.length) == "undefined"){alert("µî·ÏµÈ ¼­ÀûÀÌ ¾ø½À´Ï´Ù.");return;}
	var btnAll = ['Ãë¼Ò', '¼±ÅÃ'];
	var btnRev = ['Ãë¼Ò', '¼±ÅÃ'];
	var chkBox = obj.form.elements['ITEM[]'];
	var chkLen = chkBox.length;
	switch (obj.name)
	{
		case 'chkAll':
			switch (obj.value)
			{
				case btnAll[0]: obj.value = btnAll[1]; var chkAll = 0; break;
				case btnAll[1]: obj.value = btnAll[0]; var chkAll = 1; break;
			}
			if (!chkLen) chkBox.checked = chkAll;
			else
				for (var i=0; i < chkLen; i++) chkBox[i].checked = chkAll;
		break;

		case 'chkRev':
			switch (obj.value)
			{
				case btnRev[0]: obj.value = btnRev[1]; break;
				case btnRev[1]: obj.value = btnRev[0]; break;
			}
			if (!chkLen) chkBox.checked = !chkBox.checked;
			else
			for (var i=0; i < chkLen; i++) chkBox[i].checked = !chkBox[i].checked;
		break;
	}
}





//°­ÀÇ»óÇ° »ó¼¼º¸±â
function viewGoods(category_code,site_code,class_code,goods_code,price)
{
	//category_code : Ä«Å×°í¸® ÄÚµå
	//site_code	: »çÀÌÆ® ÄÚµå
	//class_code	: °úÁ¤ ÄÚµå
	//goods_code	: »óÇ° ÄÚµå
	var win = "./categorySub.php?mode=goods_guide&category_code="+category_code+"&site_code="+site_code+"&class_code="+class_code+"&goods_code="+goods_code+"&output_price="+price;
	window.open(win,'goods_popup','width=741,height=600,status=no,scrollbars=yes');
}


function viewGoodssample(category_code,site_code,class_code,goods_code,price)
{
	//category_code : Ä«Å×°í¸® ÄÚµå
	//site_code	: »çÀÌÆ® ÄÚµå
	//class_code	: °úÁ¤ ÄÚµå
	//goods_code	: »óÇ° ÄÚµå
	var win = "./categorySub.php?mode=goods_sampleguide&goods_code="+goods_code;
	window.open(win,'goods_popup','width=741,height=600,status=no,scrollbars=yes');
}

//¸ðÀÇ°í»ç»óÇ° »ó¼¼º¸±â
function viewExam(category_code,site_code,class_code,goods_code,price)
{
	//category_code : Ä«Å×°í¸® ÄÚµå
	//site_code	: »çÀÌÆ® ÄÚµå
	//class_code	: °úÁ¤ ÄÚµå
	//goods_code	: »óÇ° ÄÚµå
	location.href = "./categorySub.php?mode=exam_guide&category_code="+category_code+"&site_code="+site_code+"&class_code="+class_code+"&goods_code="+goods_code+"&output_price="+price;
}

// °­»ç MyPage¿¡¼­ »óÇ°Á¤º¸ »ó¼¼º¸±â
function viewGoods2(category_code,site_code,class_code,goods_code,price)
{
	//category_code : Ä«Å×°í¸® ÄÚµå
	//site_code	: »çÀÌÆ® ÄÚµå
	//class_code	: °úÁ¤ ÄÚµå
	//goods_code	: »óÇ° ÄÚµå
	location.href = "/home/category/categorySub.php?mode=maker_goods_guide&category_code="+category_code+"&site_code="+site_code+"&class_code="+class_code+"&goods_code="+goods_code+"&output_price="+price;
}

//»ùÇÃ °­ÀÇ µè±â
function viewSampleVideo(movie)
{
	alertPage(0,'/home/category/player.php?movie='+movie,325,305)
}

function viewGoods4school(goods_code,sub)
{
	//goods_code	: »óÇ° ÄÚµå
	location.href = "course_online_info.php?goods_code="+goods_code+"&sub="+sub;
}


//Àå¹Ù±¸´Ï·Î ÇÑ°³¾¿
function addCart_button(cart_code,data)
{
	if(data=='' || typeof(data) == "undefined")
	{
		return;
	}

	// ±¸¸Å±¸ºÐ - cart_code
	// '1' - »óÇ°
	// '2' - Á¾ÇÕ¹Ý
	// '3' - °­ÀÇ±³Àç
	// '4' - µµ¼­
	// '5' - ¸ðÀÇ°í»ç»óÇ°
	// '6' - ÃâÁ¦ÀÚÀÇ °ú¸ñ»óÇ°
	// '7' - ÃâÁ¦ÀÚÀÇ Á¾ÇÕ»óÇ°
	// '8' - ¸ðÀÇ°í»ç Á¾ÇÕ»óÇ°

	parent.location.href = "../order/cart.php?mode=add&cart_code="+cart_code+"&ITEM[0]="+data;
}

//°­ÀÇ»óÇ° Àå¹Ù±¸´Ï·Î ¿©·¯°³ ´ã±â
function addCart_checkbox(cart_code,obj)
{
	if(cart_code == '')
	{
		alert('Error : ±¸ºÐÄÚµå°¡ ¾ø½À´Ï´Ù.');
		return;
	}

	// ±¸¸Å±¸ºÐ - cart_code
	// '1' - »óÇ°
	// '2' - Á¾ÇÕ¹Ý
	// '3' - °­ÀÇ±³Àç
	// '4' - µµ¼­
	// '5' - ¸ðÀÇ°í»ç
	// '6' - ÃâÁ¦ÀÚÀÇ °ú¸ñ»óÇ°
	// '7' - ÃâÁ¦ÀÚÀÇ Á¾ÇÕ»óÇ°
	// '8' - ¸ðÀÇ°í»ç Á¾ÇÕ»óÇ°

	if(typeof(obj.form.elements['ITEM[]']) == "undefined")
	{
		return;
	}


	var chkBox = obj.form.elements['ITEM[]'];
	var chkLen = chkBox.length;
	var countChk=0;

	if(typeof(chkBox.value) != "undefined")
	{
		if(chkBox.checked == true)
		{
			addCart_button(cart_code,chkBox.value);
		}
		else
		{

			if(countChk <= 0)
			{
				if(cart_code == 1)
				{
					alert('¼±ÅÃÇÏ½Å °­ÀÇ°¡ ¾ø½À´Ï´Ù.');
				}
				else if(cart_code == 2)
				{
					alert('¼±ÅÃÇÏ½Å Á¾ÇÕ¹Ý»óÇ°ÀÌ ¾ø½À´Ï´Ù.');
				}
				else if(cart_code == 3)
				{
					alert('¼±ÅÃÇÏ½Å ±³Àç°¡ ¾ø½À´Ï´Ù.');
				}
				else if(cart_code == 4)
				{
					alert('¼±ÅÃÇÏ½Å µµ¼­°¡ ¾ø½À´Ï´Ù.');
				}
				else if(cart_code == 5)
				{
					alert('¼±ÅÃÇÏ½Å ¸ðÀÇ°í»ç°¡ ¾ø½À´Ï´Ù.');
				}
				else if(cart_code == 6)
				{
					alert('¼±ÅÃÇÏ½Å ÃâÁ¦°ú¸ñÀÌ ¾ø½À´Ï´Ù.');
				}
				else if(cart_code == 7)
				{
					alert('¼±ÅÃÇÏ½Å ÃâÁ¦¸ðÀÇ°í»ç°¡ ¾ø½À´Ï´Ù.');
				}
				else if(cart_code == 8)
				{
					alert('¼±ÅÃÇÏ½Å ¸ðÀÇ°í»ç Á¾ÇÕ¹Ý»óÇ°ÀÌ ¾ø½À´Ï´Ù.');
				}
				else
				{
					alert('Error : ±¸ºÐÄÚµå°¡ ¾ø½À´Ï´Ù.');
				}
				return;
			}

		}

		return;
	}

	for (var i=0; i < chkLen; i++)
	{
		if(chkBox[i].checked == true)
		{
			countChk++;
		}
	}


	if(countChk <= 0)
	{
		if(cart_code == 1)
		{
			alert('¼±ÅÃÇÏ½Å °­ÀÇ°¡ ¾ø½À´Ï´Ù.');
		}
		else if(cart_code == 2)
		{
			alert('¼±ÅÃÇÏ½Å Á¾ÇÕ¹Ý»óÇ°ÀÌ ¾ø½À´Ï´Ù.');
		}
		else if(cart_code == 3)
		{
			alert('¼±ÅÃÇÏ½Å ±³Àç°¡ ¾ø½À´Ï´Ù.');
		}
		else if(cart_code == 4)
		{
			alert('¼±ÅÃÇÏ½Å µµ¼­°¡ ¾ø½À´Ï´Ù.');
		}
		else if(cart_code == 5)
		{
			alert('¼±ÅÃÇÏ½Å ¸ðÀÇ°í»ç°¡ ¾ø½À´Ï´Ù.');
		}
		else if(cart_code == 8)
		{
			alert('¼±ÅÃÇÏ½Å ¸ðÀÇ°í»çÁ¾ÇÕ¹ÝÀÌ ¾ø½À´Ï´Ù.');
		}
		else
		{
			alert('Error : ±¸ºÐÄÚµå°¡ ¾ø½À´Ï´Ù.');
		}
		return false;
	}

	obj.form.action = "../order/cart.php?cart_code="+cart_code;
	obj.form.submit();
}

//±³Àç - Ã¥ »ó¼¼Á¤º¸ »õÃ¢ button
	// °­»ç MyPage¿¡¼­ ¿­¾úÀ» ¶§¸¦ ±¸ºÐÇÏ±â À§ÇØ member¸¦ Ãß°¡
function openBookWinow_books(data, member)
{
	if(member == '' || typeof(member) == "undefined")
	{
		member = '';
	}
	if(data=='' || typeof(data) == "undefined")
	{
		return;
	}
	url = "../movie/book_guide.php?books_code=" + data + "&member=" + member;
	alertPage(2,url,650,400);
}

function aca_openBookWindow_books(data)
{

	if(data=='' || typeof(data) == "undefined")
	{
		return;
	}
	url = "/member/aca_book_guide.php?books_code=" + data;
	alertPage(2,url,650,400);
}

//Å°º¸µå Å° Á¦ÇÑÇÏ±â
//»ç¿ë¹ý : document.onkeydown=keyProtect;
function keyProtect()
{
	if(event.keyCode == 27)
	{
		return true;
	}
	else
	{
		event.keyCode=0;
		event.cancelBubble = true;
		event.returnValue = false;
		return false;
	}

}

// °¢Á¾ ÆË¾÷
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
