//on dom ready...  
window.addEvent('domready', function() {
//set Vars
var thisisactive = 'none'; // $('content').set('text', thisisactive);

//init cookie:

var barcookie = Cookie.read('barcookie');

if(Cookie.read('barcookie')){
	if(Cookie.read('barcookie')==1){
		//alert('eins');
	}
	if(Cookie.read('barcookie')==0){
		//alert('null');
	}

}
else {
	Cookie.write('barcookie', '1', {domain: 'www.erfolgsfaktor.com',path: '/'});
}


var fx0 = new Fx.Tween(('menuolay0'),{duration: 400, link: 'chain', onComplete: function(){('menuolay0').fade('in');}}).set('opacity', 0);
var fx1 = new Fx.Tween(('menuolay1'),{duration: 400, link: 'chain',onComplete: function(){('menuolay1').fade('in');}}).set('opacity', 0);
var fx2 = new Fx.Tween(('menuolay2'),{duration: 400, link: 'chain',onComplete: function(){('menuolay2').fade('in');}}).set('opacity', 0);
var fx3 = new Fx.Tween(('menuolay3'),{duration: 400, link: 'chain',onComplete: function(){('menuolay3').fade('in');}}).set('opacity', 0);
var fx4 = new Fx.Tween(('menuolay4'),{duration: 400, link: 'chain',onComplete: function(){('menuolay4').fade('in');}}).set('opacity', 0);
var fx5 = new Fx.Tween(('menuolay5'),{duration: 400, link: 'chain',onComplete: function(){('menuolay5').fade('in');}}).set('opacity', 0);
var fx6 = new Fx.Tween(('menuolay6'),{duration: 400, link: 'chain',onComplete: function(){('menuolay6').fade('in');}}).set('opacity', 0);

var fx0sub = new Fx.Slide('sub0', {duration: 250, wait:true, link:'cancel'}).hide();
var fx1sub = new Fx.Slide('sub1', {duration: 250, wait:true, link:'cancel'}).hide();
var fx2sub = new Fx.Slide('sub2', {duration: 250, wait:true, link:'cancel'}).hide();
var fx3sub = new Fx.Slide('sub3', {duration: 250, wait:true, link:'cancel'}).hide();
var fx6sub = new Fx.Slide('sub6', {duration: 250, wait:true, link:'cancel'}).hide();

var fxthemainbar = new Fx.Morph('themainbar', {duration: 250, wait:true, link:'cancel'});

if(barcookie == 0){
	fxthemainbar.set({'height': 7});	
}


//set Functions
function fadeBGin(div)
{
 	if( div != thisisactive ) {
    if(div == 'none'){
		if(thisisactive == 'fx0'){ 
			fx0.start('opacity', 0); fx0sub.slideOut();
			fx1.set('opacity', 0); 
			fx2.set('opacity', 0); 
			fx3.set('opacity', 0); 
			fx4.set('opacity', 0); 
			fx5.set('opacity', 0); 
			fx6.set('opacity', 0); 
		}
		if(thisisactive == 'fx1'){ 
			fx1.start('opacity', 0); fx1sub.slideOut();
			fx0.set('opacity', 0); 
			fx2.set('opacity', 0); 
			fx3.set('opacity', 0); 
			fx4.set('opacity', 0); 
			fx5.set('opacity', 0); 
			fx6.set('opacity', 0); 
		}
		if(thisisactive == 'fx2'){ 
			fx2.start('opacity', 0); fx2sub.slideOut();
			fx1.set('opacity', 0); 
			fx0.set('opacity', 0); 
			fx3.set('opacity', 0); 
			fx4.set('opacity', 0); 
			fx5.set('opacity', 0); 
			fx6.set('opacity', 0); 
		}
		if(thisisactive == 'fx3'){ 
			fx3.start('opacity', 0); fx3sub.slideOut();
			fx1.set('opacity', 0); 
			fx2.set('opacity', 0); 
			fx0.set('opacity', 0); 
			fx4.set('opacity', 0); 
			fx5.set('opacity', 0); 
			fx6.set('opacity', 0); 
		}
		if(thisisactive == 'fx4'){ 
			fx4.start('opacity', 0); 
			fx1.set('opacity', 0); 
			fx2.set('opacity', 0); 
			fx3.set('opacity', 0); 
			fx0.set('opacity', 0); 
			fx5.set('opacity', 0); 
			fx6.set('opacity', 0); 
		}
		if(thisisactive == 'fx5'){ 
			fx5.start('opacity', 0); 
			fx1.set('opacity', 0); 
			fx2.set('opacity', 0); 
			fx3.set('opacity', 0); 
			fx4.set('opacity', 0); 
			fx0.set('opacity', 0); 
			fx6.set('opacity', 0); 
		}
		if(thisisactive == 'fx6'){ 
			fx6.start('opacity', 0); fx6sub.slideOut();
			fx1.set('opacity', 0); 
			fx2.set('opacity', 0); 
			fx3.set('opacity', 0); 
			fx4.set('opacity', 0); 
			fx5.set('opacity', 0); 
			fx0.set('opacity', 0); 
		}
    }
    else {    
	    if(thisisactive == 'none'){
			if(div == 'fx0'){ fx0.start('opacity', 1); fx0sub.slideIn();}
			if(div == 'fx1'){ fx1.start('opacity', 1); fx1sub.slideIn();}
			if(div == 'fx2'){ fx2.start('opacity', 1); fx2sub.slideIn();}
			if(div == 'fx3'){ fx3.start('opacity', 1); fx3sub.slideIn();}
			if(div == 'fx4'){ fx4.start('opacity', 1); }
			if(div == 'fx5'){ fx5.start('opacity', 1); }
			if(div == 'fx6'){ fx6.start('opacity', 1); fx6sub.slideIn();}
		}
		else {
		if(thisisactive == 'fx0'){ 
			fx0.start('opacity', 0); fx0sub.slideOut();
			fx1.set('opacity', 0); 
			fx2.set('opacity', 0); 
			fx3.set('opacity', 0); 
			fx4.set('opacity', 0); 
			fx5.set('opacity', 0); 
			fx6.set('opacity', 0); 
		}
		if(thisisactive == 'fx1'){ 
			fx1.start('opacity', 0); fx1sub.slideOut();
			fx0.set('opacity', 0); 
			fx2.set('opacity', 0); 
			fx3.set('opacity', 0); 
			fx4.set('opacity', 0); 
			fx5.set('opacity', 0); 
			fx6.set('opacity', 0); 
		}
		if(thisisactive == 'fx2'){ 
			fx2.start('opacity', 0); fx2sub.slideOut();
			fx1.set('opacity', 0); 
			fx0.set('opacity', 0); 
			fx3.set('opacity', 0); 
			fx4.set('opacity', 0); 
			fx5.set('opacity', 0); 
			fx6.set('opacity', 0); 
		}
		if(thisisactive == 'fx3'){ 
			fx3.start('opacity', 0); fx3sub.slideOut();
			fx1.set('opacity', 0); 
			fx2.set('opacity', 0); 
			fx0.set('opacity', 0); 
			fx4.set('opacity', 0); 
			fx5.set('opacity', 0); 
			fx6.set('opacity', 0); 
		}
		if(thisisactive == 'fx4'){ 
			fx4.start('opacity', 0); 
			fx1.set('opacity', 0); 
			fx2.set('opacity', 0); 
			fx3.set('opacity', 0); 
			fx0.set('opacity', 0); 
			fx5.set('opacity', 0); 
			fx6.set('opacity', 0); 
		}
		if(thisisactive == 'fx5'){ 
			fx5.start('opacity', 0); 
			fx1.set('opacity', 0); 
			fx2.set('opacity', 0); 
			fx3.set('opacity', 0); 
			fx4.set('opacity', 0); 
			fx0.set('opacity', 0); 
			fx6.set('opacity', 0); 
		}
		if(thisisactive == 'fx6'){ 
			fx6.start('opacity', 0); fx6sub.slideOut();
			fx1.set('opacity', 0); 
			fx2.set('opacity', 0); 
			fx3.set('opacity', 0); 
			fx4.set('opacity', 0); 
			fx5.set('opacity', 0); 
			fx0.set('opacity', 0); 
		}
			if(div == 'fx0'){ fx0.start('opacity', 1); fx0sub.slideIn();}
			if(div == 'fx1'){ fx1.start('opacity', 1); fx1sub.slideIn();}
			if(div == 'fx2'){ fx2.start('opacity', 1); fx2sub.slideIn();}
			if(div == 'fx3'){ fx3.start('opacity', 1); fx3sub.slideIn();}
			if(div == 'fx4'){ fx4.start('opacity', 1); }
			if(div == 'fx5'){ fx5.start('opacity', 1); }
			if(div == 'fx6'){ fx6.start('opacity', 1); fx6sub.slideIn();}
		}
	}
	thisisactive = div;
   	//$('content').set('text', thisisactive);
   	}
}

// Set Acion
$('hover0').addEvent('mouseover', function(e){				
	fadeBGin('fx0');
});
$('hover1').addEvent('mouseover', function(e){				
	fadeBGin('fx1');
});
$('hover2').addEvent('mouseover', function(e){				
	fadeBGin('fx2');
});
$('hover3').addEvent('mouseover', function(e){				
	fadeBGin('fx3');
});
$('hover4').addEvent('mouseover', function(e){				
	fadeBGin('fx4');
});
$('hover5').addEvent('mouseover', function(e){				
	fadeBGin('fx5');
});
$('hover6').addEvent('mouseover', function(e){				
	fadeBGin('fx6');
});
$('content').addEvent('mouseover', function(e){				
	var x = new Chain();
	var one = function(){ };
	var two = function(){ fadeBGin(myvarplease); };
	x.chain(one)
	x.chain(two);
	x.callChain();
	x.callChain.delay(4000, x);
	x.callChain.delay(4000, x);
	/*fadeBGin(myvarplease);*/
});

$('themainbar').addEvent('click', function(e){
	if(barcookie == 1){	
		$('themainbar').morph({height: 7});
		Cookie.write('barcookie', '0', {domain:'www.erfolgsfaktor.com',path: '/'});
	}
	else {
		$('themainbar').morph({height: 86});
		Cookie.write('barcookie', '1', {domain:'www.erfolgsfaktor.com',path: '/'});
	}
});

fadeBGin(myvarplease);


});
