var dataInfo = $('#komerce-container').data('info');

function ConfirmarRede(i) {
  location.href='' + dataInfo.redir + '&i='+ i;
}

$('#checkout-confirm').on('submit', function(e) {
  e.preventDefault();
  $(this).find('.ftr-steps__button').prop('disabled', true);
  var parcela = $('input[name="lista_parcelas_parcelado"]').val();
  if (parcela == '') {
    $('.ftr-notification').remove();
    notificationMsg("Selecione o valor desejado!", 'warning');
    return false;
  }
  var linha_pg = dataInfo.documento + "|" + dataInfo.telefone + "|" + parcela;
  window.open("app/komerci_form/gtw.php?i=" + linha_pg + "&pedido=" + dataInfo.order_id + "&hash=" + dataInfo.order_id_md5 + "&tipo=p","gateway","height=600,width=800,status=no,toolbar=no,menubar=no,location=no");
});

$('.ftr-js-card').on('click', function(e) {
  $('.ftr-js-card').removeAttr('style').removeClass('active');
  $(this).addClass('active').css('border', '2px solid #5CB85C');
  $('.ftr-js-card:not(.active)').css({'opacity': '.4', 'border': '2px solid #fff'});
  $('#komerce-container').find(".ftr-hidden").removeAttr('class');
  $.getJSON('app/komerci_form/get.parcelas.parcelado.php?id=' + $(this).data('card') + '&total=' + dataInfo.total + '&hash=' + dataInfo.total_md5 + '', function(data) {
    var items = '';
    $.each(data, function(key, val) {
      items += '<span class="ftr-select__content__item ftr-js-select__content__item ftr-js-ripple-effect" data-value="' + key + '">' + val + '</span>';
    });
    $('.ftr-js-lista-parcelas-parcelado').html(items);
  });
});
