var Debug = false;

var Debugger = function()
{
	// line number
	this.line = 0;
	
	// create a new element
	this.div =  document.createElement('div');
	
	// set the style
	this.div.style.cssFloat = 'left';
	this.div.style.position = 'fixed';
	this.div.style.height = '200px';
	this.div.style.overflow = 'auto';
	this.div.style.top = 0;
	this.div.style.left = 0;
	this.div.style.background = '#fff';
	this.div.style.width = '100%';
	this.div.style.padding = '5px 0';
	this.div.style.fontWeight = 'bold';
	this.div.style.fontSize = '12px';
	this.div.style.borderBottom = '2px solid #ccc';
	this.div.style.zIndex = 15000;
	
	// give it an id
	this.div.id = 'debugConsole';
	
	// for IE to be fixed
	if(navigator.appVersion.indexOf('MSIE 6.0') != -1)
	{
		this.div.style.position = 'absolute';
		window.onscroll = function()
		{
			Debug.div.style.top = document.documentElement.scrollTop + 'px';
		}
	}
	
	// display it
	document.body.appendChild(this.div);
};

Debugger.prototype = {
	// show a text
	log: function(text)
	{
		this.line++;
		this.div.innerHTML += '<span style="color: red;">' + this.line + '</span> ' + text + '<br />';
		this.div.scrollTop = this.div.scrollHeight;
	},
	
	// clear the text in its
	reset: function()
	{
		this.line = 0;
		this.div.innerHTML = '';
	}
};

function log(text)
{
	if(!Debug)
	{
		Debug = new Debugger();
	}
	Debug.log(text);
}

function newLog(text)
{
	if(!Debug)
	{
		Debug = new Debugger();
	}
	Debug.reset();
	Debug.log(text);
}