/**
 * GSI.Debug
 * @author bradleyc
 * @projectDescription
 * Methods for debugging javascript code
 */
	GSI.NameSpace.create("GSI.Debug");

/**
 * MessageTypes to use for writing debug information
 * @type {Object}
 */
	GSI.Debug.MessageType = {
		ERROR: "GSI_Debug_Error",
		MESSAGE: "GSI_Debug_Message",
		WARNING: "GSI_Debug_Warning"
	}

/**
 * The debug container element
 * @type {Element}
 */	
	GSI.Debug.container = undefined;
	
/**
 * Create a debug container
 * @param {String,False}	[elementId]	Optional ID for the element being created or false for default
 * @param {String,False}	[cssClass]	Optional CSS Classname for the element being created or false for default
 * @return {Element} The element to contain debug code
 */
	GSI.Debug.element = function( elementId, cssClass )
	{
		if( this.container === undefined ) {
			this.container = GSI.$e("div","GSI.Debug.container", "GSI_Debug", false, document.body );
		}
		return this.container;
	}

/**
 * Clear the debug console
 */
	GSI.Debug.cls = function()
	{
		this.element().innerHTML = "";
	}
	
/**
 * Write a message to the debug console
 * @param {String}	val	A String message to send to the trace div
 * @param {GSI.Debug.MessageType}	[messageType]	The type of message to write. Default = MESSAGE 
 */
	GSI.Debug.writeLine = function( val, messageType )
	{
		if( val === undefined ) return;
		messageType = ( messageType === undefined ) ? this.MessageType.MESSAGE: messageType;
		if( messageType == this.MessageType.ERROR )
		{
			val += "<br><em>" + ( arguments.caller || "Can not find calling function" ) + "</em>";
		}
		GSI.$e( "div", false, messageType, val, this.element() );
	}

/**
 * Trace an object to the debug console
 * @param {Object} obj	An Object to output to the trace console
 */
	GSI.Debug.traceObject = function( obj )
	{
		for( var i in obj )
		{
			GSI.$e("div", false, "GSI_Debug_Object", false, this.element(), [
				GSI.$e("span", false, "GSI_Debug_Object_Name", i + "&nbsp;"),
				GSI.$e("span", false, "GSI_Debug_Object_Type", "{" + typeof(obj[i]) + "}&nbsp;=&nbsp;"),
				GSI.$e("span", false, "GSI_Debug_Object_Value", obj[i])
			]);			
		}
	}
