
Function.prototype.bind = function () {

	var _method	= this;
	var _args	= arguments;
	
	return function() { 
		
		return _method.apply( /* object */ _args[ 0 ], /* array */ [] ); 
	}
}

String.prototype.equals = function () {
	
	var _value	= arguments;
	var _state	= 0;
	
	for ( var i = 0; i < _value.length; i++ ) {
	
		if ( this.toString().toLowerCase() == _value[ i ].toLowerCase() )
			_state += 1;
	}
	
	return ( _state == _value.length ) ? true : false;
};

String.prototype.regReplace = function ( /* char */ regExp, /* string */ replaceStr ) {
	
	var strValue	= this;
	var length		= this.split( regExp ).length; 
	
	if ( length > 0 ) {
		
		for ( var i = 0; i < length; i++ )			
			strValue = strValue.replace( regExp, replaceStr );
	}	
	
	return strValue;
};

Number.prototype.equals = function ( /* string */ value ) {
	
	if ( this == value )
		return true;
	else
		return false;
};	

String.prototype.toFontValue = function () {
		
	var strValue = -1;
	
	switch( this.toString() ) {
		
		case "8pt"	: strValue = "1"; break;
		case "10pt" : strValue = "2"; break;
		case "12pt" : strValue = "3"; break;
		case "14pt" : strValue = "4"; break;
		case "18pt" : strValue = "5"; break;
		case "24pt" : strValue = "6"; break;
		case "36pt" : strValue = "7"; break;
		default		: strValue = this.toString(); break;
	}
	
	return strValue;
};

String.prototype.vodParse = function ( strChar ) {

	var info = this.split( strChar );
	
	return ( { 
	
		oidFile			: ( info[ 0 ] != 'undefined' ) ? info[ 0 ] : 0
	,	fileSize		: ( info[ 1 ] != 'undefined' ) ? info[ 1 ] : 0
	,	fileDate		: ( info[ 2 ] != 'undefined' ) ? info[ 2 ] : 0
	
	,	thumb_title		: ( info[ 3 ] != 'undefined' ) ? info[ 3 ] : 0
	,	thumb_select	: ( info[ 4 ] != 'undefined' ) ? info[ 4 ] : 0
	
	,	thumb_01		: ( info[ 5 ] != 'undefined' ) ? info[ 5 ] : 0
	,	thumb_02		: ( info[ 6 ] != 'undefined' ) ? info[ 6 ] : 0
	,	thumb_03		: ( info[ 7 ] != 'undefined' ) ? info[ 7 ] : 0
	,	thumb_04		: ( info[ 8 ] != 'undefined' ) ? info[ 8 ] : 0
	,	thumb_05		: ( info[ 9 ] != 'undefined' ) ? info[ 9 ] : 0
	,	thumb_06		: ( info[ 10 ] != 'undefined' ) ? info[ 10 ] : 0
	
	,	fileName		: ( info[ 11 ] != 'undefined' ) ? info[ 11 ] : 0
	,	thumbName		: ( info[ 12 ] != 'undefined' ) ? info[ 12 ] : 0
	
	} );
};

String.prototype.imgParse = function ( strChar ) {
	
	var info = this.split( strChar );
	
	return ( {
	
		oidFile		: ( !( typeof info[ 0 ] ).equals( "undefined" ) && info[ 0 ] != "" ) ? info[ 0 ] : 0
	,	fileName	: ( !( typeof info[ 1 ] ).equals( "undefined" ) && info[ 1 ] != "" ) ? info[ 1 ] : null
	,	oidThumb	: ( !( typeof info[ 2 ] ).equals( "undefined" ) && info[ 2 ] != "" ) ? info[ 2 ] : null
	
	} );
};

String.prototype.SetUploadImgInfo = function ( /* string */ strChar ) {

	var info = this.split( strChar );
	
	return ( {
	
		oidFile		: ( !( typeof info[ 0 ] ).equals( "undefined" ) && info[ 0 ] != "" ) ? info[ 0 ] : 0
	,	oidThumb	: ( !( typeof info[ 1 ] ).equals( "undefined" ) && info[ 1 ] != "" ) ? info[ 1 ] : 0
	,	strFileName	: ( !( typeof info[ 2 ] ).equals( "undefined" ) && info[ 2 ] != "" ) ? info[ 2 ] : null
	
	} );
};

