var t;
var next;
var url;
var descerfooter = 1;
$(function(){
	$("#footer-close").click(function(){descer();})
	$("#footer-popup, #footer-close").fadeIn(2000);
	if($('.home-banner').length > 0){
		next = '#ban01';
		t = setTimeout(autoplay, 3000, next);
	}
	
	var nav = document.getElementById("menu");
	var links = nav.getElementsByTagName("a");
	
	for(var i=0; i<links.length; i++)
	{
		var linkurl = links[i].getAttribute("href");
		var currenturl = window.location.href;
		if(currenturl.indexOf(linkurl) != -1)
		{
			links[i].className = "ativo";
		}
	}
	
	if(currenturl.indexOf("send") != -1)
	{
		alert('Mensagem enviada com sucesso.');
		return false;
	}
});
function descer () {
	if(descerfooter == 1){
		//$("#footer-popup").css({bottom:"-50px"})
		//$("#footer-close").css({bottom:"-35px"})
		$('#footer-close').animate({
		bottom: '-35px'
		}, 700, function() {
		// Animation complete.
		});
		$('#footer-popup').animate({
		bottom: '-50px'
		}, 700, function() {
		// Animation complete.
		});
	descerfooter++;
	}else{
		$('#footer-close').animate({
		bottom: '15px'
		}, 700, function() {
		// Animation complete.
		});
		$('#footer-popup').animate({
		bottom: '0'
		}, 700, function() {
		// Animation complete.
		});
	descerfooter = 1;
	}
}
function autoplay(next) {
	  banner = next
	  if(banner == "#ban01"){
		  next = "#ban02";
	  }
	  if(banner == "#ban02"){
		  next = "#ban03";
	  }
	  if(banner == "#ban03"){
		  next = "#ban01";
	  }
	  
	  //desc = $('#'+next).html();
	  //$('.button').html('<a href="professional-service.html"><span>' + desc + '</span></a>'); 
	  
	  $(next).fadeIn('normal');
	  $(banner).fadeOut('normal');

	  t = setTimeout(autoplay, 5000, next);
}
function changeTabs(nav, tab){
	$('.tab-clientes a').removeClass('tab-ativa');
	$(nav).addClass('tab-ativa');
	$('.painel-cliente').fadeOut('normal',function(){
		$('#'+tab).show();	
	});
	return false;
}

