function onload_start_EVM()
{
	try { onload_start(); }catch( e ) {}
}

function WriteAvatar()
{
	var strUrl = location.href.toLowerCase();
	var strShop;
	
	if( strUrl.indexOf( "nx.aspx?url=itemmall/gostopmoneyshop") != -1 )
		strShop = "GameShop";
	else if( strUrl.indexOf( "nx.aspx?url=itemmall/fscasual") != -1 )
		strShop = "Fscasual";
	else if( strUrl.indexOf( "nx.aspx?url=itemmall/index") != -1 )
		strShop = "None";
	else if( strUrl.indexOf( "nxclub.aspx?url=itemmall/dress_popup") != -1 )
		strShop = "None";
	else if( strUrl.indexOf( "nx.aspx?url=itemmall/") != -1 )
		strShop = "Shop";
	else 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
		strShop = "None";
		
	if( strShop == "None" )
	{
		NXC3W.SetAXSessionValue( "AView_Room", "" );
		SetWearWithAView();
	}
	else if( strShop == "Shop" )
	{
		NXC3W.SetAXSessionValue( "AView_Room", "" );
		SetWearWithAView();
		//SetWearWithAView_Shop();
	}
	else if( strShop == "Fscasual" )
	{
		NXC3W.SetAXSessionValue( "AView_Room", "" );
		//SetWearWithAView_Shop();
	}
	else if( strShop == "GameShop" )
	{
		NXC3W.SetAXSessionValue( "AView_Room", "" );
		//SetWearWithAView_GameShop();
	}
	else if( strShop == "MyRoom" ) 
	{
		SetWearWithAView_Room();
	}
}

// modify by you46(2005.12.22)
function GetMemoCount()
{
	try
	{
		if ( ( document.all.spanMemoCount != undefined ) && ( document.all.spanMemoCount != null ) )
			document.all.spanMemoCount.innerHTML = 0;

		if ( ( document.all.spanMailCount != undefined ) && ( document.all.spanMailCount != null ) )
			document.all.spanMailCount.innerHTML = 0;

		var n4MailCount = 0;
		var n4MemoCount = NXC3W.Note.GetUnreadCount();

		ChangeMemoImg( n4MemoCount , n4MailCount );
		try { NotifyNewMemoForKart( n4MemoCount ); } catch( e ) {}
//		AlarmMemoPaper( n4MemoCount );
		CheckMemoCount_NXMain();
	}
	catch( e )
	{
		CheckMemoCount_NXMain();
	}

}


// added by you46(2005.12.22)
function CheckMemoCount_NXMain()
{
	var n4MemoCount = 0;

	if ( ( document.all.spanMemoImg != undefined ) && ( document.all.spanMemoImg != null ) )
	{

		try
		{
			n4MemoCount = NXC3W.Note.GetUnreadCount();

			if ( n4MemoCount > 0 )
			{
				document.all.spanMemoImg.innerHTML = "<img src='http://s.nx.com/S2/Nexon2005/Image/icon/ico_memo01_ani.gif' width='12' height='14' align='absmiddle' style='margin:0 3px 0 3px;cursor:hand;' onClick='goMessageBox();'>";
			}
			else
			{
				document.all.spanMemoImg.innerHTML = "<img src='http://s.nx.com/S2/Nexon2005/Image/icon/ico_memo01.gif' width='12' height='14' align='absmiddle' style='margin:0 3px 0 3px;cursor:hand;' onClick='goMessageBox();'>";
			}
		}
		catch( e )
		{
			if ( n4MemoCount > 0 )
			{
				document.all.spanMemoImg.innerHTML = "<img src='http://s.nx.com/S2/Nexon2005/Image/icon/ico_memo01_ani.gif' width='12' height='14' align='absmiddle' style='margin:0 3px 0 3px;cursor:hand;' onClick='goMessageBox();'>";
			}
			else
			{
				document.all.spanMemoImg.innerHTML = "<img src='http://s.nx.com/S2/Nexon2005/Image/icon/ico_memo01.gif' width='12' height='14' align='absmiddle' style='margin:0 3px 0 3px;cursor:hand;' onClick='goMessageBox();'>";
			}
		}
	}
}

