// JavaScript Document
function noSpam(){
	$('.email').each(function() {
	  var $email = $(this);
	  var address = $email.text()
		 .replace(/\s*\[at\]\s*/, '@')
		 .replace(/\s*\[dot\]\s*/g, '.');
	  $email.html('<a href="mailto:' + address + '" class="cb">'
		 + address +'</a>');
	});
}
$(function (){
	//loader
	$(window).load(function(){
	/* Logo */
	if($.support.opacity){
	$('#header img[alt="@"]').animate({
		top:'14%',
		opacity:1
	},1500,
	function(){
	
	$(this).parent().find('img[alt="arroba"]').animate({
		top:'32%',
		opacity:1
	},1500);
	$(this).parent().find('img[alt="design"]').animate({
		top:'31.5%',
		opacity:1
	},1500,
	function(){
	
	$(this).parent().find('img[alt="agencia"]').animate({
		opacity:1
	},1500);
	$(this).parent().find('img[alt="interativa"]').animate({
		opacity:1
	},2000);
	
	});
	});
	
	}else{//Para o IE
	$('#header img[alt="@"]').animate({
		top:'14%'
	},1500,
	function(){
	
	$(this).parent().find('img[alt="arroba"]').animate({
		top:'32%'
	},1500);
	$(this).parent().find('img[alt="design"]').animate({
		top:'31.5%'
	},1500,
	function(){
	
	$(this).parent().find('img[alt="agencia"]').animate({
		top:'60%'
	},1300);
	$(this).parent().find('img[alt="interativa"]').animate({
		top:'62%'
	},1500);
	});
	});
	}
	
	/* Banners */
	$('#banner').before('<div id="nav-banner">').cycle({
		fx: 'fade',
		speed: 500,
		timeout: 7000,
		pager:'#nav-banner'
	});
	$('#rotativo1').cycle({
		fx: 'fade',
		speed: 500,
		cleartype: $.support.opacity,
		timeout: 5500
	});
	$('#rotativo2').cycle({
		fx: 'fade',
		speed: 500,
		cleartype: $.support.opacity,
		timeout: 7500
	});
	$('#rotativo3').cycle({
		fx: 'fade',
		speed: 500,
		cleartype: $.support.opacity,
		timeout: 6000
	});

	//Efeitos de link
	// NAV
	$('#nav a[href] span').hover(function(){
		$(this).stop().fadeTo(380, 1)
	},function(){
		$(this).stop().fadeTo(380, 0);
	});
	
	// Clientes
	$('a.left, a.browser, button').hover(function(){
		$(this).find('img').stop().fadeTo('slow',.6);
	},function(){
		$(this).find('img').stop().fadeTo('slow',1);
	});
	
	//Portfolio
	$('#outrosProjetos a').hover(function(){
		$(this).find('img').stop().fadeTo('slow',.9);
	},function(){
		$(this).find('img').stop().fadeTo('slow',1);
	});
		
	$('#redesSociais a').hover(function(){
		$(this).stop().animate({
			top:'-3px'
		});
	},function(){
		$(this).stop().animate({
			top:'0'
		});
	});
	
	/*$('#redesSociais a').mouseout(function(){
		$(this).stop().animate({
			top:'0'
		});
	});*/
	
	function seta(){
		$('#home3 img.absolute').animate({
			bottom:'45px'
		});
		$('#home3 img.absolute').animate({
				bottom:'38px'
			},seta);
		}
		seta();
		//Efeitos de link
		
		// Mask Form //
		$(".fone").mask("(99) 9999.9999");
		$("#fcpf").mask("999.999.999-99");
		$("#fnasc").mask("99.99.9999");
		$("#fcep").mask("99.999-999");
		// Mask Form //
		
		//Blog
		$('#cont_caixa2 div.vm:last, #cont_caixa2 div.cmm:last').css({marginBottom:0});
	});
	
	if($.browser.msie && $.browser.version == 9){
		$('#newsletter input[type=text]').css({
			'padding': '2px 1px'
		});
		$('#footer ul.right li.cw.f24').css({
			'writing-mode':'tb-lr',
			'top':'0',
			'left':'375px'
		});
	}
	
	$('#mycarousel').jcarousel({
		scroll:2,
		animation:'slow',
		auto: 3,
		wrap: 'circular'
	});
	$(window).resize(function(){
		var w = $(window).width();
		var b = $('body');
		var nw = '1900';
		if(w < 800){
			nw = '800';
		} else if(w < 1024){
			nw = '1024';			
		} else if(w < 1280){
			nw = '1280';			
		} else if(w < 1440){
			nw = '1440';			
		} else if(w < 1680){
			nw = '1680';			
		} else if(w < 1920){
			nw = '1920';			
		} else if(w < 2560){
			nw = '2560';
		}
		//$('#newsletter').html(w);
		b.css({
			'backgroundImage': 'url('+url_site+'thumbs/'+nw+'x2400/nonex1/bg/'+bgImage+')'
		});
		//alert(url_site+'thumbs/'+nw+'x2400/nonex1/'+bgImage);
	}).trigger('resize');
	
	//arrobildo
	var mascote = $('#mascote')
	
	function mascote2(){
	$('#mascote').show(0,function(){
		$(this).find('img').delay(3000).fadeIn(0);
		$(this).find('img').delay(200).fadeOut(0,function(){
			mascote2();
		});
	});
	}
	mascote2();
	
	$('#nav a.mascote').hover(function(){
		mascote.show().animate({
			top:'-28px'
		});
	},function(){
		mascote.animate({
			top:'0'
		},function(){
			$(this).hide();
		});
	});
	
	$('#nav a[name=Home].Ativo').show(function(){
		mascote.css({
			top:'-28px',
			display:'block'
		});
	});
	
	//newsletter
	$('#newsletter').submit(function(){
		var data = $(this).serialize();
		$.ajax({
			url: url_site+'newsletter.php',
			type: 'POST',
			data: data,
			success: function(data){
				switch(data){
					case "vazio":
						alert('Digite o seu e-mail');
					break;
					case "emailinvalido":
						alert('E-mail inválido');
					break;
					case "jacadastrado":
						alert('E-mail já cadastrado');
					break;
					case "cadastrado":
						alert('Cadastrado com sucesso!');
					break;
					default:
						alert(data);
					break;
				}
			}
		});
		return false;
	});
	//newsletter
	
});
