function Login(rtnurl,qstr)
{
	window.open("/login/login.en?rtnurl="+rtnurl+"?"+qstr,'login','toolbar=no,resizable=no,width=370,height=210,scrollbars=no,location=no,top=0,left=200');		
}
function GoDownload(type)
{
	//document.location.href='/KicksOnline.exe';
	//alert('지금은 베타테스트 기간이 아닙니다.\n\n클라이언트 설치파일은 베타테스트 기간동안 다운로드 가능합니다.');
	//alert('클라이언트 설치파일을 다운로드 합니다.\n\n공유기나 방화벽 사용자의 경우 파일다운로드가 되지 않을 수 있으니 이런 경우\n\nhttp://www.kicksonline.co.kr/KicksOnlineSetup.exe 를 주소창에 입력하고\n\n다운로드 받으시기 바랍니다.');
	document.fm.action = "/client_down.en?type="+type;
	document.fm.target = "noshow_down";
	document.fm.submit();
}
function ClientDown()
{
	//GoDownload();
	var popup= window.open('/data/download_select.en', 'download_select','toolbar=no,resizable=no,scrollbars=no,width=315,height=255,marginwidth=0,marginheight=0,status=1');
}
function Write_Flash(Fname, Fid, Fwidth, Fheight)
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="'+Fid+'" name="'+Fid+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="' + Fwidth + '" height="' + Fheight + '"><param name=movie value="' + Fname + '"><param name=quality value=high><embed src="' + Fname + '" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' + Fwidth + '" height="' + Fheight + '"></embed></object>');
}
function Write_Flash2(Fname, Fid, Fwidth, Fheight)
{
	var tmpStr = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="'+Fid+'" name="'+Fid+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="' + Fwidth + '" height="' + Fheight + '"><param name=wmode value=transparent><param name=movie value="' + Fname + '"><param name=quality value=high><embed src="' + Fname + '" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' + Fwidth + '" height="' + Fheight + '"></embed></object>';
	document.write(tmpStr);
}
function Write_Html(html)
{
	document.write(html);
}
function MenuFlash(mode)
{
	if(!mode)
	{
		mode = 0;
	}
	
	var HTMLStr = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="855" height="250" id="kicks_navigation" align="middle">'
	+ '<param name="allowScriptAccess" value="sameDomain" />'
	+'<param name="movie" value="/images/kicks_navigation.swf?MENU_MODE=' + mode + '" />'
	+'<param name="menu" value="false" />'
	+'<param name="quality" value="high" />'
	+'<param name="bgcolor" value="#000000" />'
	+'<embed src="/images/kicks_navigation.swf?MENU_MODE=' + mode + '" menu="false" quality="high" bgcolor="#000000" width="855" height="250" name="kicks_navigation" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
	+'</object>';

	document.write(HTMLStr);
}
function MenuFlashiMBC(mode)
{
	if(!mode)
	{
		mode = 0;
	}
	
	var HTMLStr = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="855" height="250" id="kicks_navigation" align="middle">'
	+ '<param name="allowScriptAccess" value="sameDomain" />'
	+'<param name="movie" value="/images/imbc-kicks_navigation.swf?MENU_MODE=' + mode + '" />'
	+'<param name="menu" value="false" />'
	+'<param name="quality" value="high" />'
	+'<param name="bgcolor" value="#000000" />'
	+'<embed src="/images/imbc-kicks_navigation.swf?MENU_MODE=' + mode + '" menu="false" quality="high" bgcolor="#000000" width="855" height="250" name="kicks_navigation" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
	+'</object>';

	document.write(HTMLStr);
}
function ControlMovie( strVariable )
{
	var Obj = document.getElementById("kicksmovie");
	Obj.SetVariable( "_root.KICKS_STATUS", strVariable  );
	//alert(Obj.GetVariable( "_root.KICKS_STATUS" ));
}
function KicksStart()
{
	// 구버전
	/*var popup= window.open('/activex/', 'start','toolbar=no,resizable=no,scrollbars=no,width=340,height=190,marginwidth=0,marginheight=0');
	if(popup == null) {
		alert('게임 시작 팝업창 오픈을 실패했습니다. 팝업 차단 설정을 해제 하신 후 다시 시도해 주세요.');
	} else {
		popup.focus();
	}*/
	// 신버전
	document.starter.location.href = '/activex/start.php';
}
function getCookie(name){
    var nameOfCookie = name + "=";
    var x = 0;
    while ( x <= document.cookie　.length ){
        var y = (x+nameOfCookie.length);
        if ( document.cookie　.substring( x, y ) == nameOfCookie ) {
            if ( (endOfCookie=document.cookie　.indexOf( ";", y )) == -1 ) {
                endOfCookie = document.cookie　.length;
            }
            return unescape( document.cookie　.substring( y, endOfCookie ) );
        }
        x = document.cookie　.indexOf( " ", x ) + 1;
        if ( x == 0 )
        break;
    }
    return "";
}
function setCookie( name, value, expiredays ){ 
	var todayDate = new Date(); 
	todayDate.setDate(todayDate.getDate() + expiredays); 
	document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";" 
} 
/*function KicksStart()
{
	//document.getElementById('startLayer').innerHTML = '<iframe name="starter" width="20" height="1" frameborder="0" scrolling="no" src="blank.en"></iframe>';
	starter.location.href='/launcher.en';
	
	/*if(type == "normal") {
		document.fm.action = "/launcher.en?type=normal";
	} else {
		document.fm.action = "/launcher.en";
	}
	document.fm.target = "starter";
	document.fm.submit();
}*/