function ChangeMemoImg( n4MemoCount , n4MailCount )
{
	if( n4MemoCount != 0) 
	{
		if ( ( document.all.spanMemoCount != undefined ) && ( document.all.spanMemoCount != null ) )
			document.all.spanMemoCount.innerHTML = n4MemoCount;
			
		if ( ( document.all["imgMemo02"] != undefined ) && ( document.all["imgMemo02"] != null ) )//¸ÞÀÎÅ¾
			document.all["imgMemo02"].src = "http://file.nx.com/image/global/ani_top_memo02.gif";
			
		if ( ( document.all["imgMemo_main02"] != undefined ) && ( document.all["imgMemo_main02"] != null ) )//¸ÞÀÎÆäÀÌÁö
			document.all["imgMemo_main02"].src = "http://file.nx.com/image/icon/ico_memo03_ani.gif";
	
		if ( ( document.all["imgMemo"] != undefined ) && ( document.all["imgMemo"] != null ) )//È÷½ºÅä¸®Å¾
			document.all["imgMemo"].src = "http://file.nx.com/image/global/ani_top_memo.gif";
			
		if ( ( document.all["imgMemo_main"] != undefined ) && ( document.all["imgMemo_main"] != null ) )//¼­ºêÆäÀÌÁö
			document.all["imgMemo_main"].src = "http://file.nx.com/image/icon/ico_memo03_ani.gif";
//				document.all["imgMemo_main"].src = "http://file.nx.com/image/global/ani_info_memoicon.gif";			
			
	}
	
	if( n4MailCount != 0) 
	{
		if ( ( document.all.spanMailCount != undefined ) && ( document.all.spanMailCount != null ) )
			document.all.spanMailCount.innerHTML = n4MailCount;
			
		if ( ( document.all["imgMail02"] != undefined ) && ( document.all["imgMail02"] != null ) )//¸ÞÀÎÅ¾
			document.all["imgMail02"].src = "http://file.nx.com/image/global/ani_top_mail02.gif";
			
		if ( ( document.all["imgMail_main02"] != undefined ) && ( document.all["imgMail_main02"] != null ) )//¸ÞÀÎÆäÀÌÁö
			document.all["imgMail_main02"].src = "http://file.nx.com/image/icon/ico_mail01_ani.gif";
			
		if ( ( document.all["imgMail"] != undefined ) && ( document.all["imgMail"] != null ) )//È÷½ºÅä¸®Å¾
			document.all["imgMail"].src = "http://file.nx.com/image/global/ani_top_mail.gif";
			
		if ( ( document.all["imgMail_main"] != undefined ) && ( document.all["imgMail_main"] != null ) )//¼­ºêÆäÀÌÁö
			document.all["imgMail_main"].src = "http://file.nx.com/image/icon/ico_mail01_ani.gif";
			//document.all["imgMail_main"].src = "http://file.nx.com/image/global/ani_mail_lettericon.gif";
	}
}

function AlarmMemoPaper( )
{
	try
	{
		var n4MemoCount = NXC3W.Note.GetUnreadCount();
		
		// 1) NINANADA(2004/06/03) : ·Î±×ÀÎÇßÀ» ¶§  ÀÐÁö¾ÊÀº ÂÊÁö°¡ ÀÖÀ¸¸é ÆË¾÷¶ç¿ì±â.		
		if( n4MemoCount != 0 && n4MemoCount != "" ) 
		{
			if( getCookies( "MP" ) != "1" )
			{
				//openWindow_cookie("http://www.nexon.com/KR/msg/alarm_paper.html?n4Count=" + n4MemoCount, "MP", "scrollbars=no,resizable=no,width=320,height=220");
				openWindow_cookie( "http://message.nexon.com/Nxcom/Page/Gnx.aspx?URL=Message/memo_alarm&n4Count=" + n4MemoCount, "MP", "scrollbars=no,resizable=no,width=370,height=250" );
			}
		}

		setCookie( 'MP', '1' );
	}
	catch( e )
	{}

}

function SetChangedUserInfo_AvatarAcon()
{
	Avatar_Acon_User.ChangeFace( NXC3W.MyInfo.GetUserInfo().aiAvatarInfo.uEmotion );
}

function SetRefresh_Avatar()
{
	//ifrmRefresh.location.href='http://www.nexon.com/kr/mypage/ResetAView.aspx';
	ifrmRefresh.location.href='http://www.nexon.com/kr/page/nx.aspx?URL=login/ResetAView';
}

