$(function(){
	$("#menu li").hover(function(){ selecionar(this); }, function(){ selecionar($("#menu .sel").get(0)); });
	selecionar($("#menu .sel").get(0));
});

function selecionar(o){
	var init = 0;
	var index = $("#menu li").index(o);
	if(index >= 0){
		var height = $("#menu li").height();
		$("#over").addClass("over").stop().animate({marginTop: init + (index * height)});
	}
}

function faq(o) {
	var holder = $(o);
	var li = holder.parent().parent().parent().parent().parent();
	var ul = li.parent();

	$("li", ul).removeClass("open").addClass("close");

	li.removeClass("close").addClass("open");
}


function quemSomos(o) {
	var holder = $(o);
	var li = holder.parent();
	var ul = li.parent();

	$(".box", ul).slideUp();
	$(".mais", ul).slideDown();
	holder.next().slideDown(function(){ window.scroll(0,$("body").height()); });
	holder.hide();
}


function submit(o) {
	var holder = $(o);
	var form = holder.parent().parent().parent();

	form.submit();
}

function depoimento(total) {
	var prev = $("#prev");
	var next = $("#next");
	var depoimentos = $("#depoimentos");

	this.total = total;
	this.count = 1;

	this.init = function() {
		$('.jtextfill').textfill({ maxFontPixels: 25 });

		$('.depoimento', depoimentos).hide();
		$('.d1', depoimentos).show();
	}

	this.next = function(){
		if(this.count < this.total) {
			var td = $("#depoimentos .d" + this.count);
			td.fadeOut();
			td.next().fadeIn();
			this.count++;
		}
	}

	this.prev = function() {
		if(this.count > 1) {
			var td = $("#depoimentos .d" + this.count);
			td.fadeOut();
			td.prev().fadeIn();
			this.count--;
		}
	}
}
