$(document).ready(function () {
  $('#confirmDialog input.confirm, #confirmDialog a.confirm').click(function (e) {
    e.preventDefault();

    confirm("J'ai lu et j'accepte les conditions <a  href=\"#\" onclick=\"window.open('http://www.asnlstore.com/fr/cgv/')\">g&eacute;n&eacute;rales de vente</a>", function () {
      window.location.href = 'http://www.asnlstore.com/fr/e1/';
    });
  });

  $('#confirmDialog2 input.confirm, #confirmDialog2 a.confirm').click(function (e) {
    e.preventDefault();

    confirm("En transformant mes points, je confirme avoir lu et accepté <a  href=\"#\" onclick=\"window.open('http://www.google.fr')\">le règlement</a>", function () {
      window.location.href = 'http://www.asnlstore.com/fr/customerLoyaltyPoint/transform/';
    });
  });
});

function confirm(message, callback) {
  $('#confirm').modal({
    close: false,
    position: ["20%",],
    overlayId: 'confirmModalOverlay',
    containerId: 'confirmModalContainer', 
    onShow: function (dialog) {
      dialog.data.find('.message').append(message);

      dialog.data.find('.yes').click(function () {
        // call the callback
        if ($.isFunction(callback)) {
          callback.apply();
        }
        // close the dialog
        $.modal.close();
      });
    }
  });
}
