var mySlide=null;
var myScroll = {

	setup: function(){
	
		var scroller = new Fx.Scroll('scrollbox', {
			wait: false,
			duration: 2000,
			transition: Fx.Transitions.Quint.easeOut,
			wheelStops: false
		});

		var actual_position = 0;
		
		var scrollbox_width = $('scrollbox').offsetWidth;
		var section_counter = 0;
		var section_width = 0;
		
		for ( j = 0 ; j < $('wide-content').childNodes.length ; j++ )
		{
			if( $('wide-content').childNodes[j].className == 'section' )
			{
				section_counter++;
				section_width = (scrollbox_width - 0) + 'px';
				$('wide-content').childNodes[j].style.width = section_width;
			}
		}
		
		if( section_counter > 0 )
			$('wide-content').style.width = section_counter * scrollbox_width + 'px';

		var wide_content_width = ($('wide-content').getSize()).scrollSize.x;
		
		$('move-left').addEvent('click',function(){
			if(actual_position > 0)
				actual_position -= scrollbox_width;  
			else
				actual_position = wide_content_width-scrollbox_width;	
			scroller.scrollTo(actual_position,0); 
			return false;
		});

		$('move-right').addEvent('click',function(){
			if((actual_position+scrollbox_width) < wide_content_width)
				actual_position += scrollbox_width;  
			else
				actual_position = 0;	
			scroller.scrollTo(actual_position,0);
			return false;
		});
		
		
	}
}

window.addEvent('domready', myScroll.setup.bind(myScroll) );
window.addEvent('domready', function () {
	mySlide = new Fx.Slide('menucontent', {mode: 'horizontal'}).hide();
		 
		//$('popupmenu').style.display='none';
		 
		$('toggle').addEvent('click', function(e){
			e = new Event(e);
			mySlide.toggle();
			e.stop();
		});

		$('move-left').addEvent('click', function(e){
			var i=parseInt($('ktory').innerHTML);
			if(i==1)
				$('ktory').innerHTML=$('ile').innerHTML;
			else
				$('ktory').innerHTML=i-1;
		});
		
		$('move-right').addEvent('click', function(e){
			var i=parseInt($('ktory').innerHTML);
			if(i==parseInt($('ile').innerHTML))
				$('ktory').innerHTML=1;
			else
				$('ktory').innerHTML=i+1;
		});
		
				
		$('projekty').addEvent('mouseover', function(e){
			$('drop').style.display='block';
		});
		
		$('projekty').addEvent('mouseout', function(e){
			$('drop').style.display='none';
		});
	
	//test
	if ($('dzialy')) {
		$ES('a','dzialy').setStyle('display', 'block');
		$ES('a','dzialy').setStyle('float','left');
		$ES('a','dzialy').setStyle('overflow','hidden');
		$ES('a','dzialy').each(function(el) { 
			var widthChange = new Fx.Style(el, 'width', {duration:1000,transition: Fx.Transitions.Quart.easeOut});
			var marginChange = new Fx.Style(el, 'margin-right', {duration:500});
			var opacityChange = new Fx.Style(el, 'opacity', {duration:1000});

			widthChange.start(0, 47);
			marginChange.start(0, 3);
			opacityChange.start(0, 1);
		});
	}

			
});


function kolorowy(val)
{
	val.src=val.src.replace('_g.j','.j');
}

function szary(val)
{
	val.src=val.src.replace('.j','_g.j');
}