String.prototype.HtmlTagFilter = function ( codeWriterType ) {
	
	var strValue = this;
	
	var _regExp_javaScript	= /(javascript)/ig;
	var _regExp_onClick		= /(onclick)/ig;
	var _regExp_class		= /(class)/ig;
	var _regExp_form		= /(form)/ig;
	var _regExp_object		= /(object)/ig;
	var _regExp_embed		= /(embed)/ig;
	var _regExp_input		= /(input)/ig;
	var _regExp_styleSheet	= /(?:<style.*?>)((\n|\r|.)*?)(?:<\/style>)/ig;
	var _regExp_script		= /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig;
	var _regExp_ImageId		= /(_IMAGE_)(.*)(_UPLOAD_)/ig;
	var _regExp_MovieId		= /(_MOVIE_)(.*)(_UPLOAD_)/ig;
	var _regExp_EmoticonId	= /(_EDITOR_EMOTICON_)/ig;
	var _regExp_IdPattem	= /id=(.*._)/ig;
	
	if ( ( +codeWriterType ).equals( 1 ) || ( +codeWriterType ).equals( 2 ) )
		strValue = strValue.replace( _regExp_javaScript, "**" );
		
	if ( ( +codeWriterType ).equals( 1 ) || ( +codeWriterType ).equals( 2 ) )
		strValue = strValue.replace( _regExp_styleSheet, "**" );
		
	if ( ( +codeWriterType ).equals( 1 ) || ( +codeWriterType ).equals( 2 ) )	
		strValue = strValue.replace( _regExp_object, "**" );
	
	if ( ( +codeWriterType ).equals( 1 ) || ( +codeWriterType ).equals( 2 ) )
		strValue = strValue.replace( _regExp_onClick, "**" );
	
	if ( ( +codeWriterType ).equals( 1 ) || ( +codeWriterType ).equals( 2 ) )
		strValue = strValue.replace( _regExp_class, "**" );
	
	if ( ( +codeWriterType ).equals( 1 ) || ( +codeWriterType ).equals( 2 ) || ( +codeWriterType ).equals( 3 ) )
		strValue = strValue.replace( _regExp_form, "**" );
	
	if ( ( +codeWriterType ).equals( 1 ) || ( +codeWriterType ).equals( 2 ) || ( +codeWriterType ).equals( 3 ) )
		strValue = strValue.replace( _regExp_embed, "**" );
		
	if ( ( +codeWriterType ).equals( 1 ) || ( +codeWriterType ).equals( 2 ) )	
		strValue = strValue.replace( _regExp_script, "**" );
	
	if ( ( +codeWriterType ).equals( 1 ) || ( +codeWriterType ).equals( 2 ) )
		strValue = strValue.replace( _regExp_input, "**" );
	
	return strValue;
};

var NxScriptClass = {

	create : function () {		
		
		return function () { 
			this.initialize.apply(this, arguments); 
		} 
	}

,	extend : function ( destination, source ) {
		
		if ( ( typeof destination ).equals( "object" ) && destination != null ) {
			
			for ( property in source )
				destination[ property ] = source[ property ];
			
			return destination;
		}		
	}

,	using : function () {
		
		var _base	= arguments[ 0 ];
		var _args	= arguments[ 1 ];
		var _method	= {}; 
		
		for ( method in _args )
			_method[ method ] = _args[ method ];
		
		for ( method in _base )
			_method[ method ] = _base[ method ];
		
		this.extend( _base, _method );
		
		if ( ( typeof _base.base ).equals( "undefined" ) )
			_base.base = _args;
	}
};

var NxHttpRequest = NxScriptClass.create();

