(function() {
  $(document).ready(function(){
    var d = new Date();

    $.ajax({
      url:"/Javascript/pricelist.json?time="+d.getTime(),
      dataType:"json",
      success: function(data) {
        $.each(data, function(key, val) {
          if(key == "shopprice") {
            var id = "#priceshop";
          } else if(key == "bagprice") {
            var id = "#pricebag";
          }
          for(var i = 0, vl=val.length; i < vl; i++)
            $(id).append("<li>"+val[i].Karat+"<br />"+val[i].Pris+"</li>");

        });
      }
    });

    $("#showshop").click(function() {
      $("#pricebag").hide();
      $("#priceshop").show();

      $("#showbag").removeClass("selected");
      $("#showshop").addClass("selected");
    });

    $("#showbag").click(function() {
      $("#priceshop").hide();
      $("#pricebag").show();

      $("#showshop").removeClass("selected");
      $("#showbag").addClass("selected");
    });
	});
})();
