

function DebugLog( parentElement ) {

	this.construct = function( parentElement )
	{
		if( parentElement != null ) {
			this._log = new Array();
			this._pElement = parentElement;
			$(parentElement).css( 'overflow-y', 'auto' );
			$(parentElement).css( 'overflow-x', 'hidden' );		
		}
	}


	this._on = true;
	this._log = null;
	this._indent = 0;
	this._pElement = null;
	this._line = 0;


	this.indent = function()
	{
		this._indent++;
	}

	this.undent = function()
	{
		if( this._pElement != null ) {
			if( this._indent > 0 ) this._indent--;
		}
	}

	this.message = function( objId, fn, text, css )
	{
		if( this._pElement != null ) {
			if( this._on == true ) {
				if( !css ) css = 'message';
				if( !text ) text = '&nbsp;';
				if( !fn ) fn = '???';
				if( !objId ) objId = '???';

				this.write( '<div style="padding-left: ' + ( this._indent * 20 ) + 'px"><div class="debug-' + css + '">[' + this._line + '] <b>' + objId + '</b> - ' + fn + '(): ' + text + '</div></div>' );
			}
		}
	}

	this.write = function( str )
	{
		if( this._pElement != null ) {
			$(this._pElement).append( str );

			this._line++;
		}
	}

	this.on = function()
	{
		if( this._pElement != null ) {
			this._on = true;
		}
	}

	this.off = function()
	{
		if( this._pElement != null ) {
			this._on = false;
		}
	}

	this.construct( parentElement );
}
