﻿/* ===========================================================================
CODIGO JAVASCRIPT DO CADASTRO DE ATENDIMENTO
PROGRAMADOR: MARCÍLIO CANEDO GONÇALVES
DATA: 08/03/2007
ULTIMA REVISAO: 22/02/7 14:12 [MARCÍLIO CANEDO GONÇALVES]
============================================================================ */

function AjaxSave()
{
    var atendimento = ajaxNameSpace.AjaxGetClass();
    var nuLogradouro = "";
    if(document.getElementById("txt_nuLogradouro").value != '')
        nuLogradouro = document.getElementById("txt_nuLogradouro").value
    else
        nuLogradouro = -1;
    
    atendimento.cdAtendTipo = ddl_cdAtendTipo.value;
    atendimento.cdAtendAssunto = ddl_cdAtendAssunto.value;
    atendimento.dsAtendimento = txt_dsAtendimento.value;
    atendimento.nmRemetente = txt_nmRemetente.value;
    atendimento.edMail = txt_edMail.value;
    atendimento.nuTelefonePref = txt_nuTelefonePref.value;
    atendimento.nuTelefone = txt_nuTelefone.value;
    atendimento.nmPais = txt_nmPais.value;
    atendimento.nmUF = txt_nmUF.value;
    atendimento.nmCidade = txt_nmCidade.value;
    atendimento.nmBairro = txt_nmBairro.value;
    atendimento.nmLogradouro = txt_nmLogradouro.value;
    atendimento.nuLogradouro = nuLogradouro;
    atendimento.dsComplemento = txt_dsComplemento.value;
    atendimento.nuCEP = txt_nuCEP.value;    
    
    ajaxNameSpace.Save(atendimento, 
        function(res)
        {   
            Message.Hide();
            if(res.error != null) // em caso de erro
            {
                document.getElementById("resposta_erro").style.display = "block";
                document.getElementById("dados").style.display = "none";
                
            }
            else // em caso de sucesso
            {
                document.getElementById("resposta_ok").style.display = "block";
                document.getElementById("dados").style.display = "none";
            }
        }
    );
}

function Load_cdAtendAssunto()
{
    if((document.getElementById('ddl_cdAtendTipo').value != "")&&(document.getElementById('ddl_cdAtendTipo').value != null)&&(document.getElementById('ddl_cdAtendTipo').value != -1))
    {
        DropDownListBuilder.Load(document.getElementById('ddl_cdAtendAssunto'), 'ate_env', 'AjaxLoad_cdAtendAssunto', 'NMATENDASSUNTO', 'CDATENDASSUNTO', null, document.getElementById('ddl_cdAtendTipo').value, true);
    }
    else
    {
        document.getElementById('ddl_cdAtendAssunto').disabled  = true;
    }
}
