strhostname = location.host;
currentDomain = strhostname.substring(strhostname.indexOf(".")+1);

if (currentDomain == "mgame.com")
{
	document.domain	=	"mgame.com";
} else {
	document.domain	=	"game.nate.com";
}

function MM_swapImgRestoreNew() {
	var i,x,a=document.MM_sr; 
	for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++){
		var tempstr = x.oSrc;
		var tempurl = tempstr.substr(tempstr.length-6,tempstr.length)
		if(tempurl.indexOf(curimg,0) > 0)
			return;
		x.src=x.oSrc;
	};
}

function MM_findObjNew(n, d) {
	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_findObjNew(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImageNew() {
	var i,j=0,x,a=MM_swapImageNew.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObjNew(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



var	g				=	document.getElementById;
var	uri				=	location.href.replace("http://"+ location.host).split("/");
var img_url			=	"http://image.mgame.com/board/janggi_2007";
var curimg;

mkd_unload_driver_at_pageout = 1; 
function chkSubmit(f) {
	if("YES" == getCookie_key("MGAME_KEY_DEFENDER")) {
		 mkdplus_copy_to_form(document.f);
	}
	if(f.mgid_enc.value.length == 0) {
         top.Mgame_ErrorLayerOpen('free', '¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.')
		 //alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
         f.mgid_enc.focus();
         return false;
	}
	if (f.mgpwd_enc.value.length == 0) {
         top.Mgame_ErrorLayerOpen('free', '¾ÏÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.')
		// alert("¾ÏÈ£¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
         f.mgpwd_enc.focus();
         return false;
	}
	return true;
}

function OpenWindow() {
	window.open ("http://www.mgame.com/idpwsearch/","_blank","height=200,width=480,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
}

function id_pwd_search(){
	window.open("http://sign.mgame.com/t_user_search/default.mgx", "IPINWindow", "menubar=no,scrollbar=no,width=400,height=350,resizable=no,status=no,titlebar=no,toolbar=no");
}


//¾ÆÀÌÇÁ·¹ÀÓ ¸®»çÀÌÁî
function if_Resize2() { 
	setTimeout('if_Resize_real()',100);
}
function if_Resize_real() { 
	try{
		resize_td.height	=	main.document.body.scrollHeight; 
		resize_td.width	=	main.document.body.scrollWidth; 
		//alert(main.document.body.scrollHeight);
	}catch(e){
		//alert(e.description);
	}
	
}


function image_change(img,pk,mypk,maximum) {
	try{
		for(i=1;i<=maximum;i++) {
			if(document.getElementById(pk+i).src != img_url +"/"+ uri[1] +"/"+ img + i +".gif") {
				document.getElementById(pk+i).src	=	img_url +"/"+ uri[1] +"/"+ img + i +".gif";
			}
		}
		document.getElementById(pk+mypk).src	=	img_url +"/"+ uri[1] +"/"+ img + mypk +"r.gif";
		curimg	=	mypk;
	}catch(e){
	}
}

function embed(u,w,h,div) {
	html	=	'<object width="'+ w +'" height="'+ h +'" id="player" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">';
	html	+=	'	<param name="autoStart" value="True">';
	html	+=	'	<param name="URL" value="'+ u +'">';
	html	+=	'	<param name="volume" value="70">';
	html	+=	'	<param name="ShowControls" value="true">';
	html	+=	'	<param name="defaultFrame" value="content">';
	html	+=	'	<param name="uiMode" value="full">';
	html	+=	'	<param name="enableContextMenu" value="false">';
	html	+=	'	<param name="fullScreen" value="false">';
	html	+=	'	<param name="enabled" value="True">';
	html	+=	'	<param name="stretchToFit" value="true">';
	html	+=	'</object>';
	eval(div).innerHTML	=	html;
}


function popup_resize() {
	window.resizeTo(document.body.scrollWidth+10,document.body.scrollHeight+70);
}

function pagelink(page) {
	document.procform.page.value	=	page;
	document.procform.submit();
}


//js ÆÄÀÏ ÀÚ¸£´Â ÇÔ¼ö
function init(name,idx){
	arr_admin	= new Array();
	arr_admin[0]	= new Array();
	arr_admin[0][0]	= name;
	arr_admin[0][1]	= idx;

	for(i=0; i<arr_admin.length; i++){
		tmpEval= 'tmpArr = janggi_'+arr_admin[i][0]+'.split("||");'+'\n';
		tmpEval+='arr_'+arr_admin[i][0]+' = new Array();'+'\n';
		tmpEval+='for(tmpLoop=0; tmpLoop<tmpArr[0]; tmpLoop++)'+'\n';
		tmpEval+='{'+'\n';
		tmpEval+='	arr_'+arr_admin[i][0]+'[tmpLoop]		= new Array();'+'\n';

		for(j=0; j<arr_admin[i][1]; j++)
			tmpEval+='	arr_'+arr_admin[i][0]+'[tmpLoop]['+j+']	= tmpArr[tmpLoop*'+arr_admin[i][1]+'+'+(j+1)+'];'+'\n';
		
		tmpEval+='}'+'\n';
		eval(tmpEval);
	}

}

//»ý¹æ¼Û ½ÃÃ»
function TvView(){
	//alert('»ý¹æ¼Û ½ÃÃ»');
	window.open('http://janggi.mgame.com/janggitv/playlive.mgame','livev','left=100,top=100,width=400,height=460');
}


//ÇÁ¸®¹Ì¾ö °¡ÀÔ
function premium_login_check() {
	//alert('¼­ºñ½º ÁØºñÁßÀÔ´Ï´Ù.');
	//return;
	
	var loginChk = mgameUserCheck();

	if (loginChk)
	{
		if (location.host != "janggi.game.nate.com")
		{
			top.location.href	=	"http://janggi.mgame.com/course/main.mgame?leftmenu=4";
		} else {
			alert("¼­ºñ½º ÁØºñ Áß ÀÔ´Ï´Ù.");
		}
	}
	
}

function scrllnoWin(url,name,width,height) { window.open(url,name,"status=no,toolbar=no,location=no,scrollbars=no"+",left="+((screen.width - width) / 2)+",top="+((screen.height - height) / 2)+",width="+width+",height="+height);}