
	$(function(){
			   
		// * Cufon - Alteração de fontes
        Cufon('nav > ul > li > a', { fontFamily: 'HelveticaMediumCond', textShadow: '1px 1px rgba(0, 0, 0, 0.2)' });
        Cufon('section#conteudo h2', { fontFamily: 'LatoBold' });
		
		// * Para a Home, quando têm mais de 3 colunas de articles, tira a margin-right!
		$("section#conteudo .home article").each(function(index){
			var multiploTres = (index+1) % 3;
			if(multiploTres == 0)
			{
				$(this).css("margin-right","0");
			}
		});
		$("section#conteudo .interno ul.lista-clientes li").each(function(index){
			var multiploSeis = (index+1) % 7;
			if(multiploSeis == 0)
			{
				$(this).css("margin-right","0");
			}			
		});
		$("section#conteudo img").each(function(index){
				   var multiploCinco = (index+1) % 3;
				   if(multiploCinco == 0)
				   {
					   $(this).css("margin-right","0");
				   }
		});
		$("section#conteudo .lista-produtos").each(function(index){
				   var multiploCinco = (index+1) % 3;
				   if(multiploCinco == 0)
				   {
					   $(this).css("margin-right","0");
				   }
		});
		
		// * NivoSlider
		$('section#banner').nivoSlider({
			controlNav: true,
			directionNav: false,
			directionNavHide: false
		});
		
		// * Validação Campos
		// * Orçamento
		$("#formOrcamento").validate({
			errorLabelContainer:"#boxErros ul",
			wrapper: "li",
			rules:{
				txNome:{
					required:true,
					minlength: 2
				},								
				txEmpresa:{
					required:true,
					minlength: 2
				},				
				txEmail:{
					required:true,	
					email: true
				}				
			},
			messages:{
				txNome:{
					required: "Digite seu nome",
					minlenght: "Nome deve conter no mínimo 2 caracteres"
				},
				txEmpresa:{
					required: "Digite o nome da empresa",
					minlength: "Nome da Empresa deve conter no mínimo 2 caracteres"
				},				
				txEmail:{
					required: "Digite um email",	
					email: "Digite um endereço de email válido"
				}
			}
		});
		
		// * Contato
		$("#formContato").validate({
		errorLabelContainer:"#boxErros ul",
			wrapper: "li",						   
		rules:{
				txNome:{
					required:true,
					minlength: 2
				},								
				txEmpresa:{
					required:true,
					minlength: 2
				},
				txTelefone:{
					required:true
				},
				txEmail:{
					required:true,	
					email: true
				}				
			},
			messages:{
				txNome:{
					required: "Digite seu nome",
					minlenght: "Nome deve conter no mínimo 2 caracteres"
				},
				txEmpresa:{
					required: "Digite o nome da empresa",
					minlength: "Nome da empresa deve conter no mínimo 2 caracteres"
				},
				txTelefone:{
					required: "Digite um telefone para contato"
				},
				txEmail:{
					required: "Digite um email",	
					email: "Digite um endereço de email válido"
				}
			}
		});	
		
		// * Box validação email
		$("#formContato, #formOrcamento").submit(function(){
			var valido = $(this).valid();
			if(valido == false)
			{
				$("#boxErros").css("display","block");
			}
		});	
		
		// * Máscara para telefone
		$("#formContato #txTelefone, #formOrcamento #txTelefone, #formTrabalhe #txTelefoneResidencial, #formTrabalhe #txTelefoneCelular").mask("(99) 9999-9999");
		
		// * Máscara para CEP
		$("#formTrabalhe #txCEP").mask("99.999-999");
		
		// * Mega Drop-down menu
        function megaHoverOver(){
            $(this).find(".sub").stop().fadeTo('fast',1).show();
			$(this).find(".sub").parent().children("a").addClass("ativo");
        }
        function megaHoverOut(){ 
			$(this).find(".sub").stop().fadeTo('fast',0,function() {
				$(this).parent().children("a").removeClass("ativo");
				$(this).hide();
			});
        }
        var config = {    
             sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)    
             interval: 100, // number = milliseconds for onMouseOver polling interval    
             timeout: 500, // number = milliseconds delay before onMouseOut 
             over: megaHoverOver, // function = onMouseOver callback (REQUIRED)    
             out: megaHoverOut // function = onMouseOut callback (REQUIRED)    
        };
        $("nav li").hoverIntent(config);
	
	});
	
	