function KicksStartMain()
{
	//mStop();
	ControlMovie('OFF');
	document.form1.action = "/launcher.en";
	document.form1.target = "start_noshow";
	document.form1.submit();
}
function DirectXDown()
{
	document.location.href='http://file1.kicksonline.co.kr/download_control.php?filename=dx90cwebsetup.exe';
}
function betaClose(type)
{
	if(type == "1") {
		alert('킥스온라인의 프리베타테스트가 모두 종료되었습니다. \n\n오픈베타테스트를 많이 기대해 주세요.');
	} else if(type == "2") {
		alert('서비스 기간이 아닙니다.');
	} else {
		alert('서비스 기간이 아닙니다.\n\n차후 테스트 일정이 공지될 예정입니다.');
	}
}
function LoginCheck()
{
	if(!fm_login.userid.value) {
		alert('회원 아이디를 입력해 주세요.');
		fm_login.userid.focus();
		return false;
	} else if(!fm_login.passwd.value) {
		alert('회원 비밀번호를 입력해 주세요.');
		fm_login.passwd.focus();
		return false;
	}
}

function LoginCheckMain()	//member_login.en에서 사용
{
	if(!fm.userid.value) {
		alert('회원 아이디 를 입력해 주세요.');
		fm.userid.focus();
		return false;
	} else if(!fm.passwd.value) {
		alert('회원 비밀번호를 입력해 주세요.');
		fm.passwd.focus();
		return false;
	}
}

function IDSearch()
{
	window.open("/member/id_search.en",'idsearch','toolbar=no,resizable=no,width=510,height=410,scrollbars=yes,location=no, status=yes,top=0,left=200');		
}

function ImgNone(type) 
{
	if(document.fm_login.userid)
	{
		if(type == "id" || document.fm_login.userid.value != "") document.fm_login.userid.style.backgroundImage = "";
		if(type == "pw") document.fm_login.passwd.style.backgroundImage = "";
	}
}

function Logout()
{
	document.fm_login.target="noshow_login";
	document.fm_login.action="/member/member_login.en";
	document.fm_login.ret.value="logout";
	document.fm_login.submit();
}

function Logout_Buddy()
{
	document.fm_login.target="noshow_login";
	document.fm_login.action="/member/member_login.en";
	document.fm_login.ret.value="logout_buddy";
	document.fm_login.submit();
}

function AuthOpen()
{
	window.open("/member/pop_auth_main.en",'idsearch','toolbar=no,resizable=no,width=490,height=560,scrollbars=no,location=no,status=yes,top=0,left=200');		
}

