
var anzahl_offene_debug_tabs = 0;



// anzeigen/verbergen eines DIVs:
function show_debug_section(div_name, show)
{
	if(show) $("#"+div_name).slideDown('fast');
	else $("#"+div_name).slideUp('fast');
}


// Liefert DOM-Objekt... 
function get_div_object(div_name)
{
	if(document.all)
	{
		return eval("document.all." + div_name);
	} 
	else if (document.getElementById)
	{
		return document.getElementById(div_name);
	}
	return false;
}



// Bei Klick oeffnen oder schliessen,
// Wenn alle geschlossen -> einfahren...
// sonst ausfahren
function toggle_show_debug (div_name)
{
	output_div	= get_div_object(div_name);
		
	if (output_div.style.display == 'none') 
	{
		/// OEFFNEN:
		if(anzahl_offene_debug_tabs < 1)
		{
			$("#dbg").animate( { left: 1 } , 'fast', function(){
				$("#dbg").fadeTo(500, 1.0);
				$("#"+div_name).slideDown( 'fast' );			
			});
		}
		else
		{
			$("#"+div_name).slideDown( 'fast' );
		}
		$(".dbg_head").removeClass('tiplink');
		anzahl_offene_debug_tabs += 1;
	}
	else
	{
		/// SCHLIESSEN:
		if(anzahl_offene_debug_tabs == 1)
		{
			$("#dbg").fadeTo(500, 0.6);
			$("#"+div_name).slideUp( 'fast', function(){
				$(".dbg_head").addClass('tiplink');
				$("#dbg").animate( { left: -180 } , 'fast');			
			});
		}
		else
		{
			$("#"+div_name).slideUp( 'fast' );	
		}
		
		anzahl_offene_debug_tabs -= 1;
	}	
}


// alle oeffnen:
function dbg_open(begin_with) 
{
	begin_with --;
	$(".dbg_head").removeClass('tiplink');
	
	$("#dbg").animate( { left: 1 } , 'fast');
	anzahl_offene_debug_tabs ++;
	
	if (begin_with < 0) 
	{
		$("#dbg").fadeTo(500, 1.0);
		return;
	}
	
	if($("#dbg_"+begin_with).css('display') == 'none')
	{
		$("#dbg_"+begin_with).slideDown('fast', function () {
			dbg_open(begin_with);
		});
	}
	else
	{
		dbg_open(begin_with);
	}
}


// alle schliessen und Container einfahren:
function dbg_close(begin_with) 
{
	begin_with --;
	$(".dbg_head").addClass('tiplink');
	
	if (begin_with < 0) 
	{	
		anzahl_offene_debug_tabs = 0;
		$("#dbg").animate( { left: -180 } , 'fast');
		return;
	}
	
	if($("#dbg_"+begin_with).css('display') != 'none')
	{
		$("#dbg").fadeTo(500, 0.6);
		$("#dbg_"+begin_with).slideUp('fast', function () {
			dbg_close(begin_with);
		});
	}
	else
	{
		dbg_close(begin_with);
	}
}


var y_delta = 84;

function vertical_pos()
{
	return; // Daten passen nicht auf den Monitor
	new_y_pos = $(window).scrollTop();
	if(new_y_pos == 0) new_y_pos = y_delta;
	$("#dbg").animate( { top:new_y_pos }, 'fast');	
	window.setTimeout("vertical_pos()", 500);
}


if(self != top) { show_debug_section("dbg", 0); }






$("document").ready(function()
{
	$(".head:first", $("#dbg")).css('border-top', '1px solid #333');
	
	$(".head", $("#dbg")).click( function()
	{
		output_div = $(this).next(".output").attr('id');
		toggle_show_debug (output_div);
	})
		
	$("div.head", "#dbg").hover( 
		function(){ $(this).animate({ left: 0 } , 'fast'); }, 
		function(){ $(this).animate({ left: -180 } , 'fast'); }
	);
	
	vertical_pos();
	window.setTimeout('$("#dbg").fadeTo(200, 0.6)', 1000);
	
});


