var NgbLogin = new function __NgbLogin()
{
	this.isLoginProcessing = false;
	
	var _codeRegSite = 0;
	var _strRedirect;
	
	this.SubmitLogin = function()
	{
		var strEncData = arguments [ 1 ][ 0 ];
		var codeRegSite = arguments [ 1 ][ 1 ];
		var strRedirect = arguments [ 1 ][ 2 ];
		
		if ( this.isLoginProcessing )
		{
			alert( "·Î±×ÀÎ ÇÏ´Â ÁßÀÔ´Ï´Ù. Àá½Ã¸¸ ±â´Ù·ÁÁÖ¼¼¿ä." );
			return false;
		}
		this.isLoginProcessing = true;
		
		NgbClientForm.AddChildForSubform( 'strEncData', strEncData );
		NgbClientForm.AddChildForSubform( 'codeRegSite', codeRegSite );
		
		if ( typeof( strRedirect ) != 'undefined' )
				NgbClientForm.AddChildForSubform( 'strRedirect', strRedirect );
		
		NgbClientForm.SubmitForm( 'https://' + ( ( NgbUrl.GetDomainURL() == 'df.nexon.com' || NgbUrl.GetDomainURL() == 'dflogin.nexon.com' ) ? 'dflogin.nexon.com' : 'login.nexon.com' ) + '/login/page/loginproc.aspx' );
	}

	this.Login = function( strNexonID, strPassword, codeRegSite, strRedirect )
	{
		strNexonID = NgbString.Trim( strNexonID );
		strPassword = NgbString.Trim( strPassword );
		
		if ( typeof( codeRegSite ) == 'undefined' )
			codeRegSite = 0;
			
		if ( strNexonID == '' )
		{
			alert( '¾ÆÀÌµð¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.' );
			return;
		}
		else if ( strPassword == '' )
		{
			alert( 'ºñ¹Ð¹øÈ£¸¦ ÀÔ·ÂÇØ ÁÖ¼¼¿ä.' );
			return;
		}
		
		_codeRegSite = codeRegSite;
		_strRedirect = strRedirect;
		
		try
		{
			NgbSecurity.InitData();
			
			NgbSecurity.AddData( strNexonID );
			NgbSecurity.AddData( strPassword );
			
			NgbSecurity.SetURL( 'https://' + ( ( NgbUrl.GetDomainURL() == 'df.nexon.com' || NgbUrl.GetDomainURL() == 'dflogin.nexon.com' ) ? 'dflogin.nexon.com' : 'login.nexon.com' ) + '/login/page/encryptinfo.aspx', '·Î±×ÀÎ ÇÏ´Â ÁßÀÔ´Ï´Ù. Àá½Ã¸¸ ±â´Ù·ÁÁÖ¼¼¿ä.' );
			NgbSecurity.Encrypt( NgbLogin.EncryptHandler );
		}
		catch( e )
		{
			NgbEVM.AddCommand( NgbEVM.k_nEventType_onPageEnd, new NgbEVMDelegator( NgbLogin.SubmitLogin ), '', _codeRegSite, _strRedirect );
		}
	}
	
	this.EncryptHandler = function( encData )
	{
		NgbEVM.AddCommand( NgbEVM.k_nEventType_onPageEnd, new NgbEVMDelegator( NgbLogin.SubmitLogin ), encData, _codeRegSite, _strRedirect );
	}

	this.Logout = function( strURL )
	{
		if ( typeof( strURL ) == 'undefined' )
			strURL = document.location.href;
		
		document.location.href = 'http://' + ( ( NgbUrl.GetDomainURL() == 'df.nexon.com' || NgbUrl.GetDomainURL() == 'dflogin.nexon.com' )  ? 'dflogin.nexon.com' : 'login.nexon.com' ) + '/login/page/logout.aspx?redirect=' + escape( strURL );
	}
}

var NgbCookie = new function __NgbCookie()
{
	this.GetCookie = function ( 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 '';
	}
	
	this.setCookie_Permanent = function (nameVal, value)
	{
		// ÄíÅ° ÀúÀå : Permanent Cookie --> µÇµµ·ÏÀÌ¸é »ç¿ëÇÏÁö ¸¶¼¼¿ä. ÄíÅ° ²¿ÀÔ´Ï´Ù... -_-;;;
		document.cookie = nameVal + "=" + escape(value) + ";expires=Thu, 30 Aug 2030 10:02:13 UTC; path=/; domain=nexon.com;";
	}
}

