var GnxEditor = NxScriptClass.create();

GnxEditor.prototype	= {

	initialize	: function () {
			
		/*
		 * v0.0.2 : ±âº» ½ºÆÑ by emong
		 * v0.0.3 : ¿¡µðÅÍ ÀÚÃ¼ Å¸ÀÌ¸Ó ±â´É Ãß°¡, ±ÇÇÑ ¹× ¾÷·Îµå °ü·Ã Á¦ÇÑ °­È­ by emong
		 * ³ªÁß¿¡ ÄÚµå Á¤¸® ÇÊ¿äÇÔ ºÒÇÊ¿ä ÄÚµå°¡ ´À¹Ç ¸¹¾Æ¿ë.. (¤Ð¤Ð);; by emong
		 */
		this.Version				= "0.0.3";
		
		/*
		 * @codeWriterType : 1 ( À¯Àú )
		 * @codeWriterType : 2 ( ÀÛ°¡´Ü )
		 * @codeWriterType : 3 ( °ü¸®ÀÚ )
		 */
		this.codeWriterType			= 1;
		
		this.ArrayImageFiles		= new NxScriptArray();
		this.ArrayMovieFiles		= new NxScriptArray();
		this.ArrayThumbFiles		= new NxScriptArray();
		this.ArrayLoadEvents		= new NxScriptArray();
		
		this.isEnableEditor			= true;
		
		this.UniqueID				= null;
		this.hStageID				= null;	
		this.hFieldID				= null;
		
		this.codeSkinType			= 0;
		this.maskGameCode			= 0;
		
		//this.n4UploadMaxMinute		= 5;
		//this.n1UploadMaxCount		= 5;
		
		this.n1UploadFileMaxCount	= 30;
		this.n1ImgUploadMaxCount	= 30;
		this.n4VodUploadMaxMinute	= 5;
		this.n1VodUploadMaxCount	= 5;
		
		this.codeStageModeType		= 1;
		this.codeStageWriteType		= 0;
		this.codeThumbFileType		= 0;
		
		/*
		 * @codeImageToolType : 1 ( ±¸¹öÀü ÀÌ¹ÌÁö ¿¡µðÅÍ )
		 * @codeImageToolType : 2 ( ½Å¹öÀü ÀÌ¹ÌÁö ¿¡µðÅÍ )
		 * @codeImageToolType : 4 ( ½Å¹öÀü ÀÌ¹ÌÁö ¾÷·Î´õ )
		 */
		this.codeImageToolType		= 1;
		
		this.strStageContentType	= "text/html";
		this.strFileDownloader		= null;
		
		this.n4StageWidth			= 0;
		this.n4StageHeight			= 0;
		this.n4ImageThumbWidth		= 0;
		this.n4ImageThumbHeight		= 0;
		
		this.n4ImgFileTotalCount	= 0;
		
		this.n4VodFileTotalLength	= 0;
		this.n4VodFileTotalCount	= 0;
		this.n4VodFileTotalMsec		= 0;
		this.n4VodBitrate			= 1000000;
		this.n4VodResolution		= 400;
		
		this.strIntervalID			= null;
		this.n4IntervalCount		= 0;
		this.n1IntervalLimitCount	= 5;
		this.n4IntervalLoopMsec		= 5;
		
		this.__EditorLayer			= null;
		this.__EditorField			= null;
		this.__EditorStage			= null;
		this.__EditorStyle			= null;
		this.__EditorMaster			= null;
		
		this.__EditorHtmlViewer		= null;
		this.__EditorFilterLayer	= null;
		this.__EditorDivision		= null;
		this.__EditorHtmlField		= null;
		this.__EditorTextField		= null;
		this.__EditorNewImgFile		= null;
		this.__EditorOldImgFile		= null;
		this.__EditorNewMovFile		= null;
		this.__EditorOldMovFile		= null;
		this.__EditorNewThumbFiles	= null;
		this.__EditorOldThumbFiles	= null;
		
		NxScript.addScript( { Interval		: window.setInterval } );
		NxScript.addScript( { clearInterval : window.clearTimeout } );
	}

,	Execute : function () {
		
		NxScriptClass.extend( this, NxScript );			
		NxScriptClass.extend( this, GnxEditor_EventHandler );
		
		NxStaticDataSet_EditorControls.add( { itemId : this.createUniqueId( "ItemSelect_division" ), codeReadyState : 0 } );
		NxStaticDataSet_EditorControls.add( { itemId : this.createUniqueId( "HtmlTagFilter_division" ), codeReadyState : 0 } );
		
		this.__EditorLayer			= NxScript.findElement( this.UniqueID );
		this.__EditorField			= NxScript.findElement( this.hFieldID );
		this.__EditorStage			= NxScript.findElement( this.hStageID );
		this.__EditorStyle			= ( new GnxEditor_StyleDataSet( this.maskGameCode, this.codeSkinType ) ).Bind();
		this.__EditorMaster			= NxScript.findElement( "hEditDefaultFormat" );//¸¶½ºÅÍ Á¤º¸¸¦ ´ã°í ÀÖ´Â °´Ã¼¸¦ Ã£¾Æ¿Â´Ù.
		
		this.__EditorHtmlViewer		= NxScript.findElement( this.createUniqueId( "strArticleContent_Viewer" ) ); 
		this.__EditorFilterLayer	= NxScript.findElement( this.createUniqueId( "HtmlTagFilter_division" ) ); 
		this.__EditorDivision		= NxScript.findElement( this.createUniqueId( "itemSelect_division" ) );
		this.__EditorHtmlField		= NxScript.findElement( this.createUniqueId( "strContent_OnlyHtml" ) );
		this.__EditorTextField		= NxScript.findElement( this.createUniqueId( "strContent_OnlyText" ) );
		this.__EditorNewImgFile		= NxScript.findElement( this.createUniqueId( "new_oidImageFiles" ) );
		this.__EditorOldImgFile		= NxScript.findElement( this.createUniqueId( "old_oidImageFiles" ) );
		this.__EditorNewMovFile		= NxScript.findElement( this.createUniqueId( "new_oidMovieFiles" ) );
		this.__EditorOldMovFile		= NxScript.findElement( this.createUniqueId( "old_oidMovieFiles" ) );
		this.__EditorNewThumbFiles	= NxScript.findElement( this.createUniqueId( "new_oidThumbFiles" ) );
		this.__EditorOldThumbFiles	= NxScript.findElement( this.createUniqueId( "old_oidThumbFiles" ) );
		
		NxScriptClass.extend( this.__EditorHtmlViewer, this.handleElement() );
		
		this.initializeProperties();
		this.initializeComponent();
	}

,	initializeProperties : function () {

		switch ( +this.maskGameCode )
		{
			case NxScript.Constants.maskGameCode_Maple : 
				this.strFileDownloader = "http://download.maplestory.nexon.com/Isolation/File/Download/FileDownloader.aspx"; break;
			
			default :
				this.strFileDownloader = "http://file.nexon.com/Isolation/File/Download/FileDownloader.aspx"; break;
		}
	}

,	initializeComponent : function() {

		this.createStage();
		this.changeStageStatus();
		this.changeElementsStatus();
		this.createStageInterval();
		
		for ( var i = 0; i < NxStaticDataSet_EditorControls.count(); i++ ) {
		
			var _info	= NxStaticDataSet_EditorControls.row( i );
			var _el		= NxScript.findElement( _info.itemId );
			
			if ( _el != null ) {
			
				NxScriptClass.extend( _el, this.Merge( {
				
					onclick			: function() { this.controls.OnClick( this ); }	
				,	onmouseover		: function() { this.controls.OnOver( this ); }
				,	onmouseout		: function() { this.controls.OnOut( this ); }
				,	onchange		: function() { this.controls.OnChange( this ); }
				
				} ) );
				
				if ( !( typeof _el.tagName ).equals( "undefined" ) && _el.tagName.equals( "Select" ) ) {
					
					var checkValue = ( _el.id.equals( "SELFONTFAMILY" ) ) ? this.__EditorStyle.fontFamily : this.__EditorStyle.fontSize;
					
					for ( var l = 0; l < _el.options.length; l++ ) {
						
						if ( _el.options[ l ].text.equals( checkValue ) )
							_el.options[ l ].selected = true;
					}					
				}
				
				if ( !( typeof _el.tagName ).equals( "undefined" ) && _el.tagName.equals( "Input" ) ) {
					
					if ( ( +this.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_designAndHtml ) ) {
						
						if ( _el.id.equals( "btnhEditOnlyDesign" ) )
							_el.checked = true;
								
					}
					else if ( ( +this.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_htmlAndDesign ) ) {
						
						if ( _el.id.equals( "btnhEditOnlyHtml" ) )
							_el.checked = true;
					}
				}
			}
		}
		
		if ( ( +this.codeStageWriteType ).equals( NxScriptCode.codeEditorWriteType_Write ) )
		{
			if ( this.__EditorMaster != null )
			{
				this.__EditorHtmlField.value = this.__EditorMaster.innerHTML;
				
				this.changeStageStatus();
			}
		}
				
		else if ( ( +this.codeStageWriteType ).equals( NxScriptCode.codeEditorWriteType_Modify ) ) {
		
			this.__EditorHtmlField.value = this.__EditorHtmlViewer.innerHTML;
			this.__EditorTextField.value = this.__EditorHtmlViewer.innerText;
				
			if ( ( +this.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_designAndHtml ) && this.__EditorStage != null )
				this.get_StageBody().bound( this.__EditorHtmlViewer.innerHTML );		
				
			else if ( ( +this.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_htmlAndDesign ) && this.__EditorField != null )
				this.__EditorField.bound( this.__EditorHtmlViewer.innerHTML );		
				
			var AttachFiles = this.OutputFileContent();
					
			this.__EditorOldImgFile.value		= AttachFiles.images;
			this.__EditorOldMovFile.value		= AttachFiles.movies;
			this.__EditorOldThumbFiles.value	= AttachFiles.thumbs;
		}
	}

	// iframe Event ÀâÁö ¸øÇÏ´Â ¹®Á¦·Î ÀÎÇÏ¿© °í¹Î Áß.. ³ªÁß¿¡ ±¸Çö
,	findEventElement : function ( el ) {

		if ( ( typeof el.tagName ).equals( "undefined" ) || el.tagName.equals( "body" ) )		
			NxScriptClass.extend( el, { id : "hStage" } );
		
		return el;
	}

,	Merge : function ( source ) {
		
		var handle = this.handleElement();  
		
		return NxScriptClass.extend( handle, source );
	}


,	createUniqueId : function ( strId ) {

		return this.UniqueID + "_" + strId;
	}

,	createStage : function() {

		if ( this.__EditorStage != null ) {
		
			this.get_StageDoc().designMode = "On";
			this.get_StageDoc().open( this.strStageContentType, "replace" );
			this.get_StageDoc().write( "<html><head></head><body></body></html>" );
			this.get_StageDoc().close();
				
			NxScriptClass.extend( this.__EditorStage, this.handleElement() );
			NxScriptClass.extend( this.get_StageBody(), this.Merge( this.handleStageBodyEvent( this ) ) );
			NxScriptClass.extend( this.get_StageStyle(), this.__EditorStyle );
		}
		
		if ( this.__EditorField != null )		
			NxScriptClass.extend( this.__EditorField, this.Merge( this.handleStageBodyEvent( this ) ) );
	}

,	createStageInterval : function () {
		
		this.strIntervalID = NxScript.Interval( ( function() { this.get_StageEventOperator(); } ).bind( this ), this.n4IntervalLoopMsec );
	}

,	changeStageStatus : function () {
		
		if ( this.__EditorStage == null && this.__EditorField != null )
			this.codeStageWriteType = NxScriptCode.codeEditorWriteType_None;
		
		else if ( !this.__EditorHtmlViewer.innerHTML.length.equals( 0 ) && ( this.__EditorStage != null || this.__EditorField != null ) ) 
			this.codeStageWriteType = NxScriptCode.codeEditorWriteType_Modify;
			
		else if ( this.__EditorHtmlViewer.innerHTML.length.equals( 0 ) && ( this.__EditorStage != null || this.__EditorField != null ) )
			this.codeStageWriteType = NxScriptCode.codeEditorWriteType_Write;
			
		if ( ( +this.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_designAndHtml ) ) {
			
			if ( this.__EditorField != null )
				this.__EditorField.visible( true );
			
			if ( this.__EditorStage != null ) {
				
				this.__EditorStage.visible( false );
				this.get_StageBody().bound( this.__EditorHtmlField.value );
				this.get_StageFocus();
			}
			
			this.isEnableEditor = true;
		}
						
		else if ( ( +this.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_htmlAndDesign ) ) {
		
			if ( this.__EditorStage != null )
				this.__EditorStage.visible( true );
			
			if ( this.__EditorField != null ) {
			
				this.__EditorField.visible( false );
				this.__EditorField.bound( this.__EditorHtmlField.value );
				this.__EditorField.focus();
			}
			
			this.isEnableEditor = false;
		}
				
		else if ( ( +this.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_viewOnly ) ) {
			
			this.__EditorHtmlViewer.visible( false );
			
			this.ArrayLoadEvents.add( function ( sender ) {
				
				if ( sender.n4IntervalCount == 0 )				
					sender.UploadVodFileHandler();					
			} );
			
			this.ArrayLoadEvents.add( function ( sender ) {
				
				if ( sender.n4IntervalCount == 0 )				
					sender.changeElementAttribute();					
			} );
			
			this.ArrayLoadEvents.add( this.Append_ImageFileEvent );
		}
	}
	
,	get_StageEventOperator : function () {
		
		if ( this.ArrayLoadEvents.count() > 0 && !( +this.n4IntervalCount ).equals( this.n1IntervalLimitCount ) ) {
		
			for ( var i = 0; i < this.ArrayLoadEvents.count(); i++ )
				this.ArrayLoadEvents.row( i )( this );
			
			this.n4IntervalCount++;
		}
		else {
							
			NxScript.clearInterval( this.strIntervalID );
		}	
	}

,	get_StageDoc : function () {		
		return document.frames[ this.hStageID ].document;
	}

,	get_StageBody : function () {	
		return this.get_StageDoc().body;
	}

,	get_StageStyle : function () {		
		return this.get_StageBody().style;
	}

,	get_StageFocus : function () {
		
		if ( ( +this.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_designAndHtml ) )		
			return this.get_StageBody().focus();
		
		else if ( ( +this.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_htmlAndDesign ) )
			return this.__EditorField.focus();
	}

,	get_StageSelection : function () {

		var oStage = null;
		var oSelect	= this.get_StageDoc().selection; 
		
		if ( oSelect.type.toLowerCase() != "none" && oSelect.type.toLowerCase() != "control" )
			return oSelect.createRange();
		else
			return this.get_StageDoc();		
	}

,	get_htmlSrcFactory : function( prop ) {
		
		var _html_ = "";
		
		if ( prop.strType.equals( "FORECOLOR" ) || prop.strType.equals( "BACKCOLOR" ) )
		{
			var color = ( prop.strType.equals( "FORECOLOR" ) ) ? prop.EditorControl.__EditorStyle.color : prop.EditorControl.__EditorStyle.backgroundColor;
			
			_html_ += "<div style='width:230px;height:106px;background-color:#FFFFFF;text-align:center'>";
			_html_ += "<div style='height:54px;background-color:#F2F2F2;border-bottom:1px solid #CCCCCC' id='" + prop.strDisplayAreaId + "'></div>";
			_html_ += "<div style='height:35px'>";
			_html_ += "<div style='float:left'>";
			_html_ += "<div style='float:left;width:10px;height:10px;margin:8px 3px 0 10px;border:1px solid #333333;background-color:" + color  + ";display:inline' id='" + prop.strPreviewAreaId + "'>";
			_html_ += "<img src='http://s.nx.com/S2/Nexon2006/image/global/img_bl.gif' width='10' height='10' alt=''/></a>";											
			_html_ += "</div>";
			_html_ += "<input id='" + prop.strInputId + "' type='Text' style='float:left;width:54px;margin-top:3px;padding:3px 0;border:1px solid #D7D7D7'/>";
			_html_ += "</div>";
			_html_ += "<div style='float:right;margin:5px 9px 0 0;display:inline'>";
			_html_ += "<img id='" + prop.strConfirmBtnId + "' src='http://s.nx.com/S2/Nexon2006/image/button/bt_cfm.gif' width='41' height='20' alt='È®ÀÎ' style='cursor:pointer'/></a>";
			_html_ += "</div>";
			_html_ += "</div>";
			_html_ += "<div style='clear:both;float:right;height:16px;margin-right:9px;display:inline;background-color:#000'>";										
			_html_ += "<img id='" + prop.strCloseBtnId + "' src='http://s.nx.com/S2/Nexon2006/image/button/bt_close.gif' width='48' height='16' alt='´Ý±â' style='display:block' style='cursor:pointer'/>";
			_html_ += "</div>";
			_html_ += "</div>";
		
		}
		else if ( prop.strType.equals( "LINK" ) )
		{
			_html_ += "<div style='width:308px;height:122px'>";
			_html_ += "<div style='height:29px;padding-top:8px;border-bottom:1px solid #D7D7D7;text-align:center'>";
			_html_ += "<p style='padding-top:5px'>'http://'·Î ½ÃÀÛµÇ´Â ¸µÅ©ÁÖ¼Ò(URL)¸¦ ³Ö¾îÁÖ¼¼¿ä.</p>";
			_html_ += "</div>";
			_html_ += "<div style='padding:5px 0 6px;text-align:left;text-indent:9px;background-color:#F5F5F5;border-bottom:1px solid #D7D7D7'>";
			_html_ += "<b>URL</b> <input type='Text' value='http://' id='" + prop.strInputId + "' style='width:253px;height:11px;margin-left:6px;padding:3px 0;border:1px solid #606060'/>";
			_html_ += "</div>";
			_html_ += "<div style='margin:0 auto;padding-top:5px;width:41px;height:19px'><img id='" + prop.strConfirmBtnId + "' src='http://s.nx.com/S2/Nexon2006/image/button/bt_cfm.gif' width='41' height='20' alt='È®ÀÎ' style='cursor:pointer'/></div>";					
			_html_ += "<div style='float:right;height:16px;margin:10px 14px 0 0;display:inline'><img id='" + prop.strCloseBtnId + "' src='http://s.nx.com/S2/Nexon2006/image/button/bt_close.gif' width='48' height='16' alt='´Ý±â' style='cursor:pointer'/></div>";
			_html_ += "</div>";
		}
		else if ( prop.strType.equals( "EMOTICON" ) )
		{
			_html_ += "<div style='width:145px;height:300px'>";
			_html_ += "<div style='height:29px;padding-top:8px;border-bottom:1px solid #D7D7D7'>";
			_html_ += "<div style='width:130px;margin:0 auto'>";
			_html_ += "<div style='width:130px;height:20px;background:url(http://s.nx.com/S2/Nexon2006/image/global/bg_select.gif) #FFFFFF no-repeat;text-align:left'>";
			
			_html_ += "<select id='" + prop.strSelectBoxId + "' style='width:130px;' setColor='#636363,transparent,#636363,#EEEEEE,none,none' setImage='http://s.nx.com/S2/Nexon2006/image/button/bt_selectarr.gif'  setHeight='20,100' >";
			_html_ += "<option value='0'>ºÐ·ù</option>";
			
			for ( var i = 0; i < prop.cateDataSource.count(); i++ ) {
				
				_html_ += "<option value='" + prop.cateDataSource.row( i ).codeCategory + "'>" + prop.cateDataSource.row( i ).strCategoryName + "</option>";
			}
			
			_html_ += "</select>";
			
			_html_ += "</div>";
			_html_ += "</div>";
			_html_ += "</div>";
			
			_html_ += "<div style='background-color:#F5F5F5;border-bottom:1px solid #D7D7D7;padding:10px;height:160px' id='" + prop.strDisplayAreaId + "'></div>";
			
			_html_ += "<div style='width:124px;height:15px;margin:0 auto;padding-top:6px;border-bottom:1px solid #D7D7D7;font-size:11px;text-align:center'>";
			_html_ += "<img src='http://s.nx.com/S2/Nexon2006/image/button/bt_prev2.gif' width='7' height='8' alt='ÀÌÀü' id='" + prop.strPrevBtnId + "' style='cursor:pointer'/>"; 
			_html_ += "<label id='" + prop.strPageNoId + "' style='padding-left:5px;padding-right:5px'></label>"; 
			_html_ += "<img src='http://s.nx.com/S2/Nexon2006/image/button/bt_next2.gif' width='7' height='8' alt='´ÙÀ½' id='" + prop.strNextBtnId + "' style='cursor:pointer'/>";
			_html_ += "</div>";
			
			_html_ += "<div style='margin:0 auto;padding-top:5px;width:41px;height:19px'><img id='" + prop.strConfirmBtnId + "' src='http://s.nx.com/S2/Nexon2006/image/button/bt_cfm.gif' width='41' height='20' alt='È®ÀÎ' style='cursor:pointer'/></div>";					
			_html_ += "<div style='float:right;height:16px;margin:10px 14px 0 0;display:inline'><img id='" + prop.strCloseBtnId + "' src='http://s.nx.com/S2/Nexon2006/image/button/bt_close.gif' width='48' height='16' alt='´Ý±â' style='cursor:pointer'/></div>";
			_html_ += "</div>";
		}		
		
		return _html_;		
	}

,	get_bindSrcFactory : function( prop ) {
		
		var _html_	= "";
		var _item_	= null;
		
		if ( prop.strType.equals( "EMOTICON" ) )
		{
			_html_ += "<table width='120' border='0' cellspacing='1' cellpadding='0' style='margin:0 auto;background-color:#DEDEDE;border-collapse:separate'>";
			_html_ += "<tr>";
			
			for ( var i = 0; i < prop.n4PageScale; i++ ) {				
				
				_item_ = ( prop.getDataRow( prop.n4StartNo() + i  ) != null ) ? "<img src='http://file.nx.com/ActiveX/Emoticon/" + prop.getDataRow( prop.n4StartNo() + i ).strFileName + "' style='cursor:pointer'>" : "&nbsp;";
				
				_html_ += "<td height='30' width='30' align='center' valign='middle' style='border:1px solid #ffffff;background-color:#ffffff'>" + _item_ + "</td>";
				
				if ( i < ( prop.n4PageScale - 1 )  ) {
					if ( ( ( i + 1 ) % prop.n4QuotaSize  ) == 0 )
						_html_ += "</tr><tr>";
				}
			}
			
			_html_ += "</tr>";
			_html_ += "</table>";
		
		}
		
		else if ( prop.strType.equals( "FORECOLOR" ) || prop.strType.equals( "BACKCOLOR" ) ) {
			
			_html_ += "<table border='0' cellspacing='1' cellpadding='0' style='margin:10px auto 0;width:210px;height:34px;background-color:#333333'>";
			_html_ += "<tr>";
			
			for ( var i = prop.n4StartNo(); i < prop.n4EndNo() && i < prop.n4TotalCount(); i++ ) {				
			
				_html_ += "<td style='background-color:" + prop.getDataRow( i ).codeRgb + "' style='cursor:pointer'><img src='http://s.nx.com/S2/Nexon2006/image/global/img_bl.gif' width='10' height='10'/></td>";
				
				if ( i < ( prop.n4PageScale - 1 )  ) {
					if ( ( ( i + 1 ) % prop.n4QuotaSize  ) == 0 )
						_html_ += "</tr><tr>";
				}
			}
			
			_html_ += "</tr>";
			_html_ += "</table>";
		}
		
		return _html_;
		
	}

,	get_AttachFileValidation : function () {
		
		//var _n1UploadFielMaxCount	= 0;
		var _n4UploadFileTotalCount = this.n4ImgFileTotalCount + this.n4VodFileTotalCount;
		
		//_n1UploadFileMaxCount = ( this.n1UploadFileMaxCount > _n4UploadFileTotalCount ) ? ( this.n1UploadFileMaxCount - _n4UploadFileTotalCount ) : 0;
		
		if( _n4UploadFileTotalCount > this.n1UploadFileMaxCount )
		{
			alert( "ÆÄÀÏ °¹¼ö ÃÊ°ú·Î ÀÎÇÏ¿© ´õÀÌ»ó ÆÄÀÏ ¾÷·Îµå¸¦ ÇÏ½Ç ¼ö ¾ø½À´Ï´Ù." );
			return false;
		}
		
		if ( ( +this.codeThumbFileType ).equals( 1 ) ) {
			
			if ( ( +this.n4ImgFileTotalCount ).equals( 0 ) ) {
				
				alert( "ÀÌ¹ÌÁö Ã·ºÎ ÈÄ µî·ÏÀÌ °¡´ÉÇÕ´Ï´Ù." );
				return false;				
			}
			else {			
				return true;
			}
		}
		else if ( ( +this.codeThumbFileType ).equals( 2 ) ) {
			
			if ( ( +this.n4VodFileTotalCount ).equals( 0 ) ) {
				
				alert( "µ¿¿µ»ó Ã·ºÎ ÈÄ µî·ÏÀÌ °¡´ÉÇÕ´Ï´Ù." );
				return false;				
			}
			else {			
				return true;
			}
		}
		else {		
			return true;
		}
	}

,	Append_StageContent : function ( src ) {
		
		var _sel	= this.get_StageDoc().selection;
		var _rng	= null;
		
		if ( _sel != null && !_sel.type.equals( "CONTROL" ) ) {
				
			_rng = _sel.createRange();
		}
		else {
			
			_rng = _sel.createRange();
			
			if ( _rng.length > 0 )
				_sel.clear();
			
			_rng = _sel.createRange();
		}
		
		if ( _rng != null )
			_rng.pasteHTML( src );
	}

,	Append_ImageFileEvent : function ( sender ) {
		
		var _imgs		= sender.__EditorHtmlViewer.getElementsByTagName( "IMG" );
		var _tmpWidth	= 0; 
		var _tmpHeight	= 0;
		
		for ( var i = 0; i < _imgs.length; i++ ) {
			
			if ( _imgs( i ).width > sender.n4StageWidth ) {
				
				_tmpWidth			= _imgs( i ).width;
				_tmpHeight			= _imgs( i ).height;
			
				_imgs( i ).width		= ( sender.n4StageWidth - 10 );
				_imgs( i ).style.cursor = "pointer";
				
				if ( ( +sender.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_viewOnly ) ) 
					NxScriptClass.extend( _imgs( i ), sender.handleImageFileEvent( _tmpWidth, _tmpHeight ) );
			}			
		}
	}

,	UploadVodFileHandler : function () {
		
		var _divs		= this.__EditorHtmlViewer.getElementsByTagName( "DIV" );
		var _info		= null;
		var _type		= null;
		
		for ( var i = 0; i < _divs.length; i++ ) {
			
			_info	= _divs( i ).id.split( "_" );
			
			if ( _info.length > 4 ) {
				
				if ( _info[ 1 ].equals( "MOVIE" ) ) {
				
					if ( ( +this.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_viewOnly ) ) {
						
						//<! ¹Ìµð¾î ÇÃ·¹ÀÌ¾î ±â´É °­È­ by emong@nexon.co.kr ( 20070725 )
						//<! gws_javascript.js, GnxEditor_PlayerHelper.js Ã·ºÎ µÇÁö ¾ÊÀ¸¸é ÇÃ·¹ÀÌ¾î Á¤»óÀûÀ¸·Î ÀÛµ¿ÇÏÁö ¾Ê´Â´Ù. by emong@nexon.co.kr ( 20070730 )
						//<! Á¤»óÀûÀ¸·Î ÀÛµ¿µÇÁö ¾ÊÀ» ½Ã Gnx.aspx È®ÀÎÇØ º¼ °Í. by emong@nexon.co.kr ( 20070730 )
						if ( ( typeof GnxEditor_PlayerHelper ).toString() == "object" )
						{
							//<! ºÒÇÊ¿äÇÑ ÅÂ±×¸¦ »èÁ¦ÇÑ´Ù. by emong@nexon.co.kr ( 20070730 )
							System.Util.RemoveControls( _divs( i ) );
							
							//<! ±âÁ¸¿¡ »ç¿ëÇÏ¿´´ø µ¿¿µ»ó Å©±â º¸´Ù ÀÛÀ½À¸·Î °­Á¦·Î °ªÀ» º¯°æÇÑ´Ù. by emong@nexon.co.kr ( 20070730 )
							_divs( i ).style.pixelWidth			= 338;
							_divs( i ).style.pixelHeight		= 304;
							
							document.body.ondragstart	= function() { return false; };
							document.body.onselectstart	= function() { return false; };
							
							NxScriptClass.extend( _divs( i ), GnxEditor_PlayerHelper.Form.prototype );
							
							_divs( i ).CreateControls();
							_divs( i ).InitializeControls();
							
							var _vodInfo		= _info[ 2 ].vodParse( ":" ); 
							var _vodUrl			= this.strFileDownloader + "?oidFile=" + _vodInfo.oidFile;
							var _vodThumb		= this.strFileDownloader + "?oidFile=" + _vodInfo.thumb_title;
							
							_divs( i ).SetUrl( _vodUrl );
							_divs( i ).SetImageUrl( _vodThumb );
							
							//<! ÇÃ·¹ÀÌ¾î Àû¿ë ÈÄ ¹é±×¶ó¿îµå ÀÌ¹ÌÁö¸¦ Á¦°Å ÇÑ´Ù. by emong@nexon.co.kr ( 20070730 )
							_divs( i ).style.backgroundImage	= "url()";
						}
					}
				}
			}
		}
	}

,	hasStageSelection : function () {
		
		var oSelect = this.get_StageDoc().selection;
		
		if ( oSelect.type.toLowerCase() != "none" && oSelect.type.toLowerCase() != "control" )
			return true;
		else
			return false;
	}

,	OutputHtmlContent : function () {
		
		return this.get_StageBody().innerHTML.HtmlTagFilter( this.codeWriterType );
	}

,	OutputTextContent : function () {
		
		return this.get_StageBody().innerText;
	}

,	OutputFieldContent : function () {
		
		return this.__EditorField.value.HtmlTagFilter( this.codeWriterType );
	}

,	OutputFileContent : function () {
		
		var _info		= null;
		var _type		= null;
		var _oid		= null;
		var _vodInfo	= null;
		var _imgInfo	= null;
		var _thread		= null;
		
		if ( ( +this.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_designAndHtml ) )		
			_thread = this.get_StageDoc();
		
		else if ( ( +this.codeStageModeType ).equals( NxScriptCode.codeEditorModeType_htmlAndDesign ) )
			_thread = this.__EditorHtmlViewer;
		
		var _img		= _thread.getElementsByTagName( "IMG" );
		var _div		= _thread.getElementsByTagName( "DIV" );
		
		
		var _length		= new NxScriptArray();
		var _duration	= new NxScriptArray();
		
		this.ArrayImageFiles.reset();
		this.ArrayMovieFiles.reset();
		this.ArrayThumbFiles.reset();
					
		for ( var i = 0; i < _img.length; i++ ) {
		
			_info	= _img( i ).id.split( "_" );
			
			if ( _info.length > 4 ) {
			
				_type		= _info[ 1 ];
				_imgInfo	= _info[ 2 ].imgParse( ":" );
				
				if ( _type.equals( "IMAGE" ) ) {
					
					this.ArrayImageFiles.add( _imgInfo.oidFile + ":" + _imgInfo.fileName );
					
					if ( ( +this.codeThumbFileType ).equals( 1 ) )
						this.ArrayThumbFiles.add( _imgInfo.oidThumb + ":" + _imgInfo.fileName );
					
					NxScriptClass.extend( _img( i ), this.handleDisabledContent() );
				}	
			}	
		}
		
		for ( var i = 0; i < _div.length; i++ ) {
		
			_info	= _div( i ).id.split( "_" );
			
			if ( _info.length > 4 ) {
			
				_type	= _info[ 1 ];
				
				if ( _type.equals( "MOVIE" ) ) {
				
					_vodInfo	= _info[ 2 ].vodParse( ":" );
					
					this.ArrayMovieFiles.add( _vodInfo.oidFile + ":" + _vodInfo.fileName );
					
					if ( ( +this.codeThumbFileType ).equals( 2 ) )
						this.ArrayThumbFiles.add( _vodInfo.thumb_select + ":" + _vodInfo.thumbName );
					
					_length.add( _vodInfo.fileSize );
					_duration.add( _vodInfo.fileDate );
					
					NxScriptClass.extend( _div( i ), this.handleDisabledContent() );
				}
			}	
		} 
		
		this.n4ImgFileTotalCount	= this.ArrayImageFiles.count();
		this.n4VodFileTotalCount	= this.ArrayMovieFiles.count();
		this.n4VodFileTotalLength	= _length.sum();
		this.n4VodFileTotalMsec		= _duration.sum();
		
		return ( { 
			
			movies		: this.ArrayMovieFiles.join( "," )
		,	images		: this.ArrayImageFiles.join( "," )
		,	thumbs		: this.ArrayThumbFiles.join( "," )
				
		} );
	}

,	handleStageBodyEvent : function( sender )
	{
		return ( {
		
			onblur			: function() { 
				
				if ( ( typeof this.tagName ).equals( "undefined" ) ) {
								
					sender.__EditorHtmlField.value		= sender.OutputHtmlContent();
					sender.__EditorTextField.value		= sender.OutputTextContent();
					
					var fileInfo = sender.OutputFileContent();
					
					sender.__EditorNewImgFile.value		= fileInfo.images;
					sender.__EditorNewMovFile.value		= fileInfo.movies;
					sender.__EditorNewThumbFiles.value	= fileInfo.thumbs;
				}
				else {					
					sender.__EditorHtmlField.value	= sender.OutputFieldContent();
				}
			}	
		,	onfocus			: function() { sender.__EditorDivision.visible( true ); }
		,	ondrop			: function() { return false; }
		,	oncontextmenu	: function() { return false; }	
		,	onkeydown		: function() {
				
				if ( !( typeof this.tagName ).equals( "undefined" ) && this.tagName.equals( "body" ) )
					return ( sender.isEnableEditor ) ? true : false;
				else
					return true;
			}
		} );
	}

,	divStyleSheet : function( prop )
	{
		return ( {
			
			zIndex				: 1000
		,	display				: prop.strDisplay
		,	top					: ( NxClient._Y() - NxClient._offsetY() ) + ( NxClient._height() + NxDocument.scrollTop() )
		,	left				: ( NxClient._X() - NxClient._offsetX() )
		,	position			: "absolute"
		,	backgroundColor		: "#ffffff"
		,	borderStyle			: "solid"
		,	borderWidth			: "1px"
		,	borderColor			: "#808080"
			
		} );
	}

,	handleElement : function ()
	{
		return ( {
		
			controls		: this
		,	visible			: function( bool )	{ this.style.display = ( !bool ) ? "block" : "none"; }	
		,	setStylesheet	: function( style ) { NxScriptClass.extend( this.style, style ); }
		,	bound			: function( data )	{ 
				
				if( !( typeof this.tagName ).equals( "undefined" ) && ( this.tagName.equals( "input" ) || this.tagName.equals( "textarea" ) ) ) 
					this.value		= data;
				else
					this.innerHTML	= data; 
			}
		} );
	}

,	handleImageFileEvent : function ( n4Width, n4Height ) {
		
		return ( { 
			
			onclick : function () { 
				
				var cmd = new GnxCreatePopupCommand();
				
				cmd.n4PopupWidth	= n4Width + 10;
				cmd.n4PopupHeight	= n4Height + 10;
				cmd.strContent		= "<img src='" + this.src + "'/>";
				
				cmd.Execute();
			} 
		} );
	}

,	handleDisabledContent : function () {
		
		return ( { 
		
			contentEditable : false 
		,	onresize		: function () { return false; }
		,	onresizeend		: function () { return false; }
		,	onresizestart	: function () { return false; }
		
		} )
	}

,	changeElementsStatus : function () {
		
		var _el		= null;
		var _info	= null;
		var _Stage	= NxScript.findElement( "hEditStage" );
		
		for ( var i = 0; i < NxStaticDataSet_EditorControls.count(); i++ ) {
			
			_info	= NxStaticDataSet_EditorControls.row( i );
			_el		= NxScript.findElement( _info.itemId ); 
			
			if ( _el != null ) {
			
				if ( !_el.tagName.equals( "input" ) ) {
					
					if ( ( +_info.codeReadyState ).equals( 1 ) )
						_el.style.filter = ( this.isEnableEditor ) ? "alpha( opacity=100 )" : "alpha( opacity=50 )";
				}
				else {
					
					if ( ( +_info.codeReadyState ).equals( 1 ) && ( +this.codeStageModeType ).equals( NxScript.Constants.codeEditorModeType_designAndHtml ) )
						_el.disabled = ( this.isEnableEditor ) ? false : true;
				}
			}
		}
		
		if ( _Stage != null )
			_Stage.style.filter = ( this.isEnableEditor ) ? "alpha( opacity=100 )" : "alpha( opacity=50 )";
	}

,	changeElementAttribute : function () {
		
		var _el = this.__EditorHtmlViewer.getElementsByTagName( "a" );
		
		for ( var i = 0; i < _el.length; i++ )			
			_el( i ).target = "_blank";
	} 	
};