jQuery(logarAutoload);

function logarAutoload(){
    $("#ClienteEnderecoDeEntregaCep").mask('99999-999');
    $("#NaoSouClienteLogarForm").submit(naoSouClienteSubmit);
}

function naoSouClienteSubmit(){
    var form = $(this);
    if (!validaNaoSouClienteForm(form))
        return false;
    
    return true;
}
function validaNaoSouClienteForm(form){
    var obj = null;
    var msg = '';
    
    var cep = form.find('#ClienteEnderecoDeEntregaCep');
    if (jQuery.trim(cep.val()) == ''){
        msg += "O CEP é obrigatório!\n";
        obj = obj == null ? cep : obj;
    }
    
    var tipo = form.find('[name="data[Cliente][tipo]"]:checked');
    if (tipo.size() == 0){
        msg += "Selecione o tipo de cadastro!\n";
    }
    
    if (msg === ''){
        return true;
    } else {
        alert(msg);
        if (obj)
            obj.focus();
        return false;
    }
}