function SetRefresh_NickName()
{
	ifrmRefresh.location.href='http://www.nexon.com/kr/page/nx.aspx?URL=login/ResetNickName';
}


//ÇØ´ç ¾ÆÀÌµð¿¡°Ô ÂÊÁöº¸³»±âÃ¢ ¶ç¿ì±â
function OpenWin_SendNote( strReceiverID, maskGameCode )
{
	openWin("http://message.nexon.com/Nxcom/Page/Gnx.aspx?URL=message/memo_send&strLocalID=" + strReceiverID + "&strVirtualUserName=" + strReceiverID + "&maskGameCode=" + maskGameCode, 268, 370, 0, 0);
}

// ¼Û½ÅÀÚ°¡ Á¸ÀçÇÏ°í ÇØ´ç ¾ÆÀÌµð¿¡°Ô ÂÊÁö º¸³»±âÃ¢ ¶ç¿ì±â
function OpenWin_SendNote2( strVirtualIDCode, strReceiverID, maskGameCode )
{
	openWin( "http://message.nexon.com/Nxcom/Page/Gnx.aspx?URL=message/memo_send&strVirtualIDCode=" + strVirtualIDCode + "&strLocalID=" + strReceiverID + "&strVirtualUserName=" + strReceiverID + "&maskGameCode=" + maskGameCode, 268, 370, 0, 0 );
}

function HTMLEncode( /*string*/ strHTML )
{
	var result = strHTML.replace( /</gi, "&lt;" );
	result = result.replace( />/gi, "&gt;" );
	return result;
}

function sendMessageForGift( strLocalID , strMemo )
{
	var n4Dummy = 0;
	EVM.addCommand( EVM.k_nEventType_onLoginReplyOK, EVM.k_nPriority_normal, new EVMDelegator( NXC3W.UserMemo_Send_Gift ), strLocalID , strMemo );
}

function sendMessageForGift_Parent( strLocalID , strMemo )
{
	var n4Dummy = 0;
	parent.frmBottom.EVM.addCommand( parent.frmBottom.EVM.k_nEventType_onLoginReplyOK, parent.frmBottom.EVM.k_nPriority_normal, new EVMDelegator( parent.frmBottom.NXC3W.UserMemo_Send_Gift ), strLocalID , strMemo );
}

function ReloadTopPage( inType, inSubCode )
{
	NXC3W.CustomEvent( inType, 100, inSubCode );
	if( (getQS( "NoWindowMove" ) != "1" ) && IsClosedWindow() )
	{
		window.close();
	}
}

function SaveAvatarAview()
{	
	try
	{
		NXC3W.SetAXSessionValue('AView', Avatar_User.GetAView());
		NXC3W.SetAXSessionValue('AView_Shop', Avatar_User.GetAView());
		NXC3W.SetAXSessionValue('AView_GameShop', Avatar_User.GetAView());
		return true;
	}
	catch(e)
	{
	}
}


function ResetNickName()
{
	opener.NXC3W.RefreshInfo( NXC_EVENT.k_nRefresh_NickName );
	window.close();
}

function onItemmallBuy_GameLock(  source, arguments  )
{
	return;
}

function onItemmallBuy_GameLockFull(  source, arguments  )
{
	return;
}

var isBuying = false;
function onBuyButtonClickCount( source, arguments )
{
	var isReturn = false;

	if( isBuying )
	{
		isReturn = false;						
	}
	else
	{
		isBuying = true;
		isReturn = true;	
	}

	arguments.IsValid = isReturn;
}


/*********************************************************************
*	1) deute(2007/02/07) : ÂÊÁö ÆË¾÷ ¶ç¿ì±â ¼³Á¤ 
*********************************************************************/
function openMemobox( url ){
	var memo_cs = "";
	if ( getCookies( "IL" ) == 1  ) {
		memo_cs = getCookies( "NXCHOID" );	
	}
	var memobox_target = "memo_box_" + memo_cs;
	window.open( 'http://message.nexon.com/nxcom/page/Gnx.aspx?URL=message/memo_box', memobox_target , 'width=640,height=480,toolbar=no,status=no,directories=no,scrollbars=no,location=no,resizable=no,menubar=no');
}