$(document).ready(function(){
    $('#cidade_newsletter').blur(function(){
        var valor = $(this).val();
        
        if(valor==''){
            $(this).val('Cidade');
        }
    });
    
    $('#cidade_newsletter').focus(function(){
        var valor = $(this).val();
        
        if(valor=='Cidade'){
            $(this).val('');
        }
    });


    $('#email_newsletter').blur(function(){
        var valor = $(this).val();
        
        if(valor==''){
            $(this).val('Email');
        }
    });
    
    $('#email_newsletter').focus(function(){
        var valor = $(this).val();
        
        if(valor=='Email'){
            $(this).val('');
        }
    });
    
    $('#enviar').click(function(){
        var nome = $('#nome_newsletter').val();
        var mail = $('#email_newsletter').val();
        var cidade = $('#cidade_newsletter').val();
        
        $.post('../ajax/newsletter.ajax.php',{
            nome:nome,
            mail:mail,
            cidade:cidade
        },function(res){
            if(res==1){
                alert('Você se cadastrou com sucesso, em breve receberá nossos newsletters!');
            }else{
                alert('Erro ao cadastrar, email já cadastrado!');
            }
        });
    });
    
    $('#nome_newsletter').blur(function(){
        var valor = $(this).val();
        
        if(valor==''){
            $(this).val('Nome');
        }
    });
    
    $('#nome_newsletter').focus(function(){
        var valor = $(this).val();
        
        if(valor=='Nome'){
            $(this).val('');
        }
    });
});
