
var GnxEditor_PlayerHelper = new System.Object();

/************************************************************
	!GnxEditor_PlayerHelper.Form 
************************************************************/

GnxEditor_PlayerHelper.Form = System.Extend( System.Classes.HtmlControl.Form );

GnxEditor_PlayerHelper.Form.prototype.CreateControls = function () {
	
	try
	{	
		this.Controls = System.Util.CreateControl
		(
			[
				{ id:"g_dvMediaContainer", type:System.Properties.HtmlControl.div, extend:System.Classes.HtmlControl.Label },
				{ id:"g_dvMediaViewer", type:System.Properties.HtmlControl.div, extend:System.Classes.HtmlControl.Label },
				{ id:"g_dvMediaMaskLayer", type:System.Properties.HtmlControl.div, extend:System.Classes.HtmlControl.Label },
				{ id:"g_dvTrackContainer", type:System.Properties.HtmlControl.div, extend:GnxEditor_PlayerHelper.Controls.Container.MediaTrackContainer },
				{ id:"g_dvVolumeContainer", type:System.Properties.HtmlControl.div, extend:GnxEditor_PlayerHelper.Controls.Container.MediaVolumeContainer },
				{ id:"g_dvMuteContainer", type:System.Properties.HtmlControl.div, extend:System.Classes.HtmlControl.Label },
				{ id:"g_dvStatusContainer", type:System.Properties.HtmlControl.div, extend:System.Classes.HtmlControl.Label },
				
				{ id:"g_imgMediaSnapshot", type:System.Properties.HtmlControl.img, extend:System.Classes.HtmlControl.Label },
								
				{ id:"g_imgTrackProgressBar", type:System.Properties.HtmlControl.img, extend:GnxEditor_PlayerHelper.Controls.ProgressBar },
				{ id:"g_imgTrackControler", type:System.Properties.HtmlControl.img, extend:GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton },
				
				{ id:"g_imgVolProgressBar", type:System.Properties.HtmlControl.img, extend:GnxEditor_PlayerHelper.Controls.ProgressBar },
				{ id:"g_imgVolControler", type:System.Properties.HtmlControl.img, extend:GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton },
				
				{ id:"g_imgMuteControler", type:System.Properties.HtmlControl.img, extend:GnxEditor_PlayerHelper.Controls.Button.MediaMuteButton },
				
				{ id:"g_pButHolder", type:System.Properties.HtmlControl.p, extend:System.Classes.HtmlControl.Label },
				{ id:"g_butMediaPlay", type:System.Properties.HtmlControl.img, extend:GnxEditor_PlayerHelper.Controls.Button.MediaPlayButton },
				{ id:"g_butMediaStop", type:System.Properties.HtmlControl.img, extend:GnxEditor_PlayerHelper.Controls.Button.MediaStopButton },
				{ id:"g_butMediaPause", type:System.Properties.HtmlControl.img, extend:GnxEditor_PlayerHelper.Controls.Button.MediaPauseButton },
				{ id:"g_butFullScreen", type:System.Properties.HtmlControl.img, extend:GnxEditor_PlayerHelper.Controls.Button.MediaScreenChangeButton },
				{ id:"g_spStatusText", type:System.Properties.HtmlControl.span, extend:GnxEditor_PlayerHelper.Controls.Viewer.MediaTrackStateViewer },
				
				{ id:"g_butMediaStart", type:System.Properties.HtmlControl.img, extend:GnxEditor_PlayerHelper.Controls.Button.MediaStartButton },
				{ id:"g_MediaPlayer", type:System.Properties.HtmlControl.object, extend:GnxEditor_PlayerHelper.Controls.MediaPlayer }
			]
		);
		
		this.Controls.g_dvMediaContainer.SetAttribute( { className:"PlayerSec2" } );
		this.Controls.g_dvMediaViewer.SetAttribute( { className:"MovieV" } );
		
		this.Controls.g_dvTrackContainer.SetAttribute( { className:"PlayerBar" } );
		this.Controls.g_dvTrackContainer.SetStyleSheet( { width:"230px" } );
		
		this.Controls.g_dvVolumeContainer.SetAttribute( { className:"SoundBar" } );
		this.Controls.g_dvVolumeContainer.SetStyleSheet( { width:"70px" } );
		
		this.Controls.g_dvMuteContainer.SetAttribute( { className:"SpeakerIcon" } );
		this.Controls.g_dvStatusContainer.SetAttribute( { className:"bottom" } );		
		
		this.Controls.g_MediaPlayer.SetAttribute
		( 
			{ 
				classid:"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
			} 
		);
		
		this.Controls.g_MediaPlayer.SetAttribute
		(
			{
				uiMode:"none",
				Volume:"100",
				AutoStart:"false",
				enableContextMenu:"false"	
			}
		);
		
		this.Controls.g_MediaPlayer.SetStyleSheet
		(
			{
				pixelWidth:322,
				pixelHeight:242
			}
		)
		
		this.Controls.g_MediaPlayer.Visible( false );
		
		this.Controls.g_dvMediaViewer.appendChild( this.Controls.g_MediaPlayer );
		
		this.Controls.g_butMediaStart.SetAttribute( { src:"http://s.nx.com/S2/Portal/Nexon/Movie_Tool2/image/bt_play_off.gif" } );
		this.Controls.g_butMediaStart.SetStyleSheet( { position:"absolute",top:"50%",left:"50%",width:"72px",height:"73px",marginTop:"-36px",marginLeft:"-35px",cursor:"pointer" } );
		
		this.Controls.g_dvMediaMaskLayer.SetStyleSheet( { width:"320px",height:"240px",position:"relative" } );
		this.Controls.g_dvMediaMaskLayer.appendChild( this.Controls.g_butMediaStart );
		
		this.Controls.g_dvMediaViewer.appendChild( this.Controls.g_dvMediaMaskLayer );

		this.Controls.g_imgTrackProgressBar.SetAttribute( { className:"BarOn", src:"http://s.nx.com/S2/Portal/Nexon/Movie_Tool2/image/img_bar3_on.gif" } );
				
		this.Controls.g_imgTrackControler.SetAttribute( { className:"BarIcon", src:"http://s.nx.com/S2/Portal/Nexon/Movie_Tool2/image/bar_scroll1.gif" } );
		this.Controls.g_imgTrackControler.SetStyleSheet( { width:"27px" } );
		
		this.Controls.g_dvTrackContainer.appendChild( this.Controls.g_imgTrackProgressBar );
		this.Controls.g_dvTrackContainer.appendChild( this.Controls.g_imgTrackControler );		
		
		this.Controls.g_imgVolProgressBar.SetAttribute( { className:"BarOn", src:"http://s.nx.com/S2/Portal/Nexon/Movie_Tool2/image/img_bar3_on.gif" } );
		this.Controls.g_imgVolProgressBar.SetStyleSheet( { width:"30px" } );
		
		this.Controls.g_imgVolControler.SetAttribute( { className:"BarIcon", src:"http://s.nx.com/S2/Portal/Nexon/Movie_Tool2/image/bar_scroll2.gif" } );
		this.Controls.g_imgVolControler.SetStyleSheet( { width:"19px" } );
		
		this.Controls.g_dvVolumeContainer.appendChild( this.Controls.g_imgVolProgressBar );
		this.Controls.g_dvVolumeContainer.appendChild( this.Controls.g_imgVolControler );
		
		this.Controls.g_imgMuteControler.SetAttribute( { className:"MuteCtrl", src:"http://s.nx.com/S2/Portal/Nexon/Movie_Tool2/image/ico_sound.gif" } );
		this.Controls.g_dvMuteContainer.appendChild( this.Controls.g_imgMuteControler );
		
		this.Controls.g_butMediaPlay.SetAttribute( { src:"http://s.nx.com/S2/Movie_Tool/image/button/bt_play.gif" } );
		this.Controls.g_butMediaPlay.SetStyleSheet( { marginRight:"3px",cursor:"pointer" } );
		
		this.Controls.g_butMediaStop.SetAttribute( { src:"http://s.nx.com/S2/Movie_Tool/image/button/bt_stop.gif" } );
		this.Controls.g_butMediaStop.SetStyleSheet( { marginRight:"3px",cursor:"pointer" } );
		
		this.Controls.g_butMediaPause.SetAttribute( { src:"http://s.nx.com/S2/Movie_Tool/image/button/bt_pause.gif" } );
		this.Controls.g_butMediaPause.SetStyleSheet( { marginRight:"3px",cursor:"pointer" } );
		
		this.Controls.g_butFullScreen.SetAttribute( { src:"http://s.nx.com/S2/Movie_Tool/image/button/bt_full.gif" } );
		this.Controls.g_butFullScreen.SetStyleSheet( { marginRight:"3px",cursor:"pointer" } );
		
		this.Controls.g_pButHolder.appendChild( this.Controls.g_butMediaPlay );
		this.Controls.g_pButHolder.appendChild( this.Controls.g_butMediaStop );
		this.Controls.g_pButHolder.appendChild( this.Controls.g_butMediaPause );
		this.Controls.g_pButHolder.appendChild( this.Controls.g_butFullScreen );
		
		this.Controls.g_dvStatusContainer.appendChild( this.Controls.g_pButHolder );
		this.Controls.g_dvStatusContainer.appendChild( this.Controls.g_spStatusText );
		
		this.Controls.g_dvMediaContainer.appendChild( this.Controls.g_dvMediaViewer );
		this.Controls.g_dvMediaContainer.appendChild( this.Controls.g_dvTrackContainer );
		this.Controls.g_dvMediaContainer.appendChild( this.Controls.g_dvVolumeContainer );
		this.Controls.g_dvMediaContainer.appendChild( this.Controls.g_dvMuteContainer );
		this.Controls.g_dvMediaContainer.appendChild( this.Controls.g_dvStatusContainer );
		
		this.appendChild( this.Controls.g_dvMediaContainer );
	}
	catch ( ex )
	{
		this.appendChild( document.createTextNode( ex.message ) );
		//this.appendChild( document.createTextNode( "gws_javascript ±â¹Ý¿¡¼­ ±¸Çö °¡´ÉÇÕ´Ï´Ù." ) );
	}	
};

