
$(document).ready(function(){
	//$('#navegacao').css('height',$('#main').height());
	//$('#col-esq').css('height',$('#col-meio').height());
	
	
//	$(".troca").live("click",function(e) {
  //  e.preventDefault();
	
//	var v =$(this).attr('id');
	
//	$("#resultado").html("Carregando Dados");
//	$("#resultado").load("include/resultado_ajax.php?id="+v).animate({height: 'toggle', opacity: 'toggle'},"slow");
//	$("#resultado").animate({height:'toggle'});
	
//	})
	
	
	 $("a[rel^='blank']").attr("target","_blank");

	 $("a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'});
	 $("a[rel^='emconstrucao']").click(function(){alert("Área em construção."); return false;});
	 $("a[rel^='discurso']").click(function(){window.open('discurso.html','Discurso','width=600, height=500, scrollbars=yes, resizable=yes');return false;});
	 $("a[rel^='palavra']").click(function(){window.open('palavra.html','Discurso','width=600, height=500, scrollbars=yes, resizable=yes');return false;});

     $("#boleto2via").click(function(){window.open('http://www.acimderj.org.br/boleto.php','Impressão do Boleto','width=700, height=500, scrollbars=yes, resizable=yes');return false;});
     
     //$("#logos-associados a").easyTooltip();

     // validar email para contato e enviar :)

function validar_email(email) {
	er = /^[a-zA-Z0-9][a-zA-Z0-9\._-]+@([a-zA-Z0-9\._-]+\.)[a-zA-Z-0-9]{2}/;
	if(er.exec(email)) {
		return true;
		} else {
			return false;
	}
}

$("#enviar").live("click",function(e) {
 e.preventDefault();
 var campo="";

$('.campo_new').each(function () {

  if (this.title!='') {
  if (this.value=='') {
  alert('O campo  ' + this.name + '  esta vazio');
  $(this).css({ backgroundColor:"#ffffcc"}).focus();
   campo=1;
  return false;
}
if(this.name=="email") {

var email=$("#email").val();
 if (email == "") {
    alert("Digite seu e-mail");
    campo=1;
     $("#email").css({ backgroundColor:"#ffffcc"});
         // $("#email").focus();

     return false;
    }


}
}

$(this).css({ backgroundColor:"#efefef"});

})

if(campo!=1) {


jQuery.ajax({
type:"POST",
url:"mandar_email.php",
data:jQuery("#contato").serialize(),
success: function(msg){

if(msg==1) {
alert("Email Enviado com Sucesso");
jQuery("#sumi").animate({height: 'toggle', opacity: 'toggle'},"slow");
jQuery("#sumi").animate({height:'toggle'}).html("E-mail enviado com sucesso.");

}



}
});

}

campo="";

})


// validar usuario


$("#login_user").blur(function(){
if($(this).val() == ''){
$(this).val('Usuário');
}
});

$("#login_user").focus(function(){
if($(this).val() == 'Usuário'){
$(this).val('');
}
});

$("#senha").focus(function(){
if($(this).val() == 'Pesquisar'){
$(this).val('');
}
});


$("#logando_user").live("click",function(e) {
 e.preventDefault();
 var login_user  = $('#login_user').val();
 var senha       = $('#senha').val();
 

 
 /*if (!validar_email(login_user)) {
    alert("Por favor, digite um formato de e-mail válido");
    $("#login_user").addClass("input-invalido").focus();


     return false;
    }*/

    $("#login_user").removeClass("input-invalido");

    if(senha =='Pesquisar' || senha=="") {
    
    alert("Adicione seu login para validar");
    $("#senha").addClass("input-invalido").focus();
    
    return false;
    }

   $.ajax({

   type: "POST",

   url: "include/validar_user.php",

   data:jQuery("#logar_usuario").serialize(),

   success: function(msg){
   if(msg!=1) {
        alert( "Senha inválida, tente novamente.");
      return false;
     }
     //else {
      location.href='http://www.acimderj.org.br/restrito.php';

    // }

   //

   }

 });


 
 

 
 
 
 
 })

// final do validar usuario

     
     
     
     // final dessa parte de envio de email e validacao tambem



   $("#cidade-bairro").change(function (e) {

e.preventDefault();
if($(this).val() != ''){

var valor=$(this).val();

$("#cidade-produtos").html("Carregando Dados");
$('#cidade-produtos').load('ajax_lista.php?id='+valor);


}
	
});


$("#fazer_busca_interna").live("click",function(e) {
 e.preventDefault();
 
 if($("#cidade-bairro").val()=="") {
 
 alert(" O campo Cidade/Bairro na busca esta vazio");
 return false;
 }
 
// if($("#cidade-produtos").val()=="") {
 
// alert(" O campo Produtos oferecidos: na busca esta vazio");
// return false;
// }
 
 $("#form_pesquisa").submit();
});
	
	
	
	



	
	});

