$(function(){
/*		   
if ($.browser.msie && $.browser.version < 7){		   
   alert('Por favor utilize Internet Explorer 7 ou superior, ou MOZILLA FIREFOX'+$.browser.version);
   setTimeout('location="naoabre.php"',0);
}
*/
$(".plongo").hide();

$(".pcurto").click(function(){
		 $(this).next(".plongo").slideToggle(500);
		 $(this).toggleClass("pcurtoD"); 
		 return false;
   });//pcurto	

//**************************************
//TELA INICIAL
$("#btenviarcpf").click(function(){
			$("#dvcpf")
			      .empty()
			      .html("Por favor aguarde enquanto verificamos seu cpf em nosso cadastro")
				  .css({"background-color":"#FF0"});
  			  $.ajax({
				type: 'POST',
 				data: ({ttcpf: $("#txtcpf1").val()}),
				 url: 'vercre.php',	
			dataType: 'json', 
			 success: function(data){
				    
					if (data.tipo == 'ERRO') {
						$("#dvcpf").empty()
					    .html(data.message)
						.css({"background-color":"#F00"});
					} else {
						$("#dvcpf").empty()
					    .html(data.message)
						.css({"background-color":"#090"});
  					    setTimeout('location="?a=a"',0);

  				    } //if
			     } //sucesso
   				   }); //ajax
					  }); //botao
//*************************************
//BOTAO MAIS AJUDA
$("#btenviarajuda").click(function(){
			$("#dvajrsp").empty().html("Aguarde enviando seus dados");					   
  			var sen = $("#fmajuda").serialize();
			//alert(sen);
			   $.ajax({
				type: 'POST',
 				//data: ({tmsg: $("#txtmsgsms").val(), tdest: ssel}),
				data: sen,
				 url: 'ajuda/salvarfale.php',	
			dataType: 'json', 
			 success: function(data){
				    if (data.tipo == 'ERRO') {
						alert(data.message);
				        $("#dvajrsp").empty().html(data.message);
					} else {
						alert(data.message);
 			 	        $("#dvajrsp").empty().html(data.message);
						$("#txtajnm").val('');
	 					$("#txtajem").val('');
						$("#txtajtxt").val('');
					}
			     }
   				   });
});//bt

$("#txtcpf1").numeric();
$("#txtenumero").numeric();
$("#txtrnumero").numeric();
$("#txtecep").numeric();
$("#txtrcep").numeric();
$("#txtcnpj").numeric();
$("#txtddd").numeric();
$("#txttelefone").numeric();

//****************************************
//COPIANDO DADOS
$("#ckcopiar").click(function(){
			if (this.checked) {
				$('.cc').each(function(){
					var monta = this.name.replace('txte','txtr');
					$("#"+monta).val($(this).val());
									   })
			} else {
				$('.cc').each(function(){
					var monta = this.name.replace('txte','txtr');
					$("#"+monta).val("");
									   })
			    	
			}
});///ckcopiar

//*******************************************
//GRAVANDO OS DADOS PREENCHIDOS
$("#btgravarpreenche").click(function(){
			$("#btgravarpreenche").hide();
			$("#dvrscpftxt")
			      .empty()
			      .html("Por favor aguarde enquanto salvamos seus dados...");
			var dados = $("#fmPreenche").formSerialize();
			
  			$.post('salvarpreenche.php',dados, function(data){
					if (data.tipo == 'ERRO') {
						$("#dvrscpftxt").empty()
					    .html(data.message)
						.show();
						$("#dvrscpf").show();
					} else {
						setTimeout('location="?a=f"',0);
						/*
						$("#Tdvrscpftxt").empty()
					    .html(data.message)
   						.show();
						$("#Tdvrscpf").show();
						*/
  				    } //if
			     }, 'json'); //sucesso

}); //botao

$("#btfecharerro").click(function(){
		$("#dvrscpf").hide();
		$("#btgravarpreenche").show();
								  });

$("#btfecharT").click(function(){
		$("#Tdvrscpf").hide();
        setTimeout('location="?a=a"',0);

								  });

});//jq