NxHttpRequest.prototype = {
	
	initialize : function( /* function */callback ) {

		this.transport		= null;
		this.strRequestType	= null;
		this.strSendPath	= null;
		this.strSendData	= null;
		this.callBack		= null;
		
		if ( ( typeof callback ).equals( "Function" ) )
			this.dispatch( callback );
	}

,	Execute : function ( strRequestType, strSendPath, strSendData ) {
		
		this.strRequestType		= strRequestType;
		this.strSendPath		= strSendPath;
		this.strSendData		= strSendData;

		if ( strRequestType != null && strSendPath != null )			
			this.sender();
	}

,	create : function () {
		
		if( window.ActiveXObject ) {

			try {

				return new ActiveXObject( "Msxml2.XMLHTTP" );
			}
			catch( ex ) {

				try {

					return new ActiveXObject( "Microsoft.XMLHTTP" );
				}
				catch ( ex2 ) {}
			}
		}
		else if( window.XMLHttpRequest ) {

			return new XMLHttpRequest();
		}
	}

,	sender	: function () {
		
		this.transport = this.create();

		if ( this.transport != null ) {

			this.transport.onreadystatechange = this.onStateChange.bind( this );

			this.transport.open( this.strRequestType, this.strSendPath, true );
			this.transport.setRequestHeader( 'Content-Type', 'application/x-www-form-unlencoded' );
			this.transport.send( this.strSendData );	
		}
	}

,	onStateChange : function () {
		
		if ( this.callBack != null )
			this.callBack( this.transport );
	}

,	dispatch : function ( _callback ) {
		
		this.callBack = _callback;
	}
};

/*
 * QueryString °ü·Ã Utility
 */

var NxQueryParam = {

	screen			: window.document
,	arrParameters	: {}

,	Target			: function ( _screen ) {
		
		this.screen = _screen;
	}

,	Search			: function ( _key ) {
		
		var _strValue = null;
		
		for( prop in this.arrParameters ) {
				
			if ( prop.equals( _key ) ) {
			
				_strValue = this.Output( prop );
				break;
			}
		}
		
		return _strValue;	
	}

,	Output			: function ( _key ) {
		
		return this.arrParameters[ _key ].strValue;
	}
	
,	IsApply			: function ( _key ) {
	
		var _state = true;
		
		for ( prop in this.arrParameters ) {
			
			if ( prop.equals( _key ) ) {
				
				_state = ( ( +this.arrParameters[ prop ].codeReadyState ).equals( 0 ) ) ? true : false;
				break;
			}
		}
		
		return _state;		
	}

,	Register		: function ( _key, _value ) {

		this.arrParameters[ _key ] = { strValue : _value, n4UpdateCount : 0, codeReadyState : 0 };
	}

,	Update			: function ( _key, _value ) {
		
		this.arrParameters[ _key ].strValue			= _value;
		this.arrParameters[ _key ].codeReadyState	= 1;
		this.arrParameters[ _key ].n4UpdateCount	+= 1;			
	}

,	Remove			: function ( _key ) {
		
		this.Parse();
		
		for ( prop in this.arrParameters ) {
			
			if ( prop.equals( _key ) ) {
			
				this.arrParameters[ prop ].codeReadyState = 2;
				break;
			}
		}		
	}

,	Parse			: function () {
		
		var _key			= null;
		var _value			= null;
		
		var _strParameter	= this.screen.location.search + "&";
		var _arrParameter	= _strParameter.substring(1).split("&");
		
		for( prop in _arrParameter ) {
			
			if ( _arrParameter[ prop ].indexOf( "=" ) != -1 ) {
				
				_key	= _arrParameter[ prop ].split( "=" )[ 0 ];
				_value	= _arrParameter[ prop ].split( "=" )[ 1 ];
				
				if ( this.IsApply( _key ) )
					this.Register( _key, _value );
			}	
		}
	}

,	add				: function ( _key, _value ) {
		
		var _state = true;
		
		this.Parse();
		
		for( prop in this.arrParameters ) {
				
			if ( prop.equals( _key ) ) {
			
				_state = false;
				
				this.Update( prop, _value );
				break;
			}
		}
		
		if ( _state )
			this.Register( _key, _value );
	}

,	toArray			: function () {
		
		var _arrParameter	= [];
		
		for( prop in this.arrParameters ) {
			
			var _key	= prop; 
			var _value	= this.Output( _key );
				
			if ( !( +this.arrParameters[ prop ].codeReadyState ).equals( 2 ) )
				_arrParameter[ _arrParameter.length ] = _key + "=" + _value;
		}
		
		return _arrParameter;
	}
}

