	
	function uObject() {
		if(document.URL.match("jsdebug")) {
			this.debugLevel = 1;
			
		} else if(window.JSDebug) {
			this.debugLevel = 1;
			
		} else {
			this.debugLevel = 0;
		}
		
		this.__errorHistory		= [];
		this.__warningHistory	= [];
		this.__currentError		= '';
		this.__currentWarning	= '';
		
		return this;
    }
	
	uObject.prototype.Debug = function(level) {
		
		if(level != undefined) {
			this.debugLevel = level;
			if(level > 0) { this._uo_creaContainer(); }
		}
		
		if(this.debugLevel) { return this.debugLevel; }
		else { return 0; }
		
	}
	
	uObject.prototype._uo_posContainer = function() {
		var container = document.getElementById("usvx_debug_container");
		if(! container) {
			// alert("uObject: Imposible encontrar el container del debugger");
			return false;
		}
		var x; var y; var w; var h;  
		/// Saca aqui las coords porque en IE es diferente:
		// Estandares:
		 // alert(document.documentElement.scrollTop);
		 
		// Calcula la altura que sale el debugger:
		//var elTop = document.documentElement.scrollTop;	// Los pixeles escroleados
		//elTop = elTop + document.documentElement.clientHeight;		// El tamanio de la ventana
		// elTop = elTop - container.offsetHeight;	// El tamanio de la ventanita
		//elTop = elTop - 110;
		//elTop = elTop - 11;		// Unos px de margen;
		
		container.style.left = "11px";
		container.style.width = (document.documentElement.clientWidth - 32) + "px";
		//container.style.top = elTop + "px";
		// container.style.bottom = "11px";
		return true;
		
	}
	
	uObject.prototype._uo_creaContainer = function() {
		if(! document.getElementById("usvx_debug_container")) {
			var error_container = document.createElement("ul");
			error_container.style.margin = "0";
			error_container.style.padding = "0";
			error_container.id = "usvx_debug_container";
			error_container.style.border = "1px #999 solid";
			error_container.style.zIndex = "99";
			error_container.style.backgroundColor = "#eee";
			error_container.style.overflow = "auto";
			error_container.style.position = "fixed";
			error_container.style.height = "100px";
			error_container.style.bottom = "11px";
			
			error_container.style.left = "0";
			error_container.style.opacity = '0.75';
			
			if(document.body) { document.body.appendChild(error_container); }
			
			this._uo_posContainer();
			
			window.onresize = this._uo_posContainer;
		}
		
	}
	
	uObject.prototype.debuggerShow =  function(msg, type) {
		if(this.Debug())  { if(! document.getElementById("usvx_debug_container")) { this._uo_creaContainer(); } }
		if(type == undefined) {
			this.setInfo(msg);
			
		} else if(type == "error") {
			this.setError(msg);
			
		} else if(type == "warn") {
			this.setWarning(msg);
			
		} else if(type == "info"){
			this.setInfo(msg);
			
		}
	}
	
	uObject.prototype.addMsg = function(msg, color) {
		var container = document.getElementById("usvx_debug_container");
		var mensaje = document.createElement("li");
		mensaje.style.listStyle		= "none";
		// mensaje.style.color			= color;
		mensaje.style.color			= "black";
		mensaje.style.padding		= "3px";
		mensaje.style.fontSize		= "12px";
		mensaje.style.fontFamily	= "Andale Mono, Courier New";
		// mensaje.appendChild(document.createTextNode(arguments.callee.constructor.name  + " : " + msg));
		
		var sp = document.createElement("span");
		if(color == "blue")	{ sp.appendChild(document.createTextNode('[INFO] '));	}
		if(color == "#fc0")	{ sp.appendChild(document.createTextNode('[INFO] '));	}
		if(color == "red")	{ sp.appendChild(document.createTextNode('[ERROR] '));	}
		sp.style.color = color;
		mensaje.appendChild(sp);
		
		if(this.constructor.name) {
			var sp2 = document.createElement("span");
			sp2.appendChild(document.createTextNode(this.constructor.name+": "));
			sp2.style.color = "#666";
			mensaje.appendChild(sp2);
		}
		
		mensaje.appendChild(document.createTextNode(msg));
		container.appendChild(mensaje);
	}
	
	uObject.prototype.Warning = function() {
		//#uDOC:TITLE Error
		//#uDOC:DESCR Regresa la ultima wrning que paso en el objeto
		
		return this.__currentWarning;
		
	}
	
	uObject.prototype.Error = function() {
		//#uDOC:TITLE Error
		//#uDOC:DESCR Regresa el ultimo error de la historia del uobject
		
		return this.__currentError;
		
	}
	
	uObject.prototype.setError = function(msg) {
		//#uDOC:TITLE setError
		//#uDOC:DESCR Registra un error y registralo en la historia, mostrando en el debugger, si si
		
		// Fija el error en el objeto:
		this.__currentError = msg;
		
		// Mete el error en la historia
		// alert(this.__errorHistory);
		this.__errorHistory.unshift(msg);
		if(this.__errorHistory.length > 15) { this.__errorHistory.length = 15; } /// No se si esto jale brous
		
		// Checa si hay que mostrarlo en la ventana de debug:
		if(this.Debug())  {
			if(! document.getElementById("usvx_debug_container")) { this._uo_creaContainer(); }
			this.addMsg(msg, "red");
		} 
		return false;		
	}

	uObject.prototype.setInfo = function(msg) {
		if(this.Debug())  {
			if(! document.getElementById("usvx_debug_container")) { this._uo_creaContainer(); }
			this.addMsg(msg, "blue");
		}
	}

	uObject.prototype.setWarning = function(msg) {
		//#uDOC:TITLE setWarning
		//#uDOC:DESCR Regresa la ultima warning que sostuvo el objeto
		
		// Fija la warning en el objeto
		this.__currentWarning = msg;
		
		// Mete la warning en la historia:
		this.__warningHistory.unshift(msg);
		if(this.__warningHistory.length > 15) { this.__warningHistory.length = 15; }
		
		// Checa si tenemos que sacar el mensaje o no:
		if(this.Debug())  { if(! document.getElementById("usvx_debug_container")) { this._uo_creaContainer(); } }
		if(this.Debug()) { this.addMsg(msg, "#FC0"); }
		
		return false;
		   
	}
	
	
	