var NgbString = new function __NgbString()
{
	this.TrimStart = function ( 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;
	}

	this.TrimEnd = function ( 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;
	}

	this.Trim = function ( word ) 
	{
		word = this.TrimStart( word );
		word = this.TrimEnd( word );
		return word;
	}

	this.TrimAll = function ( word ) 
	{
		var wordLeng = word.length;
		var i;
	
		for(i=0; i<wordLeng; i++) {
			word = word.replace(' ','');
		}
		return word;
	}
	
	this.IsEmpty = function ( strParam )
	{
		if( strParam == null )
			return true;
		else if( strParam == 'undefined' )
			return true;
		else if( this.TrimAll( strParam ) == '' )
			return true;
		else
			return false;
	}
	
	this.GetLengthToByte = function ( word )
	{
		var nValue = 0;
		
		for ( var i = 0; i < word.length; i ++ )
		{
			if ( word.charCodeAt( i ) > 255 )
				nValue += 2;
			else
				nValue ++;
		}
		
		return nValue;
	}
	  
	
}

var NgbClientForm = new function __NgbClientForm()
{
	this.AddChildForSubform = function ( strName, strValue )
	{
		var objForm = document.getElementById( 'formLogin' );
		var objInput;
		try
		{
			objInput = eval( 'document.getElementById( "formLogin" ).' + strName );
			objInput.value = strValue;
		}
		catch( e )
		{
			var objInput		= document.createElement( 'input' );
			objInput.type		= 'hidden';
			objInput.name		= strName;
			objInput.value		= strValue;
			objForm.appendChild( objInput );
		}
	}

	this.SubmitFormWithTarget = function ( strURL , strTarget )
	{
		var objForm = document.formLogin;
		
		if( NgbString.Trim(strTarget) == '' )
			objForm.target = '_self';
		else
			objForm.target = strTarget;
		
		objForm.action = strURL;
		objForm.submit();
	}
	
	this.SubmitForm = function ( strURL )
	{
		this.SubmitFormWithTarget( strURL, '_self' );
	}
}

var NgbMember = new function __NgbMember()
{
	this.GoLoginPage = function()
	{
		document.location.href = 'http://login.nexon.com/login/page/nx.aspx?url=login/login&redirect=' + escape( document.location.href );
		return false;
	}

	this.OpenUserProfile = function( oidUser )
	{
		var strURL = 'http://www.nexon.com/mypage/page/nxpop.aspx?url=member/profile&oidUser=' + oidUser ;
		window.open( strURL , 'UserProfile', 'scrollbars=no, resizable=no, width=488, height=570' ); 
		return false;
	}
		
	this.SearchNexonID = function( codeRegSite, strWiseLogParam )
	{
		if ( typeof( codeRegSite ) == 'undefined' )
			codeRegSite = 1;
			
		if ( typeof( strWiseLogParam ) == 'undefined' )
			strWiseLogParam = "";
			
		var strURL = 'https://www.nexon.com/member/page/nxpop.aspx?url=nexon/searchid&codeRegSite=' + codeRegSite + strWiseLogParam;
		window.open( strURL , 'SearchID', 'scrollbars=no, resizable=no, width=488, height=580' ); 
		
		return false;
	}
	
	this.SearchPassword = function( codeRegSite, strWiseLogParam )
	{
		if ( typeof( codeRegSite ) == 'undefined' )
			codeRegSite = 1;
			
		if ( typeof( strWiseLogParam ) == 'undefined' )
			strWiseLogParam = "";
			
		var strURL = 'https://www.nexon.com/member/page/nxpop.aspx?url=nexon/searchpassword&codeRegSite=' + codeRegSite + strWiseLogParam;
		window.open( strURL , 'SearchPass', 'scrollbars=no, resizable=no, width=488, height=580'); 
		
		return false;
	}
	
	this.GoRegisterPage = function( codeRegSite, strWiseLogParam )
	{
		if ( typeof( codeRegSite ) == 'undefined' )
			codeRegSite = 1;
		if ( typeof( strWiseLogParam ) == 'undefined' )
			strWiseLogParam = "";

		window.open( 'https://www.nexon.com/join/page/nx.aspx?URL=join/join&codeRegSite=' + codeRegSite + strWiseLogParam );
		
		return false;
	}
	
	this.GoCashReFillPage = function( )
	{
		if( NgbMember.IsLogin() )
		{
			var strURL = 'http://www.nexon.com/mypage/page/cashfill.aspx' ;
			window.open( strURL , 'UserProfile', 'scrollbars=no, resizable=no, width=480, height=600' ); 
		}
		else
		{
			NgbMember.GoLoginPage();
		}
		
		return false;
	}
	
	this.IsLogin = function()
	{
		if( NgbCookie.GetCookie( 'IL' ) == '1' )
			return true;
		else
			return false;
	}
	
	this.GoPersonalInfoPage = function( n4RenderType, strWiselogParam )
	{
		var strURL = 'https://www.nexon.com/mypage/page/nxsecure.aspx?url=myinfo/personalinfo' + strWiselogParam ;
		
		if ( n4RenderType == 0 )
			location.href = strURL; 
		else
			window.open( strURL , 'Privacy', 'scrollbars=no, resizable=no, width=600, height=575' ); 
	}
	
	this.GoPrivacyPage = function()
	{
		var strURL = 'http://www.nexon.com/etc/pop_privacy.html?ST=nexon&PS=footer' ;
		window.open( strURL , 'Privacy', 'scrollbars=no, resizable=no, width=600, height=575' ); 
	}
	
	this.GoStipulationPage = function()
	{
		var strURL = 'http://www.nexon.com/etc/pop_stipulation.html?ST=nexon&PS=footer' ;
		window.open( strURL , 'Stipulation', 'scrollbars=no, resizable=no, width=590, height=525' ); 
	}
	
}

