/* MAIN */

window.onload = divload;

function divload()
{
	var body 					= 	document.getElementsByTagName('body');
	var rahmen 					= 	document.getElementById('rahmen');
	var banner 					= 	document.getElementById('banner');
	
	var home 					= 	document.getElementById('home');
	var strom	 				= 	document.getElementById('strom');
	var erdgas	 				= 	document.getElementById('erdgas');
	var wasser	 				= 	document.getElementById('wasser');
	var waerme	 				= 	document.getElementById('waerme');
	
	var navi	 				= 	document.getElementById('navi');
	var bluenavi 				= 	document.getElementById('bluenavi');
	var bluenavinavi			= 	document.getElementById('bluenavi_navi');
	var logo	 				= 	document.getElementById('logo');
	
	var service 				= 	document.getElementById('service').firstChild;
	var foerderprogramme 		= 	document.getElementById('foerderprogramme').firstChild;
	var netze 					= 	document.getElementById('netze').firstChild;
	
	var serviceauf 				= 	document.getElementById('serviceauf');
	var foerderprogrammeauf 	= 	document.getElementById('foerderprogrammeauf');
	var netzeauf 				= 	document.getElementById('netzeauf');

	var servicecheck			= 	document.getElementById("navilist").getElementsByTagName("ul").firstChild;
	
	var newsaktuell 			= 	document.getElementById("newsaktuell");
	var content 				= 	document.getElementById("content");
	
	var neuigkeiten				=	document.getElementById("neuigkeiten");
	
	var strombtn			 	= 	document.getElementById('strombtn');
	var erdgasbtn 				= 	document.getElementById('erdgasbtn');
	var wasserbtn 				= 	document.getElementById('wasserbtn');
	var waermebtn 				= 	document.getElementById('waermebtn');
	
	var open 					=	"null";
		
	var downloadaufdiv			= 	document.getElementById('downloadauf');
	var downloadzu				= 	document.getElementById('downloadzu');
	
	// var newsbanner				= 	document.getElementById('newsbanner');
	
	
	
	var opacityTween = new OpacityTween(banner, Tween.regularEaseIn, 0, 100, 0.7);
	opacityTween.start();
	
	// ANIMATION NEWSBANNER - wieder hinzuf�gen, wenn newsbanner angezeigt werden soll
	
	//var opacityTween2 = new OpacityTween(newsbanner, Tween.regularEaseIn, 0, 100, 1.2);
	//opacityTween2.start();
		
	///// DECKRAFT ZU BEGINN AUF 30% SETZEN
	
	opacity(home);
	opacity(strom);
	opacity(erdgas);
	opacity(wasser);
	opacity(waerme);
				
	///// POSITION BLUENAVI BESTIMMEN
	
	bluenaviposition = bluenavi.offsetLeft;	
		
	home.onmouseover = function() {	new events(this.offsetLeft, this, bluenavi.offsetLeft, 50, 0.3, 0.3, bluenavi, 171, 212 ); bluenavinavi.innerHTML="<b>Home</b><ul><li id='neuigkeiten'><a href='index.php'>aktuell</a></li></ul>"; logo.style.left="-20px"; }
	strom.onmouseover = function() { new events(this.offsetLeft, this, bluenavi.offsetLeft, 50, 0, 0.3, bluenavi, 171, 171 ); bluenavinavi.innerHTML="<b>Strom</b><ul><li id='stromtarifrechner'><a href='index.php?ac=stromtarifrechner'>Preise/Tarifrechner</a></li><li id='stromtransparenz'><a href='index.php?ac=stromtransparenz'>Transparenz</a></li><li id='stromstrommix'><a href='index.php?ac=strommix'>Strommix</a></li><li id='stromavb'><a href='index.php?ac=energiespartipps'>Energiespartipps</a></li></ul>"; logo.style.left="-90px"; }
	erdgas.onmouseover = function() { new events(this.offsetLeft, this, bluenavi.offsetLeft, 50, 0, 0.3, bluenavi, 171, 171 ); bluenavinavi.innerHTML="<b>Erdgas</b><ul><li id='erdgastarifrechner'><a href='index.php?ac=erdgastarifrechner'>Preise/Tarifrechner</a></li><li id='bioerdgas'><a href='index.php?ac=bioerdgas'>BIO-Erdgas</a></li><li id='erdgastransparenz'><a href='index.php?ac=transparenz'>Transparenz</a></li><li id='erdgasavb'><a href='index.php?ac=energiespartipps'>Energiespartipps</a></li></ul>"; logo.style.left="-90px"; }
	wasser.onmouseover = function() { new events(this.offsetLeft, this, bluenavi.offsetLeft, 50, 0, 0.3, bluenavi, 171, 171 ); bluenavinavi.innerHTML="<b>Wasser</b><ul><li id='wassertarifrechner'><a href='index.php?ac=wassertarifrechner'>Preise/Tarifrechner</a></li><li id='wasserstrommix'><a href='index.php?ac=herkunft'>Herkunft &amp; Qualit&auml;t</a></li><li id='wasseravb'><a href='index.php?ac=energiespartipps'>Wasserspartipps</a></li></ul>"; logo.style.left="-90px"; }
	waerme.onmouseover = function() { new events(this.offsetLeft, this, bluenavi.offsetLeft, 50, 0, 0.3, bluenavi, 171, 171 ); bluenavinavi.innerHTML="<b>W&auml;rme</b>"; logo.style.left="-90px"; }
	
	// LEFT-NAVI ANIMATION
	
	var leftnavigation = new Array("service", "foerderprogramme", "netze");
		
	service.onclick = function() { aufklapp( service, 250, 270, serviceauf, foerderprogrammeauf, netzeauf, foerderprogramme, netze ); }
	foerderprogramme.onclick = function() { aufklapp( foerderprogramme, 60, 80, foerderprogrammeauf, serviceauf, netzeauf, service, netze ); } 
	netze.onclick = function() { aufklapp( netze, 20, 75, netzeauf, serviceauf, foerderprogrammeauf, service, foerderprogramme ); } 
		
	strombtn.onmouseover = function() { new eventsbtn(213, this, bluenavi.offsetLeft, 50, 20, 0.3, bluenavi, 171, 171 ); bluenavinavi.innerHTML="<b>Strom</b><ul><li id='stromtarifrechner'><a href='index.php?ac=stromtarifrechner'>Preise/Tarifrechner</a></li><li id='stromtransparenz'><a href='index.php?ac=stromtransparenz'>Transparenz</a></li><li><a href='index.php?ac=strommix'>Strommix</a></li><li id='stromavb'><a href='index.php?ac=energiespartipps'>Energiespartipps</a></li></ul>"; logo.style.left="-90px"; }//213 // 385
	erdgasbtn.onmouseover = function() { new eventsbtn(385, this, bluenavi.offsetLeft, 50, 20, 0.3, bluenavi, 171, 171 ); bluenavinavi.innerHTML="<b>Erdgas</b><ul><li id='erdgastarifrechner'><a href='index.php?ac=erdgastarifrechner'>Preise/Tarifrechner</a></li><li id='bioerdgas'><a href='index.php?ac=bioerdgas'>BIO-Erdgas</a></li><li id='erdgastransparenz'><a href='index.php?ac=transparenz'>Transparenz</a></li><li id='erdgasavb'><a href='index.php?ac=energiespartipps'>Energiespartipps</a></li></ul>"; logo.style.left="-90px"; } //385 // 557
	wasserbtn.onmouseover = function() { new eventsbtn(557, this, bluenavi.offsetLeft, 50, 20, 0.3, bluenavi, 171, 171 ); bluenavinavi.innerHTML="<b>Wasser</b><ul><li id='wassertarifrechner'><a href='index.php?ac=wassertarifrechner'>Preise/Tarifrechner</a></li><li id='wasserstrommix'><a href='index.php?ac=herkunft'>Herkunft &amp; Qualit&auml;t</a></li><li id='wasseravb'><a href='index.php?ac=energiespartipps'>Wasserspartipps</a></li></ul>"; logo.style.left="-90px"; } //557 // 729
	waermebtn.onmouseover = function() { new eventsbtn(729, this, bluenavi.offsetLeft, 50, 20, 0.3, bluenavi, 171, 171 ); bluenavinavi.innerHTML="<b>W&auml;rme</b>"; logo.style.left="-90px"; } //557 // 729
}