GnxEditor_PlayerHelper.Form.prototype.SetUrl = function ( url ) {
			
	this.Controls.g_MediaPlayer.SetUrl( url );   
};

GnxEditor_PlayerHelper.Form.prototype.SetImageUrl = function ( url ) {
			
	this.Controls.g_dvMediaMaskLayer.SetStyleSheet( { backgroundImage:"url( " + url + " )" } );   
};

/************************************************************
	!GnxEditor_PlayerHelper.Properties 
************************************************************/

GnxEditor_PlayerHelper.Properties = new System.Object();

/************************************************************
	!GnxEditor_PlayerHelper.Properties.Media
************************************************************/

GnxEditor_PlayerHelper.Properties.Media = new System.Object();

// @Namespace : GnxEditor_PlayerHelper.Properties.Media.None
GnxEditor_PlayerHelper.Properties.Media.None = new System.Classes.Object();
GnxEditor_PlayerHelper.Properties.Media.None.ToByte = function () { return 0; };
GnxEditor_PlayerHelper.Properties.Media.None.ToString = function () { return "Undefined" };

// @Namespace : GnxEditor_PlayerHelper.Properties.Media.Stopped
GnxEditor_PlayerHelper.Properties.Media.Stopped = new System.Classes.Object();
GnxEditor_PlayerHelper.Properties.Media.Stopped.ToByte = function () { return 1; };
GnxEditor_PlayerHelper.Properties.Media.Stopped.ToString = function () { return "Stopped" };

