EnableUFOrigem = function(Value)
{
    $("#origem_local,#destino_uf,#destino_local").each(function()
    {
       $(this).attr('disabled','disabled').val('');
    });
    
    if (Value != '')
        $.ajax({
          url:'plugins/others/support.php',
          data:'Action=GetLocal&Estado=' + Value,
          cache:false,  
          success:function(ValuesHtml)
          {
            $("#origem_local").html(ValuesHtml).removeAttr('disabled');
          }  
        });
}

EnableEstadoDestino = function(Value)
{
    $("#destino_uf,#destino_local").each(function()
    {
       $(this).attr('disabled','disabled').val('');
    });    
    if (Value != '')
        $.ajax({
          url:'plugins/others/support.php',
          data:'Action=GetEstadoDestino&Estado=' + $("#origem_uf").val(),
          cache:false,  
          success:function(ValuesHtml)
          {
            $("#destino_uf").html(ValuesHtml).removeAttr('disabled');
          }  
        });    
}

EnableLocalDestino = function(Value)
{
    $("#destino_local").attr('disabled','disabled').val('');
    if (Value != '')
      $.ajax({
          url:'plugins/others/support.php',
          data:'Action=GetLocal&Estado=' + Value,
          cache:false,  
          success:function(ValuesHtml)
          {
            $("#destino_local").html(ValuesHtml).removeAttr('disabled');
          }  
       });
}

GetCidades = function(Value)
{
    $("#cidade").attr('disabled','disabled').html('<option value="">--</option>');
    if (Value != '')
      $.ajax({
          url:'plugins/others/support.php',
          data:'Action=GetCidades&Estado=' + Value,
          cache:false,  
          success:function(ValuesHtml)
          {
            $("#cidade").html(ValuesHtml).removeAttr('disabled');
          }  
       });    
}

CheckCotacao = function(Form)
{
    Resultado = CheckDataForm(Form);
    if (Resultado)
    {
      Resultado = ($("#PF:checked,#PJ:checked").size() == 1);
      if (!Resultado)
      {
        $("#PF").focus();
        alert('Escolha o tipo de pessoa nos dados da empresa');
      }
      else
      {
          Resultado = ($(".chTipoFrete:checked").size() == 1);
          if (!Resultado)
          {
            $("#Tipo_Frete").focus();
            alert('Escolha o tipo de frete');
          }
          else
          {
              Resultado = ($(".chInflamavel:checked").size() == 1);
              if (!Resultado)
              {
                $("#Inflamavel").focus();
                alert('Informe o tipo de material');
              }
          }
      }
         
    }
    return Resultado;
}

CheckCurriculos = function(Form)
{
    Resultado = CheckDataForm(Form);
    if (Resultado)
    {
      Resultado = ($(".classSexo:checked").size() == 1);
      if (!Resultado)
      {
        $("#sexo").focus();
        alert('Preencha o sexo corretamente');
      }
      else
      {
          Resultado = Resultado = CheckPrimeiroEmprego();
          if (Resultado)
            { 
              Resultado = ($(".classDispViajar:checked").size() == 1);
              if (!Resultado)
              {
                $("#dispViajar").focus();
                alert('Informe a disponibilidade para viagens');
              }
              else
              {
                  Resultado = ($(".classDispMudar:checked").size() == 1);
                  if (!Resultado)
                  {
                    $("#dispMudar").focus();
                    alert('Informe a disponibilidade para mudar de residencia');
                  }
              }
          }
      }
         
    }
    return Resultado;
}

CheckPrimeiroEmprego = function()
{
   Retorno = true;
   var Field;
   $(".RequiredPrimeiroEmprego").removeClass('ErrorField');
   if ($(".CheckPrimeiroEmprego:checked").hasClass('Yes'))
     return true;
   
   $(".RequiredPrimeiroEmprego").each(function() {
        chkCampo = ($(this).val() != '');
        if (chkCampo && $(this).hasClass('Email'))
          chkCampo = ($(this).val().indexOf('@') > 0);
          
        Retorno = Retorno && chkCampo;
        if (!chkCampo)
        {
          $(this).addClass('ErrorField');
          if (!Field)
            Field = $(this);
        }
    })
  
   if (!Retorno)
   {
      alert('Preencha os campos corretamente.')
      Field.focus();
   }

   return Retorno;
}