var NgbGameUser = new function __NgbGameUser()
{
	this.SearchGamePassword = function( maskGameCode )
	{
		var strURL = '';
		
		switch( maskGameCode )
		{
			case 131072: //baram
			case 196608: //lod 
			case 393216: //asgard
			case 262144: //elan 
			case 524288: //tales
				strURL = "https://www.nexon.com/doomvas/member/page/nxpop.aspx?url=game/changepassword&maskgamecode=" + maskGameCode;
				break; 
			case 589824: //maple
				strURL = "https://www.nexon.com/member/page/nxpop.aspx?url=game/changepassword_maple";
				break;
			case 720896: //ca
				strURL = "https://www.nexon.com/member/page/nxpop.aspx?url=game/changepassword_ca";
				break;
		}
		
		window.open( strURL , 'FindGamePwd_Popup', 'toolbar=no, location=no, scrollbars=no, resizable=no, width=488, height=500'); 
		
		return false;
		
	}
	
	this.ChangeGameNexonID = function( maskGameCode )
	{
		var strURL = '';
		var n4Height = 350;
		
		switch ( maskGameCode )
		{
			case 131072: //baram
			case 196608: //load 
			case 393216: //asgard
			case 262144: //elan 
				strURL = "https://www.nexon.com/doomvas/member/page/nxpop.aspx?url=game/changeid&maskgamecode=" + maskGameCode;
				break;
			case 589824: //maple
				strURL = "https://www.nexon.com/member/page/nxpop.aspx?url=game/changeid_maple";
				n4Height = 400;
				break;
			case 720896: //ca
				strURL = "https://www.nexon.com/member/page/nxpop.aspx?url=game/changeid_ca";
				break;
			case 786432: //qplay
				strURL = "https://www.nexon.com/member/page/nxpop.aspx?url=game/changeid_qplay";
				break;
		}
		
		window.open( strURL , 'ChangeNexonID_Popup', 'toolbar=no,location=no,scrollbars=no,resizable=no,width=488,height=' + n4Height ); 
		
		return false;
	}
}