/*
 * Request °ü·Ã Mothod 
 */
var NxRequest = {
	
	QueryString		: function () {
		
		var _strValue		= null;
		var _arrParameter	= [];
		
		NxScript.Common.QueryParam.Parse();
		
		if ( ( +arguments.length ).equals( 0 ) ) {
			
			_strValue = NxScript.Common.QueryParam.toArray().join( "&" );	
		}
				
		else if ( ( +arguments.length ).equals( 1 ) ) {
		
			_strValue = NxScript.Common.QueryParam.Search( arguments[ 0 ] );
		}
		
		else if ( ( +arguments.length ).equals( 2 ) )
		{
			_strValue = NxScript.Common.QueryParam.Search( arguments[ 0 ] );
			
			if ( _strValue == null )
				_strValue = arguments[ 1 ];
		}	
		
		return _strValue;
	}
};

var NxResponse = {

	Redirect : function ( strPageURL ) {
	
		window.location.href = strPageURL;
	}

,	RedirectQueryString : function ( strPageURL ) {
		
		this.Redirect( strPageURL + "?" + NxScript.Request.QueryString() );
	}

};

var NxScriptCache = {
	
	arrCacheData : {}

,	get : function( cacheName ) {
	
		return this.arrCacheData[ cacheName ];
	}

,	set : function ( cacheName, data ) {
		
		this.arrCacheData[ cacheName ] = data;
	}	
};

