
window.width = 200;
$(document).ready(function(){	
	$(".slide").cycle({
		timeout:  5000,
		fx: 'scrollHorz',
		pager:  '#nav',
		pagerAnchorBuilder: function(idx, slide) {       
        return '#nav li:eq(' + (idx) + ') a';
   		}
	});
	
	$(".jqzoom").jqzoom({
		//tipo da lente (standard ou reverse)
		zoomType: "reverse",
		zoomWidth: 200, //largura da janela de zoom
		zoomHeight: 200, //altura da janela de zoom
		xOffset: 30, //distancia no eixo X entre a imagem e o zoom
		yOffset: -60, //distancia no eixo Y entre a imagem e o zoom
		lens: true, //opção para mostrar ou não a lente
		imageOpacity: 0.5, //opacidade da imagem
		title: false, //opção para esconder o título do zoom
		showEffect: "fadein", //efeito para mostrar o zoom
		fadeinSpeed: 400, //velocidade para mostrar o zoom
		hideEffect: "fadeout", //efeito para esconder o zoom
		fadeoutSpeed: 200, //velocidade para esconder o zoom
		preloadText: "Carregando" //texto do preloader
	});
	
	$(function($){
		$("#telefone").mask("(99) 9999-9999");		
	});
	
	$("#area_vip").validate({
		submitHandler: function() {		
			var dados = $("#area_vip").serialize();						
						
			$.ajax({
				url: "admin/autentica.php",
				type: "POST",
				data: dados,
				success: function(resposta) {					
					if(resposta == 1) {
						document.location = 'admin/painel.php';			
					}
				},
				error: function(requisicao) {
					alert("Erro: "+requisicao.statusText);
				}
			});
			
			return false;
		}	
	});		
		
	$(".carregando").hide();
	$("#email_msg").hide();
	$("#sucesso_msg").hide();	
	
	$("#faleconosco").validate({			
		submitHandler: function() {
			$(".carregando").ajaxStart(function(){
				$(this).show();			
			});
	    	
			$(".carregando").ajaxStop(function(){
				$(this).hide();			
			});
			
			var dados = $("#faleconosco").serialize();					
			
			$.ajax({
				url: "class/Faleconosco/FaleconoscoControl.php",
				type: "POST",
				data: dados,
				success: function(resposta) {							
					if(resposta == 1) {								
						$("#sucesso_msg").show();
						setTimeout(function(){
							$("#sucesso_msg").fadeOut(1000);
							$("#faleconosco").resetForm();
						}
						, 2000);
						
						
					}else if(resposta == 2) {
						$("#email_msg").show();
						setTimeout(function(){
							$("#email_msg").fadeOut(1000);}
						, 2000);
					}
				},
				error: function(requisicao) {
					alert("Erro: "+requisicao.statusText);
				}
			});		
			return false;
		}
	});
	
	
	$(".carregando_assistencia").hide();
	$("#email_assistencia").hide();
	$("#fone_assistencia").hide();
	$("#sucesso_assistencia").hide();
	
	$("#assistencia").validate({			
		submitHandler: function() {
			$(".carregando_assistencia").ajaxStart(function(){
				$(this).show();			
			});
	    	
			$(".carregando_assistencia").ajaxStop(function(){
				$(this).hide();			
			});
			
			var dados = $("#assistencia").serialize();					
			
			$.ajax({
				url: "class/Assistencia/AssistenciaControl.php",
				type: "POST",
				data: dados,
				success: function(resposta) {							
					if(resposta == 1) {								
						$("#sucesso_assistencia").show();
						setTimeout(function(){
							$("#sucesso_assistencia").fadeOut(1000);
							$("#assistencia").resetForm();
						}
						, 2000);												
					}else if(resposta == 2) {
						$("#email_assistencia").show();
						setTimeout(function(){
							$("#email_assistencia").fadeOut(1000);}
						, 2000);
					}else if(resposta == 3) {
						$("#fone_assistencia").show();
						setTimeout(function(){
							$("#fone_assistencia").fadeOut(1000);}
						, 2000);
					}
				},
				error: function(requisicao) {
					alert("Erro: "+requisicao.statusText);
				}
			});		
			return false;
		}
	});
	
	
	$(".carregando_vip").hide();
	$("#vazio_usuario").hide();
	$("#vazio_senha").hide();
	$("#erro").hide();
	
	$("#areavip").validate({			
		submitHandler: function() {
			$(".carregando_vip").ajaxStart(function(){
				$(this).show();			
			});
	    	
			$(".carregando_vip").ajaxStop(function(){
				$(this).hide();			
			});
			
			var dados = $("#areavip").serialize();					
			
			$.ajax({
				url: "admin/autentica.php",
				type: "POST",
				data: dados,
				success: function(resposta) {							
					if(resposta == 1) {								
						document.location = 'admin/painel.php';												
					}else if(resposta == 3) {
						$("#vazio_usuario").show();
						setTimeout(function(){
							$("#vazio_usuario").fadeOut(1000);}
						, 2000);
					}else if(resposta == 5) {
						$("#vazio_senha").show();
						setTimeout(function(){
							$("#vazio_senha").fadeOut(1000);}
						, 2000);
					}else if(resposta == 4) {
						$("#erro").show();
						setTimeout(function(){
							$("#erro").fadeOut(1000);}
						, 2000);
						$("#areavip").resetForm();
					}
				},
				error: function(requisicao) {
					alert("Erro: "+requisicao.statusText);
				}
			});		
			return false;
		}
	});
	
	
	$(".carregando_orcamento").hide();
	$("#email_orcamento").hide();
	$("#fone_orcamento").hide();
	$("#sucesso_orcamento").hide();
	
	$("#orcamento").validate({			
		submitHandler: function() {
			$(".carregando_orcamento").ajaxStart(function(){
				$(this).show();			
			});
	    	
			$(".carregando_orcamento").ajaxStop(function(){
				$(this).hide();			
			});
			
			var dados = $("#orcamento").serialize();					
			
			$.ajax({
				url: "class/Produtos/ProdutosControl.php",
				type: "POST",
				data: dados,
				success: function(resposta) {							
					if(resposta == 1) {								
						$("#sucesso_orcamento").show();
						setTimeout(function(){
							$("#sucesso_orcamento").fadeOut(1000);}
						, 2000);
						$("#orcamento").resetForm();									
					}else if(resposta == 2) {
						$("#email_orcamento").show();
						setTimeout(function(){
							$("#email_orcamento").fadeOut(1000);}
						, 2000);						
					}else if(resposta == 3) {
						$("#fone_orcamento").show();
						setTimeout(function(){
							$("#fone_orcamento").fadeOut(1000);}
						, 2000);						
					}
				},
				error: function(requisicao) {
					alert("Erro: "+requisicao.statusText);
				}
			});		
			return false;
		}
	});
	
	$(".lightbox").lightBox({
		overlayBgColor: "#404040",
		overlayOpacity: 0.8,
		containerResizeSpeed: 200,
		keyToPrev: 'a',
		keyToNext: 'p',
		txtImage: "Imagem",
		txtOf: "de",
		imageBtnClose: "recursos/imagens/lightbox-btn-close.gif",
		imageLoading: "recursos/imagens/lightbox-ico-loading.gif",
		imageBtnPrev: "recursos/imagens/lightbox-btn-prev.gif",
		imageBtnNext: "recursos/imagens/lightbox-btn-next.gif",
		fixedNavigation: true,
		keyToClose: "f"
	});
});
