var clickEventFired = false;
var requests = new Array();

$(document).ready(function() {
	$("a").click(function() {
		clickEventFired = true;
		
		$.each(requests, function(index, value) {
			value.abort();
		});
	});
	
	$(".ajaxPrice").each(function() {
		var ProdNo = $(this).attr("ProdNo");
		var Gr7 = $(this).attr("Gr7");
		
		if (clickEventFired === true) {
			console.log(clickEventFired);
			return false;
		}
		
		//console.log(ProdNo);
		
		var request = $.ajax({
			type: "GET",
			url: "/inc/ajax.fetchPrice.php",
			data: { ProdNo: ProdNo, Gr7: Gr7 },
			success: function(data) {
				if (data == 'Pris p&aring; foresp&oslash;rsel') {
					priceStr = "<b>" + data + "</b>";
				} else {
					priceStr = "Kr. <b>" + data + "</b>";
				}
				
				$("#" + ProdNo).html(priceStr);
			}
		});
		
		requests[requests.length] = request;
	});
});