function StopAuth()
{
	if(confirm('부모동의를 중단하시겠습니까?\n\n중단하셔도 30일 이내에는 로그인 후 동의가 가능합니다.') == true)
	{
		alert('만 14세미만 회원가입이 완료되었습니다.\n\n킥스온라인의 모든 서비스를 이용하시기 위해서는 30일 이전에 부모님동의를 꼭 받아야 합니다.\n\n사이트 로그인 후 부모님동의와 관련된 내용이 안내됩니다.');
		document.fm.action = "consent_email_auth.en";
		document.fm.ret.value = "stopauth";
		document.fm.submit();
	}
}

function calculateBytes( szValue)
{
  var tcount = 0;

  var tmpStr = new String(szValue);
  var temp = tmpStr.length;

  var onechar;
  for ( k=0; k<temp; k++ )
  {
    onechar = tmpStr.charAt(k);
    if (escape(onechar).length > 4)
    {
      tcount += 2;
    }
    else
    {
      tcount += 1;
    }
  }

  return tcount;
}

function getCookie(name)
{
	var nameOfCookie=name+"=";
	var x=0;
	while(x<=document.cookie.length)
	{
		var y=(x+nameOfCookie.length)
		if(document.cookie.substring(x,y)==nameOfCookie)
		{
			if((endOfCookie=document.cookie.indexOf(";",y))==-1)
				endOfCookie=document.cookie.length;
			return unescape(document.cookie.substring(y,endOfCookie));
		}
		x=document.cookie.indexOf(" ",x) +1;
		if(x==0)
			break;
	}
	return "";
}

function charLogin(url)
{
	var result = window.open('/club/character_login.en?nextpage='+url, 'character_login','toolbar=no,resizable=no,width=315,height=215,scrollbars=no,location=no,top=0,left=200,status=1');
	if(!result)
	{
		alert('윈도우 XP 팝업차단 기능이 설정되어 있습니다.\\n\\n클럽에서 로그인을 하시려면 팝업설정을 \'현재 사이트의 팝업을 항상 허용\'으로 설정하시기 바랍니다.');
	}
}

function CharLogout()
{
	document.fm.action = '/club/character_login.en';
	document.fm.target = 'noshow';
	document.fm.mode.value = 'logout';
	document.fm.submit();
}

function goClub()
{
	var fm = document.fm_login;
	for(i=0;i<fm.clubinfo.length;i++) 
	{
		if(fm.clubinfo[i].selected == true) 
		{
			var tmpVar = fm.clubinfo[i].value.split("|");
			var club_url = tmpVar[0];
			var goclub_seq = tmpVar[1];

			if(club_url)
			{
				//window.open('http://club.kicksonline.co.kr/'+club_url, 'clubhp','toolbar=1,menubar=1,resizable=1,width=1000,height=600,scrollbars=1,menubars=1,location=1,top=0,left=0,status=1');
				fm.target = '_blank';
				fm.action = 'http://club.kicksonline.co.kr/'+club_url;
				fm.goclub.value = 'ok';
				fm.goclub_seq.value = goclub_seq;
				fm.submit();
				fm.clubinfo[0].selected = true;
			}
		}
	}
}

function SelfClose()
{
	self.close();
}

function clubRank()
{
	alert('클럽랭킹은 준비중입니다.');
	return;
}

//캐쉬충전창 오픈
function OpenCash()
{
	var popup= window.open('http://payment.kicksonline.co.kr/index.en?mode=web', 'cashopen','toolbar=no,resizable=no,scrollbars=no,width=397,height=497,marginwidth=0,marginheight=0,status=1');
}

//대회창 오픈
function OpenKicksCup()
{
	var popup= window.open('/kickscup/index.en', 'matchopen','toolbar=no,resizable=no,scrollbars=no,width=350,height=220,marginwidth=0,marginheight=0,status=1');
}

//숫자형식(콤마)으로 변환
function Number_Format(str)
{
	return Number(String(str).replace(/\..*|[^\d]/g,"")).toLocaleString().slice(0,-3);
}

