
// ---------------------------------------------------------------------- CEVENT

	oEvent = new CEvent ;					// Inicializo mis mates
	
	function CEvent(){
		
		this.vEvent = [] ;									// Array de Eventos		
		
		//------------------------------------------
		// METODOS
		//------------------------------------------


		// HAS EVENT
		//
		//-------------------------------------------------
		this.HasEvent = function HasEvent( sEvent , oFunction ){
			
			if( this.vEvent.hasOwnProperty( sEvent ) ){
				
				for( i = 0 ; i < this.vEvent[sEvent].length ; i++ ){
					
					if( this.vEvent[sEvent][i] == oFunction ) {
						
						return true ;
						
					}
					
				}
			}
			
			return false;
				
				
		}


		// HANDLE
		//
		//-------------------------------------------------
		this.Handle = function Handle( sEvent , oFunction ){
			
			//if( !this.HasEvent( sEvent , oFunction ) ){
				
				if( !this.vEvent.hasOwnProperty( sEvent ) ){
					
					this.vEvent[ sEvent ] = [] ;
					
				}
				
				this.vEvent[ sEvent ].push( oFunction ) ;
				
			//}
			
		}
		

		// UN HANDLE
		//
		//-------------------------------------------------
		this.UnHandle = function UnHandle( sEvent , oFunction ){
			
			if( this.vEvent.hasOwnProperty( sEvent ) ){
				
				for( i = 0 ; i < this.vEvent[sEvent].length ; i++ ){
					
					if( this.vEvent[sEvent][i] == oFunction ) {
						
						this.vEvent[sEvent].splice( i , 1 ) ;
						
						if( this.vEvent[sEvent].length == 0 ){
							
							delete this.vEvent[sEvent] ;
							
						}
						
						return ;
						
					}
					
				}
				
			}
			
		}


		//UN HANDLE ALL
		//
		//-------------------------------------------------
		this.UnHandleAll = function UnHandleAll( sEvent ){
			
			if( this.vEvent.hasOwnProperty(sEvent) ){
				delete this.vEvent[sEvent] ;
			}
			
		}



		// THROW
		// Lanza un evento - ( Ejecuta todas las funciones asociadas )
		//-------------------------------------------------
		this.Throw = function Throw( sEvent ){
			//alert("Throwing Event: " + sEvent );
			if ( this.vEvent.hasOwnProperty(sEvent) ){

				for( i = 0 ; i < this.vEvent[sEvent].length ; i++ ){
					
					this.vEvent[sEvent][i]() ;
					
				}
				
			}
			
		}



	}
