//carousel imoveis
$(document).ready(function(){
	$('#slide-clientes .content-slide-clientes').cycle({
		fx:   		'scrollHorz',
		prev: 		'#slide-clientes .anterior',
		next: 		'#slide-clientes .proximo',
        speed:  1400,
		timeout: 4500

	});
	
});

$(document).ready(function(){
	$('#portfolio .content-portfolio-lojas').cycle({
		fx:   		'scrollHorz',
		prev: 		'#portfolio .anterior-port',
		next: 		'#portfolio .proximo-port',
        speed:  1500,
		timeout: 0

	});
	
});


$(document).ready(function(){
	$('#topo #slide-topo ul').cycle({
		fx:   		'fade',
        timeout: 4500,
         pager:  '#pager-slide' 

	});
	
});

//fades
	$(function($) {
  $('.logo h1, #slide-clientes .anterior a, #slide-clientes .proximo a, #rodape .conteudo-rodape .links-e-newsletter .newsletter .btn_newsletter, #topo #slide-topo #pager-slide a, .area-do-cliente a, #contato .btn_enviar, .anterior-port, .proximo-port, #ligamos, #form-ligamos .btn_enviar, .sociais a, #video-aulas p a, #sex-shop-virtual a, .img-adquira').hover(function() {
    $(this).animate({opacity:0.7}, {queue:false, duration:400});
  }, function() {
    $(this).animate({opacity:1}, {queue:false, duration:400});
  });
});


//colorbox

		$(document).ready(function(){
			//Examples of how to assign the ColorBox event to elements
			$("a[rel='example1']").colorbox();
			$("a[rel='fotos']").colorbox({transition:"fade"});
			$("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
			$("a[rel='example4']").colorbox({slideshow:true});
			$(".example5").colorbox();
			$(".abre-video-aula").colorbox({iframe:true, innerWidth:625, innerHeight:400});
			$(".boleto").colorbox({width:"780px", height:"550px", iframe:true});
			$(".abre-depoimento").colorbox({width:"550px", inline:true, href:"#ver-depoimento"});
			
			$(".abre-depoimento-2").colorbox({width:"550px", inline:true, href:"#ver-depoimento-2"});
			$("#ligamos").colorbox({width:"372px", height:"545px", inline:true, href:"#form-ligamos"});
			$(".abre-promocao").colorbox({inline:true, href:"#promocao"});
			$(".example9").colorbox({
				onOpen:function(){ alert('onOpen: colorbox is about to open'); },
				onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
				onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
				onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
				onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
			});
			
			//Example of preserving a JavaScript event for inline calls.
			$("#click").click(function(){ 
				$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
				return false;
			});
		});
	
// validate newsletter	
$(document).ready( function() {
	$("#formNewsletter").validate({
		rules:{
			nome:{
				required: true
			},
			email:{
				required: true, email: true
			}

		},

		messages:{

			nome:{
				required: "Digite o seu nome"
			},
			email:{
				required: "Digite o seu e-mail",
				email: "Digite um e-mail válido"
			},

		}
	});
});

// validate contato		
$(document).ready( function() {
	$("#formContato").validate({
		rules:{
			nome:{
				required: true
			},
			email:{
				required: true, email: true
			},
			assunto:{
				required: true
			},
			mensagem:{
				required: true
			},
		},

		messages:{

			nome:{
				required: "Digite o seu nome"
			},
			email:{
				required: "Digite o seu e-mail",
				email: "Digite um e-mail válido"
			},
			assunto:{
				required: "Digite um assunto"
			},
			mensagem:{
				required: "Digite uma mensagem"
			}

		}
	});
});

// validate ligação
$(document).ready( function() {
	$("#formLigacao").validate({
		rules:{
			nome:{
				required: true
			},

			telefone:{
				required: true,
				minlength: 10
			}

		},

		messages:{

			nome:{
				required: "Digite o seu nome"
			},
			ddd:{
				required: "Digite o seu DDD",
				minlength: "Digite corretamente"
				
			},
			telefone:{
				required: "Digite o seu telefone",
				minlength: "Digite corretamente"
				
			},

		}
	});
});

$(document).ready(function(){

// Imagens portfolio

$("#portfolio li").hover(function() {
	$(this).css({'z-index' : '10'});
	$(this).find('img').addClass("hover").stop()
		.animate({
			marginTop: '0px', 
			marginLeft: '0px', 
			top: '12%', 
			left: '0', 
			width: '156px', 
			height: '100px',
			padding: '0px' 
		}, 400);
	
	} , function() {
	$(this).css({'z-index' : '0'});
	$(this).find('img').removeClass("hover").stop()
		.animate({
			marginTop: '0', 
			marginLeft: '0',
			top: '0', 
			left: '0', 
			width: '156px', 
			height: '100px', 
			padding: '0px'
		}, 400);
});
});

function masc_inputs(w,e,m,r,a){
        
        // Cancela se o evento for Backspace
        if (!e) var e = window.event
        if (e.keyCode) code = e.keyCode;
        else if (e.which) code = e.which;
        
        // Variáveis da função
        var txt  = (!r) ? w.value.replace(/[^\d]+/gi,'') : w.value.replace(/[^\d]+/gi,'').reverse();
        var mask = (!r) ? m : m.reverse();
        var pre  = (a ) ? a.pre : "";
        var pos  = (a ) ? a.pos : "";
        var ret  = "";

        if(code == 9 || code == 8 || txt.length == mask.replace(/[^#]+/g,'').length) return false;

        // Loop na máscara para aplicar os caracteres
        for(var x=0,y=0, z=mask.length;x<z && y<txt.length;){
                if(mask.charAt(x)!='#'){
                        ret += mask.charAt(x); x++;
                } else{
                        ret += txt.charAt(y); y++; x++;
                }
        }
        
        // Retorno da função
        ret = (!r) ? ret : ret.reverse()        
        w.value = pre+ret+pos;
}

