
function doUpdateSession()
{
	if( getCookies( "IL" ) == "1" 	// À¥¼¼¼ÇÀÌ Á¸ÀçÇÏ´Â °æ¿ì¸¸, Auth Server ¿¡ UpdateSession
	&& location.href.toLowerCase().indexOf( "/localhost/" ) == -1  
	&&  location.href.toLowerCase().indexOf("?url=_comp/login_notlogin") == -1
	&&  location.href.toLowerCase().indexOf("?url=login/logout") == -1
	&&  location.href.toLowerCase().indexOf("?url=login/loginproc") == -1)
	{
		AuthSystem.UpdateSession( onUpdateResponse );
	}
}

var objUpdateInterval = null;
function onUpdateResponse( resultObject, responseXML )
{
	if( resultObject.ErrorCode == undefined )	// Auth Server ¿¡ Session ÀÌ Á¸ÀçÇÏÁö ¾ÊÀ¸¹Ç·Î, ·Î±×¾Æ¿ô Ã³¸®
	{
		var strRedirect  = document.location.href.toLowerCase();
		location.href ="http://login.nexon.com/nx/Page/gnx.aspx?URL=Login/Logout&redirect" + strRedirect ;
	}
	else if( resultObject.ErrorCode == CommonError.NoError )		// OK
	{
		EVM.raiseEvent( EVM.k_nEventType_onRefreshNoteBox, resultObject.UnreadNoteCount );	// ÂÊÁöCount  ¸¦ Ã³¸®ÇÏ±â À§ÇÑ ÀÌº¥Æ® ¹ß»ý
		
		if( objUpdateInterval != null )
			window.clearInterval( objUpdateInterval );
		objUpdateInterval = setInterval( "doUpdateSession()", resultObject.UpdateInterval * 1000 );	// ExpireLimit(Second) ÀÌÈÄ, UpdateSession
		
		Debug.print( "objUpdateInterval = " + objUpdateInterval );
	}
	else if( resultObject.ErrorCode == AuthSystemError.Disconnected )
	{
		alert( "´Ù¸¥ ÄÄÇ»ÅÍ¿¡¼­ ¿¬°áÀ» ¿äÃ»ÇÏ¿© ·Î±×¾Æ¿ô µË´Ï´Ù." );

		var strRedirect  = document.location.href.toLowerCase();
		location.href ="http://login.nexon.com/nx/Page/gnx.aspx?URL=Login/Logout&redirect" + strRedirect ;
	}
	else
	{
		// Error »óÈ²À¸·Î Debeg ¸¦ À§ÇÑ Á¤º¸ Ãâ·Â
		Debug.print( 'onUpdateResponse(' + resultObject._cs + ')<br>\r\n'
				+ 'resultObject.ErrorCode = ' + resultObject.ErrorCode + '<br>\r\n'	// °á°ú(0 ÀÌ ¾Æ´Ï¸é ¿¡·¯, ¿¡·¯ ÄÚµå ÂüÁ¶)
				+ 'resultObject.ErrorMessage = ' + resultObject.ErrorMessage + '<br>\r\n'
				+ 'resultObject.NewPassport = ' + resultObject.NewPassport + '<br>\r\n'
				+ 'resultObject.UnreadNoteCount = ' + resultObject.UnreadNoteCount + '<br>\r\n'
				+ 'resultObject.StatusFlag = ' + resultObject.StatusFlag + '<br>\r\n'
				+ 'resultObject.UpdateInterval = ' + resultObject.UpdateInterval + '<br>\r\n' );
		alert( "³Ø½¼ À¥»çÀÌÆ®¿¡¼­ ·Î±×¾Æ¿ô µÇ¾ú½À´Ï´Ù. " );

		var strRedirect  = document.location.href.toLowerCase();
		location.href ="http://login.nexon.com/nx/Page/gnx.aspx?URL=Login/Logout&redirect" + strRedirect ;
	}
}

setTimeout( "doUpdateSession()", 1 );	// ExpireLimit(Second) ÀÌÈÄ, UpdateSession

