$(function () {
  country = $.url(location.href).param("country");

  if (country == "GH") {
    gh_selected = 'selected="selected"';
  } else {
    gh_selected = "";
  }

  selects = $("select[name='country']");
  selects.append('<option value="GH" ' + gh_selected + ">Ghana</option>");

  var change = 0,
    updatePrices = function (item) {
      change = 1;

      $(item.children).each(function () {
        if (this.selected) sel = $(this).val();
      });

      if (typeof sel === "undefined") {
        sel = "GH";
      }

      if (sel == "GH") {
        $(".old_price_val").html("954");
        $(".old_price_cur").html("GHC");
        $(".new_price_val").html("477");
        $(".new_price_cur").html("GHC");
        $("select").val("GH").trigger("change");
        initializeMask({ mask: "(+233)999999999", removeMaskOnSubmit: false });
      }

      change = 0;
    };
  $("select")
    .change(function () {
      if (change == 0) updatePrices(this);
    })
    .change();

  function initializeMask(mask) {
    $("[name=phone]").inputmask(mask);
  }
  $(document).ready(function () {
    $("[name=phone]").keydown(function (event) {
      if (
        event.keyCode == 46 ||
        event.keyCode == 8 ||
        event.keyCode == 9 ||
        event.keyCode == 27 ||
        (event.keyCode == 65 && event.ctrlKey === true) ||
        (event.keyCode >= 35 && event.keyCode <= 39)
      ) {
        return;
      } else {
        if (
          (event.keyCode < 48 || event.keyCode > 57) &&
          (event.keyCode < 96 || event.keyCode > 105)
        ) {
          event.preventDefault();
        }
      }
    });
  });
});

var img = document.getElementById("myImg");
var popup = document.getElementById("myPopup");
var popupImg = document.getElementById("popupImg");

img.onclick = function () {
  popup.style.display = "block";
  popupImg.src = this.src;
};

popup.onclick = function () {
  popup.style.display = "none";
};
