Array.prototype.Append = function( item )
{
	this[this.length] = item;
}

function Stat( liDepth, sName, dtStart, dtEnd, ticks )
{
	this.Depth = liDepth;
	this.Name = sName;
	this.Start = dtStart;
	this.End = dtEnd;
	
	this.Ticks = ticks;
}

Stat.prototype.ToString = function()
{		
	//return this.Name + ': ' + this.Start + ' - ' + this.End ;
	return this.Name + ': ' + this.Ticks;
}

var gStats = new Array();

function ShowStats()
{
	var statsDiv = document.getElementById( 'statsDiv' );
	
	if ( !statsDiv )
	{
		statsDiv = document.createElement('div');
		statsDiv.setAttribute('id','statsDiv');
		statsDiv.style.display = 'block';
		statsDiv.style.top = '0px';
		statsDiv.style.left = '0px';
		statsDiv.style.width = '500px';
		statsDiv.style.height = '200px';
		statsDiv.style.backgroundColor = 'white';
		statsDiv.style.position = 'absolute';
		statsDiv.style.overflow = 'auto';
		statsDiv.style.textAlign ='left';
		statsDiv.style.padding = '5';
		statsDiv.style.border = '1px solid black';
		
		for( var i=0; i< gStats.length ; i++ )
		{
			var p = document.createElement('p');
			p.style.marginLeft = gStats[i].Depth*5 + 'px';
			p.innerText = gStats[i].ToString();
			statsDiv.appendChild(p);
		}

		document.body.appendChild(statsDiv);
	}
	else
	{
		document.body.removeChild( statsDiv );
	}

}

function keyCheck(e)
{
	var keyID = (window.event) ? event.keyCode : e.keyCode;
	var ctrlKey = (window.event) ? event.ctrlKey : e.ctrlKey;
	var altKey = (window.event) ? event.altKey : e.altKey;

	if ( ctrlKey && altKey )
	{
	
		if(keyID == 69)  // Ctrl-Alt E
		{ 
			ShowStats();
		}
	}
}


addEvent(document, 'keydown', keyCheck, false);