function rollover ( div )
{
	this.div = div;
}

// DECKKRAFT ZU BEGINN AUF 30% SETZEN

function opacity( div )
{
	div.style.opacity="0"; 	
}

// DEFINITION DER NAVIANIMATION

function events ( Position, div, bluenaviposition, opacitystart, opacityend, duration, bluenavi, widthstart, widthend )
{
	this.Position = Position;
	this.namen = div;
	this.bluenaviposition = bluenaviposition;
	this.opacitystart = opacitystart;
	this.opacityend= opacityend;
	this.duration= duration;
	
	var opacityTween = new OpacityTween(div,Tween.regularEaseIn, opacitystart, opacityend, duration);
	opacityTween.start();
	
	bluenaviposition = bluenavi.offsetLeft;
	
	if ( bluenavi.offsetLeft == 0 )
	{
		testi = new Tween(bluenavi.style,'width',Tween.strongEaseOut, widthstart, widthend, 0.5,'px');
		testi.start();
	}
	else
	{
		testi = new Tween(bluenavi.style,'width',Tween.strongEaseOut, widthstart, widthend, 0.5,'px');
		testi.start();
	}
	
	// testii = new Tween(bluenavi.style,'left',Tween.strongEaseOut, bluenaviposition, div.offsetLeft ,0.6,'px');
	// testii.start();
	
	new Effect.Move('bluenavi', { x: Position, y: 0, mode: 'absolute', duration: 0.3, queue: 'end', transition: Effect.Transitions.sinoidal });
	
}

