function display_array( array )
{
	var str = "";
	var oszlop = 1;
	for( i in array )
	{
		if( oszlop == 2 ) 
		{
			oszlop = 1;
			str +="\n";
		}
		if( typeof( array[ i ] ) != "function" )
		{
			str += "[ " + i + " ] => " + array[ i ] + "\t\t";
			oszlop++;
		}
	}
/*
	alert( "win"  );
	var win = window.open( "_new" );
	win.document.open();
	win.document.write( str );
	win.document.close();
*/
	alert( str );
		
}

function arraytoString( array, str )
{
	for( i in array )
	{
		if( array[ i ] instanceof Array )
		{
			str += "[ " + i + " ] => {\n" + arraytoString( array[ i ], '' ) + "}\n";
		} else
		if( typeof( array[ i ] ) == 'object'  )
		{
//			str += "[ " + i + " ] => {\n" + arraytoString( array[ i ], '' ) + "}\n";
			str += "[ " + i + " ] => object\n";
		} else
		{
			str += "[ " + i + " ] => " + array[ i ] + "\n";
		}
	}
	return str;
		
}

function display_arraykeys( array )
{
	var str = "";
	for( i in array )
		str += "[ " + i + " ]\t\t";
	alert( str );
		
}

function backtrace()
{
	var f = backtrace;
	var stack = "Stack trace:";
	while (f) {
	  stack += "\n" + f.name;
	  f = f.caller;
	}
	alert( stack );
}

var debugwin = {
	win: null,
	doc: null,
	aktiv: null,
	
	setupwin: function()
	{
		if( this.win == null )
		{
			this.win = window.open( "",	"_new",	"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=450,height=300" );
			this.win.document.open();
			this.win.document.write( "<b>Tag Information</b><div id=\"content\"></div>" );
			this.win.document.close();
			this.doc = this.win.document;
			this.content = this.win.document.getElementById( "content" );
		}
	},

	newSection: function( name )
	{
		this.aktiv.innerHTML += "<h4>" + name + "</h4>";
	},
	
	arrayTable: function( array, col, name )
	{
		if( name )
		{
			this.aktiv.innerHTML += "<span>" + name + "</span>";
		}
//		var array = $H( array );
		var ptable = Elem.create( 'table' );
		var icol = 0; 
		var tr = Elem.create( 'tr' );
		ptable.appendChild( tr );
		for( i in array )
		{
			var e = array[i];
			if( typeof( e ) == "function" || typeof( e ) == 'object' ) continue;
			if( i.toLowerCase() == "innerhtml" ||
				i.toLowerCase() == "outerhtml" ||
				i.toLowerCase() == "innertext" ||
				i.toLowerCase() == "outertext" )
				continue;

			if( icol == col )
			{
				var tr = Elem.create( 'tr' );
				ptable.appendChild( tr );
				icol = 0;
			}
			
			var td = Elem.create( 'td' );
			td.innerHTML = i.bold();
			tr.appendChild( td );
			
			var td = Elem.create( 'td' );
			td.innerHTML = e;
			tr.appendChild( td );
			icol++;
		};
//		alert( ptable.tagName );
		var ph = Elem.create( 'div' );
		ph.appendChild( ptable ); 
		this.aktiv.innerHTML += ph.innerHTML;
//		this.aktiv.appendchild( ptable );
	},
	
	show: function( obj )
	{
		if( typeof( obj ) != "object" )
			obj = this.doc.getElementById( obj );
		this.setupwin();
		var id = obj.id;
		var mdiv = this.doc.getElementById( id+"frame" );
		if( mdiv )
		{
//			mdiv.removeChild( mdiv.firstChild );
		} else
		{
			var mdiv = this.doc.createElement( "div" );
			mdiv.setAttribute( "id", id+"frame" );
			mdiv.setAttribute( "border", "1" );
			this.content.appendChild( mdiv );
			
		}
		
		var cdiv = this.doc.createElement( 'div' );
		cdiv.setAttribute( "id", id+"content" );
		mdiv.appendChild( cdiv );
		this.aktiv = cdiv;

		this.newSection( "Elem" );
		this.arrayTable( { tag: obj.tagName, id: obj.id });
		this.newSection( "Object" );
		this.arrayTable( obj, 4 );
		this.newSection( "Stílus" );
		this.arrayTable( obj.style, 4 );
	},
	
	attribChange: function()
	{
		alert( 'attribChange' );
	},
	
	msg: function( string )
	{
		this.setupwin();

		var mdiv = this.doc.getElementById( "msgframe" );
		if( mdiv )
		{
//			mdiv.removeChild( mdiv.firstChild );
		} else
		{
			var mdiv = this.doc.createElement( "div" );
			mdiv.setAttribute( "id", "msgframe" );
			mdiv.setAttribute( "border", "1" );
			this.content.appendChild( mdiv );
		}
		
		mdiv.innerText = string;
		
		
	}
};