var NgbNote = new function __NgbNote()
{
	this.OpenNotebox = function ( strNoteBoxURL, strWiseLogParam )
	{
		strNoteBoxURL = NgbString.IsEmpty( strNoteBoxURL ) ? 'http://message.nexon.com/nxcom/page/Gnx.aspx?URL=message/memo_box' : strNoteBoxURL;
		
		if ( !NgbString.IsEmpty( strWiseLogParam ) )
			strNoteBoxURL = strNoteBoxURL + strWiseLogParam;
		try
		{
			if( NgbMember.IsLogin() )
			{
				var memobox_target = 'memo_box_' + NgbCookie.GetCookie( 'NXCHOID' );
				window.open( strNoteBoxURL , memobox_target , 'width=640,height=480,toolbar=no,status=no,directories=no,scrollbars=no,location=no,resizable=no,menubar=no' );
			}
			else
			{
				NgbMember.GoLoginPage();
			}
		}
		catch( E )
		{
			window.open( strNoteBoxURL , memobox_target , 'width=640,height=480,toolbar=no,status=no,directories=no,scrollbars=no,location=no,resizable=no,menubar=no' );
		}
	}
	
	this.OpenNoteSend = function ( GameCode , ToCharacterName )
	{
		strNoteSendURL = 'http://message.nexon.com/nxcom/page/Gnx.aspx?URL=message/memo_send&maskGameCode=' + GameCode;
		if ( !NgbString.IsEmpty( ToCharacterName ) )
		{
			strNoteSendURL += '&strVirtualUserName=' + ToCharacterName;
		}
		
		if( NgbMember.IsLogin() )
		{
			window.open( strNoteSendURL , 'memo_send' , 'width=370,height=298,toolbar=no,status=no,directories=no,scrollbars=no,location=no,resizable=no,menubar=no' );
		}
		else
		{
			NgbMember.GoLoginPage();
		}
	}
}

var NgbReport = new function __NgbReport()
{
	this.OpenArticleReport = function ( GameCode, BoardSN, ArticleSN, BoardURL )
	{
		if( NgbMember.IsLogin() )
		{
			strReportURL = 'http://www.nexon.com/common/page/nxpop.aspx?url=report/article';
			strReportURL += '&maskGameCode=' + GameCode
			strReportURL += '&oidBoard=' + BoardSN
			strReportURL += '&oidArticle=' + ArticleSN
			strReportURL += '&strBoardUrl=' + BoardURL
			
			window.open( strReportURL , 'ReportArticle' , 'width=488,height=440,toolbar=no,status=no,directories=no,scrollbars=no,location=no,resizable=no,menubar=no' );
		}
		else
		{
			NgbMember.GoLoginPage();
		}
	}
}

var NgbBrowser = new __NgbBrowser();
function __NgbBrowser()
{
	this.agt = navigator.userAgent.toLowerCase();
	this.check = function(browserName) { return this.agt.indexOf(browserName) != -1 };
	this.msie = function() { return this.check("msie") };
	this.msie5 = function() { return this.check("msie 5") };
	this.msie55 = function() { return this.check("msie 5.5") };
	this.msie6 = function() { return this.check("msie 6") };
	this.msie7 = function() { return this.check("msie 7") };
	this.msie8 = function() { return this.check("msie 8") };
	this.chrome = function() { return this.check("chrome") };
	this.firefox = function() { return this.check("firefox") };
	this.netscape = function() { return this.check("netscape") };
	this.safari = function() { return this.check("safari") };
	this.opera = function() { return this.check("opera") };
	this.gecko = function() { return this.check("gecko") };
	this.khtml = function() { return this.check("khtml") };
	this.windows = function() { return this.check("windows") };
	this.windows2000 = function() { return this.check("windows nt 5.0") };
	this.windowsXP = function() { return this.check("windows nt 5.1") };
	this.windows98 = function() { return this.check("windows 98") };
	this.mac = function() { return this.check("mac") };
	this.linux = function() { return this.check("linux") };
	this.chrome = function() { return this.check("chrome") };
}