var NxRepeater = {

	Item			: []
,	RegExpScript	: /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig

,	Begin : function ( strClientID ) {	
		
		var _strRepeaterID	= "g_" + strClientID + "_ctl" + this.Item.length;
		var _strTemplateID	= "g_" + strClientID + "_ctl" + this.Item.length + "_Itemtemplate";
		
		NxScript.write( "<div id='" + _strRepeaterID + "'></div>" );
		NxScript.write( "<div id='" + _strTemplateID + "' style='display:none'>" );
		
		this.Item[ this.Item.length ] = { codeReadyState : 1, strRepeaterID : _strRepeaterID, strTemplateID	: _strTemplateID };
	}
		
,	End : function () {
		
		NxScript.write( "</div>" );
		
		for ( var i = 0; i < this.Item.length; i++ ) {
			
			var _info = this.Item[ i ];
			
			if ( ( +_info.codeReadyState ).equals( 1 ) ) {
						
				_info.codeReadyState = 2;
				
				NxScript.findElement( _info.strTemplateID ).innerHTML = this.Restrictor( _info.strTemplateID );
				NxScript.Classes.extend( NxScript.findElement( _info.strRepeaterID ), this.Handler( NxScript.findElement( _info.strTemplateID ) ) );
			}
		}
	}

,	Restrictor : function ( _strTemplateID ) {
		
		return NxScript.findElement( _strTemplateID ).innerHTML.replace( this.RegExpScript , "" );
	}

,	Handler : function ( Template ) {

		return ( {		
				
			_type			: "Repeater"
		
		,	DataSource		: []		
		,	ItemTemplate	: Template
		,	ItemSource		: Template.innerHTML
		
		,	InitializeTemplate : function () {
				
				this.ItemTemplate.innerHTML = this.ItemSource;
			}
		
		,	CheckDisplayProperty : function ( _el ) {
				
				return "inline";
			}
		
		/*
		 * Element Display »óÅÂ¸¦ Ã¼Å© & º¯°æ ÇÏ°í, Property °ªÀ» ¹Ý¿µÇÑ´Ù.
		 *
		 * @param _el ( object )
		 * @param _src ( object )
		 *
		 * @return ( object )
		 *
		 */
		
		,	RenderCheckValidation : function ( _el, _src ) {
		
				var _visible		= true;
				var _strText		= null;
				var _dataRow		= _src[ _el.id ];
				var _codeRenderType	= ( !( typeof _dataRow.codeRenderType ).equals( "undefined" ) ) ? _dataRow.codeRenderType : 0;
				
				if ( ( +_codeRenderType ).equals( NxScript.Constants.codeRenderType_Hidden ) ) {
					
					_visible				= false;
					_el.style.display		= this.CheckDisplayProperty( _el );
					_el.style.position		= "absolute";
					_el.style.visibility	= "hidden";
				}
				
				else if ( ( +_codeRenderType ).equals( NxScript.Constants.codeRenderType_Disable ) ) {
					
					_visible				= false;
					
					_el.style.filter		= "alpha( opacity=25 )";
					_el.style.visibility	= "visible";
				}
										
				else if ( ( +_codeRenderType ).equals( NxScript.Constants.codeRenderType_Active ) ) {
					
					_visible				= true;
					
					_el.style.display		= this.CheckDisplayProperty( _el );
					_el.style.position		= "static";
					_el.style.visibility	= "visible";
				}
				
				else {
					
					_visible				= true;
				}					
				
				if ( _visible && !( typeof _dataRow.Properties ).equals( "undefined" ) )
					NxScript.Classes.extend( _el, _dataRow.Properties );
				
				if ( ( typeof _dataRow ).equals( "string" ) )
					_strText = _dataRow;
				
				else if ( !( typeof _dataRow.strText ).equals( "undefined" ) )
					_strText = _dataRow.strText;
				
				return ( {  
				
					visible	: _visible
				,	strText	: _strText  
				
				} );
			}
		
		,	ReplaceForImgElement : function ( _src ) {
				
				for ( var i = 0; i < this.ItemTemplate.getElementsByTagName( "img" ).length; i++ ) {
				
					var _el = this.ItemTemplate.getElementsByTagName( "img" )[ i ];
					
					if ( _el.id != "" && _src[ _el.id ] != undefined )
						this.RenderCheckValidation( _el, _src );
				}
			}
		
		,	ReplaceForInputElement : function ( _src ) {
		
				for ( var i = 0; i < this.ItemTemplate.getElementsByTagName( "input" ).length; i++ ) {
					
					var _el		= this.ItemTemplate.getElementsByTagName( "input" )[ i ];
					
					if ( _el.id != "" && _el.type.equals( "checkBox" ) && _src[ _el.id ] != undefined ) 
						this.RenderCheckValidation( _el, _src );						
				}
			}
		
		,	ReplaceForDivElement : function ( _src ) {
				
				for ( var i = 0; i < this.ItemTemplate.getElementsByTagName( "div" ).length; i++ ) {
				
					var _el		= this.ItemTemplate.getElementsByTagName( "div" )[ i ];
					
					if(  _el.id != "" && _src[ _el.id ] != undefined ) {
						
						var _info = this.RenderCheckValidation( _el, _src );	
						
						if ( _info.visible && _info.strText != null )
							_el.innerHTML = _info.strText;
					}
				}
			}
		
		,	ReplaceForSpanElement : function ( _src ) {
				
				for ( var i = 0; i < this.ItemTemplate.getElementsByTagName( "span" ).length; i++ ) {
				
					var _el		= this.ItemTemplate.getElementsByTagName( "span" )[ i ];
					
					if(  _el.id != "" && _src[ _el.id ] != undefined ) {
						
						var _info = this.RenderCheckValidation( _el, _src );	
						
						if ( _info.visible && _info.strText != null )
							_el.innerHTML = _info.strText;
					}
				}
			}
		
		,	ReplaceForLinkElement : function ( _src ) {
				
				for ( var i = 0; i < this.ItemTemplate.getElementsByTagName( "A" ).length; i++ ) {
				
					var _el		= this.ItemTemplate.getElementsByTagName( "A" )[ i ];
					
					if(  _el.id != "" && _src[ _el.id ] != undefined ) {
						
						var _info = this.RenderCheckValidation( _el, _src );	
						
						if ( _info.visible && _info.strText != null )
							_el.innerHTML = _info.strText;
					}
				}
			}
		
		,	Remove : function () {
			
				this.innerHTML = "";
			}
		
		,	DataBind : function () {
				
				if ( this.ItemTemplate != null ) {
				
					this.Remove();
					
					for ( var i = 0; i < this.DataSource.length; i++ ) {
						
						this.InitializeTemplate();
						
						var _src = this.DataSource[ i ];
						
						this.ReplaceForDivElement( _src );
						this.ReplaceForSpanElement( _src );
						this.ReplaceForLinkElement( _src );
						this.ReplaceForImgElement( _src );
						this.ReplaceForInputElement( _src );
						
						this.innerHTML += this.ItemTemplate.innerHTML;
					}
				}
			}					
		} );		
	}
};

