$(document).ready(function(){	
						   
	$("#menu li").mouseover(function(){
		$(this).css({marginTop:"6px"});
	});
	$("#menu li").mouseout(function(){
		$(this).css({marginTop:"14px"});
	});
	
	$("#menu_act").css({marginTop:"6px"});
	$("#menu_act").css("background-image", "url(../images/menu_a.png)"); 
	
	$("#menu_act").mouseout(function(){
		$(this).css({marginTop:"6px"});
	});
	
	
	
	
	
	
	
	
	
	
	
	
	var pocz
	var t = "";
	
	
	$("span").click(function(){
		if(t!=0){
			clearInterval(t);
			t = "";
		}else{
			start(i);
			t = setInterval(now,3000);
		}
	});	
	
	$(".selector_box").click(function(){
		clearInterval(t);
		
		$("#selector_"+i).css("background-color", "#000000");
		$("#slide_"+i).css("opacity", 0);
		
		start(parseInt($(this).val()));
		t = setInterval(now,3000);	
	});	
	
	switch (strona)
	{
	case 1:
	  start(1);
	  break
	case 2:
	  start(2);
	  break
	case 3:
	  start(3);
	  break
	case 4:
	  start(4);
	  break
	case 5:
	  start(5);
	  break
	}
	
	var $currElement;
	var $prevElement;
	var $cElement;
	var $pElement;
	var i;
	
	function start(first){
		pocz = first
		
		for (j=1;j<=5;j++)
		{
			if(j != pocz)
			{
				$("#slide_"+j).css({opacity: 0})
			}else{
				$("#slide_"+pocz).css({opacity: 1})
			}
		}
		
		
		$("#selector_"+pocz).css("background-color", "#f2c187");		
	
		$currElement = $("#slide_"+pocz);
		$prevElement = $currElement;
		
		$cElement = $("#selector_"+pocz);
		$pElement = $cElement;
		
		i = pocz;	
	};
					
	function now(){

		for (j=1;j<=5;j++)
		{
			if(j != i)
			{
				$("#slide_"+j).css({opacity: 0})
			}
		}
		$prevElement = $currElement;
		$currElement = $currElement.next();
		
		$pElement = $cElement;
		$cElement = $cElement.next();
	
		$prevElement.animate({opacity: 0}, 1000, function(){
		$currElement.animate({opacity: 1}, 1000);
		}); 
	
		if(i == 5){
			$prevElement = $currElement;
			$currElement = $("#slide_1");
			$cElement = $("#selector_1");
			i=0;
		}
		
		i = i+1;
		$pElement.css("background-color", "#000000");
		$cElement.css("background-color", "#f2c187");
	};					
	t = setInterval(now,3000);
	
});

























function ustaw(e){	
	if (nac == true)
	{
		x = parseInt(e.clientX)
		y = parseInt(e.clientY)
		
		x3 = parseInt(menu_suwak.style.left)
		y3 = parseInt(menu_suwak.style.top)
		if(((y- (y1-y2))>597)&&(y- (y1-y2))<878)
		{
			menu_suwak.style.top=y- (y1-y2)
		}
		document.getElementById('menu_slider').scrollTop=(y3-597)*5.1;				
		
	}
}

function sprawdz(e)
{
	nac = true;
	
	x1 = parseInt(e.clientX)
	x2 = parseInt(menu_suwak.style.left)
	y1 = parseInt(e.clientY)
	y2 = parseInt(menu_suwak.style.top)
}

function upusc()
{
	if (nac == true)
	{
		nac = false;   
		menu_suwak.style.left = x3
		menu_suwak.style.top = y3 
	}
 
}

