var slideWidth = 150;

$(document).ready(function() {

	$('#footer #slider #sliderContainer').each(function(k, el) {
		
		var slides = $(this).find('div');
		$(this).css('width', slideWidth*slides.size())
		
		var steps = Math.ceil(slides.size() / 2);
		var sliderContainer = this;
		this.rel = 0; //current step
		
		if(steps == 1)
			$(this).parent().parent().find('.button').css('display', 'none');
			
		else {
					
			$(this).parent().parent().find('.next').click(function() {			
				goNext(sliderContainer, steps)			
			});		
			
			$(this).parent().parent().find('.prev').click(function() {			
				goPrev(sliderContainer, steps)			
			}).css('display', 'none');		
			
		}
		
	})

})

function goNext(cont, steps) {
	goStep(cont, steps, 1);
}

function goPrev(cont, steps) {
	goStep(cont, steps, -1);
}

function goStep(cont, steps, where) {

	if(where > 0 && cont.rel == steps)
		return false;
	
	if(where < 0 && cont.rel == 0)
		return false;
		
	cont.rel += where;
	$(cont).animate({ marginLeft: -(slideWidth*cont.rel*2) })
	
	if(cont.rel+1 < steps)
		$(cont).parent().parent().find('.next').css('display', 'block');
	else
		$(cont).parent().parent().find('.next').css('display', 'none');

	if(cont.rel > 0)
		$(cont).parent().parent().find('.prev').css('display', 'block');
	else
		$(cont).parent().parent().find('.prev').css('display', 'none');

}