var NxWebControls = {
	
	Repeater : NxRepeater	
};

var NxScriptCode = {
	
	codeEditorModeType_designAndHtml	: 1
,	codeEditorModeType_htmlAndDesign	: 2
,	codeEditorModeType_designOnly		: 3
,	codeEditorModeType_htmlOnly			: 4
,	codeEditorModeType_viewOnly			: 5

,	codeEditorWriteType_None			: 0
,	codeEditorWriteType_Write			: 1
,	codeEditorWriteType_Modify			: 2

,	maskGameCode_NX						: 65536
,	maskGameCode_Kart					: 73985
,	maskGameCode_WarRock				: 94212
,	maskGameCode_BigShot				: 74243
,	maskGameCode_Lunia					: 94213
,	maskGameCode_LuniaTest				: 126979
,	maskGameCode_Zera					: 851969
,	maskGameCode_Baram					: 131072
,	maskGameCode_Lod					: 196608
,	maskGameCode_Asgard					: 393216
,	maskGameCode_Elan					: 262144
,	maskGameCode_Maple					: 589824
,	maskGameCode_CA						: 720896
,	maskGameCode_Tales					: 524288
,	maskGameCode_Qplay					: 786432
,	maskGameCode_AppZera				: 74242
,	maskGameCode_Guild					: 268435456
,	maskGameCode_GameChannel			: 268500992
,	maskGameCode_Elsword				: 94224

,	maskGameCode_Group_Amity			: 268435967
,	maskGameCode_Group_Kart				: 268435458
,	maskGameCode_Group_WarRock			: 268435459
,	maskGameCode_Group_Manmani			: 268435463
,	maskGameCode_Group_BigShot			: 268435460
,	maskGameCode_Group_Zera				: 268435461

,	codeObjectType_Media				: 1
,	codeObjectType_Flash				: 2

,	codeRenderType_Hidden				: 1
,	codeRenderType_Disable				: 2
,	codeRenderType_Active				: 3

};

var NxActivate = {

	Renderer : function ( /* object */ property ) {
	
		if ( ( +property.codeObjectType ).equals( NxScript.Constants.codeObjectType_Media ) ) {
		
			NxScript.write( "<div id='" + property.strClientId + "_Containner'>" );
			NxScript.write( "<object id='" + property.strClientId + "' classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' standby='Loading Microsoft Windows Media Player components...' TYPE='application/x-oleobject' width='" + property.n4Width + "' height='" + property.n4Height + "'>" );
			NxScript.write( "<param name='uiMode'		value='" + property.strUIMode + "'>" );
			NxScript.write( "<param name='Volume'		value='" + property.n4Volume + "'>" );
			NxScript.write( "<param name='AutoStart'	value='" + property.isAutoStart + "'>" );
			NxScript.write( "</object>" );
			NxScript.write( "</div>" );
			
			NxScript.write( "<sc" + "ript for='" + property.strClientId + "' Event='playStateChange( oldState, NewState )' Language='JavaS" + "cript'>" );
			NxScript.write( property.strPlayStateEventFunc + "( oldState, NewState )" );
			NxScript.write( "</sc" + "ript>" );
			
			NxScript.write( "<sc" + "ript for='" + property.strClientId + "' Event='OpenStateChange( oldState, NewState )' Language='JavaS" + "cript'>" );
			NxScript.write( property.strOpenStateEventFunc + "( oldState, NewState )" );
			NxScript.write( "</sc" + "ript>" );
		}		
	}
};

