function preloadImages() {
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

(function ($) {
  $.fn.tag = function() {
	$(this).each(function() {
	  var xOffset = -10,
	  yOffset = -20,
	  $tag = $('.mais', this);
	  $(this).mousemove(function(e) { 
		$tag.css({top:(e.pageY-yOffset)+"px", left:(e.pageX-xOffset)+"px"}); 
	  });
	  $(this).hover(
		function() { $tag.show(); },
		function() { $tag.hide(); }
	  );
	});
  };
})(jQuery);
$(function() { 
  $(".tag").tag();
});

$(document).ready(function(){
$('a[href*=#]').click(function() {
  if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
  && location.hostname == this.hostname) {
	var $target = $(this.hash);
	$target = $target.length && $target
	|| $('[name=' + this.hash.slice(1) +']');
	if ($target.length) {
	  var targetOffset = $target.offset().top;
	  $('html,body')
	  .animate({scrollTop: targetOffset}, 900, 'easeOutQuart');
	 return false;
	}
  }
});
});

function gerCase(id, acao) {
	for (i=1; i<=3; i++) {
		if (i != id) {
			$("#case-"+i).slideUp(900, 'easeInOutCubic');
		}
	}

	if (acao != 0) {
		targetOffset = $('#cases-descricao').offset().top;
		$("#case-"+id).slideDown(900, 'easeInOutCubic');
	} else {
		targetOffset = $('#cases').offset().top;
		$("#case-"+id).slideUp(900, 'easeInOutCubic');
	}

	$('html,body').animate({scrollTop: targetOffset}, 900, 'easeOutQuart');
}

function destaque(id) {
	$("html,body").stop();
	$(".padding").removeClass("destaque");

	if (id != 0) {
		$("#"+id).addClass("destaque");

		$("#"+id).delay(2500).animate({border: "none"}, 0, function() {
			$(this).removeClass("destaque");
		});
	}
}

function fContato() {
	$(".padding").removeClass("destaque");

	if(document.formContato.nome.value == "Nome"){
		$("#alerta-nome").text("Digite o seu nome.");
		$("#alerta-nome").show(800, 'easeOutQuart');
		document.formContato.nome.focus();
		document.formContato.nome.className = "destaque";
		return false;
	}
	
	if(document.formContato.email.value == "E-mail"){
		$("#alerta-email").text("Digite o seu e-mail.");
		$("#alerta-email").show(800, 'easeOutQuart');
		document.formContato.email.focus();
		document.formContato.email.className = "destaque";
		return false;
	}
	
	if(document.formContato.email.value != "E-mail"){
		elemento = document.formContato.email.value;
		
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(elemento)){
		} else {
			$("#alerta-email").text("Digite um e-mail válido.");
			$("#alerta-email").show(800, 'easeOutQuart');
			document.formContato.email.focus();
			document.formContato.email.className = "destaque";
			return false;
		}
	}
	
	if(document.formContato.mensagem.value == "Mensagem"){
		$("#alerta-mensagem").text("Digite a mensagem.");
		$("#alerta-mensagem").show(800, 'easeOutQuart');
		document.formContato.mensagem.focus();
		document.formContato.mensagem.className = "destaque";
		return false;
	}

	document.formContato.submit();
}

window.onload = preloadImages('bg_bco.jpg','bg_pto.jpg','divisao.gif','assinatura.png','case-esq.png','case-dir.png','passaro.png');