function jpxDebug ()
{
	
}

/**
 * Public vars
 */
jpxDebug.forceDebug             = false;
jpxDebug.debugLogContainerId    = 'jpxDebugLogContainer';
jpxDebug.debugLogContainerStyle = 'background-color: #fff; color: #000; border: 1px solid #EC0081; position: absolute; top: 0px; z-index: 10000; width: 400px; height: 300px; font-family: Courier New, Courier; font-size: 10px; overflow-y:scroll; padding: 5px;';
jpxDebug.debugLogHeadingId      = 'jpxDebugLogHeading';
/**
 * Firefox 3.6 has some issues with setting the background color. So "background-color: #EC0081;" has been removed from the style string.
 */
jpxDebug.debugLogHeadingStyle   = 'color: #fff; font-size: 10px; font-weight: bold; cursor: default; position: absolute; top: 0; padding: 3px 5px;';

/**
 * Private vars
 */
jpxDebug.msgNumber      = 0;
jpxDebug.isInitialized  = false;
jpxDebug.jpxDropDownVar = null;

jpxDebug.initialize = function ()
{
	if (!jpxDebug.isInitialized && !document.getElementById(jpxDebug.debugLogContainerId))
	{
		/**
		 * Create heading element.
		 */
		var heading_el = document.createElement('DIV');
		heading_el.id = jpxDebug.debugLogHeadingId;
		heading_el.appendChild(document.createTextNode('Debug Log'));
		document.getElementsByTagName('body')[0].appendChild(heading_el);
		
		/**
		 * Create container element
		 */
		var container_el = document.createElement('DIV');
		container_el.id = jpxDebug.debugLogContainerId;
		container_el.style.display = 'none';
		document.getElementsByTagName('body')[0].appendChild(container_el);
		
		/**
		 * Apply stylesheets
		 */
		jpxLib.addCssRule('#' + jpxDebug.debugLogContainerId, jpxDebug.debugLogContainerStyle);
		jpxLib.addCssRule('#' + jpxDebug.debugLogHeadingId, jpxDebug.debugLogHeadingStyle);
		
		/**
		 * Make all elements dynamic
		 */
		jpxDebug.jpxDropDownVar = new jpxDDDebug('jpxDebug.jpxDropDownVar', document.getElementById(jpxDebug.debugLogHeadingId), document.getElementById(jpxDebug.debugLogContainerId));
		
		return true;
	}
	else if (document.getElementById(jpxDebug.debugLogContainerId))
	{
		return true;
	}
	
	return false;
}

jpxDebug.allowDebug = function ()
{
	if ((typeof IS_DEV != "undefined" && IS_DEV) || jpxLib.getUrlParam('jpx_debug') == 'true' || jpxDebug.forceDebug)
	{
		return true;
	}
	else
	{
		return false;
	}
}

jpxDebug.debugMessage = function (strClass, strMethod, strAction)
{
	if (jpxDebug.allowDebug())
	{
		jpxDebug.msgNumber++;
		
		var debug_msg = jpxDebug.msgNumber + ". ";
		debug_msg += "[" + jpxDebug.getFormattedTime() + "] ";
		debug_msg += strClass + "::" + strMethod + " ";
		debug_msg += "--> " + strAction;
		
		if (window.console && window.console.debug)
		{
			window.console.debug(debug_msg);
		}
		
		if (jpxDebug.initialize())
		{
			var div_el = document.getElementById(jpxDebug.debugLogContainerId);
			div_el.innerHTML = debug_msg + "<br />" + div_el.innerHTML;
		}
	}
}

jpxDebug.getFormattedTime = function ()
{
	var current_time = new Date();
	var hour = String(current_time.getHours());
	if (hour.length == 1)
	{
		hour = "0" + hour;
	}
	
	var min = String(current_time.getMinutes());
	if (min.length == 1)
	{
		min = "0" + min;
	}
	
	var sec = String(current_time.getSeconds());
	if (sec.length == 1)
	{
		sec = "0" + sec;
	}
	
	var msec = String(current_time.getMilliseconds());
	if (msec.length == 1)
	{
		msec = "00" + msec;
	}
	else if (msec.length == 2)
	{
		msec = "0" + msec;
	}

	return hour + ":" + min + ":" + sec + "." + msec;
}

/**
 * The jpxDDDebug class for collapsing and expanding the debug log.
 */
function jpxDDDebug (in_name, in_heading, in_box)
{
	this.jpxDropDown(in_name, in_heading, in_box);
}
jpxDDDebug = jpxLib.objectInherit(jpxDDDebug, jpxDropDown);
jpxDDDebug.prototype.box_position = 4;
jpxDDDebug.prototype.use_toggle   = true;
jpxDDDebug.prototype.use_drag     = true;
jpxDDDebug.prototype.use_hover    = true;