$(function(){
	
	var szelcsendvan = true;
	var sc=2;
	var ss=''
	
	setInterval(function(){
		if (szelcsendvan) { //amíg csendben van a júzer
			ss="#slider"+sc+"-kicsi";
			$(ss).trigger('szlajd');
			sc++;
			if (sc==5) sc=1;
		}
	}, 3200);
	
	$("#fooldal-slider div.kicsi").bind('szlajd', function() {
		$clicked = $(this);
		
		// if the button is not already "transformed" AND is not animated
		if ($clicked.css("opacity") != "1" && $clicked.is(":not(animated)")) {
			
			$clicked.animate({
				opacity: 1,
			}, 500 );
			
			// each button div MUST have a "xx-button" and the target div must have an id "xx" 
			var idToLoad = $clicked.attr("id").split('-');
			
			//we search trough the content for the visible div and we fade it out
			$("#nagyok").find("div:visible").fadeOut("fast", function(){
				//once the fade out is completed, we start to fade in the right div
				
				$(this).parent().find("#"+idToLoad[0]).find(".box").fadeIn(1000);
				$(this).parent().find("#"+idToLoad[0]).fadeIn();
			})
		}
		
		//we reset the other buttons to default style
		$clicked.siblings(".kicsi").animate({
			opacity: 0.55,
		}, 500 );
		
	});
	
	$("#fooldal-slider div.kicsi").click(function(){
		szelcsendvan=false; //beklikkel a júzer
		$(this).trigger('szlajd');
	});
		
});