function console_class(params) {
	if(typeof(params)!='undefined')
	{
		this._parent=(typeof(params['parent'])=='undefined')?document.body:params['parent'];
		this._flushmode=(typeof(params['flushmode'])=='undefined')?0:params['flushmode'];
		this._lineseparator=(typeof(params['lineseparator'])=='undefined')?'<br>':params['lineseparator'];
	}
	this._holder=false;
	this._stack=[];	
}
console_class.prototype={
	init:function ()
	{
		var hHolder=document.createElement('div');
		
		hHolder.setAttribute('style','height:200px; border:1px solid black; overflow:scroll; font-family:"Trebuchet MS", Tahoma; font-size:12px; padding:5px; margin:5px');		
		this._parent.insertBefore(hHolder,this._parent.firstChild);
		
		this._holder=hHolder;		
	},
	
	cls:function ()
	{
		this._holder.innerHTML='';
	},
	
	add:function(s)
	{
		this._stack[this._stack.length]=s;
		if(this._flushmode==0) this.flush();
	},
	
	flush: function()
	{
		if (!this._holder) this.init();
		this._stack.reverse();
		this._holder.innerHTML=this.prepareString(this._stack.join(''))+this._lineseparator+this._holder.innerHTML;
		this._stack=[];		
	},
	
	prepareString: function(s)
	{
		s=s.replace(/</gi,'&lt;');
		s=s.replace(/>/gi,'&gt;');
		s=s.replace(/\n/gi,'<br>');
		s=s.replace(/\t/gi,'&nbsp;&nbsp;&nbsp;&nbsp;');
		return s;
	}
}
