$(function () {

	var b = new banner();
	b.obj.show();

	$('.b_avancar').click(function () { b.go();   clearInterval(b.int); b.int = setInterval(function() { b.go(); }, b.tempo); return false; });
	$('.b_voltar').click(function ()  { b.back(); clearInterval(b.int); b.int = setInterval(function() { b.go(); }, b.tempo); return false; });

	b.int = setInterval(function() { b.go(); }, b.tempo);
});

var banner = function () {
	this.tempo = 5000;
	this.obj   = $('#banner ul li:first');
    this.c1    = $('#banner ul li').index(this.obj) + 1;
    this.c2    = $('#banner ul li').index(this.obj) - 1;
    this.int   = '';

    this.f   = function (c) {
		$('#banner ul li').hide();
		$('#banner ul li:eq('+ c +')').show();
		return $('#banner ul li').index($('#banner ul li:eq('+ c +')'));
	}

	this.go   = function () {
		this.c2 = this.c1 -1;
		if (this.c1 == $('#banner ul li').length)
			this.c1 = 0;
		this.c1 = this.f(this.c1) + 1;

	}

	this.back = function () {
		this.c1 = this.c2 +1;
		if (this.c2 < 0)
			this.c2 = $('#banner ul li').length - 1;
		this.c2 = this.f(this.c2) - 1;
	}
}
