
/***************************************************************
TRACING - This is a simple tracing/debugging mechanism used
to display and track information by any script on the site.

To enable tracing, simply call EnableTracing() from the onload 
event of the <body> tag. (e.g. <body onload='EnableTracing();'>...)

To disable tracing, call DisableTracing()
****************************************************************/
var trace;
function EnableTracing(){
	trace = new Tracing();
	trace.Enable();
	window.onerror = WriteEx;
}
function DisableTracing(){
	if(trace == null)
		return;
	trace.Disable();
}
function Write(msg){
	if(trace == null)
		return;
	trace.Write(msg);
}
function WriteEx(ex){
	if(trace == null)
		return false;
	trace.WriteEx(ex);
	return true;
}
function MinimizeWindow(){
	if(trace == null)
		return;
	trace.Minimize();
}
function Tracing(){
		var width = '100%';
		var max_height = '300px';
		var min_height = '25px'
		var right = '0px';
		var bottom = '0px';
		var bg = '#EEF';
		var zIndex = '10000000';
		var position = 'absolute';
		var id = 'edifice_tracer';
		var list;
		var div;
		function enable(){	
			list = document.createElement("select");
			list.id = id;
			list.style.bottom = bottom;
			list.style.right = right;
			list.style.position = position;			
			list.style.width = width;
			list.style.height = min_height;	
			list.multiple = "true";
			list.style.borderStyle = 'solid';
			list.style.borderWidth = '1px';
			list.style.borderColor = 'black';
			list.style.zindex = zIndex;
			list.style.backgroundColor = bg;
			list.onmouseover = Expand;
			list.onmouseout = Contract;
			list.onclick = function(){ alert(list.options[list.selectedIndex].text); }
			document.body.appendChild(list);
			window.onerror = writeEx;
		}
		function Expand(){
			list.style.height = max_height;
		}
		function Contract(){
			list.style.height = min_height;
		}
		function write(msg){
			var o = new Option();
			o.text = msg;
			o.value = msg;
			list.options.add(o);
			Expand();
			window.setTimeout("MinimizeWindow();",500);
		}
		function writeEx(ex){
			var o = new Option();
			o.text = 'ERROR: '+ex;
			list.options.add(o);
			Expand();
			window.setTimeout("MinimizeWindow();",500);
		}

		function disable(){
			document.body.removeChild(list);
			list = null;
		}
		this.Enable = enable;
		this.Disable = disable;
		this.Write = write;
		this.WriteEx = writeEx;
		this.Minimize = Contract;
}