var NgbUrl = new function __NgbUrl()
{
	this.GetQueryString = function ( strQuery ) 
	{
		var strQueryString;
		var strHref = document.location.href.toLowerCase();
		strQuery = strQuery.toLowerCase();
		
		strQueryString = strHref.substr(strHref.indexOf("?")+1);
		strQueryString = "&" + strQueryString + "&";

		var n4Index = strQueryString.indexOf("&" + strQuery + "=");
		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 = "";
				
			tempValue = tempValue.replace("#","");
			return tempValue;
		}
	};
	this.SetQueryString = function ( url, strParam, strValue )
	{
		var blParam = false;
		var strHref = url.toLowerCase();
		var strTempURL = "";		
				
		if (( strParam != "" ) && ( strValue.toString() != "" )) 
		{			
			var strTempParam = "&" + strParam.toLowerCase() + "=";
			
			// if strParam Exists...
			if ( strHref.indexOf( strTempParam ) != -1 ) 
			{	
				var strTempQueryString = strHref.split( strTempParam );
				var strBaseURL = strTempQueryString[0];
				var strLastURL = strTempQueryString[1].substr(strTempQueryString[1].indexOf("&")+1);
									
				strTempURL = strBaseURL + strTempParam + strValue;
											
				if ( strLastURL.indexOf( "=" ) != -1 )
					strTempURL += "&" + strLastURL;
			} 
			else 
			{
				strTempURL = strHref + strTempParam + strValue;
			}
		}
						
		return strTempURL.toString();
	};
	
	this.Redirect = function ( url )
	{
		if ( url != "" )
		{
			document.location.href = url.toString();
		}
	};
	
	this.GetDomainURL = function ()
	{
		var url = location.href;
		var reg = /(.)+:\/\/([^\/\s]+)/i;
		var data = url.match(reg);
		return data[2];
 	};
}

var NgbAjax = new function __NgbAjax()
{
	this.NxRequest = new Array();
	this.nRequestCount = 0;

	this.GetAjaxObject = function ( nIndex ) 
	{
		if( window.ActiveXObject )
		{
			try 
			{
				this.NxRequest[ nIndex ] = new ActiveXObject( 'Msxml12.XMLHTTP' );
			} 
			catch( e ) 
			{
				try 
				{
					this.NxRequest[ nIndex ]= new ActiveXObject( 'Microsoft.XMLHTTP' );
				} 
				catch (e2) 
				{
					this.NxRequest[ nIndex ] = new XMLHttpRequest();	// IE 7.0
				}
			}
		} 
		else 
		{
			this.NxRequest[ nIndex ] = new XMLHttpRequest();
		}
	}
	
	this.AddRequest = function( objAjaxRequest )
	{
		var nIndex = this.nRequestCount;
		this.nRequestCount++;
		this.GetAjaxObject( nIndex );

		if( this.NxRequest[ nIndex ] )
		{
			this.NxRequest[ nIndex ].open( 'Post', objAjaxRequest.strURL + '?' + objAjaxRequest.GetQueryString(), true );
			this.NxRequest[ nIndex ].setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=ks_c_5601-1987' );
			this.NxRequest[ nIndex ].onreadystatechange = function() { objAjaxRequest.HandleReponse( nIndex ); } ;
			this.NxRequest[ nIndex ].send( objAjaxRequest.GetPostData() );
		}
	}
	
	
	this.AddAmlRequest = function( objAjaxRequest )
	{
		var nIndex = this.nRequestCount;
		this.nRequestCount++;
		this.GetAjaxObject( nIndex );

		if( this.NxRequest[ nIndex ] )
		{
			this.NxRequest[ nIndex ].open( 'Post', objAjaxRequest.strURL + '?' + objAjaxRequest.GetQueryString(), true );
			this.NxRequest[ nIndex ].setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=ks_c_5601-1987' );
			this.NxRequest[ nIndex ].onreadystatechange = function() { objAjaxRequest.HandleAmlReponse( nIndex ); } ;
			this.NxRequest[ nIndex ].send( objAjaxRequest.GetPostData() );
		}
	}
	
	this.RemoveRequest = function( nIndex )
	{
		this.NxRequest[ nIndex ] = null;
	}
}