// @Namespace : GnxEditor_PlayerHelper.Properties.Media.Paused
GnxEditor_PlayerHelper.Properties.Media.Paused = new System.Classes.Object();
GnxEditor_PlayerHelper.Properties.Media.Paused.ToByte = function () { return 2; };
GnxEditor_PlayerHelper.Properties.Media.Paused.ToString = function () { return "Paused" };

// @Namespace : GnxEditor_PlayerHelper.Properties.Media.Playing
GnxEditor_PlayerHelper.Properties.Media.Playing = new System.Classes.Object();
GnxEditor_PlayerHelper.Properties.Media.Playing.ToByte = function () { return 3; };
GnxEditor_PlayerHelper.Properties.Media.Playing.ToString = function () { return "Playing" };

// @Namespace : GnxEditor_PlayerHelper.Properties.Media.Buffering
GnxEditor_PlayerHelper.Properties.Media.Buffering = new System.Classes.Object();
GnxEditor_PlayerHelper.Properties.Media.Buffering.ToByte = function () { return 6; };
GnxEditor_PlayerHelper.Properties.Media.Buffering.ToString = function () { return "Buffering" };

// @Namespace : GnxEditor_PlayerHelper.Properties.Media.Ready
GnxEditor_PlayerHelper.Properties.Media.Ready = new System.Classes.Object();
GnxEditor_PlayerHelper.Properties.Media.Ready.ToByte = function () { return 10; };
GnxEditor_PlayerHelper.Properties.Media.Ready.ToString = function () { return "Ready" };

// @Namespace : GnxEditor_PlayerHelper.Properties.Media.Play
GnxEditor_PlayerHelper.Properties.Media.Play = new System.Classes.Object();
GnxEditor_PlayerHelper.Properties.Media.Play.ToByte = function () { return 255; };
GnxEditor_PlayerHelper.Properties.Media.Play.ToString = function () { return "Play" };

/************************************************************
	!GnxEditor_PlayerHelper.Controls 
************************************************************/

GnxEditor_PlayerHelper.Controls = new System.Object();

