// VALIDANDO FORMULARIO DE SOLICITAÇÃO SERVER
/*
function validaForm(){
	d = document.server_cotacao;
	if (d.nome.value == ""){
		alert("O campo NOME deve ser preenchido!");
		d.nome.focus();
		return (false);
	}
	if (d.email.value == ""){
		alert("O campo E-MAIL deve ser preenchido!");
		d.email.focus();
		return (false);
	}
	if (d.ddd.value == ""){
		alert ("O campo DDD deve ser preenchido!");
		d.ddd.focus();
		return (false);
	}
	if (d.telefone.value == ""){
		alert ("O campo TELEFONE deve ser preenchido!");
		d.telefone.focus();
		return (false);
	}
	if (d.qde_maquinas.value == ""){
		alert ("O campo QUANTIDADE DE MAQUINAS deve ser preenchido!");
		d.qde_maquinas.focus();
		return (false);
	}
	return (true);
}*/
$(document).ready(function(){
	$("#server_cotacao").submit(function(){
		var nome  = $("#nome").val();
		var email = $("#email").val();
		var ddd = $("#ddd").val();
		var telefone = $("#telefone").val();
		var qde_maquinas = $("#qde_maquinas").val();
		
		if(nome == ""){
			alert("Insira um NOME para contato!");
			$("#nome").focus();
			return false;
		}
		if(email != ""){
			var filtro = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
			if(filtro.test(email)){
			} else {
				alert("Este endereço de email não é válido!");
				$("#email").focus();
				return false;
			}
		} else {
			alert('Digite seu EMAIL para contato!');
			$("#email").focus();
			return false;
		}
		if(ddd == ""){
			alert("Informe seu DDD!");
			$("#ddd").focus();
			return false;
		}
		if(telefone == ""){
			alert("Insira um número de TELEFONE para contato!");
			$("#telefone").focus();
			return false;
		}
		if(qde_maquinas == ""){
			alert("Defina a QUANTIDADE DE MAQUINAS!");
			$("#qde_maquinas").focus();
			return false;
		}
	return true;
	});
});
/*
function checkMail(){
  var obj = eval("document.forms[0].email");
  var txt = obj.value;
  if (txt.indexOf("@") == -1 || txt.indexOf(".") == -1)
  //if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7)))
  {
    alert('Email incorreto');
	obj.focus();
  }
}
*/
function numero(e){
	var tecla;  
  	if (e.keyCode) { // IE  
    	tecla = e.keyCode;  
  	}  
  	else if (e.which) { // Firefox  
    	tecla = e.which;  
  	}  
  	else { 
    	return false;  
  	}  
  	return !(tecla < 48 || tecla > 57);  
}
function minuscula(z){
	v = z.value.toLowerCase();
	z.value = v;
}

//enviar email para o BD
function getXmlHttp() {
var xmlhttp;
try{
 xmlhttp = new XMLHttpRequest();
}catch(ee){
 try{
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 }catch(e){
  try{
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }catch(E){
    xmlhttp = false;
  }
 }
}
return xmlhttp;
} 

//Collapsible Panel
function collapsible(){
    $(".CollapsiblePanelTab").map(function(){
    if (!$(this).hasClass("open"))
            $(this).next(".CollapsiblePanelContent").hide();
  });

    $(".CollapsiblePanelTab").click(
        function(e){
            var content = $(this).next(".CollapsiblePanelContent");

            if (content.is(':visible')){
                content.slideUp();
                $(e.target).removeClass('open');
            } else {
                content.slideDown();
                $(e.target).addClass('open');
            }
        }
    );

}
// politica de privacidade
function abrir(URL) {
  var width = 500;
  var height = 550;
  var left = 99;
  var top = 99;
  window.open(URL,'janela', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}

// lightbox initialize script -->
$(function() {
   $('a.lightbox').lightBox();
});

// TOP SEARCH 
$('#s').focus(function() {
		$(this).animate({width: "215"}, 300 );	
		$(this).val('')
});

$('#s').blur(function() {
		$(this).animate({width: "100"}, 300 );
		$(this).val('procurar');
});

// ajax contact form -->
$(document).ready(function(){
  $('#contact').ajaxForm(function(data) {
	 if (data==1){
		 $('#success').fadeIn("slow");
		 $('#bademail').fadeOut("slow");
		 $('#badserver').fadeOut("slow");
		 $('#contact').resetForm();
		 }
	 else if (data==2){
			 $('#badserver').fadeIn("slow");
		  }
	 else if (data==3)
		{
		 $('#bademail').fadeIn("slow");
		}
		});
	 });
// dropdown setup 
$(document).ready(function(){ 
	$("ul.sf-menu").superfish({
		delay:       200,                             // one second delay on mouseout 
		animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
		speed:       'fast',                          // faster animation speed 
		autoArrows:  true,                           // disable generation of arrow mark-up 
		dropShadows: true                            // disable drop shadows 			
		}); 
});

//sliding boxes

$(document).ready(function(){
		//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
		//Vertical Sliding
		$('.boxgrid.slidedown').hover(function(){
			$(".cover", this).stop().animate({top:'-260px'},{queue:false,duration:300});
		}, function() {
			$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
		});
		//Horizontal Sliding
		$('.boxgrid.slideright').hover(function(){
			$(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});
		}, function() {
			$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});
		});
		//Diagnal Sliding
		$('.boxgrid.thecombo').hover(function(){
			$(".cover", this).stop().animate({top:'260px', left:'325px'},{queue:false,duration:300});
		}, function() {
			$(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});
		});
		//Partial Sliding (Only show some of background)
		$('.boxgrid.peek').hover(function(){
			$(".cover", this).stop().animate({top:'90px'},{queue:false,duration:160});
		}, function() {
			$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
		});
		//Full Caption Sliding (Hidden to Visible)
		$('.boxgrid.captionfull').hover(function(){
			$(".cover", this).stop().animate({top:'180px'},{queue:false,duration:160});
		}, function() {
			$(".cover", this).stop().animate({top:'250px'},{queue:false,duration:160});
		});
		//Caption Sliding (Partially Hidden to Visible)
		$('.boxgrid.caption').hover(function(){
			$(".cover", this).stop().animate({top:'180px'},{queue:false,duration:160});
		}, function() {
			$(".cover", this).stop().animate({top:'250px'},{queue:false,duration:160});
		});
	});