function __NgbAjaxRequest( url )
{
	this.strURL = url;
	this.arrQueryString = new Array();
	this.arrPostData = new Array();
	this.Handler = null;
	
	this.HandleReponse = function( nIndex )
	{
		var xmlRequest =NgbAjax.NxRequest[ nIndex ];
		if( xmlRequest && xmlRequest.readyState == 4 && xmlRequest.status == 200 ) 
		{
			NgbAjax.RemoveRequest( nIndex );

			var responseText = xmlRequest.responseText;
			this.Handler( responseText );
		}
	}
	
	this.HandleAmlReponse = function( nIndex )
	{
		var xmlRequest =NgbAjax.NxRequest[ nIndex ];

		if( xmlRequest && xmlRequest.readyState == 4 && xmlRequest.status == 200 ) 
		{
			NgbAjax.RemoveRequest( nIndex );
                        try 
			{
			   var responseXML = xmlRequest.responseText;
			   var resultObject = NxamlParser.ParseXmlText( responseXML );
                        } 
			catch (e)
			{
				alert( '[XMLDoc Parse Error] ' + e.description );
			}
			this.Handler( responseXML, resultObject  );
		}
	}
	
	this.GetQueryString = function()
	{
		var strQueryString = '';
		if( this.strURL.indexOf( '?' ) != -1 )
			strQueryString = this.strURL.substr( this.strURL.indexOf( '?' ) );
			
		for( var i = 0 ; i < this.arrQueryString.length ; i++ )
		{
			if( strQueryString != '' )
				strQueryString += '&';
			
			strQueryString += this.arrQueryString[ i ].key + '=' +  this.arrQueryString[ i ].value;
		}
		
		return strQueryString;	
	}
	
	this.GetPostData = function()
	{
		var strPostData = '';

		for( var i = 0 ; i < this.arrPostData.length ; i++ )
		{
			if( strPostData != '' )
				strPostData += '&';
			
			strPostData += this.arrPostData[ i ].key + '=' +  this.arrPostData[ i ].value;
		}
		
		return strPostData;	
	}
	
	this.AddQueryString = function( key, value )
	{
		this.arrQueryString[ this.arrQueryString.length ] = { key:key, value:value };
	}
	
	this.AddPostData = function( key, value )
	{
		this.arrPostData[ this.arrPostData.length ] = { key:key, value:value };
	}
	
	this.AddHandler = function( handler )
	{
		this.Handler = handler;
	}
	
	this.Execute = function()
	{
		NgbAjax.AddRequest( this );
	}
	
	this.ExecuteAml = function()
	{
		NgbAjax.AddAmlRequest( this );
	}
}

var NgbUserEvent = new __NgbUserEvent();
function __NgbUserEvent()
{
	this.MousePositionX = function(evnt)
	{
		var LeftValue;
		if ( window.pageYOffset ) { LeftValue = window.pageXOffset; }
		else if ( document.documentElement && document.documentElement.scrollTop ) { LeftValue = document.documentElement.scrollLeft; }
		else if ( document.body ) { LeftValue = document.body.scrollLeft; }

		if(NgbBrowser.msie()) { return LeftValue + event.clientX; }
		else { return evnt.pageX; }
	};
	this.MousePositionY = function(evnt)
	{
		var TopValue;
		if ( window.pageYOffset ) { TopValue = window.pageYOffset;	}
		else if ( document.documentElement && document.documentElement.scrollTop ) { TopValue = document.documentElement.scrollTop; }
		else if ( document.body ) { TopValue = document.body.scrollTop; }

		if(NgbBrowser.msie()) { return TopValue + event.clientY; }
		else { return evnt.pageY;}
	};
	this.DetectKey = function( evnt )
	{
		if( NgbBrowser.msie() )
		{
			if( event.ctrlKey == true )
				return false;
			
			if ( event.keyCode == 27 )
				return false;
			
			if ( event.keyCode == 116 || ( event.ctrlKey && (event.keyCode == 78 || event.keyCode == 82) ) )
			{
        		event.keyCode= 1;
				return false;
			}
		}
		else
		{
			if( evnt.keyCode == 17 )	// ctrl key
				return false;
			
			if ( evnt.keyCode == 27 )
				return false;
			
			if ( evnt.keyCode == 116 || ( evnt.keyCode == 17 && ( evnt.keyCode == 78 || evnt.keyCode == 82 ) ) )
			{
        		evnt.keyCode = 1;
				return false;
			}
		}
	}
}

