(function(){
	// Si les namespaces/classes nécessaires ne sont pas chargées : exception
	if(!window.ev){throw new Error("Le namespace 'ev' doit exister");}
	// On s'assure que le namespace ev.me existe
	if(!ev.me){ ev.me={}; }
	//Si la classe ev.meh.ME1HDisplay est définie on sort
	if(ev.me.ErrorManager){return;}

	ev.me.ErrorManager = function() {
	
		if(arguments.callee.singletonInstance){
			// si le singleton a été instancié on le retourne directement.
			return arguments.callee.singletonInstance;
		}
		
		// sinon, definition de l'instance
		arguments.callee.singletonInstance=this;
		
		var array=new Array();
		
		this.add=function(_error){
			if(_error==undefined) throw new Error("error is undefined");
			if(_error==null) throw new Error("error is null");
			if(!(_error instanceof ev.me.Error)) throw new Error("error is not instance of ev.me.Error");
			array.push(_error);
	
			if(_error.getLevel() == ev.me.ErrorLevel.FATAL){//la recherche ne peut pas continuer, on fait part de l'erreur à l'internaute
				_error.print();
				throw new Error("ERREUR FATALE : " + " - " + _error.getMessageKey() + " - " + _error.getMessage());//on affiche une erreur
			}else{//le recherche peut quand même continuer, on peut avertir l'internaute qu'un problème mineur est survenu au cours de la recherche
				_error.print();
				throw new Error("ERREUR MINEUR : " + " - " + _error.getMessageKey() + " - " + _error.getMessage());//on affiche une erreur
			}
		
		}
		
		this.get=function(_index){
			if(_index>=array.length) return null;
			if(_index<0) return null;
			return array[_index];
		}
		
		this.clear=function() {
			array=new Array();
		}	
		
		this.getList=function() {
			return array;
		}
			
		return arguments.callee.singletonInstance;
	}
	
	// instanciation singleton
	new ev.me.ErrorManager();

})();