
var funcUrl = location.href.toLowerCase();
var split_funcUrl;
var split_funcUrlVar;

split_funcUrl = funcUrl.split("://",1);


if(split_funcUrl[0] == 'https' )
{
	split_funcUrlVar = "https://www.nexon.com";
}
else
{
	split_funcUrlVar = "http://file.nx.com";
}

// Avatar.js ¿¡ ÀÖ´Â °ªÀÌ¶û ¸ÂÃß¾î¾ß ÇÔ
k_nDefaultHeadItem = 0x8000008;
k_nDefaultBodyItem = 0x8000000;

k_sDefaultAView = new Array();
k_sDefaultAView[ 1 ] = "AView:1,1,1,0|";
k_sDefaultAView[ 2 ] = "AView:2,1,1,0|";

function _func_LaunchGame( uGameCode, strParam )
{
	NXC3W.Game.Launch( uGameCode, strParam );
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ÆË¾÷Ã¢À» ¶ç¿î´Ù..
*	args : URL, height, width, isResizable, isScrollbars, isNewWin , isAlertMessage
*********************************************************************/
function openWin( strUrl )
{
	var args = openWin.arguments;
	var sHeight = window.screen.height;
	var sWidth = window.screen.width;
	var iHeight, iWidth, isResizable, isScrollbars,isNewWin,isAlertMessage;
	var iLeft, iTop;
	if( args.length >= 2 )
		iHeight = args[1];
	else
		iHeight = 500;
		
	if( args.length >= 3 )
		iWidth = args[2];
	else
		iWidth = 300;
		
	if( args.length >= 4 )
		isResizable = args[3];
	else
		isResizable = 1;
		
	if( args.length >= 5 )
		isScrollbars = args[4];
	else
		isScrollbars = 0;
		
	if( args.length >= 6 )
		isNewWin = args[5];
	else
		isNewWin = null;
		
	if( args.length >= 7 )
		isAlertMessage = args[6];
	else
		isAlertMessage = "";
		
	iTop = ( sHeight-iHeight )/2;
	iLeft = ( sWidth-iWidth )/2;
	
	//alert( iHeight + "-" + iWidth );
	if( isAlertMessage != "" )
		openWindow_cookie(strUrl, isNewWin, "height=" + iHeight +", width=" + iWidth + ", top=" + iTop + ", left=" + iLeft + ", resizable=" + isResizable + " ,scrollbars=" + isScrollbars , true , isAlertMessage );
	else
		openWindow(strUrl, isNewWin, "height=" + iHeight +", width=" + iWidth + ", top=" + iTop + ", left=" + iLeft + ", resizable=" + isResizable + " ,scrollbars=" + isScrollbars );
}

/*********************************************************************
*	1) TERRA(2004/09/03) : ÆË¾÷Ã¢À» ¶ç¿î´Ù..
*	args : strURL, strName, strFeatures, isReplace , alertMessage
*********************************************************************/
function openWindow()
{
	var args = openWindow.arguments;
	var objNewWindow;
	switch( args.length )
	{
		case 1:
			objNewWindow = window.open( args[0] );
			break;
		case 2:
			objNewWindow = window.open( args[0], args[1] );
			break;
		case 3:
			objNewWindow = window.open( args[0], args[1], args[2] );
			break;
		case 4:
			objNewWindow = window.open( args[0], args[1], args[2], args[3] );
			break;	
		case 5:
			objNewWindow = window.open( args[0], args[1], args[2], args[3] );
			break;	
	}

}

function openWindow_cookie()
{
	var args = openWindow_cookie.arguments;
	var objNewWindow;
	
	switch( args.length )
	{
		case 1:
			objNewWindow = window.open( args[0] );
			break;
		case 2:
			objNewWindow = window.open( args[0], args[1] );
			break;
		case 3:
			objNewWindow = window.open( args[0], args[1], args[2] );
			break;
		case 4:
			objNewWindow = window.open( args[0], args[1], args[2], args[3] );
			break;
		case 5:
			objNewWindow = window.open( args[0], args[1], args[2], args[3] );
			break;		
	}
	if( objNewWindow == null )
	{
		if ( getCookies( "NotPopup" ) != "1" )
		{
			setCookie( "NotPopup" , "1"  );
				
			if( confirm("ÆË¾÷ÀÌ Â÷´Ü µÇ¾ú½À´Ï´Ù ¾È³» ÆäÀÌÁö·Î ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î? ÆË¾÷ÀÌ Â÷´ÜµÇ¾úÀ» °æ¿ì, ¼­ºñ½º ÀÌ¿ë¿¡ ºÒÆíÀÌ ÀÖÀ» ¼ö ÀÖ½À´Ï´Ù.") )
			{
				setCookie( "NotPopup" , "0"  ) ;
				parent.location.href = "http://help.nexon.com/help/page/Gnx.aspx?URL=Info/XPGuide";
			}
		}
		else if ( getCookies( "NotPopup" ) == "1" && args[4] != null && args[4] != "" )
		{
			alert( args[4] );
		}
	}
	
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ÆË¾÷À» È­¸é °¡¿îµ¥·Î ÀÌµ¿ÇÏ°í »çÀÌÁî¸¦ ÀûÀýÈ÷ Á¶Á¤ÇÑ´Ù.
*********************************************************************/
function resizePopTo_C( width, height )
{
	if ( parent == self )
	{
		resizePopTo( width, height );
	}
	else
	{
		resizePopTo_P( width, height );
	}
}

function resizePopTo( width, height )
{
	if( getQS( "NoWindowMove" ) != "1" )
	{
		var sHeight = window.screen.height;
		var sWidth = window.screen.width;
		var height = height;
		var width = width;
		var top = ( sHeight-height )/2;
		var left = ( sWidth-width )/2;
		window.moveTo(left, top);
		window.resizeTo(width, height);
	}
}

function resizePopTo_P( width, height )
{
	if( getQS( "NoWindowMove" ) != "1" )
	{
		var sHeight = window.screen.height;
		var sWidth = window.screen.width;
		var height = height;
		var width = width;
		var top = ( sHeight-height )/2;
		var left = ( sWidth-width )/2;
//		parent.window.moveTo(left, top);
		parent.window.resizeTo(width, height);
	}
}

function resizePopTo_NotMove( width, height )
{
	if( getQS( "NoWindowMove" ) != "1" )
	{
		var sHeight = window.screen.height;
		var sWidth = window.screen.width;
		var height = height;
		var width = width;
		var top = ( sHeight-height )/2;
		var left = ( sWidth-width )/2;
		parent.window.resizeTo(width, height);
	}
}

/*********************************************************************
*	1) TERRA(2003/??/??) : »Ñ·ÁÁø ¾ÆÀÌÅÛÀ» ¾Æ¹ÙÅ¸¿¡ ÀÔÈú¶§ »ç¿ë
*********************************************************************/
function fn_Wear( maskLayerInfo, oidItem, codeMessengerPos, isItemmall )
{
	var args = fn_Wear.arguments;
	var isGameShop;
	if( args.length >= 5 )
		isGameShop = args[4];
	else
		isGameShop = false;

	var strUrl = location.href.toLowerCase();
	var strShop = "";
	
	if( strUrl.indexOf( "nx.aspx?url=mypage/item_myroomall") != -1 )
		strShop = "MyRoom";
	else if( strUrl.indexOf( "nx.aspx?url=mypage/item_myroom") != -1 )
		strShop = "MyRoom";
	else if( strUrl.indexOf( "nxclub.aspx?url=itemmall/dress_popup") != -1 )
		strShop = "MyRoom";
	
	try {	
		var strAView;
		if( isGameShop )
		{
			if( isSetOtherSex ) 
			{
				Avatar_User.ToggleWear(maskLayerInfo, oidItem, codeMessengerPos);
				if( NXC3W.GetAXSessionValue("isOtherSex") == "1" )
				{
					NXC3W.SetAXSessionValue("AView_GameShop_Other",  Avatar_User.GetAView() );
				}
				else
				{
					strAView = Avatar_User.GetAView();
					NXC3W.SetAXSessionValue("AView_GameShop", strAView);
				}
			}
		}
		else if( isItemmall )
		{
			if( isSetOtherSex ) 
			{
				Avatar_User.ToggleWear(maskLayerInfo, oidItem, codeMessengerPos);
				if( NXC3W.GetAXSessionValue("isOtherSex") == "1")
				{
					NXC3W.SetAXSessionValue("AView_Other",  Avatar_User.GetAView() );
				}
				else
				{
					strAView = Avatar_User.GetAView();
					NXC3W.SetAXSessionValue("AView_Shop", strAView);
				}
			}
		}
		else if( strShop == "MyRoom" )
		{
			Avatar_User.ToggleWear(maskLayerInfo, oidItem, codeMessengerPos);
			strAView = Avatar_User.GetAView();
			NXC3W.SetAXSessionValue("AView_Room", strAView);
		}
		else
		{
			Avatar_User.ToggleWear(maskLayerInfo, oidItem, codeMessengerPos);
		}
	} catch( e ) {}
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ¼¥°ú ¿ÊÀåÀÌ ¾Æ´Ñ°æ¿ì¿¡ ¾Æ¹ÙÅ¸°¡ ÀÔ°í ÀÖ´Â ¿ÊÀ» º¸¿©ÁØ´Ù.
*********************************************************************/
function SetWearWithAView()
{
	var strAViewOther;
	try {	
		//ActiveX Session¿¡¼­ AView¸¦ °¡Á®¿Í¼­ ºñ¿ö ÀÖ´Â °æ¿ì´Â 
		//Ã³À½ µé¾î¿Â °æ¿ìÀÌ¹Ç·Î ±×·ÁÁø ¾Æ¹ÙÅ¸¿¡¼­ AView¸¦ °¡Á®´Ù°¡ ActiveX Session¿¡ ³Ö´Â´Ù.
		var AView = NXC3W.GetAXSessionValue("AView");
		if(AView == "")
		{
			AView = Avatar_User.GetAView();
			NXC3W.SetAXSessionValue("AView", AView);
			NXC3W.SetAXSessionValue("Sex", Avatar_User.m_nSex);
		}
		else
		{
			Avatar_User.SetWithAView( AView );
		}
		Avatar_User.ChangeFace( NXC3W.MyInfo.GetEmotion() );

		//»óÁ¡ÀÌ ¾Æ´Ï¹Ç·Î Shop¿¡¼­ ÄÚµðÇÑ ³»¿ëÀº ¸ðµÎ Áö¿î´Ù.
		NXC3W.SetAXSessionValue("isOtherSex", "0");
		
		strAViewOther = GetDefaultAView( +NXC3W.GetAXSessionValue("Sex") );
		NXC3W.SetAXSessionValue("AView_Other", strAViewOther);
		NXC3W.SetAXSessionValue("AView_Shop", AView); 
		NXC3W.SetAXSessionValue("AView_GameShop_Other", strAViewOther); 
		NXC3W.SetAXSessionValue("AView_GameShop", AView); 
	} catch( e ) {}
}


/*********************************************************************
*	1) TERRA(2003/??/??) : ¼¥ÀÎ °æ¿ì¿¡ ¾Æ¹ÙÅ¸°¡ ÀÔ°í ÀÖ´Â ¿ÊÀ» º¸¿©ÁØ´Ù.
*********************************************************************/
function SetWearWithAView_Shop()
{
	try
	{
		//ÀÌ¼ºÀÇ»óÀ» º¸°í ÀÖÀ¸´ÂÁö °Ë»ç.
		if( NXC3W.GetAXSessionValue( "isOtherSex") == "1" )
		{
			//ÀÌ¼ºÀÇ»óÀ» º¸´Â ÁßÀÌ¸é AView_OtherÀÇ °ªÀ» ÀÔÈù´Ù.
			Avatar_User.SetWithAView( NXC3W.GetAXSessionValue("AView_Other") );
			
		}
		else
		{
			//º»ÀÎÀÇ»óÀ» º¸´Â ÁßÀÌ¸é AView_ShopÀÇ °ªÀ» ÀÔÈù´Ù.
			Avatar_User.SetWithAView( NXC3W.GetAXSessionValue("AView_Shop" ));
			//alert( "1" );
			Avatar_User.ChangeFace( NXC3W.MyInfo.GetEmotion() );
		}
	}
	catch( e ) {}
}

/*********************************************************************
*	1) TERRA(2004/07/22) : °ÔÀÓ¸Ó´Ï¼¥ÀÎ °æ¿ì¿¡ ¾Æ¹ÙÅ¸°¡ ÀÔ°í ÀÖ´Â ¿ÊÀ» º¸¿©ÁØ´Ù.
*********************************************************************/
function SetWearWithAView_GameShop()
{
	//ÀÌ¼ºÀÇ»óÀ» º¸°í ÀÖÀ¸´ÂÁö °Ë»ç.
	if( NXC3W.GetAXSessionValue("isOtherSex") == "1")
	{
		//ÀÌ¼ºÀÇ»óÀ» º¸´Â ÁßÀÌ¸é AView_GameShop_Other ÀÇ °ªÀ» ÀÔÈù´Ù.
		try {	
			Avatar_User.SetWithAView(NXC3W.GetAXSessionValue("AView_GameShop_Other"));
			
			} catch( e ) {}
		
	}
	else
	{
		//º»ÀÎÀÇ»óÀ» º¸´Â ÁßÀÌ¸é AView_GameShop ÀÇ °ªÀ» ÀÔÈù´Ù.
		try {	
			Avatar_User.SetWithAViewNR(NXC3W.GetAXSessionValue("AView_GameShop"));
			Avatar_User.ChangeFace(NXC3W.MyInfo.GetEmotion());
		} catch( e ) {}
	}
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ¿ÊÀåÀÎ °æ¿ì¿¡ ¾Æ¹ÙÅ¸°¡ ÀÔ°í ÀÖ´Â ¿ÊÀ» º¸¿©ÁØ´Ù.
*********************************************************************/
function SetWearWithAView_Room()
{
	var strAView = NXC3W.GetAXSessionValue("AView_Room");
	if( strAView != "" )
		Avatar_User.SetWithAViewNR( strAView );
	Avatar_User.ChangeFace(NXC3W.MyInfo.GetEmotion());
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ¿ÊÀå¿¡¼­ ÀÔ°í ÀÖ´ø ¿ÊÀÌ ÀúÀåµÈ AxtiveX SesseionÀ» ÃÊ±âÈ­ ÇÑ´Ù.
*********************************************************************/
function ReSetWearWithAView_Room()
{
	try
	{
		NXC3W.SetAXSessionValue("AView_Room", "");
	}
	catch( e ) 
	{}
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ¼ºº°¿¡ µû¸¥ Default AView¸¦ ³Ñ°ÜÁØ´Ù.
*********************************************************************/
function GetDefaultAView( codeSex )
{
	if( +codeSex == 1 )
		strAView = k_sDefaultAView[ 2 ];
	else
		strAView = k_sDefaultAView[ 1 ];
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ¿ÊÀå ÆË¾÷À» ¶ç¿î´Ù.
*********************************************************************/
function goDress()
{
	openWindow('http://www.nexon.com/KR/Page/nxclub.aspx?URL=itemmall/dress_popup', null, 'height=600, width=466, resizable=0');
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ÇöÀç ÀÔ°í ÀÖ´Â ¿ÊÀ» ¼±¹°ÇÑ´Ù.
*********************************************************************/
function goGiftAll()
{
	try {	
		var AView = Avatar_User.GetAView();
		var IList = AView2IList(AView);
		IList = IList.substr(6);
		
		var strUrl = getQS( "URL" ).toLowerCase();
		var strOidShop = getQS( "oidShop" ).toLowerCase();
		
		if( strUrl == "itemmall/gostopmoneyshop" || strOidShop == 1540 )	// ninanada : °í½ºÅé¸Ó´Ï˜Þ¿¡¼­ ¼±¹°½Ã 
			openWin('NXIPop.aspx?URL=itemmall/giftGameMoney_item&IList=' + IList , 458,508,0,0);
		else
			openWin('NXIPop.aspx?URL=itemmall/gift_popup&IList=' + IList,458,508,0,0);
			
	} catch( e ) {}
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ÇöÀç ÀÔ°í ÀÖ´Â ¿ÊÀ» ±¸ÀÔÇÑ´Ù.
*********************************************************************/
function goBuyCA()
{
	try {	
		var AView = Avatar_User.GetAView();
		var IList = AView2IList(AView);
		IList = IList.substr(6);
		
		var strUrl = getQS( "URL" ).toLowerCase();
		var strOidShop = getQS( "oidShop" ).toLowerCase();
		
		if( strUrl == "itemmall/gostopmoneyshop" || strOidShop == 1540 )	// ninanada : °í½ºÅé¸Ó´Ï˜Þ¿¡¼­ ±¸¸Å½Ã 
			openWin("NXIPop.aspx?URL=itemmall/buyGameMoney_item&isBuy=1&IList=1|" + oidItem + ",1|",468,460,0,0);
		else
			openWin('NXIPop.aspx?URL=itemmall/buy_popup&IList=' + IList);
	} catch( e ) {}
}

function AViewMatchIList( isIList , isAview )
{
	var count = 0;
	var tempList = isIList;

	IList_count = isIList.substr(0,1);
	Aview_count = isAview.substr(0,1);
	
	isIList = isIList.substr(2);
	isAview = isAview.substr(2);
	
	isItemNum_list = isIList.split(",1|");	
	isItemNum_AView = isAview.split(",1|");

	for( j = 0; j < isItemNum_list.length-1 ; j++ )
	{	
		for ( i = 0 ; i < isItemNum_AView.length-1 ; i++ )
		{
			if ( isItemNum_list[j] == 134217736 || isItemNum_list[j] == 134217735 || isItemNum_list[j] == 134217734 
						|| isItemNum_list[j] == 134217733 || isItemNum_list[j] == 134217738 || isItemNum_list[j] == 134217737 )
			{
				count++
				break;
			} 
			else if ( ( isItemNum_AView[i] == isItemNum_list[j] )  )
			{
				count++
				break;
			}
		}
	}


	if ( IList_count == count ) 
		return false;
	else
		return true;
}

// ninanada : °ÔÀÓ³» °í½ºÅé¸Ó´Ï˜Þ¿¡¼­ ±¸¸Å½Ã 
function goBuyCA_inGame()
{
	try {	
		// ¸®½ºÆ®
		var AView = Avatar_User.GetAView();
		var IList = AView2IList(AView);
		IList = IList.substr(6);
		
		// ÃÊ±â ¾Æ¹ÙÅ¸
		var strAView = NXC3W.GetAXSessionValue("AView");
		var isAview = AView2IList(strAView);
		isAview = isAview.substr(6);
	
		if ( AViewMatchIList( IList , isAview ) )
		{
			location.href="http://www.nexon.com/KR/Page/NXIPop.aspx?URL=itemmall/buyGameMoney_item&IList=" + IList;
		}
		else
		{
			alert("±¸¸Å ÇÒ »óÇ°À» ¼±ÅÃÇÏ¼¼¿ä.");
		}
	} catch( e ) {}
}

/*********************************************************************
*	1) TERRA(2004/??/??) : ¸ðµÎ ¹þ±â. 
*********************************************************************/
function setDefault_Dress()
{
	try
	{
		Avatar_User.TakeOffAll();
		if( NXC3W != null )
		{
			var strAView = Avatar_User.GetAView();
			NXC3W.SetAXSessionValue("AView_Room", strAView);
		}
	} catch( e ) {}
}

function setDefault()
{
	try
	{
		if( isSetOtherSex && NXC3W != null )
		{
			var strAView;
			
			var isOtherSex = NXC3W.GetAXSessionValue("isOtherSex");
			if( ( isOtherSex == "1" && NXC3W.GetAXSessionValue("Sex") == "1" ) || ( isOtherSex != "1" && NXC3W.GetAXSessionValue("Sex") != "1" ))
				strAView = k_sDefaultAView[ 2 ];
			else
				strAView = k_sDefaultAView[ 1 ];
	
			if( isOtherSex == "1" )
			{
				NXC3W.SetAXSessionValue("AView_GameShop_Other", strAView );
				NXC3W.SetAXSessionValue("AView_Other", strAView);
			}
			else
			{
				NXC3W.GetAXSessionValue("AView_Shop", strAView );
				NXC3W.GetAXSessionValue("AView_GameShop", strAView );
			}
			Avatar_User.TakeOffAll();
		}
	} catch( e ) {}
}

/*********************************************************************
*	1) TERRA(2004/??/??) : ¿ø·¡ ÀÔ°í ÀÖ´ø ¿ÊÀ¸·Î °¥¾ÆÀÔ±â.
*********************************************************************/
function setOrigin_Dress()
{
	try
	{
		if( NXC3W != null )
		{
			var strAView = NXC3W.GetAXSessionValue("AView");
			Avatar_User.SetWithAView(strAView);
			NXC3W.SetAXSessionValue("AView_Room", strAView);
		}
	} catch( e ) {}
}
function setOrigin()
{
	var strAView;
	try
	{
		if( NXC3W.GetAXSessionValue("isOtherSex") == "1")
		{
			if( NXC3W.GetAXSessionValue("Sex")=="1" )
				strAView = k_sDefaultAView[ 2 ];
			else
				strAView = k_sDefaultAView[ 1 ];
			NXC3W.SetAXSessionValue("AView_GameShop_Other", strAView);
			NXC3W.SetAXSessionValue("AView_Other", strAView);
		}
		else
		{
			strAView = NXC3W.GetAXSessionValue("AView");
			NXC3W.SetAXSessionValue("AView_Shop", strAView);
			NXC3W.SetAXSessionValue("AView_GameShop", strAView);
		}
		try {	
			Avatar_User.SetWithAView(strAView);
		} catch( e ) {}

	}
	catch(e)
	{
	}
}

/*********************************************************************
*	1) TERRA(2004/??/??) : opener reload ÈÄ ÆË¾÷ ´ÝÀ½.. 
*********************************************************************/
function winClose()
{
	try
	{
		opener.location.reload();
	}
	catch( e ) {}
	window.close();
}

/*********************************************************************
*	1) TERRA (2003/??/??) :	QueryStringÀ¸·Î ³Ñ¾î¿Â °ªÀ» ³Ñ°ÜÁØ´Ù.
*********************************************************************/
function getQS(isValue)
{
	var strQueryString;
	var strHref = document.location.href.toLowerCase();
	isValue = isValue.toLowerCase();
	
	strQueryString = strHref.substr(strHref.indexOf("?")+1);
	strQueryString = "&" + strQueryString + "&";

	var n4Index = strQueryString.indexOf("&" + isValue + "=");
	var tempValue ;
	
	strUrlString = document.location.href.substr(strHref.indexOf("?")+1);
	strUrlString = "&" + strUrlString + "&";
	
	if(n4Index == -1)
	{
		return "";
	}
	else
	{
		tempValue = strUrlString.substr(n4Index+1);
		tempValue = tempValue.substring(tempValue.indexOf("=")+1, tempValue.indexOf("&"));
		if( tempValue == "undefined")
			tempValue = "";
		return tempValue;
	}
}

/*********************************************************************
*	1) TERRA (2003/??/??) :	ÆäÀÌÁö¸¦ ÀÌµ¿ÇÑ´Ù. ( nType = 1 ÆäÀÌÁö nType=2 :  ÆË¾÷)
*********************************************************************/
function goLocation( nType, strLink )
{
	if( nType == 1)
	{
		location.href = strLink;
	}
	else
	{
		if( opener == null )
		{
			openWindow( strLink );
		}
		else
		{
			try
			{
				opener.location.href =strLink;
			}
			catch( e )
			{
				openWindow(strLink);
			}
			
		}
		window.close();
	}
}

/*********************************************************************
*	1) TERRA (2003/??/??) :	±æµå¹Ù·Î°¡±â SelectBox¿¡¼­ Å¬·´À» ¼±ÅÃÇßÀ»¶§..
*********************************************************************/
function goSelectedClub(object)
{
	objIndex = object.selectedIndex ;
	if( objIndex != 0 )
	{
		goClub( object[objIndex].value );
	}
}

/*********************************************************************
*	1) TERRA (2003/??/??) :	Æ¯Á¤ serialnoÀÇ ±æµå·Î ÀÌµ¿ÇÑ´Ù.
*********************************************************************/
/*
// closed by jjong(2005.11.16)
function goClub(clubserialno)
{
	if( clubserialno == -1 )
	{
		location.href = "http://club.nexon.com/nxclub/club/my_club.jsp";
	}
	else if( clubserialno == -2 )
	{
		return false;
	}
	else if( clubserialno == -3 )
	{
		openWindow('http://club.nexon.com/nxclub/club/club_setting_popup.jsp', 'club_setting', 'width=455, height=510');
	}
	else
	{
		location.href = "http://club.nexon.com/nxclub/club/mainframe.jsp?clubserialno=" + clubserialno;
	}
}
*/

// added by jjong(2005.11.16)
function goClub( sValue )
{
	if( sValue == '-1' )
	{
		location.href = "http://guild.nexon.com/guildnexon/page/Gnx.aspx?URL=Guild/guild_bookmark";
	}
	else if( sValue == '-2' )
	{
		return false;
	}
	else if( sValue == '-3' )
	{
		location.href = "http://Guild.Nexon.Com/GuildNexon/Page/Gnx.aspx"
	} 
	else
	{
		location.href = "http://Guild.Nexon.Com/" + sValue
	}
} 

/*********************************************************************
*	1) TERRA (2003/??/??) :	·Î±äÈÄ »ç¿ëÇÏ¶ó´Â Ä¿¸ÇÆ®¸¦ ÁÖ°í ·Î±äÃ¢¿¡ Æ÷Ä¿½º
*********************************************************************/
function alertLogin()
{
	alert("·Î±×ÀÎ ÈÄ »ç¿ë ÇÒ ¼ö ÀÖ½À´Ï´Ù.");
	try { setFocusLogin(); } catch(e) {}
}

/*********************************************************************
*	1) TERRA (2003/??/??) :	À¯ÀúÀÇ ·¹º§µîÀ» °Ë»çÇÑ ÈÄ °ÔÀÓÀ» ½ÇÇàÇÑ´Ù. 
*********************************************************************/
function fn_LaunchGame(maskGame, n1Level)
{
	var isLaunch = false;
	if( getCookies( "IL") == 1 )
		isLaunch = true;
	if( isLaunch )
	{
		isLaunch = false;
		var n1UserLevel = +fn_GetGameLevel();//fn_GetMoenyLevel
		var n1StartLevel = +fn_GetGameStartLevel();
		var codeGame = + document.getElementById( 'hiddenCodeGame' ).value; 
		var n4Money = + document.getElementById( 'hiddenMoney' ).value;

		if( codeGame == 12 )
		{
			if( n1UserLevel >= n1Level ) 
				isLaunch = true;
		}
		else if( codeGame == 3 || codeGame == 4 ) 
		{
			if( n1Level == 0 || ( n1UserLevel >= n1Level &&  n1Level >= n1StartLevel ) )
				isLaunch = true;
		}
		else if( codeGame == 14 )
		{
			n1UserLevel =  fn_GetMoenyLevel();

			if( n1Level <= n1UserLevel )
			{
				isLaunch = true;
			}
		}
		else if( codeGame == 10801 )// »Ñ±î
		{
			n1UserLevel = +fn_GetMoenyLevel() + 1 ;//fn_GetMoenyLevel
			if( n1UserLevel >= n1Level )
				isLaunch = true;
		}
		else if( codeGame == 20 )//À¥ºñÁî
		{
			n1UserLevel = +fn_GetMoenyLevel() + 1 ;//fn_GetMoenyLevel
			if( n1UserLevel >= n1Level )
				isLaunch = true;
		}
		else if (codeGame == 28) // ¸¸¸¸ÀÌ
		{
			var tempLevel = n1Level.split("-custom:");
			if (tempLevel.length > 0)
			{
				if (n1UserLevel >= parseInt(tempLevel[0]))
				{
					isLaunch = true;
				}
			}
		}
		else if (codeGame == 33) // ±«µµ³ÉÀÌ
		{
			if( n1UserLevel >= n1Level )
				isLaunch = true;
		}
		else
		{
			if( n1UserLevel >= n1Level )
				isLaunch = true;
		}
	}

	try
	{
		if( isLaunch )
		{	
			EVM.addCommand( EVM.k_nEventType_onLoginReplyOK, EVM.k_nPriority_normal, new EVMDelegator( _func_LaunchGame ), maskGame, n1Level+"" );
		}
	}
	catch(e)
	{
		alert("·Î±×ÀÎ ÈÄ °ÔÀÓÀ» ÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");
	}
}

/*********************************************************************
*	1) TERRA (2003/??/??) :	·Î±×ÀÎ Çß´ÂÁö °Ë»çÈÄ °ÔÀÓÀ» ½ÇÇàÇÑ´Ù.
*********************************************************************/
function fn_LaunchGame_Login( maskGame, n1Level )
{
	var isLaunch = false;
	if( getCookies( "IL") == 1 )
		isLaunch = true;

	if( isLaunch )
	{
		EVM.addCommand( EVM.k_nEventType_onLoginReplyOK, EVM.k_nPriority_normal, new EVMDelegator( _func_LaunchGame ), maskGame, n1Level+"" );
	}
	else
	{
		alert("·Î±×ÀÎ ÈÄ °ÔÀÓÀ» ÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.");
	}
}

/*********************************************************************
*	1) TERRA (2003/??/??) :	°ÔÀÓ ´Ù½Ã ¼³Ä¡ÇÏ±â
*********************************************************************/
function fn_LaunchGame_ReSetup( maskGame, installOption )
{
	EVM.addCommand( EVM.k_nEventType_onLoginReplyOK, EVM.k_nPriority_normal, new EVMDelegator( _func_LaunchGame ), maskGame, installOption );
}

/*********************************************************************
*	1) TERRA (2003/??/??) :	·¹º§ ·Î±ä¿¡ »ó°ü¾øÀÌ °ÔÀÓÀ» ½ÇÇàÇÑ´Ù. ( For RPG )
*********************************************************************/
function fn_LaunchGame_AllLevel( maskGame, n1Level )
{
	EVM.addCommand( EVM.k_nEventType_onLoginReplyOK, EVM.k_nPriority_normal, new EVMDelegator( _func_LaunchGame ), maskGame, n1Level+"" );
}

/*********************************************************************
*	1) TERRA (2003/??/??) :	TextBox¿¡ ¿£ÅÍÃÆÀ»¶§ Submit ¸øÇÏ°Ô..
*********************************************************************/
function IgnoreEnter()
{
	if(event.keyCode == 13)
	{
		return false;
	}
	else
	{
		return true;
	}
}

/*********************************************************************
*	1) TERRA(2003/??/??) : À¥°ÔÀÓ¿ë ¸®ÇÊÆË¾÷À» ¶ç¿î´Ù.(°¢°ÔÀÓÆäÀÌÁö, ¸¶ÀÌÆäÀÌÁö°ÔÀÓÁ¤º¸)
*********************************************************************/
function doRefill(codeGame)
{
	openWin('NXPop.aspx?URL=game/moneyrefill_pop&codeGame=' + codeGame ,287,370,0,0);
}

/*********************************************************************
*	1) TERRA(2003/??/??) : À¥ºê¶ó¿ìÁ®ÀÇ Å¸ÀÌÆ²À» ¹Ù²Û´Ù.
*********************************************************************/
function resetTitle( strValue )
{
	document.title = strValue;
}


/*********************************************************************
*	1) TERRA(2003/??/??) : ÆË¾÷À¸·Î PostBack
*********************************************************************/
/*
 * closed by you46(2005.12.15)
 *
function submitTarget( isNewWin,  strTarget )
{
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf('netscape') > -1) {
		theform = document.forms['NX'];
	}
	else {
		theform = document.NX;
	}

	if( isNewWin )
	{
		var popWin;
		openWindow('about:blank', popWin, 'height=500, width=300, resizable=0');
		theform.target = popWin;
	}
	else
	{
		theform.target = strTarget;
	}
}
*/

// modify by you46(2005.12.15)
// Ã¢Å©±â¸¦ ¼³Á¤ÇÒ ¼ö ÀÖµµ·Ï ÀÎÀÚ¸¦ 2°³ ´õ Ãß°¡ÇÔ.
function submitTarget( isNewWin, strTarget, strWidth, strHeight )
{
	var theform;
	if (window.navigator.appName.toLowerCase().indexOf('netscape') > -1) {
		theform = document.forms['NX'];
	}
	else {
		theform = document.NX;
	}

	if( isNewWin )
	{
		var popWin;
		
		if ( ( strWidth != "" ) && ( strHeight != "" ) )
		{
			var strAttribute = "";
			strAttribute = "width=" + strWidth + ", height=" + strHeight + ", resizable=0";

			openWindow( 'about:blank', popWin, strAttribute );
		}
		else
		{
			openWindow( 'about:blank', popWin, 'height=500, width=300, resizable=0' );
		}
		theform.target = popWin;
	}
	else
	{
		theform.target = strTarget;
	}

}

/*********************************************************************
*	1) TERRA(2003/??/??) : ÃæÀüÇÏ±â ÆË¾÷ ¶ç¿ì±â.
*********************************************************************/
function openCash()
{
	if( getCookies( "IL" ) == "1"  )
	{
		openWindow('http://www.nexon.com/KR/etc/cash.aspx', null, 'height=430, width=455, resizable=0');
	}
	else
	{
		alert("·Î±×ÀÎ ÈÄ »ç¿ëÇÏ¼¼¿ä.");
	}
	
	window.event.cancelBubble = true;
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ·Î±×¾Æ¿ô ÆäÀÌÁö·Î ÀÌµ¿
*********************************************************************/
function F_logOut()
{
	if( location.href.toLowerCase().indexOf( "?url=login/loginmes" ) == -1 )
		location.href = 'http://www.nexon.com/KR/Page/NX.aspx?URL=Login/Logout&redirect=' + escape( document.location.href ) ;
	else
		location.href = 'http://www.nexon.com/KR/Page/NX.aspx?URL=Login/Logout';
}

/*********************************************************************
*	1) YOU46(2006/03/08) : ÇØ´ç ¾ÆÀÌµð¿¡°Ô Ä£±¸¿äÃ» ¸Þ¼¼Áö¸¦ º¸³½´Ù.
*********************************************************************/
function AddGameFriend( strFriendID, maskGameCode )
{
	window.open( "http://message.nexon.com/Nxcom/Page/Gnx.aspx?URL=Message/memo_friend_add&maskGameCode=" + maskGameCode + "&strLocalID="+ strFriendID + "&strVirtualUserName=" + strFriendID, "add_friend", "width=348, height=284 scrollbars=0,location=0,status=no,resizable=0,menubar=0,titlebar=0,toolbar=0" );
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ÇØ´ç ¾ÆÀÌµð¿¡°Ô Ä£±¸¿äÃ» ¸Þ¼¼Áö¸¦ º¸³½´Ù.
	2) YOU46(2006/03/08) : MODIFY
*********************************************************************/
function FriendList_AddFriend_NotMemo( strLocalID )
{
	//openWin( "http://www.nexon.com/kr/msg/add_friend.html?strLocalID=" + strLocalID + "&strVirtualUserName=", 350, 348, 0, 0 );
	window.open( "http://message.nexon.com/Nxcom/Page/Gnx.aspx?URL=Message/memo_friend_add&maskGameCode=65536&strLocalID="+ strLocalID + "&strVirtualUserName=", "add_friend", "width=348, height=284 scrollbars=0,location=0,status=no,resizable=0,menubar=0,titlebar=0,toolbar=0" );
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ÇØ´ç ¾ÆÀÌµð¿¡°Ô Ä£±¸¿äÃ» ¸Þ¼¼Áö¸¦ º¸³½´Ù.
	2) YOU46(2006/03/08) : MODIFY
*********************************************************************/
function FriendList_AddFriend_Kart( strVirtualUserName )
{
	//openWin("http://www.nexon.com/kr/msg/add_friend_kart.html?strLocalID=&strVirtualUserName="+ strVirtualUserName , 350, 348, 0, 0);
	window.open( "http://message.nexon.com/Nxcom/Page/Gnx.aspx?URL=Message/memo_friend_add&maskGameCode=73985&strLocalID=&strVirtualUserName=" + strVirtualUserName, "add_friend", "width=348, height=284 scrollbars=0,location=0,status=no,resizable=0,menubar=0,titlebar=0,toolbar=0" );
}

/*********************************************************************
*	1) YOU46(2005/06/21) : ÇØ´ç ¿ö·Ï ¾ÆÀÌµð¿¡°Ô Ä£±¸¿äÃ» ¸Þ¼¼Áö¸¦ º¸³½´Ù.
	2) YOU46(2006/03/08) : MODIFY
*********************************************************************/
function FriendList_AddFriend_Warrock( strVirtualUserName )
{
	//openWin("http://www.nexon.com/kr/msg/add_friend_warrock.html?strLocalID=&strVirtualUserName="+ strVirtualUserName , 350, 348, 0, 0);
	window.open( "http://message.nexon.com/Nxcom/Page/Gnx.aspx?URL=Message/memo_friend_add&maskGameCode=94212&strLocalID=&strVirtualUserName=" + strVirtualUserName, "add_friend", "width=348, height=284 scrollbars=0,location=0,status=no,resizable=0,menubar=0,titlebar=0,toolbar=0" );
}

/*********************************************************************
*	1) YOU46(2005/12/17) : ÇØ´ç ¾ÆÀÌµð¿¡°Ô Ä£±¸¿äÃ» ¸Þ¼¼Áö¸¦ º¸³½´Ù.
	2) YOU46(2006/03/08) : MODIFY
*********************************************************************/
function FriendList_AddFriend_Bigshot( strVirtualUserName )
{
	//openWin("http://www.nexon.com/kr/msg/add_friend_bigshot.html?strLocalID=&strVirtualUserName="+ strVirtualUserName , 350, 348, 0, 0);
	window.open( "http://message.nexon.com/Nxcom/Page/Gnx.aspx?URL=Message/memo_friend_add&maskGameCode=74243&strLocalID=&strVirtualUserName=" + strVirtualUserName, "add_friend", "width=348, height=284 scrollbars=0,location=0,status=no,resizable=0,menubar=0,titlebar=0,toolbar=0" );
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ÇÇ¾¾¹æ Ã£±â ÆË¾÷ ¶ç¿ì±â
*********************************************************************/
function fn_findPC()
{
	openWindow('http://pcbang.nexon.co.kr/nexoncom/PCBANG_init.asp',null, 'height=451, width=475,toolbars=no, scrollbars=yes');
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ·Î±×ÀÎ TextBox¿¡ focus
*********************************************************************/
function setFocusLogin( )
{
	var strSaveID  = getCookies('SaveID') ;

	if( strSaveID != '' )
	{
		try { 
			document.forms[0].NxTxtLocalID.value = strSaveID
			document.forms[0].NxCheckSaveID.checked = true;
			document.forms[0].NxTxtPassword.focus();
		} catch( e ) {
			try { 
				document.forms[0].NxTxtLocalID.focus();
			} catch( e ) {}
		}
	}
	else
	{
		try { 
			document.forms[0].NxTxtLocalID.focus();
		} catch( e ) {}
	}
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ¸ÞÀÎ ÆäÀÌÁö Popup ÆË¾÷ ¹Ù²ð¶§ ¸¶´Ù ÄíÅ° ÀÌ¸§µµ ¹Ù²ãÁÖ±â..
*********************************************************************/
function openIndexEvnet()
{

	if( getCookies( "OK" ) != "1" )
	{
//		openWindow_cookie("http://www.nexon.com/html/popup/open_kartnpucca.html", "openIndexEvnet", "scrollbars=no,resizable=no,width=401,height=398");
	}

}

function openPollEvent()
{

	if( getCookies( "permanent_PollEvent" ) != "1" )
	{
		openWindow("http://www.nexon.com/html/popup/poll_card.html", "permanent_PollEvent", "scrollbars=no,resizable=no,width=455,height=400");
	}
}

/*********************************************************************
*	1) TERRA(2003/??/??) : ½ºÆ®¸µÀÇ ±æÀÌ¸¦ ±¸ÇÑ´Ù. 
*********************************************************************/
function Hlen( paramString )
{
	var	hlen=0;
	for (t=0; t<paramString.length; t++)
	{
	    if (paramString.charCodeAt(t) > 255)
		{
			hlen=hlen+2;
		}
	    	else
		{
    		hlen=hlen+1;
		}
	}
	return hlen;
}

/*********************************************************************
*	1) TERRA(2003/??/??) : º°¸í ±æÀÌ¸¦ °Ë»çÇÑ´Ù.
*********************************************************************/
function chkNickNameLen( source, arguments )
{
	var isReturn = false;
	var strNickName = arguments.Value;
	if( Hlen(strNickName) <= 12 )
		isReturn = true;

	arguments.IsValid = isReturn;
}

function chkNickNameChar( source, arguments )
{
	var isReturn = false;
	var strNickName = arguments.Value;

	if( strNickName.indexOf("'") == -1 )
		isReturn = true;
	else
		isReturn = false;

	arguments.IsValid = isReturn;
}

/*********************************************************************
*	1) TERRA(2004/??/??) : formSub¿¡ hidden typeÀÇ textboxÀ» Ãß°¡ÇÑ´Ù.
*********************************************************************/
function addChildForSubform( strName, strValue )
{
	var objForm = document.getElementById( 'formSub' );
	var objInput;
	try
	{
		objInput = document.getElementById( 'formSub' ) + strName ;
		objInput.value = strValue;
	}
	catch( e )
	{
		objInput = document.createElement( "<input type='hidden' name='" + strName + "' value='" + strValue + "' >" );
		objForm.appendChild( objInput );
	}
}

/*********************************************************************
*	1) TERRA(2004/??/??) : formSubÀ» submit ÇÑ´Ù.
*********************************************************************/
function submitForSubform( strURL )
{
	var objForm = document.formSub;
	objForm.action = strURL;
	objForm.submit();
}

/*********************************************************************
*	1) TERRA(2004/??/??) : LoginÃ³¸®ÆäÀÌÁö·Î Submit 
*********************************************************************/
function submitLogin()
{
	addChildForSubform( "strPassport", NXC3W.MyInfo.GetPassport() );
	submitForSubform( "http://www.nexon.com/nx/Page/gnx.aspx?URL=Login/LoginProc");
}


/*********************************************************************
*	1) TERRA(2004/??/??) : Nxconn¿¡¼­ LoginReply°¡ ¿ÔÀ»¶§ ÄÚµåº°·Î ¿¡·¯Ã³¸® È¤Àº ·Î±ä
*********************************************************************/
function GetLoginMessage( subCode )
{
	if( MSGER.k_isLoginning )
	{
		if ( subCode == LoginResult.kOK 
			|| subCode == LoginResult.kNewUser
			|| subCode == LoginResult.kSwitchDomain
			|| subCode == LoginResult.kTempBlockByForeigner
			|| subCode == LoginResult.kTempBlockByWarning )
		{
			submitLogin();
		}
		else if ( subCode == LoginResult.kWrongId )
		{
			window.open( "http://www.nexon.com/nx/page/gnxPopupNomsg.aspx?URL=login/loginfail_wrongid", "NotLogin", "width=370,height=210,toolbar=no,status=no,directories=no,scrollbars=no,location=no,resizable=no,menubar=no" );
		}
		else if ( subCode == LoginResult.kWrongPwd )
		{
			window.open( "http://www.nexon.com/nx/page/gnxPopupNomsg.aspx?URL=login/LoginFail_WrongPwd", "NotLogin", "width=370,height=210,toolbar=no,status=no,directories=no,scrollbars=no,location=no,resizable=no,menubar=no" );
		}
		else if ( subCode == LoginResult.kWrongOwner )
		{
			window.open( "http://www.nexon.com/nx/page/gnxPopupNomsg.aspx?URL=login/LoginFail_WrongOwner", "NotLogin", "width=370,height=210,toolbar=no,status=no,directories=no,scrollbars=no,location=no,resizable=no,menubar=no" );
		}
		else if ( subCode == LoginResult.kBlockByAdmin )
		{
			window.open( "http://www.nexon.com/nx/page/gnxPopupNomsg.aspx?URL=login/LoginFail_BlockByAdmin", "NotLogin", "width=370,height=210,toolbar=no,status=no,directories=no,scrollbars=no,location=no,resizable=no,menubar=no" );
		}
		else if ( subCode == LoginResult.kTempBlockByLoginFail )
		{
			window.open( "http://www.nexon.com/nx/page/gnxPopupNomsg.aspx?URL=login/LoginFail_BlockByLoginFail", "NotLogin", "width=370,height=210,toolbar=no,status=no,directories=no,scrollbars=no,location=no,resizable=no,menubar=no" );
		}
		else if ( subCode == LoginResult.kLockedByAnotherProcess )
		{
			alert( "ÀÌ¹Ì ´Ù¸¥ ¾ÆÀÌµð·Î À¥ÀÌ³ª ³Ø½¼ÇÃ·¯±×¿¡ ·Î±×ÀÎ ÁßÀÔ´Ï´Ù. ³Ø½¼Àº ÇÑ ÄÄÇ»ÅÍ¿¡¼­ ÇÑ ¾ÆÀÌµð·Î¸¸ ·Î±×ÀÎ ÇÒ ¼ö ÀÖ½À´Ï´Ù." );
		}
		else if ( subCode == LoginResult.kBlockedIp )
		{
			alert( "Æ¯Á¤ IP ¹× ¿î¿µÃ¼Á¦¿¡¼­´Â ·Î±×ÀÎÇÒ ¼ö ¾ø½À´Ï´Ù." );
		}
		MSGER.k_isLoginning = false;
	}
}

/*********************************************************************
*	1) TERRA(2004/??/??) : ·Î±ä ÅØ½ºÆ®¹Ú½º¿¡ ¿£ÅÍÃÆÀ»¶§ ·Î±äÃ³¸®
*********************************************************************/
function chkEnter()
{
	if( event.keyCode == 13 )
	{
		submitLoginMes();
	}
}

/*********************************************************************
*	1) TERRA(2004/??/??) : ÀÌº¥Æ® ÆäÀÌÁö¿¡ ½æ³×ÀÏÀ» ¸î°³ º¸¿©ÁÙÁö ¼³Á¤
*********************************************************************/
function getQSForEvent()
{
	return 1;
}

/*********************************************************************
*	1) TERRA(2004/??/??) : ÀÌº¥Æ® ÆäÀÌÁö¸¦ À§ÇÑ ·£´ýÇÔ¼ö
*********************************************************************/
// Randmize ÇÔ¼ö (ÇÑ°è°ªÀ» ¹ë·ù·Î ¹Þ´Â´Ù)
frk_rnd.today=new Date();
frk_rnd.seed=frk_rnd.today.getTime();

function frk_randomize(number) {
	return Math.ceil(frk_rnd()*number);
}

function frk_rnd() {
	frk_rnd.seed = (frk_rnd.seed*9301+49297) % 233280;
	return frk_rnd.seed/(233280.0);
}

/*********************************************************************
*	1) TERRA(2004/??/??) : ÂÊÁöÇÔÀ¸·Î ÀÌµ¿
*********************************************************************/
function goMessageBox()
{
	window.open( "http://message.nexon.com/nxcom/page/Gnx.aspx?URL=message/memo_box", "memo_box", "width=640,height=480,toolbar=no,status=no,directories=no,scrollbars=no,location=no,resizable=no,menubar=no");
}

function NxConn_MessageBox()
{
	window.open( "http://message.nexon.com/nxcom/page/Gnx.aspx?URL=message/memo_box", "memo_box", "width=640,height=480,toolbar=no,status=no,directories=no,scrollbars=no,location=no,resizable=no,menubar=no");
}

/*********************************************************************
*	1) TERRA(2004/??/??) : Å×ÀÌºíÀÇ TR¸¦ Áö¿î´Ù.
*********************************************************************/
function ResetTable( objTable )
{
	var args = ResetTable.arguments;
	var iStartIndex;
	if( args.length >= 2 )
		iStartIndex = args[1];
	else
		iStartIndex = 0;

	var iLength = objTable.rows.length;
	for(var i=iStartIndex ; i< iLength; i++)
	{
		objTable.deleteRow( iStartIndex );
	}
}


//Util
function rTrim(word) {
	var wordLeng = word.length;
	var i;
	var pos, first, last;

	for(i = wordLeng-1; i >= 0; i--) {
		if(word.charAt(i) != " ") break;
	}
	pos = i;
	first = 0;
	last = pos + 1;
	word = word.substring(first,last);
	return word;
}

function lTrim(word) {
	var wordLeng = word.length;
	var i;
	var pos, first, last;

	for(i = 0; i < wordLeng; i++) {
		if(word.charAt(i) != " ") break;
	}
	pos = i;
	first = pos;
	last = wordLeng;
	word = word.substring(first,last);
	return word;
}

function trim(word) {
	word = lTrim(word);
	word = rTrim(word);
	return word;
}

function trimAll(word) {
	var wordLeng = word.length;
	var i;

	for(i=0; i<wordLeng; i++) {
		word = word.replace(' ','');
	}
	return word;
}



// ÄíÅ° ÀúÀå : Permanent Cookie --> µÇµµ·ÏÀÌ¸é »ç¿ëÇÏÁö ¸¶¼¼¿ä. ÄíÅ° ²¿ÀÔ´Ï´Ù... -_-;;;
function setCookie_Permanent(nameVal, value)
{
//	document.Domain = "nexon.com"
	document.cookie = nameVal + "=" + escape(value) + ";expires=Thu, 30 Aug 2030 10:02:13 UTC; path=/; domain=nexon.com;";
}

// ÄíÅ° ÀúÀå : Temporary Cookie --> µÇµµ·ÏÀÌ¸é ÀÌ¸¦ »ç¿ëÇÏ±â ¹Ù¶ø´Ï´Ù. Permanent CookieÀÇ ³²¹ßÀº ¾öÃ»³­ Àç¾ÓÀ» ÃÊ·¡ÇÕ´Ï´Ù.
function setCookie_setTimeout(nameVal, value, dayTimeout) {
	dayTimeout = +dayTimeout;

	if (!dayTimeout || dayTimeout <= 0) {
		dayTimeout = 1;
	}
	var dateNow = new Date();
	var dateTommorrow = new Date(dateNow.getTime() + 1*24*60*60*1000*dayTimeout);
	document.cookie = nameVal + "=" + escape(value) + ";expires=" + dateTommorrow.toUTCString() + "; path=/; domain=nexon.com";
}

// ÄíÅ° ÀúÀå : Temporary Cookie --> ÀÍ½º ÇÃ·Î·¯ ÇÑ¹ø ²¯´Ù Å³µ¿¾È
function setCookie(nameVal, value) {
	document.cookie = nameVal + "=" + value + "; path=/; domain=nexon.com;";
}

// ÄíÅ° ÀÐ±â
function getCookies(nameVal)
{
	if ( nameVal.length > 4 )
	{
		if ( nameVal.substring( 0, 4 ) == "NXCH" )
		{
			return getCookies2( nameVal );
		}
	}

	var numCookie = document.cookie.length;
	var oven = document.cookie.split( "; " );

	for ( var i = 0; i < oven.length; i++ )
	{
		if ( oven[i].indexOf( "=" ) != -1 )
		{
			cookieName = oven[i].substring( 0, oven[i].indexOf( "=" ) );
		} else {
			cookieName = oven[i];
		}

		if ( cookieName == nameVal )
		{
			if ( oven[i].indexOf( "=" ) != -1 )
			{
				cookieVal = oven[i].substr( oven[i].indexOf( "=" ) + 1 );
			} else {
				cookieVal = "";
			}
			return cookieVal;
		}
	}
	return "";
}

// added by you46(2006.02.02)
function getCookies2( nameVal )
{
	if ( nameVal == "" )
	{
		return "";
	}

	if ( nameVal.length <= 4 )
	{
		return getCookies( nameVal );
	}

	var retCookieValue = "";
	var numCookie = document.cookie.length;

	var strNXCHCookieValue = "";
	var strHeaderKey = nameVal.substring( 0, 4 );
	var strSubHeaderKey = nameVal.substring( 4, nameVal.length );

	// "NXCH" ¶Ç´Â "NXLO" CookieCollection¿¡ ´ëÇØ¼­¸¸ µ¿ÀÛÇÔ.
	if ( ( strHeaderKey == "NXCH" ) || ( strHeaderKey == "NXLO" ) )
	{
		// ÀüÃ¼ ÄíÅ°°ªÀ» ºÐ¸®ÇÔ.
		var strCookieSplitValue = document.cookie.split( "; " );

		// ¹®ÀÚ¿­ ¹è¿­¿¡¼­ "NXCH" ¶Ç´Â "NXLO" CookieCollection °ªÀÌ Á¸ÀçÇÏ´ÂÁö¸¦ Ã¼Å©ÇÔ.
		for ( var i = 0; i < strCookieSplitValue.length; i++ )
		{
			if ( strCookieSplitValue[i].indexOf( "=" ) != -1 )
			{
				if ( strCookieSplitValue[i].substring( 0, strCookieSplitValue[i].indexOf( "=" ) ) == strHeaderKey )
				{
					strNXCHCookieValue = strCookieSplitValue[i].substr( strCookieSplitValue[i].indexOf( "=" ) + 1 );
				}
			}
		}

		if ( strNXCHCookieValue != "" )
		{
			// ¿øÇÏ´Â CookieCollection°ªÀ» ´Ù½Ã ºÐ¸®ÇÔ.
			var strSplitValue = strNXCHCookieValue.split( "&" );

			// ¹®ÀÚ¿­ ¹è¿­¿¡¼­ ¿øÇÏ´Â "ID", "SEX", "AGE" µîÀ» ±¸ÇÑ´Ù.
			for ( var j = 0; j < strSplitValue.length; j++ )
			{
				if ( strSplitValue[j].substring( 0, strSplitValue[j].indexOf( "=" ) ) == strSubHeaderKey )
				{
					if ( strSplitValue[j].indexOf( "=" ) != -1 )
					{
						retCookieValue = strSplitValue[j].substr( strSplitValue[j].indexOf( "=" ) + 1 );
					}
					break;
				}
			}
		}
		return retCookieValue;
	}
	else
	{
		return getCookies( nameVal ); // CookieCollectionÀÌ ¾Æ´Ñ °æ¿ì ÇØ´ç ÄíÅ°°ªÀ» ¹ÝÈ¯.
	}
}

function AddFriend()
{
	var strLocalID, strMessage;
	if((document.forms[0].txtLocalID.value) == "")
	{
		alert("¾ÆÀÌµð¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		document.forms[0].txtLocalID.focus();
	}
	else
	{
		strLocalID = document.forms[0].txtLocalID.value + "";
		if( document.forms[0].txtMessage.value == "" )
			strMessage = "";
		else
			strMessage = document.forms[0].txtMessage.value;
		
		NXC3W.Friend.RequestNewFriend( strLocalID, strMessage, 0, GameCode.NxCom, GameCode.NxCom, 0, 0 );

		document.forms[0].txtLocalID.value = "";
		document.forms[0].txtMessage.value = "";
	}
}

function AddFriend_kart()
{
	var strLocalID, strMessage;
	if((document.forms[0].txtLocalID.value) == "")
	{
		alert("¶óÀÌ´õ¸íÀ» ÀÔ·ÂÇÏ¼¼¿ä.");
		document.forms[0].txtLocalID.focus();
	}
	else
	{
		strLocalID = document.forms[0].txtLocalID.value + "";
		if( document.forms[0].txtMessage.value == "" )
			strMessage = "";
		else
			strMessage = document.forms[0].txtMessage.value;
		
		NXC3W.Friend.RequestNewFriend( strLocalID, strMessage, 0, GameCode.Kart, GameCode.Kart, 0, 0 );

		document.forms[0].txtLocalID.value = "";
		document.forms[0].txtMessage.value = "";
	}
}

function AddFriend_warrock()
{
	var strLocalID, strMessage;
	if((document.forms[0].txtLocalID.value) == "")
	{
		alert( "¿ö·Ï°ÔÀÓID¸¦ ÀÔ·ÂÇÏ¼¼¿ä." );
		document.forms[0].txtLocalID.focus();
	}
	else
	{
		strLocalID = document.forms[0].txtLocalID.value + "";
		if( document.forms[0].txtMessage.value == "" )
			strMessage = "";
		else
			strMessage = document.forms[0].txtMessage.value;
		
		NXC3W.Friend.RequestNewFriend( strLocalID, strMessage, 0, GameCode.Warrock, GameCode.Warrock, 0, 0 );

		document.forms[0].txtLocalID.value = "";
		document.forms[0].txtMessage.value = "";
	}
}

function AddFriend_bigshot()
{
	var strLocalID, strMessage;
	if((document.forms[0].txtLocalID.value) == "")
	{
		alert("ºò¼¦°ÔÀÓID¸¦ ÀÔ·ÂÇÏ¼¼¿ä.");
		document.forms[0].txtLocalID.focus();
	}
	else
	{
		strLocalID = document.forms[0].txtLocalID.value + "";
		if( document.forms[0].txtMessage.value == "" )
			strMessage = "";
		else
			strMessage = document.forms[0].txtMessage.value;
		
		NXC3W.Friend.RequestNewFriend( strLocalID, strMessage, 0, GameCode.Bigshot, GameCode.Bigshot, 0, 0 );

		document.forms[0].txtLocalID.value = "";
		document.forms[0].txtMessage.value = "";
	}
}

function OpenWinAddFriend()
{
	strURL = "http://message.nexon.com/Nxcom/Page/Gnx.aspx?URL=Message/memo_friend_add&maskGameCode=" + m_nGameCode + "&strVirtualIDCode=" + strSelVirtualIDCode + "&strLocalID=&strVirtualUserName=";
	window.open( strURL , 'add_friend', 'width=348, height=284 scrollbars=0,location=0,status=no,resizable=0,menubar=0,titlebar=0,toolbar=0' );
}

function SetMailCount( n1Count )
{
	// Not Use
}

function GetMailCount()
{
	// Not Use
	return 0;
}

function fn_FormatGameMoney( n4Money )
{
	var strReturn = '';
	var isMinus = false;
	var arrMoney = new Array(); 
	arrMoney[0] = '¿ø'
	arrMoney[1] = '¸¸'
	arrMoney[2] = '¾ï'
	arrMoney[3] = 'Á¶'
	
	var strMoney = n4Money;
	
	if( strMoney.substr( 0, 1 ) == '-' )
	{
		isMinus = true;
		strMoney = strMoney.Substring( 1 );
	}
	var strTempMoney='';
	var n4TempMoney;
	
	if( n4Money == 0 )
	{
		strTempMoney = '0¿ø';
		strReturn = '0¿ø';
	}
	else
	{
		for( var i=0; i<4; i++)
		{
			if( strMoney.length>4 )
			{
				n4TempMoney = strMoney.substr( strMoney.length - 4, 4);
				strMoney = strMoney.substr(0, strMoney.length-4);
				
			}
			else
			{
				n4TempMoney = strMoney ;
				strMoney = '';
			}

			if( n4TempMoney == 0 && i == 0)
			{
				strTempMoney = '¿ø';
			}
			else if( n4TempMoney != 0 )
			{
				strTempMoney = ' ' + n4TempMoney + arrMoney[i];
			}
			else
			{
				strTempMoney = '';
			}

			strReturn = strTempMoney + strReturn;

			if( strMoney == '' )
				break;
		}
	}
	strReturn = trim( strReturn );
	if( isMinus )
		strReturn = '-' + strReturn;
	return strReturn;
}


function goUserInfo( /* int */ oidUser )
{
	//openWindow('http://club.nexon.com/nxclub/club/include/member_popup.jsp?memberserialno=' + oidUser , 'UserInfo', 'width=360, height=450');
	openWindow( "http://message.nexon.com/nxcom/page/Gnx.aspx?URL=User/Popup/UserInfo_Popup&oidUser=" + oidUser , "UserInfo", "width=330, height=420" );
}


// !!!!
function Nxconn_ReInstall()
{
	EVM.addCommand( EVM.k_nEventType_onLoginReplyOK, EVM.k_nPriority_normal, new EVMDelegator( function(){ NXC3W.Util.ReinstallPlug(); } ) );
}

// !!!!
function IsClosedWindow()
{
	var strUrl = getQS( "URL" ).toLowerCase();
	if( strUrl == "mypage/chgnick_popup" || strUrl == "itemmall/dress_popup" 
	|| strUrl == "login/resetaview" || strUrl == "login/resetnickname" )
		return true;
	else
		return false;
}

function _ReplaceAll( word, word1, word2 ) {
	var wordLeng = word.length;
	for( var i=0; i < wordLeng; i++ ) {
		word = word.replace( word1, word2 );
	}
	return word;
}

/*==================================================

	* ¿ÍÀÌÁî·Î±× ¼¼ÆÃ °ü·Ã
	
==================================================*/

function submitForIFrame( strUrl, MainCat, SubCat, Value )
{
	var objIFrame = document.getElementById( 'formForWiseLog' );
	var iframeUrl = strUrl;
	
	if ( MainCat != '' )
		iframeUrl += "&MainCat=" + MainCat;
		
	if ( SubCat != '' )
		iframeUrl += "&SubCat=" + SubCat;
		
	if ( Value != '' )
		iframeUrl += "&Value=" + Value;
	
	objIFrame.src = iframeUrl;
}


function GoGsEshop( strURL, isLogging )
{
	var strMedia = "mo";

	if ( strURL == "" )
	{
		strURL = "http://with.gseshop.co.kr/jsp/main.jsp";
	}

	window.open( "http://with.gseshop.co.kr/jsp/jseis_withLGeshop.jsp?media=" + strMedia + "&gourl=" + escape( strURL ) );
		
		var strURLForWiseLog = "http://event.nexon.com/common/page/Gnx.aspx?URL=ForWiseLog/GoGSeshop";
	if( typeof( document.getElementById( 'formForWiseLog' ) ) == "object" )
		document.getElementById( 'formForWiseLog' ).src = strURLForWiseLog;
}