var NgbCache = new __NgbCache();
function __NgbCache() 
{
	//¹è¿­Á¤ÀÇ
	this.cacheObjArray = new Array();
	
	//Key Value(Cache array first value)Á¤ÇØÁÖ´Â ÇÔ¼ö
	this.cacheObjNaming = function() {
		var cacheObjName = "";
		for( var i = 0 ; i < arguments.length ; i++ )
		{
			if( i != 0 )
				cacheObjName += "_";
			cacheObjName += arguments [ i ];
		}
		return cacheObjName;
	}
	
	//Å° °ª¿¡ µû¶ó ±× Ç×¸ñÀÌ ¹è¿­¿¡ ÀÖ´ÂÁö °Ë»ç
	this.isCacheObj = function( tempObjNaming ) {
		if( this.cacheObjArray.length>0 )
		{
			for( var i = 0; i < this.ArrayCount; i++ )
			{
				if(this.cacheObjArray[i][0] == tempObjNaming )
				{
					isCacheObjArrayValue = this.cacheObjArray[i];
					return isCacheObjArrayValue;
				}
			}
		}
		else
		{
			return false;
		}
	}

	this.cacheObjInsert = function() {
		if(NgbCache.isCacheObj(arguments[0])) {
			if( this.cacheObjArray.length>0 )
			{
				for( var i = 0; i < this.ArrayCount; i++ )
				{
					if(this.cacheObjArray[i][0] == tempObjNaming )
					{
						for( var j = 0 ; j < arguments.length ; j++ )
						{
							this.cacheObjArray[i][j] = arguments[ j ];
						}
					}
				}
			}
			else
			{
				return false;
			}
		} else {
			this.cacheObjArray[this.ArrayCount] = new Array();
			for( var i = 0 ; i < arguments.length ; i++ )
			{
				this.cacheObjArray[this.ArrayCount][i] = arguments[ i ];
			}
			this.ArrayCount = this.cacheObjArray.length;
		}
	}
	
	this.cacheObjDel = function() {
		if(NgbCache.isCacheObj(arguments[0])) {
			if( this.cacheObjArray.length>0 )
			{
				for( var i = 0; i < this.ArrayCount; i++ )
				{
					if(this.cacheObjArray[i][0] == tempObjNaming )
					{
						isCacheObjArrayValue = this.cacheObjArray[i];
						this.cacheObjArray[i] = "";
					}
				}
			this.ArrayCount = this.cacheObjArray.length;
			}
			else
			{
				return false;
			}
		}
	}
	
	this.ArrayCount = 0;
}

var NgbSearchUtil = new function __NgbSearchUtil()
{
	this._MakeURL = function ( strSectionName, strSearchText )
	{
		if( this._IsValidSection( strSectionName ) == false )
		{
			strSectionName = 'total';
		}
			
		if( this._IsValidSearchText( strSearchText) == true)
		{
			var strURL = "http://search.nexon.com/search/page/nx.aspx?url=search/";
			strURL += strSectionName.toLowerCase();
			strURL += "&strSearchText=";
			strURL += escape(strSearchText);
			return strURL;
		}
		else
			return '';
	}

	this._IsValidSection = function ( strSectionName )
	{
		switch( strSectionName.toLowerCase() )
		{
			case 'total':
			case 'kplus':
			case 'gameweb':
			case 'gameweb_game':
			case 'channelfun':
			case 'guild':
			case 'guildweb':
			case 'image':
			case 'webzine':
				return true;
			default:
				return false;
		}
	}

	this._IsValidSearchText = function ( strSearchText )
	{
		if( strSearchText.length < 2 )
		{
			alert('°Ë»ö¾î¸¦ 2±ÛÀÚ ÀÌ»ó ÀÔ·ÂÇÏ¼¼¿ä');
			return false;
		}

		return true;
	}

	this.OnSearch = function( strSectionName, strSearchText , strTargetFrame, strWiseLog)
	{
		var strURL = this._MakeURL( strSectionName, strSearchText );
		if( strURL != '' )
		{
			if( strWiseLog != null && typeof(strWiseLog) != "undefined" && strWiseLog != '' )
			{
				strURL = strURL + strWiseLog;	
			}
			
			if( strTargetFrame != null && typeof(strTargetFrame) != "undefined" && strTargetFrame != '' )
			{
				try
				{
					eval( strTargetFrame.toLowerCase().replace(/_/g, "") ).location.href = strURL;
					return;
				}
				catch(err) { }
			}
			
			window.open( strURL );
		}
	}
}


