var actTab = "1";
var now = new Date();
var day = now.getDay();
var ruhetag = 0;

function showDiv(con)
{
	if ( document.getElementById("con" + actTab) )
		Element.hide("con" + actTab);
	
	if ( document.getElementById("nav" + actTab) )
		document.getElementById("nav" + actTab).style.color = "#D02424";

	if ( document.getElementById("con" + con) )
	{
		if (con == 1 && day == ruhetag)
			new Effect.Appear("ruhetag");
		else if (con != 1 && day == ruhetag)
		{
			Element.hide("ruhetag");
			new Effect.Appear("con" + con);
		}
		else
			new Effect.Appear("con" + con);
	}
		
	if ( document.getElementById("nav" + con) )
		document.getElementById("nav" + con).style.color = "#FECB65"; //E5B28D";

	actTab = con;
}

function hideDiv(con)
{
	if ( document.getElementById("con" + con) )
		Element.hide("con" + con);
		
	if ( document.getElementById("nav" + con) )
		document.getElementById("nav" + con).style.color = "#D02424";
}

function setContentHeight()
{
	if (screen.width == "800")
	{
		document.getElementById("content").style.height = "130px !important";
		document.getElementById("poster").style.height = "70px";
		document.getElementById("content").style.minHeight = "50px !important";
		document.getElementById("poster").style.background = "#000";
		document.getElementById("rightSection").style.display = "none";
	}
}

function appearAll()
{
	showDiv('1');
	new Effect.Appear('mains');
	window.setTimeout("new Effect.Appear('poster')", 200);
	document.getElementById('content').style.display='block';
	window.setTimeout("new Effect.Appear('nav1')", 400);
	
	if ( day != ruhetag )
	{
		window.setTimeout("new Effect.Appear('nav2')", 600);
		window.setTimeout("new Effect.Appear('nav3')", 800);
		window.setTimeout("new Effect.Appear('nav4')", 1000);
		window.setTimeout("new Effect.Appear('nav5')", 1400);
		window.setTimeout("new Effect.Appear('nav6')", 1500);
		window.setTimeout("new Effect.Appear('content')", 1600);
	}
	else
	{
		document.getElementById('content').style.display='block';
		window.setTimeout("document.getElementById('con1').style.display='none';", 100);
		window.setTimeout("new Effect.Appear('ruhetag')", 600);
	}
	
	window.setTimeout("new Effect.Appear('logo')", 1200);
	window.setTimeout("new Effect.Appear('baum')", 1500);
}

// tageszeitabhaengiger hintergrund
function setBG()
{
	var jetzt = new Date();
	var h = jetzt.getHours();
	var m = jetzt.getMinutes();
	
	if (h > 5 && h < 12)
	{
		$("welcome").innerHTML = "Guten Morgen!";
		$("bgPic").style.backgroundImage = "url('pix/sun2.png')";
		new Effect.Move( $("bgPic"), { x:250, y:0, mode: 'relative', duration:8 } );
	}
	else if (h >= 12 && h < 19)
	{
		$("welcome").innerHTML = "Guten Tag!";
		$("bgPic").style.backgroundImage = "url('pix/sun2.png')";
		new Effect.Move( $("bgPic"), { x:250, y:0, mode: 'relative', duration:8 } );
	}
	else if (h >= 19 && h < 23)
	{
		$("welcome").innerHTML = "Guten Abend!";
		$("bgPic").style.backgroundImage = "url('pix/moon2.png')";
		new Effect.Move( $("bgPic"), { x:250, y:0, mode: 'relative', duration:8 } );
	}
	else
	{
		$("welcome").innerHTML = "Gute Nacht!";
		$("bgPic").style.backgroundImage = "url('pix/moon2.png')";
		new Effect.Move( $("bgPic"), { x:250, y:0, mode: 'relative', duration:8 } );
	}

	if (h >= 12)
	{
		h = 11-(h-12);
		m = 60-m;
	}
	
	dm = h*60 + m;
	dm = dm * 0.7;
	ratio = dm/10;
	str_ratio = ratio + "%";
	//var bod = document.getElementById("bod");
	//bod.style.backgroundColor = "rgb(" + str_ratio+ ", " + str_ratio + ", " + str_ratio + ")";
}

// begriffserkklaerung im unteren bereich (bottom) einblenden
function showText(text)
{
	window.setTimeout('document.getElementById("sonstiges").style.display="none";', 90);
	window.setTimeout('document.getElementById("bottom").style.backgroundColor = "#444";', 60);
	document.getElementById("begriffe").innerHTML = text;
	window.setTimeout('document.getElementById("begriffe").style.display="block"', 90);  
}

// begriffserklaerung ausblenden
function hideText()
{
	window.setTimeout('document.getElementById("begriffe").style.display="none";', 90);
	window.setTimeout('document.getElementById("bottom").style.backgroundColor = "#440000";', 60);
	window.setTimeout('document.getElementById("sonstiges").style.display="block"', 90);
}

window.onload = function() {
	setBG();
	//window.setInterval('setBG()', 60000);
	appearAll();
	window.setTimeout('setContentHeight()', 1);
	//$("nav1").onclick = function() { showDiv('1'); }
	
	/*
	var brows = navigator.appName;
	var version = navigator.appVersion;
	var codeName = navigator.appCodeName;
	//alert(brows + " | " + version + " | " + codeName);
	
	if ( version.search(/MSIE 6.0/)  != -1 )
	{
		$("ie6").className = "display";
	}
	*/
}