// DEFINITION DER NAVIANIMATION F�R BTNS

function eventsbtn ( Position, div, bluenaviposition, opacitystart, opacityend, duration, bluenavi, widthstart, widthend )
{
	this.Position = Position;
	this.namen = div;
	this.bluenaviposition = bluenaviposition;
	this.opacitystart = opacitystart;
	this.opacityend= opacityend;
	this.duration= duration;

	bluenaviposition = bluenavi.offsetLeft;
	
	if ( bluenavi.offsetLeft == 0 )
	{
		testi = new Tween(bluenavi.style,'width',Tween.strongEaseOut, widthstart, widthend, 0.5,'px');
		testi.start();
	}
	else
	{
		testi = new Tween(bluenavi.style,'width',Tween.strongEaseOut, widthstart, widthend, 0.5,'px');
		testi.start();
	}
	
	// testii = new Tween(bluenavi.style,'left',Tween.strongEaseOut, bluenaviposition, Position, 0.6,'px');
	// testii.start();
	
	// new Effect.Move('bluenavi', { x: Position, y: 0, mode: 'absolute', duration: 0.3, delay: 0.1, transition: Effect.Transitions.spring });
	
	new Effect.Move('bluenavi', { x: Position, y: 0, mode: 'absolute', duration: 0.3, queue: 'end', transition: Effect.Transitions.sinoidal });

}

// ANIMATION DER LINKEN NAVIGATION

function aufklapp ( div, heightstart, heightend, aufklapper, zuklappdiv, zuklapp1div, zuklapp, zuklapp1 )
{
	aufklapper.style.display="block";
	zuklappdiv.style.display="none";
	zuklapp1div.style.display="none";
	
	/* DIESEN CODE SP�TER AUSLAGERN!!! */
	
	
	div.style.backgroundImage="url('img/navi_bg_hl.jpg')";
	div.style.backgroundRepeat="repeat-y";
	div.style.backgroundColor="#FCF000";
	div.style.color="#4676A0";
	
	zuklapp.style.backgroundImage="url('img/navi_bg.jpg')";
	zuklapp.style.backgroundRepeat="repeat-y";
	zuklapp.style.backgroundColor="#4676A0";
	zuklapp.style.color="#ffffff";
	
	zuklapp1.style.backgroundImage="url('img/navi_bg.jpg')";
	zuklapp1.style.backgroundRepeat="repeat-y";
	zuklapp1.style.backgroundColor="#4676A0";
	zuklapp1.style.color="#ffffff";
	
	var testiii = new Tween(aufklapper.style,'height',Tween.elasticEaseOut, heightstart, heightend, 1.5,'px');
	testiii.start();	
}

function seitenwechsel(content, ac)
{
	new Ajax.Updater(content, ac, { method:"get" });
		
	var opacityTween = new OpacityTween(content, Tween.regularEaseIn, 0, 100, 3);
	opacityTween.start();
}

function downloadauf()
{
	var downloadaufdiv = document.getElementById('downloadauf');
	//var fragenaufdiv = document.getElementById('fragenauf');

	downloadaufdiv.style.display="block";
	
	var opacityTween = new OpacityTween(downloadaufdiv, Tween.regularEaseIn, 0, 100, 0.5);
	opacityTween.start();

	downauf = new Tween(downloadaufdiv.style,'width',Tween.strongEaseOut, 0, 300, 1,'px');
	downauf.start();
	
	//var opacityTween2 = new OpacityTween(fragenaufdiv, Tween.regularEaseIn, 100, 0, 0.5);
	//pacityTween2.start();
	
	//opacityTween2.onMotionFinished = function()
	//{
		//fragenaufdiv.style.display="none";
	//}
	//opacityTween2.onMotionResumed = function()
	//{
	//	fragenaufdiv.style.display="block";
	//}
}

function downloadauflassen()
{
	var downloadaufdiv			= 	document.getElementById('downloadauf');
	
	downloadaufdiv.style.display="block";	
}

function downloadzu()
{

	var downloadaufdiv = document.getElementById('downloadauf');
	
	var opacityTween = new OpacityTween(downloadaufdiv, Tween.regularEaseIn, 100, 0, 0.5);
	opacityTween.start();

	downzu = new Tween(downloadaufdiv.style,'width',Tween.strongEaseOut, 250, 0, 1,'px');
	downzu.start();
	
	opacityTween.onMotionFinished = function()
	{
		downloadaufdiv.style.display="none";
	}
	opacityTween.onMotionResumed = function()
	{
		downloadaufdiv.style.display="block";
	}
}