var NgbBannerManager = new function __NgbBannerManager()
{
	this.AddBanner = function ( divID, ID, width, height, domain )
	{
		NgbEVM.AddHandler( NgbEVM.k_nEventType_onPageEnd, new NgbEVMDelegator( NgbBannerManager.WriteBanner ), divID, ID, width, height, domain );
	}
	
	this.WriteBanner = function()
	{
		var divID = arguments [ 1 ][ 0 ];
		var ID = arguments [ 1 ][ 1 ];
		var width = arguments [ 1 ][ 2 ];
		var height = arguments [ 1 ][ 3 ];
		var domain = arguments [ 1 ][ 4 ];
		
		new __NgbBanner( divID, ID, width, height, domain ).Write();
	}
}

function __NgbBanner( divID, ID, width, height, domain )
{
	this.divID = divID;
	this.ID = ID;
	this.width = width;
	this.height = height;
	this.domain = domain;
	
	this.Write = function()
	{
		//alert(  this.GetIframeString() );
		document.getElementById( this.divID ).innerHTML = this.GetIframeString();
	}

	this.GetIframeString = function()
	{
		return '<IFRAME name="' + this.divID + '_iframe" tabindex=0 SRC="' + this.GetIframeSrc() + '" WIDTH=' + this.width + ' HEIGHT=' + this.height + ' NORESIZE SCROLLING="No" FRAMEBORDER="0" MARGINHEIGHT="0" MARGINWIDTH="0" allowTransparency="true"></IFRAME>';
	}
	
	this.GetIframeSrc = function()
	{
		if( this.ID == 'test' )
			return 'http://ad.nexon.com/NetInsight/html/test/test/test@test';
		else if( this.ID == 'test2' )
			return 'http://ad.nexon.com/NetInsight/html/test/test/test@ti';
		else if( this.domain != null && this.domain != '' )
			return 'http://ad.nexon.com/NetInsight/html/nexon/' + this.domain + '/' + this.ID;
		else
			return 'http://ad.nexon.com/NetInsight/html/nexon/www.nexon.com/' + this.ID;
	}
	
	this.AppendScript = function()
	{
		/*
		var script		= document.createElement( 'script' );
		
		script.src		= this.GetIframeString();
		script.type	= 'text/javascript';
		script.charset	= 'ks_c_5601-1987';
		
		document.getElementById( this.divID ).appendChild( script );
		*/
	}
}

//±âÁ¸ÆÄÀÏ º¸Á¸
var NgbSearchBar = new function __NgbSearchBar() 
{
	this._MakeURL = function ( strSectionName, strSearchText )
	{
		if( this._IsValidSection( strSectionName ) == false )
		{
			strSectionName = 'total';
		}
			
		if( this._IsValidSearchText( strSearchText) == true)
		{
			var strURL = "http://search.nexon.com/search/page/nx.aspx?url=search/";
			strURL += strSectionName.toLowerCase();
			strURL += "&strSearchText=";
			strURL += escape(strSearchText);
			return strURL;
		}
		else
			return '';
	}

	this._IsValidSection = function ( strSectionName )
	{
		switch( strSectionName.toLowerCase() )
		{
			case 'total':
			case 'kplus':
			case 'gameweb':
			case 'gameweb_game':
			case 'channelfun':
			case 'guild':
			case 'guildweb':
			case 'image':
			case 'webzine':
				return true;
			default:
				return false;
		}
	}

	this._IsValidSearchText = function ( strSearchText )
	{
		if( strSearchText.length < 2 )
		{
			alert('°Ë»ö¾î¸¦ 2±ÛÀÚ ÀÌ»ó ÀÔ·ÂÇÏ¼¼¿ä');
			return false;
		}

		return true;
	}

	this.OnSearch = function( strSectionName, strSearchText , strTargetFrame, strWiseLog)
	{
		var strURL = this._MakeURL( strSectionName, strSearchText );
		if( strURL != '' )
		{
			if( strWiseLog != null && typeof(strWiseLog) != "undefined" && strWiseLog != '' )
			{
				strURL = strURL + strWiseLog;	
			}
			
			if( strTargetFrame != null && typeof(strTargetFrame) != "undefined" && strTargetFrame != '' )
			{
				try
				{
					eval( strTargetFrame.toLowerCase().replace(/_/g, "") ).location.href = strURL;
					return;
				}
				catch(err) { }
			}
			
			window.open( strURL );
		}
	}
}
