/*

	Class: VIEWZI.debug

	The Viewzi debug class is for firing events in the live environment to study and track how the
	backend systems are getting and returning data, data performance, and general debugging.
	

*/

	VIEWZI.debug.msgLog		= [];
	VIEWZI.debug.module		= "DEBUG";
	VIEWZI.debug.live		= false;

//
// quick ref to a layer by id
//	

	VIEWZI.debug.init	= function()
	{
		if (!window.console) {
			window.console = {};
			window.console.log = function(x){};
		}
	};
	
	function airdebug() {
		alert(document.body.innerHTML);
	}
		
/*
	Function: VIEWZI.debug.trace

		Event Listener function for throwing messags into the live debug stack.

		Firing a Custom Event for debug tracing will add that message to the stack. The event
		will be passed an Object with the following properties: module, msg. Module is the calling
		Class or Object module by name. Msg is the string you wish to add to the stack.

	Parameters:

		type	 	- the event type that was executed.
		evt			- the data result of the call event

	Returns:

		Null
*/

	VIEWZI.debug.trace	= function(type, evt)
	{	
		if (VIEWZI.debug.live) VIEWZI.debug.liveLog(evt[0].module, evt[0].msg);
		VIEWZI.debug.msgLog.push(evt[0]);
	};
	
/*
	Function: VIEWZI.debug.showDebug

		Display the results of the current debug stack out to the console.

	Returns:

		Null
*/

	VIEWZI.debug.showDebug = function()
	{
		var aLen	= VIEWZI.debug.msgLog.length;
		for (var x=0; x<aLen; x++) {
			VIEWZI.debug.liveLog(VIEWZI.debug.msgLog[x].module, VIEWZI.debug.msgLog[x].msg);
		}
	};
	
/*
	Function: VIEWZI.debug.liveLog

		Shortcut method to throw the messages into the console.

	Parameters:

		mod	 		- the calling module or object name
		msg			- the message to be displayed

	Returns:

		Null
*/

	VIEWZI.debug.liveLog = function (mod, msg)
	{
		console.log("[VIEWZI-"+mod.toUpperCase()+"] " + msg);
	};
	
	VIEWZI.debug.init();
	VIEWZI.trace.subscribe(VIEWZI.debug.trace,VIEWZI.debug);
	VIEWZI.trace.fire({module:"DEBUG",msg:"version number : " + VIEWZI.version});