/************ 버디버디용 함수 ****************/
function OpenCashBuddy()
{
	var popup= window.open('https://bill.buddybuddy.co.kr/recharge/', 'cashopenbuddy','toolbar=no,resizable=no,scrollbars=no,width=386,height=481,marginwidth=0,marginheight=0,status=1');
}

function IdFindBuddy()
{
	var popup= window.open('http://user.buddybuddy.co.kr/idsearch/IdPwSearchForm.asp?from=game', 'idfindbuddy','toolbar=no,resizable=no,scrollbars=no,width=500,height=550,marginwidth=0,marginheight=0,status=1');
}

//버디게임용 로그인 체크함수
function LoginCheckBuddy()
{
	if(!fm_login.ID.value) {
		alert('버디게임 아이디를 입력해 주세요.');
		fm_login.ID.focus();
		return false;
	} else if(!fm_login.PWD.value) {
		alert('비밀번호를 입력해 주세요.');
		fm_login.PWD.focus();
		return false;
	}

	if(fm_login.SECCHK.checked == true) {
		fm_login.action = 'https://user.buddybuddy.co.kr/Login/Login.asp';
	} else {
		fm_login.action = 'http://user.buddybuddy.co.kr/Login/Login.asp';
	}
}

//버디용 푸터 링크함수
function OpenCooper()
{
	var popup= window.open('http://corp.buddygames.co.kr/Cooperation/Regist.aspx?GAMECD=0010', 'buddyopen1','toolbar=no,resizable=no,scrollbars=no,width=600,height=550,marginwidth=0,marginheight=0,status=1');
}
/******************************************/

//iMBC 그랜드오픈 이벤트용 복주머니 전송함수
function SendGball()
{
	document.form_imbc.action = '/channeling/imbc/SendGball.en';
	document.form_imbc.submit();
}

function winResize() 
{ 
	var Dwidth = parseInt(document.body.scrollWidth); 
	var Dheight = parseInt(document.body.scrollHeight); 
	var divEl = document.createElement("div"); 
	divEl.style.position = "absolute"; 
	divEl.style.left = "950px"; 
	divEl.style.top = "550px"; 
	divEl.style.width = "100%"; 
	divEl.style.height = "100%"; 

	document.body.appendChild(divEl); 

	window.resizeBy(Dwidth-divEl.offsetWidth, Dheight-divEl.offsetHeight); 
	document.body.removeChild(divEl); 
}

function popupAutoResize() {
    var thisX = parseInt(document.body.scrollWidth);
    var thisY = parseInt(document.body.scrollHeight);
    var maxThisX = screen.width - 50;
    var maxThisY = screen.height - 50;
    var marginY = 0;
    //alert(thisX + "===" + thisY);
    //alert("임시 브라우저 확인 : " + navigator.userAgent);
    // 브라우저별 높이 조절. (표준 창 하에서 조절해 주십시오.)
	if(navigator.userAgent.indexOf("MSIE 7") > 0) marginY = 75;    // IE 7.x
    else if (navigator.userAgent.indexOf("MSIE 6") > 0) marginY = 55;        // IE 6.x
    else if(navigator.userAgent.indexOf("Firefox") > 0) marginY = 50;   // FF
    else if(navigator.userAgent.indexOf("Opera") > 0) marginY = 30;     // Opera
    else if(navigator.userAgent.indexOf("Netscape") > 0) marginY = -2;  // Netscape
	else marginY = 75;

    if (thisX > maxThisX) {
        window.document.body.scroll = "yes";
        thisX = maxThisX;
    }
    if (thisY > maxThisY - marginY) {
        window.document.body.scroll = "yes";
        thisX += 19;
        thisY = maxThisY - marginY;
    }
    window.resizeTo(thisX+10, thisY+marginY);

    // 센터 정렬
    // var windowX = (screen.width - (thisX+10))/2;
    // var windowY = (screen.height - (thisY+marginY))/2 - 20;
    // window.moveTo(windowX,windowY);
}