$(document).ready(function() {

	// remove o logo over na index.php ------------------
	
	$('#logo-over').delay(1000).animate({opacity: '0'}, 3000, 'linear', function(){
		// callback
		$(this).remove();
		//alert("olá");
	});

	// LInks pgn servicos

	

	$("a.servicos").click(function() {

		var dvItem = $(this).attr("href").replace("#","");

		

		$("p.descricao").each(function(i) {

			$(this).hide();

		});

		

		$("#" + dvItem).fadeIn('slow');

		return false;

	});

	

	// Portfolio

	

	$("a.thumb").click(function() {

		var dvItem = $(this).attr("href").replace("#","");

		

		$("#quadro-portifolio").fadeOut("fast", function() {

			$(this).html("<img src='site/img/portifolio/" + dvItem + ".jpg' alt='' />");

			$(this).fadeIn("slow");

		});

		

		return false;

	});

	

	// Tooltip

	

	$(".tooltip").tooltip({

		delay:100,

		id:"tooltip-c",

		left:-20,

		showURL:false,

		top:25,

		track:true

	});

	

	// Fancybox

	

	$("a.fancybox").click(function() {

		$(this).fancybox({

			'overlayColor'	: '#000000',					

			'overlayOpacity': 0.8,

			'opacity'		: true,

			'title'			: this.title,

			'padding'		: 10,

			'href'			: this.href,

			'swf'			: {

				'wmode'		: 'transparent',

				'allowfullscreen'	: 'true'

			}

		});

		

		return false;

	});

	

	$("a.fancybox-youtube").click(function() {

		$(this).fancybox({

			'overlayColor'	: '#000000',

			'overlayOpacity': 0.8,

			'opacity'		: true,

			'padding'		: 10,

			'autoScale'		: false,

			'transitionIn'	: 'slow',

			'transitionOut'	: 'slow',

			'title'			: this.title,

			'width'			: 680,

			'height'		: 495,

			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),

			'type'			: 'swf',

			'swf'			: {

				'wmode'		: 'transparent',

				'allowfullscreen'	: 'true'

			}

		});

		

		return false;

	});





	// Botões

	

	$("a.voltar").click(function() {

		if ($.browser.msie) window.history.go(-2);

		else window.history.back();

		

		return false;

	});

	

	$(".confirm").click(function() {

		var tit = $(this).attr("title");

		var msg = "Confirmar operação";

		if (tit != "") msg = tit;

		return confirm(msg+'?');

	});

	

	$(".imprimir").click(function() {

		window.print();

		return false;

	});

	

	$("#btnLimpar").click(function() {

		$("[name*=Bsc]").val("");

		$("#bscBtn").val("block");

		$("#bsc").val("ativar");

		$("#frm-busca").submit();

	});

	

	// Rollover

	

	$(".rollover").opacityrollover({

		mouseOutOpacity:1.0,

		mouseOverOpacity:0.7,

		fadeSpeed:'fast'

	});

	

	// Busca - exibir, paginacao e ordenacao

	

	$("a.bsc-form").click(function() {

		$("#busca").toggle(0, function() {

			if($(this).css("display") == "block") {

				$("#bscBtn").val("block");

				$("#bsc").val("ativar");

			} else {

				$("#bscBtn").val("none");

				$("#bsc").val("");

			}

		});

		

		return false;

	});

	

	$("a.bsc-form-pgn").click(function() {

		var pgn = $(this).attr("href").replace("#","");

		$("#bscPgn").val(pgn);

		$("#frm-busca").submit();

		return false;

	});

	

	$("a.bsc-form-ord").click(function() {

		var tmp = $(this).attr("href").replace("#","").split("|");

		var ord = tmp[0];

		var sen = tmp[1];

		

		$("#bscOrdenar").val(ord);

		$("#bscSentido").val(sen);

		$("#frm-busca").submit();

		return false;

	});

	

	$("#slcBscQtdReg").change(function() {

		$("#bscQtdReg").val($(this).val());

		$("#bscPgn").val(1);

	});

	

	// Mascara/validacao form

	

	$(".f-numero-int").keypress(function(event) {

		return fNumeroInt($(this), event);

	});

	

	$(".f-numero-float").keypress(function(event) {

		return fNumeroFloat($(this), event);

	});

	

	$(".f-cpf").mask("999.999.999-99", {placeholder:" "});

	$(".f-cnpj").mask("99.999.999/9999-99", {placeholder:" "});

	$(".f-cep").mask("99999-99", {placeholder:" "});

	$(".f-data").mask("99/99/9999", {placeholder:" "});

	$(".f-data-hora").mask("99/99/9999 99:99", {placeholder:" "});

	

	$(".f-data").focus(function() {

		vCalendarData(this);

	});	

	

	$(".f-data-hora").focus(function() {

		vCalendarDataHora(this);

	});

	

	// Exibe campo de form com erro

	

	$(".ecmp").each(function(i) {

		var campo = $(this).attr("rel");

		$("#"+campo).addClass("erro");

	});

	

	$(".ecmp").click(function() {

		var campo = $(this).attr("rel");					  

		$("#"+campo).focus();

	});							

});
