var Showcase;
var ShowcaseTimer;
el={'a' : 0,'b' : 1,'c' : 2,'d' : 3,'e' : 4,'f' : 5,'g' : 6,'h' : 7}
eln={0 : 'a',1 : 'b',2 : 'c',3 : 'd',4 : 'e',5 : 'f',6 : 'g',7 : 'h'}
link={0 : '/roboty_drogowe_brukarstwo_lodz_lodzkie.html',
	  1 : '/wyburzanie_i_rozbiorki_lodz_lodzkie.html',
	  2 : '/zagospodarowanie_terenu_lodz_lodzkie.html',
	  3 : '/transport_uslugi_transportowe_lodzkie_lodz.html',
	  4 : '/wynajem_maszyn_budowlanych_lodzkie_lodz.html',
	  5 : 'http://alfasklad.pl',
	  6 : '/sieci_wodno_kanalizacyjne__lodzkie_lodz.html',
	  7 : '/fundamenty_wykopy_lodzkie_lodz.html'
}

window.addEvent('domready', function() {
	for(var i=0; i < 7;i++)
	{
		element=$(eln[i])
		element.set('href',link[i])
		element.addEvent('click',function(){document.location.href=this.get('href')})
		
		element=$('i_'+eln[i])
		element.set('href',link[i])
		element.addEvent('click',function(){document.location.href=this.get('href')})
		
	}
	
	$$('#navi_box div.item img').each(function(elm){
		elm.setStyle('opacity',0.6);
	})
	
	$$('#navi_box div.item').addEvents({
		'mouseenter' : function(){
			
			this.eff=new Fx.Tween(this.getElement('img'),{duration : 250}).start('opacity',0.6,1)
		}
		,'mouseleave' : function(){
			
			this.eff=new Fx.Tween(this.getElement('img'),{duration : 450}).start('opacity',1,0.6)
		}
		
	});
	
	$$('#top_menu a').addEvents({
		'mouseenter' : function(){
			this.eff=new Fx.Tween(this,{duration : 250}).start('background-color','#0d0f0f','#202020')
		}
		,'mouseleave' : function(){
			
			this.eff=new Fx.Tween(this,{duration : 450}).start('background-color','#202020','#0d0f0f')
		}
	});

	Fx.Elements.implement({
		flip : function(el_id)
		{
			if(this.running) return false;
			this.toid=el_id;
			this.toel=el[this.toid];	
			aaa={};
			aaa[this.active]={'width' : [460, 0]};
			aaa[this.toel]={'width' : [0, 460]};
			this.start(aaa);
			this.running=true; 
		}
		,show_next : function()
		{
			this.flip(eln[this.active+1 == this.elements.length ? 0 : this.active+1]);	
		}
		,show_prev : function()
		{
			this.flip(eln[this.active == 0 ? this.elements.length-1 : this.active-1]);
		},
		switchElement: function()
		{
			$(this.active_id).removeClass('active');
			$(this.toid).addClass('active');
			this.active=this.toel;
			this.active_id=this.toid;
			
		}
	});

	Showcase=new Fx.Elements($$('.content'),{duration: 250,transition: Fx.Transitions.Expo.easeIn,onComplete: function(){this.running=false;this.switchElement();}});
	Showcase.active=0;	
	Showcase.active_id='a';
	Showcase.running=false;	
	ShowcaseTimer = setInterval("Showcase.show_next();",3000);
	
	var scroll=new Fx.Scroll(window, {
	wait: false,
	duration: 1000,
	onComplete: function(){
		var myFx = new Fx.Tween('container',{duration : '1000'});
		myFx.start('background-color', '#aaaaaa', '#181818');	
	}
	});
	
	if(document.location.pathname != '/' || document.location.pathname != '/index.html') scroll.toElement('container');
	
})