// @Namespace : GnxEditor_PlayerHelper.Controls.MediaPlayer
GnxEditor_PlayerHelper.Controls.MediaPlayer = System.Extend( System.Classes.Control );

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.m_file		= null;
GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.m_index		= 0;

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.GetVersion = function () {

	var _el		= this.m_form.Controls.g_MediaPlayer;
	var _var	= 0;
	
	if ( !System.Util.IsNull( _el ) 
		&& !System.Util.IsUndefined( _el.versionInfo ) )
	{
		var _info	= _el.versionInfo;
		var _split	= _info.split( '.' );
		
		if ( _split.length > 0 )
			_var = _split[ 0 ];
	}
	
	return _var;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.Play = function () {

	if ( System.Util.IsNull( this.GetUrl() ) )
		throw new System.Exception( { message:"Àç»ý °¡´ÉÇÑ ¹Ìµð¾î ÆÄÀÏÀÌ ¾ø½À´Ï´Ù." } );
	
	if ( System.Util.IsNull( this.m_readyState ) )
	{
		this.URL = this.GetUrl();
		this.m_readyState = GnxEditor_PlayerHelper.Properties.Media.Play;
		
		this.AddEventListener 
		(
			{
				type:GnxEditor_PlayerHelper.Properties.Media.Play,
				delegator:{
					sender:this,
					method:function () { this.controls.play(); }
				}
			}
		);
	}
	else
	{
		if ( this.m_readyState.ToByte() == GnxEditor_PlayerHelper.Properties.Media.Buffering.ToByte() )
			throw new System.Exception( { message:"ÆÄÀÏ ºÒ·¯¿À´Â Áß ÀÔ´Ï´Ù. Àá½Ã¸¸ ±â´Ù¸®¼¼¿ä." } );
		
		this.controls.play();	
	}	
	
	if ( System.Util.IsNull( this.m_key ) )
		this.EventListener();
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.Stop = function () {

	this.controls.Stop();
	
	this.m_readyState = GnxEditor_PlayerHelper.Properties.Media.Stopped;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.Pause = function () {

	this.controls.Pause();
	
	this.m_readyState = GnxEditor_PlayerHelper.Properties.Media.Paused;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.Mute = function ( bool ) {

	if ( !System.Util.IsUndefined( bool ) )
		this.settings.mute = bool
		
	return this.settings.mute;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.FullScreen = function ( bool ) {

	this.fullscreen = bool;
}; 

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.Dispose = function () {

	this.m_key			= null;
	this.m_readyState	= null;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.SetUrl = function ( url ) {
	
	if ( System.Util.IsNull( this.m_file ) )
		this.m_file = {};
	
	this.m_file[ "url" ] = url;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.GetUrl = function () {

	return ( !System.Util.IsNull( this.m_file ) && !System.Util.IsUndefined(this.m_file[ "url" ]) ) ? this.m_file[ "url" ] : null;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.SetVolume = function ( vol ) {

	this.settings.volume = vol;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.GetVolume = function () {
	
	return this.settings.volume;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.SetPosition = function ( pos ) {

	this.controls.CurrentPosition = pos;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.GetPosition = function ( pos ) {

	return +this.controls.CurrentPosition;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.GetReadyState = function () {
	
	return this.m_readyState;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.GetDuration = function () {
	
	return +this.currentMedia.duration;
};

GnxEditor_PlayerHelper.Controls.MediaPlayer.prototype.EventListener = function () {

	switch ( +this.playState )
	{
		case GnxEditor_PlayerHelper.Properties.Media.Ready.ToByte()		: this.m_readyState = GnxEditor_PlayerHelper.Properties.Media.Ready; break;
		case GnxEditor_PlayerHelper.Properties.Media.Playing.ToByte()	: this.m_readyState = GnxEditor_PlayerHelper.Properties.Media.Playing; break;
		case GnxEditor_PlayerHelper.Properties.Media.Stopped.ToByte()	: this.m_readyState = GnxEditor_PlayerHelper.Properties.Media.Stopped; break;
		case GnxEditor_PlayerHelper.Properties.Media.Buffering.ToByte() : this.m_readyState = GnxEditor_PlayerHelper.Properties.Media.Buffering; break;
	}
	
	System.Event.Listener( this.m_delegate.Select( this.m_readyState ) );
	
	switch ( this.m_readyState.ToByte() )
	{
		case GnxEditor_PlayerHelper.Properties.Media.Ready.ToByte()		: 
		case GnxEditor_PlayerHelper.Properties.Media.Stopped.ToByte()	: this.Dispose(); break;
		
		default : this.Sleep( 500 ); break;
	}		
};

// @Namespace : GnxEditor_PlayerHelper.Controls.ProgressBar
GnxEditor_PlayerHelper.Controls.ProgressBar = System.Extend( System.Classes.Control ); 
GnxEditor_PlayerHelper.Controls.ProgressBar.prototype.Initialize = function () {
	
	this.isEnablePostBack = true;
	this.isUsePostBackForwarding = true;
	
	this.SetStyleSheet( { pixelWidth:0 } );
};

/************************************************************
	!GnxEditor_PlayerHelper.Controls.Viewer 
************************************************************/

GnxEditor_PlayerHelper.Controls.Viewer = new System.Object();

GnxEditor_PlayerHelper.Controls.Viewer.MediaTrackStateViewer = System.Extend( System.Classes.HtmlControl.Label ); 
GnxEditor_PlayerHelper.Controls.Viewer.MediaTrackStateViewer.prototype.Initialize = function () {

	this.ResetTrackState();
	
	this.m_form.Controls.g_MediaPlayer.AddEventListener 
	(
		{
			type:GnxEditor_PlayerHelper.Properties.Media.Playing,
			delegator:{			 
				sender:this,
				method:this.ChangedTrackState
			}
		}
	);
	
	this.m_form.Controls.g_MediaPlayer.AddEventListener 
	(
		{
			type:GnxEditor_PlayerHelper.Properties.Media.Ready,
			delegator:{			
				sender:this,
				method:this.ResetTrackState
			}
		}
	);
};

GnxEditor_PlayerHelper.Controls.Viewer.MediaTrackStateViewer.prototype.ResetTrackState = function () {

	this.SetAttribute( { innerText : "" } );
};

GnxEditor_PlayerHelper.Controls.Viewer.MediaTrackStateViewer.prototype.ChangedTrackState = function () {
	
	var _duration	= this.m_form.Controls.g_MediaPlayer.GetDuration();
	var _position	= this.m_form.Controls.g_MediaPlayer.GetPosition();
	
	var _total		= System.Util.ToDateTime( _duration );
	var _total_min	= ( _total.Minute < 10 ) ? "0" + _total.Minute : _total.Minute;
	var _total_sec	= ( _total.Second < 10 ) ? "0" + _total.Second : _total.Second;
	
	var _block		= System.Util.ToDateTime( _position );
	var _block_min	= ( _block.Minute < 10 ) ? "0" + _block.Minute : _block.Minute;
	var _block_sec	= ( _block.Second < 10 ) ? "0" + _block.Second : _block.Second;
	
	this.SetAttribute( { innerText : _block_min + ":" + _block_sec + " / " + _total_min + ":" + _total_sec } );
};

/************************************************************
	!GnxEditor_PlayerHelper.Controls.Container 
************************************************************/

GnxEditor_PlayerHelper.Controls.Container = new System.Object();

// @Namespace : GnxEditor_PlayerHelper.Controls.Container.MediaTrackContainer
GnxEditor_PlayerHelper.Controls.Container.MediaTrackContainer = System.Extend( System.Classes.HtmlControl.Container );
GnxEditor_PlayerHelper.Controls.Container.MediaTrackContainer.prototype.OnPostBack = function ( evt ) {
	
	if ( !System.Util.IsNull( this.m_form.Controls.g_MediaPlayer.GetReadyState() ) )
	{
		this.m_form.Controls.g_MediaPlayer.Pause();
		
		var _duration	= this.m_form.Controls.g_MediaPlayer.GetDuration();
		var _ctrl		= this.m_form.Controls.g_imgTrackControler.style.pixelWidth;
		var _width		= this.style.pixelWidth;
		var _xpos		= ( evt.offsetX * _duration ) / _width;
		
		this.m_form.Controls.g_MediaPlayer.SetPosition( _xpos );
		this.m_form.Controls.g_MediaPlayer.Play();
	}
};

// @Namespace : GnxEditor_PlayerHelper.Controls.Container.MediaVolumeContainer
GnxEditor_PlayerHelper.Controls.Container.MediaVolumeContainer = System.Extend( System.Classes.HtmlControl.Container );
GnxEditor_PlayerHelper.Controls.Container.MediaVolumeContainer.prototype.OnPostBack = function ( evt ) {

	if ( !System.Util.IsNull( this.m_form.Controls.g_MediaPlayer.GetReadyState() ) )
	{
		var _ctrl		= this.m_form.Controls.g_imgVolControler.style.pixelWidth;
		var _width		= this.style.pixelWidth;
		var _vol		= Math.ceil( ( evt.offsetX * 100 ) / _width );
		
		this.m_form.Controls.g_MediaPlayer.SetVolume( _vol );
		this.m_form.Controls.g_imgVolControler.ChangedPosition();
	}
};

/************************************************************
	!GnxEditor_PlayerHelper.Controls.Button 
************************************************************/

GnxEditor_PlayerHelper.Controls.Button = new System.Object();

// @Namespace : GnxEditor_PlayerHelper.Controls.Button.MediaStartButton
GnxEditor_PlayerHelper.Controls.Button.MediaStartButton = System.Extend( System.Classes.HtmlControl.Button );
GnxEditor_PlayerHelper.Controls.Button.MediaStartButton.prototype.OnPostBack = function ( evt ) {

	this.m_form.Controls.g_MediaPlayer.Play();
	
	this.m_form.Controls.g_MediaPlayer.Visible( true );
	this.m_form.Controls.g_dvMediaMaskLayer.Visible( false );
};

GnxEditor_PlayerHelper.Controls.Button.MediaStartButton.prototype.OnMouseOver = function ( evt ) {

	this.SetAttribute( { src:"http://s.nx.com/S2/Portal/Nexon/Movie_Tool2/image/bt_play_over.gif" } );
};

GnxEditor_PlayerHelper.Controls.Button.MediaStartButton.prototype.OnMouseOut = function ( evt ) {

	this.SetAttribute( { src:"http://s.nx.com/S2/Portal/Nexon/Movie_Tool2/image/bt_play_off.gif" } );
};

// @Namespace : GnxEditor_PlayerHelper.Controls.Button.MediaPlayButton
GnxEditor_PlayerHelper.Controls.Button.MediaPlayButton = System.Extend( System.Classes.HtmlControl.Button );
GnxEditor_PlayerHelper.Controls.Button.MediaPlayButton.prototype.OnPostBack = function ( evt ) {

	this.m_form.Controls.g_MediaPlayer.Play();
	
	this.m_form.Controls.g_MediaPlayer.Visible( true );
	this.m_form.Controls.g_dvMediaMaskLayer.Visible( false );
};

GnxEditor_PlayerHelper.Controls.Button.MediaPlayButton.prototype.OnMouseOver = function ( evt ) {

	this.SetAttribute( { src:"http://s.nx.com/S2/Movie_Tool/image/button/bt_play_on.gif" } );
};

GnxEditor_PlayerHelper.Controls.Button.MediaPlayButton.prototype.OnMouseOut = function ( evt ) {

	this.SetAttribute( { src:"http://s.nx.com/S2/Movie_Tool/image/button/bt_play.gif" } );
};

// @Namespace : GnxEditor_PlayerHelper.Controls.Button.MediaStopButton
GnxEditor_PlayerHelper.Controls.Button.MediaStopButton = System.Extend( System.Classes.HtmlControl.Button );
GnxEditor_PlayerHelper.Controls.Button.MediaStopButton.prototype.OnPostBack = function ( evt ) {

	if ( !System.Util.IsNull( this.m_form.Controls.g_MediaPlayer.GetReadyState() ) )
	{
		this.m_form.Controls.g_MediaPlayer.Stop();
		
		this.m_form.Controls.g_MediaPlayer.Visible( false );
		this.m_form.Controls.g_dvMediaMaskLayer.Visible( true );
	}
};

GnxEditor_PlayerHelper.Controls.Button.MediaStopButton.prototype.OnMouseOver = function ( evt ) {

	this.SetAttribute( { src:"http://s.nx.com/S2/Movie_Tool/image/button/bt_stop_on.gif" } );
};

GnxEditor_PlayerHelper.Controls.Button.MediaStopButton.prototype.OnMouseOut = function ( evt ) {

	this.SetAttribute( { src:"http://s.nx.com/S2/Movie_Tool/image/button/bt_stop.gif" } );
};

// @Namespace : GnxEditor_PlayerHelper.Controls.Button.MediaPauseButton
GnxEditor_PlayerHelper.Controls.Button.MediaPauseButton = System.Extend( System.Classes.HtmlControl.Button );
GnxEditor_PlayerHelper.Controls.Button.MediaPauseButton.prototype.OnPostBack = function ( evt ) {

	if ( !System.Util.IsNull( this.m_form.Controls.g_MediaPlayer.GetReadyState() ) )
		this.m_form.Controls.g_MediaPlayer.Pause();
};

GnxEditor_PlayerHelper.Controls.Button.MediaPauseButton.prototype.OnMouseOver = function ( evt ) {

	this.SetAttribute( { src:"http://s.nx.com/S2/Movie_Tool/image/button/bt_pause_on.gif" } );
};

GnxEditor_PlayerHelper.Controls.Button.MediaPauseButton.prototype.OnMouseOut = function ( evt ) {

	this.SetAttribute( { src:"http://s.nx.com/S2/Movie_Tool/image/button/bt_pause.gif" } );
};

// @Namespace : GnxEditor_PlayerHelper.Controls.Button.MediaScreenChangeButton
GnxEditor_PlayerHelper.Controls.Button.MediaScreenChangeButton = System.Extend( System.Classes.HtmlControl.Button );
GnxEditor_PlayerHelper.Controls.Button.MediaScreenChangeButton.prototype.OnPostBack = function ( evt ) {

	if ( !System.Util.IsNull( this.m_form.Controls.g_MediaPlayer.GetReadyState() ) )
		this.m_form.Controls.g_MediaPlayer.FullScreen( true );
};

GnxEditor_PlayerHelper.Controls.Button.MediaScreenChangeButton.prototype.OnMouseOver = function ( evt ) {

	this.SetAttribute( { src:"http://s.nx.com/S2/Movie_Tool/image/button/bt_full_on.gif" } );
};

GnxEditor_PlayerHelper.Controls.Button.MediaScreenChangeButton.prototype.OnMouseOut = function ( evt ) {

	this.SetAttribute( { src:"http://s.nx.com/S2/Movie_Tool/image/button/bt_full.gif" } );
};

// @Namespace : GnxEditor_PlayerHelper.Controls.Button.MediaMuteButton
GnxEditor_PlayerHelper.Controls.Button.MediaMuteButton = System.Extend( System.Classes.HtmlControl.Button );
GnxEditor_PlayerHelper.Controls.Button.MediaMuteButton.prototype.OnPostBack = function ( evt ) {

	if ( !System.Util.IsNull( this.m_form.Controls.g_MediaPlayer.GetReadyState() ) )
	{
		if ( this.m_form.Controls.g_MediaPlayer.Mute() )
		{
			this.SetAttribute( { src:"http://s.nx.com/S2/Portal/Nexon/Movie_Tool2/image/ico_sound.gif" } );
			
			this.m_form.Controls.g_MediaPlayer.Mute( false );
			this.m_form.Controls.g_imgVolControler.ChangedPosition();
		}
		else
		{
			this.SetAttribute( { src:"http://s.nx.com/S2/Portal/Nexon/Movie_Tool2/image/ico_sound_off.gif" } );
			
			this.m_form.Controls.g_MediaPlayer.Mute( true );
			this.m_form.Controls.g_imgVolControler.ResetPosition();	
		}
	}
};

// @Namespace : GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton
GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton = System.Extend( System.Classes.HtmlControl.Button );
GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton.prototype.m_oldPixel = 0;
GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton.prototype.m_oldPosition = 0;
GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton.prototype.m_isDragStart = false;

GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton.prototype.isEnableMouseUpEvent = false;
GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton.prototype.isEnableMouseMoveEvent = false;

GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton.prototype.Initialize = function () {
	
	this.ResetPosition();
	
	this.m_form.Controls.g_MediaPlayer.AddEventListener 
	(
		{
			type:GnxEditor_PlayerHelper.Properties.Media.Playing,
			delegator:{
				sender:this,
				method:this.ChangedPosition
			}
		}
	);
	
	this.m_form.Controls.g_MediaPlayer.AddEventListener 
	(
		{
			type:GnxEditor_PlayerHelper.Properties.Media.Ready,
			delegator:{
				sender:this,
				method:this.ResetPosition
			}
		}
	);
	
	this.m_form.Controls.g_MediaPlayer.AddEventListener 
	(
		{
			type:GnxEditor_PlayerHelper.Properties.Media.Stopped,
			delegator:{
				sender:this,
				method:this.ResetPosition
			}
		}
	);
};

GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton.prototype.ResetPosition = function () {

	this.SetStyleSheet( { pixelLeft:0 } );
	
	if ( !System.Util.IsUndefined( this.m_form.Controls.g_imgTrackProgressBar ) )
		this.m_form.Controls.g_imgTrackProgressBar.SetStyleSheet( { pixelWidth:0 } );
	
	this.m_form.Controls.g_MediaPlayer.Visible( false );
	this.m_form.Controls.g_dvMediaMaskLayer.Visible( true );
};

GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton.prototype.ChangedPosition = function () {
	
	if ( !this.m_isDragStart )
	{	
		var _position	= this.m_form.Controls.g_MediaPlayer.GetPosition();
		var _duration	= this.m_form.Controls.g_MediaPlayer.GetDuration();
		var _track		= this.m_form.Controls.g_dvTrackContainer.style.pixelWidth;
		var _width		= this.style.pixelWidth;
		var _xpos		= ( _position * ( _track - _width ) ) / _duration;
		
		this.SetStyleSheet( { pixelLeft : _xpos } );
		
		if ( !System.Util.IsUndefined( this.m_form.Controls.g_imgTrackProgressBar ) )
			this.m_form.Controls.g_imgTrackProgressBar.SetStyleSheet( { pixelWidth : _xpos } );
	} 
};

GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton.prototype.OnMouseDown = function ( evt ) {

	if ( !System.Util.IsNull( this.m_form.Controls.g_MediaPlayer.GetReadyState() ) )
	{
		this.m_isDragStart	= true;
		this.m_oldPosition	= evt.clientX;
		this.m_oldPixel 	= this.style.pixelLeft;
		
		this.isEnableMouseUpEvent = true;
		this.isEnableMouseMoveEvent = true;
		
		this.m_form.Controls.g_MediaPlayer.Pause();
	}	
};

GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton.prototype.OnMouseUp = function ( evt ) {

	var _position	= this.m_form.Controls.g_MediaPlayer.GetPosition();
	var _duration	= this.m_form.Controls.g_MediaPlayer.GetDuration();
	var _track		= this.m_form.Controls.g_dvTrackContainer.style.pixelWidth;
	var _width		= this.style.pixelWidth;
	var _left		= this.style.pixelLeft;
	var _xpos		= _left * _duration / ( _track - _width );
	
	this.m_form.Controls.g_MediaPlayer.SetPosition( _xpos );
	this.m_form.Controls.g_MediaPlayer.Play();
	
	this.m_isDragStart	= false;
	this.m_oldPosition	= 0;
	this.m_oldPixel 	= 0;
	
	this.isEnableMouseUpEvent	= false;
	this.isEnableMouseMoveEvent = false;
};

GnxEditor_PlayerHelper.Controls.Button.MediaTrackControlerButton.prototype.OnMouseMove = function ( evt ) {

	var _track		= this.m_form.Controls.g_dvTrackContainer.style.pixelWidth;
	var _width		= this.style.pixelWidth;
	var _xpos		= this.m_oldPixel + ( evt.clientX - this.m_oldPosition );
	
	if ( _xpos > 0 && ( _track - _width ) >= _xpos )
	{
		this.SetStyleSheet( { pixelLeft : _xpos } );
	
		if ( !System.Util.IsUndefined( this.m_form.Controls.g_imgTrackProgressBar ) )
			this.m_form.Controls.g_imgTrackProgressBar.SetStyleSheet( { pixelWidth : _xpos } );
	}
};

// @Namespace : GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton
GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton = System.Extend( System.Classes.HtmlControl.Button );
GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton.prototype.m_oldPixel = 0;
GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton.prototype.m_oldPosition = 0;
GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton.prototype.m_isDragStart = false;

GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton.prototype.isEnableMouseUpEvent = false;
GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton.prototype.isEnableMouseMoveEvent = false;

GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton.prototype.Initialize = function () {
	
	this.ResetPosition();
	
	this.m_form.Controls.g_MediaPlayer.AddEventListener 
	(
		{
			type:GnxEditor_PlayerHelper.Properties.Media.Play,
			delegator:{
				sender:this,
				method:this.ChangedPosition
			}
		}
	);
	
	this.m_form.Controls.g_MediaPlayer.AddEventListener 
	(
		{
			type:GnxEditor_PlayerHelper.Properties.Media.Ready,
			delegator:{
				sender:this,
				method:this.ResetPosition
			}
		}
	);
	
	this.m_form.Controls.g_MediaPlayer.AddEventListener 
	(
		{
			type:GnxEditor_PlayerHelper.Properties.Media.Stopped,
			delegator:{
				sender:this,
				method:this.ResetPosition
			}
		}
	);
};

GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton.prototype.ResetPosition = function () {

	this.SetStyleSheet( { pixelLeft:0 } );
	
	if ( !System.Util.IsUndefined( this.m_form.Controls.g_imgVolProgressBar ) )
		this.m_form.Controls.g_imgVolProgressBar.SetStyleSheet( { pixelWidth:0 } );
};

GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton.prototype.ChangedPosition = function () {
	
	if ( !this.m_isDragStart )
	{	
		var _volume		= this.m_form.Controls.g_dvVolumeContainer.style.pixelWidth;
		var _vol		= this.m_form.Controls.g_MediaPlayer.GetVolume();
		var _width		= this.style.pixelWidth;
		var _xpos		= Math.ceil( ( _vol / 100 ) * ( _volume - _width ) );
		
		this.SetStyleSheet( { pixelLeft : _xpos } );
		
		if ( !System.Util.IsUndefined( this.m_form.Controls.g_imgVolProgressBar ) )
			this.m_form.Controls.g_imgVolProgressBar.SetStyleSheet( { pixelWidth:_xpos } );
	}
};

GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton.prototype.OnMouseDown = function ( evt ) {

	if ( !System.Util.IsNull( this.m_form.Controls.g_MediaPlayer.GetReadyState() ) )
	{
		this.m_isDragStart	= true;
		this.m_oldPosition	= evt.clientX;
		this.m_oldPixel 	= this.style.pixelLeft;
		
		this.isEnableMouseUpEvent	= true;
		this.isEnableMouseMoveEvent = true;
	}	
};

GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton.prototype.OnMouseUp = function ( evt ) {
	
	var _volume		= this.m_form.Controls.g_dvVolumeContainer.style.pixelWidth;
	var _width		= this.style.pixelWidth;
	var _left		= this.style.pixelLeft;
	var _vol		= Math.ceil( ( _left * 100 ) / ( _volume - _width ) );
	
	this.m_form.Controls.g_MediaPlayer.SetVolume( _vol );
	
	this.m_isDragStart	= false;
	this.m_oldPosition	= 0;
	this.m_oldPixel 	= 0;
	
	this.isEnableMouseUpEvent	= false;
	this.isEnableMouseMoveEvent = false;
};

GnxEditor_PlayerHelper.Controls.Button.MediaVolumeControlerButton.prototype.OnMouseMove = function ( evt ) {

	var _volume		= this.m_form.Controls.g_dvVolumeContainer.style.pixelWidth;
	var _width		= this.style.pixelWidth;
	var _xpos		= this.m_oldPixel + ( evt.clientX - this.m_oldPosition );
	
	if ( _xpos > 0 && ( _volume - _width ) >= _xpos )
	{
		this.SetStyleSheet( { pixelLeft : _xpos } );
		
		if ( !System.Util.IsUndefined( this.m_form.Controls.g_imgVolProgressBar ) )
			this.m_form.Controls.g_imgVolProgressBar.SetStyleSheet( { pixelWidth:_xpos } );
	}
};

