function orderElements(){
	var width = $(".news:eq(0)").width();
	
	var i=0;
	$(".news").each(function(){
		$(this).css({'left' : i*width });
		i++;
	});
}

function animate(el){
	var width = $(".news:eq(0)").width();
	var c_pos = parseFloat(el.css('left'));
	var ilosc = $(".news").length - 1;
	
	el.animate({'left': c_pos - width },400,function(){
		if(parseFloat(el.css('left')) <= -width){
			var clone = el.clone();
			clone.css({'left' : ilosc * width });
			$("#news-slide").append(clone);
			el.remove();					
		}		
	})
}

function toggleElements(){
		
	$(".news").each(function(){
		animate($(this));			
	});
		
}

$(document).ready(function(){
	//animation form news component
	orderElements();
	
	if($(".news").length >2){
		setInterval(function(){
			toggleElements();	
		},1000 * 6);
	}
	// add odd | even class to page-right-container list elements
	colorize_lists();
	
	$('.zapytanie-ofertowe').click(function(){
		showForm();	
	});
	
    $('.galeria').each(function(){
        $(this).find('a').lightBox();
    });
	
});
