var Empreendimentos = {
	
	offset: 0,
	containers: null,
	ativo: null,
	muda_emp: null,
	emp_anterior: null,
	emp_proximo: null,
	ativo_limite: 0,
	
	init: function () {
		this.ativo = $('#emp_TD');
		this.ativo_limite = (this.ativo.find('div.box_empree').length - 5) * 192;
		this.containers = $('div.slider_empreendimentos');
		this.muda_emp = $('a.muda_emp');
		this.muda_emp.bind('click', Empreendimentos.mudaEmp);
		
		this.emp_anterior = $('#emp_anterior').bind('click', Empreendimentos.anterior);
		this.emp_proximo = $('#emp_proximo').bind('click', Empreendimentos.proximo);
		
		this.atualizaSetas();
	},
	
	mudaEmp: function () {
		Empreendimentos.muda_emp.removeClass('ativo');
		$(this).addClass('ativo');
		Empreendimentos.ativo.hide();
		Empreendimentos.ativo = $('#emp_' + this.name);
		Empreendimentos.ativo.css('left', '0px');
		Empreendimentos.offset = 0;
		Empreendimentos.ativo.show();
		Empreendimentos.ativo_limite = (Empreendimentos.ativo.find('div.box_empree').length - 5) * 192;
		Empreendimentos.atualizaSetas();
		return false;
	},
	
	proximo: function () {
		if (Empreendimentos.offset >= Empreendimentos.ativo_limite) return false;
		Empreendimentos.offset = Empreendimentos.offset + 192;
		Empreendimentos.rolar();
		return false;
	},
	
	anterior: function () {
		if (Empreendimentos.offset == 0) return false;
		Empreendimentos.offset = Empreendimentos.offset - 192;
		Empreendimentos.rolar();
		return false;
	},
	
	atualizaSetas: function () {
		if (Empreendimentos.offset == 0) {
			Empreendimentos.emp_anterior.addClass('inativo');
		} else {
			Empreendimentos.emp_anterior.removeClass('inativo');
		}
		if (Empreendimentos.offset >= Empreendimentos.ativo_limite) {
			Empreendimentos.emp_proximo.addClass('inativo');
		} else {
			Empreendimentos.emp_proximo.removeClass('inativo');
		}
	},
	
	rolar: function () {
		Empreendimentos.atualizaSetas();
		Empreendimentos.ativo.animate({ left: -Empreendimentos.offset + 'px' }, 200);
	}
};
$(function () {	Empreendimentos.init(); });
