function TabAware(o)
{
	
	if(o === null) { return; }
	
	this._o = o;
	this._isTabLast = false;
	// for gecko:
	this._restoreFocusWithCaret = -1;
	this._lastCaretPosition = -1;
	
	this.onObjectKeyDown = function(event)
	{
		var keyCode = ((window.event) ? window.event.keyCode : event.which );
		this.handler._isTabLast = ( keyCode == 9 );
	}
	
	this.onObjectBlur = function(event)
	{
		if (this.handler._isTabLast)
		{
			this.handler._isTabLast = false;
			this.focus();
			if ( document.selection )
				document.selection.createRange().text = "\t";
			else
			{
				this.handler._lastCaretPosition = this.selectionEnd;
				this.handler._restoreFocusWithCaret = setTimeout(
					function (obj)
					{
						clearTimeout(obj.handler._restoreFocusWithCaret);
						obj.handler._restoreFocusWithCaret = -1;
						obj.focus();
						var o = document.getElementById("txt");
						var len = obj.selectionEnd;
						obj.value = obj.value.substr( 0, len ) + "\t" + obj.value.substr( len );
						obj.setSelectionRange(len+1,len+1);
					},
					10, this
				);
			}
		}
	}
	
	this._o.handler = this;
	if ( document.all )
	{
		this._o.onkeydown = this.onObjectKeyDown;
		this._o.onblur = this.onObjectBlur;
	}
	else
	{
		this._o.addEventListener("keydown", this.onObjectKeyDown, false);
		this._o.addEventListener("blur", this.onObjectBlur, false);
	}
}