// INPUT
$(document).ready(function(){
	// TARGET _blank
	$('a[rel=blank]').click(function(){
		window.open(this.href);
		return false;
	});
	// INPUT
	if ($('.input-news, .input-restrita, .textarea, .input').val() != ''){
		$(this).prev().hide();
	}
	$('.input-news, .input-restrita, .textarea, .input').focusin(function(){
		$(this).prev().hide();
	}).focusout(function(){
		if ($(this).val() == ''){
			$(this).prev().show();
		}
	});
	
	$(".fadehover").hover(
		function() {
			$(this).find('.mask').stop().fadeTo('fast','1',function(){
			});
		},
		function() {
			$(this).find('.mask').stop().fadeTo('slow','0');
		}
	);


});

 

// FUNÇÕES GERAIS
function selecionar(ele){
	var ele = $(ele);
	var val = ele.find('option:selected').attr('label');
	ele.prev().val(val);
}



function cidadesUpdate(obj){
	 $('#cidades').empty();
	 var valor = $(obj).val()
	 $.post("../ajax/_busca_cidades.php", { sigla: valor },
	 function(data) {
	   	$('#cidades').append(data);
	 }, 
	 "html"
	);
}



function validaContato() {

    var nome =  $('#nome').val();
	if(nome == "" || nome == " " || nome == "Nome*") {
		jAlert('Por favor, preencha o campo Nome');
		$('#nome').focus();
		return false;
	}

    var email =  $('#email').val();
	if(email == "" || email == " " || email == "Email*") {
		jAlert('Por favor, preencha o campo Email');
		$('#email').focus();
		return false;
	}

    var telefone =  $('#telefone').val();
	if(telefone == "" || telefone == " " || telefone == "Telefone*") {
		jAlert('Por favor, preencha o campo Telefone');
		$('#telefone').focus();
		return false;
	}


	var assunto =  $('#assunto').val();
	if(assunto == "" || assunto == " " || assunto == "Assunto") {
		jAlert('Por favor, Selecione o Assunto');
		$('#assunto').focus();
		return false;
	}


    var mensagem =  $('#mensagem').val();
	if(mensagem == "" || mensagem == " " || mensagem == "Mensagem*") {
		jAlert('Por favor, digite sua Mensagem');
		$('#mensagem').focus();
		return false;
	}

}


function validaNews() {

	var news =  $('#news').val();
	
	if(news == "" || news == " " || news == "Digite seu email") {
		jAlert('Por Favor, Preencha Seu Email');
		$('#news').focus();
		return false;
	}
		
	$.post("../ajax/recebeNews.php", { news:news },
	 function(data){
     if (data.enviado != '1') {
		 jAlert('Email j\u00e1 existente. Por Favor, digite outro Email');
		 return false;
	 }else{
		document.formnews.submit(); 
	 }
	 }, "json");
	 
	 return false;
	
}


function validaReserva() {

    var razao =  $('#razao').val();
	if(razao == "" || razao == " " || razao == "Raz\u00e3o Social") {
		jAlert('Por favor, preencha o campo Raz\u00e3o Social');
		$('#razao').focus();
		return false;
	}

    var cnpj =  $('#cnpj').val();
	if(cnpj == "" || cnpj == " " || cnpj == "CNPJ") {
		jAlert('Por favor, preencha o campo CNPJ');
		$('#cnpj').focus();
		return false;
	}



	var ie =  $('#ie').val();
	if(ie == "" || ie == " " || ie == "Incri\u00e7\u00e3o estadual") {
		jAlert('Por favor, Selecione A Incri\u00e7\u00e3o estadual');
		$('#ie').focus();
		return false;
	}
	
	
    var endereco =  $('#endereco').val();
	if(endereco == "" || endereco == " " || endereco == "Endere\u00e7o") {
		jAlert('Por favor, preencha o campo Endere\u00e7o');
		$('#endereco').focus();
		return false;
	}


    var cep =  $('#cep').val();
	if(cep == "" || cep == " " || cep == "CEP") {
		jAlert('Por favor, preencha o CEP');
		$('#cep').focus();
		return false;
	}

  
    var telefone =  $('#telefone').val();
	if(telefone == "" || telefone == " " || telefone == "Telefone") {
		jAlert('Por favor, preencha o Telefone');
		$('#telefone').focus();
		return false;
	}


    var estado =  $('#estado').val();
	if(estado == "" || estado == " " || estado == "Estado") {
		jAlert('Por favor, selecione o Estado');
		$('#estado').focus();
		return false;
	}


    var cidade =  $('#cidade').val();
	if(cidade == "" || cidade == " " || cidade == "Cidade") {
		jAlert('Por favor, selecione a Cidade');
		$('#cidade').focus();
		return false;
	}


    var email =  $('#email').val();
	if(email == "" || email == " " || email == "Email") {
		jAlert('Por favor, preencha o Email');
		$('#email').focus();
		return false;
	}


    var pessoa =  $('#pessoa').val();
	if(pessoa == "" || pessoa == " " || pessoa == "Pessoa para contato") {
		jAlert('Por favor, informe uma pessoa para contato');
		$('#pessoa').focus();
		return false;
	}


    var interesse =  $('#interesse').val();
	if(interesse == "" || interesse == " " || interesse == "Interessa em metros quadrados") {
		jAlert('Por favor, informe o valor de metros de seu interesse');
		$('#interesse').focus();
		return false;
	}



    var contato =  $('#contato').val();
	if(contato == "" || contato == " ") {
		jAlert('Por favor, informe a forma de contato');
		$('#contato').focus();
		return false;
	}


    var mensagem =  $('#mensagem').val();
	if(mensagem == "" || mensagem == " " || mensagem =="Mensagem") {
		jAlert('Mensagem Vazia');
		$('#mensagem').focus();
		return false;
	}


}





