$(document).ready(function(){

	$('#js-coupon-quantity').change(function(){
		var q = parseInt($(this)[0].value);
		var price = parseInt($('#js-coupon-price').text());
		var total =( q * price / 100);
		$('#js-coupon-total').text(total);
		$('#js-coupon-total-formatted').text("£" + total);
	}).change();

 // if (false)//($('.feedback')[0])
  //{
 // var msg = $('.feedback').html();
 //   $.gritter.add({
			// (string | mandatory) the heading of the notification
			//title: msg,
			// (string | mandatory) the text inside the notification
			//text: " ",
			//sticky: false,

	//	});

  //}

  // turn links with class "form_submit" into buttons that submits the parent form
  $("input.orange_submit").each(function() {
    //hide submit button in the way that enter still working
    $(this).css("visibility", "hidden");
    $(this).css("position", "absolute");

    //create pretty button for submit
    var pretty_link = $(document.createElement("a"));
    pretty_link.attr("href", "#");
    pretty_link.addClass("button " + this.className + " orange");
    pretty_link.html("<span>" + this.value + "</span>");
    pretty_link.click(function(e) {
      e.preventDefault();
      e.stopPropagation();

      $(this).parents("form").submit();
    });

    //insert the button next to previous submit
    $(this).after(pretty_link);
  });

});

