  // POP - UP
function abre() {
	document.getElementById("pop").style.display="block";
}

function sair() {
	document.getElementById("pop").style.display="none";
}

  // Carrosel de imagens
$(function(){
   $("#caixa").jCarouselLite({
	 btnNext: ".proximo",
	 btnPrev: ".anterior",
	 visible: 3,
	 speed: 500
   })
})

function popup(pagina, largura, altura) {
  // Definindo meio da tela
  var esquerda = (screen.width - largura)/2;
  var topo = (screen.height - altura)/2;

  // Abre a nova janela 
  window.open(pagina,'','height=' + altura + ', width=' + largura + ', top=' + topo + ', left=' + esquerda); 
}

// VALIDAÇÃO DE FORMULÁRIO

// Máscara
jQuery(function($){
	$("#celular").mask("(99) 9999-9999");
});

// Opção Celular
function opcao_celular(){
  document.getElementById("campo").style.display="none";
  document.getElementById("email").style.display="none";
  document.getElementById("celular").style.display="block";
}

// Opção E-mail
function opcao_email(){
  document.getElementById("campo").style.display="none";
  document.getElementById("celular").style.display="none";
  document.getElementById("email").style.display="block";
}

// Valida
function checa(name_form) {
	
		// Selecionar opção
		if (name_form.meio[0].checked || name_form.meio[1].checked) {
			opcao = "";
		} else {
		   opcao = "- Selecione uma opção!";
		   alert(opcao);
		   return false
		}
		
		// Validação Campo Celular
		if (name_form.meio[1].checked && name_form.cel.value == '') {
			valor = "- Digite o número do celular";
			alert(valor);
			return false
		} else {
			valor = "";
		}
		
		// Validação Campo E-mail
		if (name_form.meio[0].checked && name_form.ml.value == '') {
			valor = "- Digite o e-mail";
			alert(valor);
			return false
		}
		
		// Verificação de e-mail válido
		if(name_form.meio[0].checked && (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.name_formulario.ml.value)))) {
			valor = "- O campo e-mail deve ser um endereco eletrônico!";
			alert(valor);
			return false;
		}
		
		// Resultado Final
		if (valor == "") {
		   resultado = "";
		} else {
		   resultado = valor;
		   alert(resultado);
		   return false
		}

		//submete formulário	
		document.name_formulario.operacao.value = 1;
		document.name_formulario.submit();
}