var NxClient = {

	_X			: function () { return ( event != null ) ? ( +event.clientX ) : 0; } 
,	_Y			: function () { return ( event != null ) ? ( +event.clientY ) : 0; } 
,	_offsetX	: function () {	return ( event != null ) ? ( +event.offsetX ) : 0; }
,	_offsetY	: function () {	return ( event != null ) ? ( +event.offsetY ) : 0; }
,	_height		: function () { return ( event != null ) ? ( +event.srcElement.clientHeight ) : 0; }
,	_width		: function () { return ( event != null ) ? ( +event.srcElement.clientWidth ) : 0; }
,	_element	: function () { return ( event != null ) ? event.srcElement : null; }
,	_keyCode	: function () { return ( event != null ) ? event.keyCode : -1; }

};

var NxEvent = {

	xPos		: function () { return ( event != null ) ? ( +event.clientX ) : 0; }
,	yPos		: function () { return ( event != null ) ? ( +event.clientY ) : 0; }	
,	xSet		: function () {	return ( event != null ) ? ( +event.offsetX ) : 0; }
,	ySet		: function () {	return ( event != null ) ? ( +event.offsetY ) : 0; }
,	eWidth		: function () {	return ( event != null ) ? ( +event.srcElement.clientWidth ) : 0; }
,	eHeight		: function () {	return ( event != null ) ? ( +event.srcElement.clientHeight ) : 0; }
,	element		: function () { return ( event != null ) ? event.srcElement : null; } 
,	keyCode		: function () {	return ( event != null ) ? event.keyCode : -1; }

};

var NxDocument = {

	scrollTop : function () {
		
		var Value = 0;
		
		if ( window.pageYOffset )
			Value = window.pageYOffset;
		
		else if ( document.documentElement && document.documentElement.scrollTop )
			Value = document.documentElement.scrollTop;
		
		else if ( document.body )
			Value = document.body.scrollTop;
		
		return Value;
	}

,	body : function () { 
		
		var value = null;
		
		if ( document.body )			
			value = document.body;
		
		return value;
	}
};

var NxCommon = {

	QueryParam	: NxQueryParam
} 

var NxCurrent = {

	_Array		: []

,	Client		: NxClient
,	Activate	: NxActivate /* Common À¸·Î ÀÌµ¿ ´ë»ó */
,	Cache		: NxScriptCache /* Common À¸·Î ÀÌµ¿ ´ë»ó */
,	Document	: NxDocument
,	Event		: NxEvent

,	Exception	: function ( /* object */ ex ) { 
		
		var _message = null;
		
		for ( var i = 0; i < this._Array.length; i++ ) {
			
			if ( ( +this._Array[ i ].code ).equals( ex ) ) {
				
				_message = this._Array[ i ].message;
				break;
			}
		}
		
		if ( _message != null )
			alert( _message );
		else
			alert( ex.message );
	}
	
,	addExceptionMessage : function ( /* intger */ errorCode, /* string */ strMessage  ) {  
		
		this._Array[ this._Array.length ] = { code : errorCode, message : strMessage };
	}
};

var NxNet = {

	HttpWebRequest : function ( strRequestType, strSendPath, strSendData, cellBack ) {
		
		( new NxHttpRequest( cellBack ) ).Execute( strRequestType, strSendPath, strSendData );
	}
};

var NxDataSet = {

	arrDataSet	: {}

,	Register	: function () {
		
		this.arrDataSet[ arguments[ 0 ] ] = arguments[ 1 ];
	}

,	Output		: function ( fieldName ) {
		
		var _tmpDataSet = [];
		
		for ( key in this.arrDataSet ) {
			
			if ( key.equals( fieldName ) ) {
				
				for ( var i = 0; i < this.arrDataSet[ key ].length; i++ ) {
				
					_tmpDataSet[ _tmpDataSet.length ] = this.arrDataSet[ key ][ i ];
				}
								
				break;				
			}			
		}
		
		if ( _tmpDataSet.length )
			return _tmpDataSet;
		else
			return null;
	}

,	RowCount	: function ( fieldName ) {
		
		var _tmpDataSet = this.Output( fieldName );
		
		if ( _tmpDataSet != null )
			return _tmpDataSet.length;
		else
			return null;
	}
}

var NxScriptFramework = NxScriptClass.create();

NxScriptFramework.prototype = {
	
	initialize : function() {
	
		this.write			= document.write;
		this.create			= document.createElement;
		this.popup			= window.open;
		this.dialog			= showModelessDialog;

		this.Request		= NxRequest;
		this.Response		= NxResponse;
		this.Constants		= NxScriptCode;
		this.Current		= NxCurrent;
		this.Document		= NxDocument;
		this.Classes		= NxScriptClass;
		this.Net			= NxNet;
		this.DataSet		= NxDataSet;
		this.WebControls	= NxWebControls;
		this.Common			= NxCommon;
	}

,	findElement	: function () {
		
		var _el		= null;
		var _id		= null;
		var _type	= null;
		var _parent	= null;
		
		if ( ( +arguments.length ).equals( 3 ) ) {
		
			_parent	= arguments[ 0 ];
			_type	= arguments[ 1 ];
			_id		= arguments[ 2 ];
			
			for ( var i = 0; i < _parent.getElementsByTagName( _type ).length; i++  ) {
			
				var _obj = _parent.getElementsByTagName( _type )[ i ];
				
				if ( !( typeof _obj.tagName ).equals( "undefined" ) 
					&& _obj.tagName.equals( _type ) 
					&& _obj.id.equals( _id ) )
				{
					_el = _obj;
					break;
				}				
			}
			
			return _el;
		}
		else if ( ( +arguments.length ).equals( 2 ) ) {
			
			_parent	= arguments[ 0 ];
			_id		= arguments[ 1 ];
			_type	= [ "div", "span", "a" ];
			
			for ( var i = 0; i < _type.length; i++ ) {
			
				for ( var i = 0; i < _parent.getElementsByTagName( _type[ i ] ).length; i++  ) {
				
					var _obj = _parent.getElementsByTagName( _type[ i ] )[ i ];
					
					if ( !( typeof _obj.tagName ).equals( "undefined" ) 
						&& _obj.tagName.equals( _type[ i ] ) 
						&& _obj.id.equals( _id ) )
					{
						_el = _obj;
						break;
					}				
				}
			}				
			
			return _el;
		}
		else if ( ( +arguments.length ).equals( 1 ) ) {
					
			return document.getElementById( arguments[ 0 ] );
		}		
	}	
	
,	addScript		: function ( /* object */ source ) {
		
		NxScriptClass.extend( this, source );
	}

,	addEventListner	: function ( /* object */ target, /* object */ func ) {
		
		NxScriptClass.extend( target, func );
	}

};

var NxScriptArray = NxScriptClass.create();

NxScriptArray.prototype = {

	initialize : function () {
	
		this.__Array = [];
	}

,	row : function ( key ) {
		
		return this.__Array[ key ];
	}

,	add : function ( dataSet ) {
		
		this.__Array[ this.__Array.length ] = dataSet;
	}

,	count : function () {
		
		return this.__Array.length;
	}

,	search : function ( value ) {
		
		var key = null;
		
		for ( var i = 0; i < this.count(); i++ ) {
		
			if ( this.__Array[ i ] != null && this.__Array[ i ].equals( value ) ) {
			
				key = i; break; 
			}
		}
		
		return key;
	}

,	remove : function ( key ) {
		
		if ( key != null ) 
			this.__Array[ key ] = null;
	}

,	update : function ( oldData, newData ) {
		
		var key = this.search( oldData );
		
		if ( key != null )
			this.__Array[ key ] = newData;
	}

,	sum : function () {
		
		var value = 0;
	
		for ( var i = 0; i < this.count(); i++ )		
			value += ( ( typeof ( +this.__Array[ i ] ) ).equals( "Number" ) ) ? ( +this.__Array[ i ] ) : 0;
		
		return value;
	}

,	reset : function () {
		
		this.__Array.length = 0;
	}

,	join : function ( strChar ) {
		
		return ( this.__Array.length > 0 ) ? this.__Array.join( strChar ) : "";
	}
};

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;
	}
}

var NxScript = new NxScriptFramework();