function color_flash(element)
{
	element.parent().css("background-color", "#6297BA").animate({backgroundColor:"#eeeeee"}, { queue: false, duration:4000 });
}

function update_price(data, textStatus)
{
	if (textStatus == "success")
	{
		$("#price_net").text(data["price_net"]);
		color_flash($("#price_net"));
		
		$("#price_gross").text(data["price_gross"]);
		color_flash($("#price_gross"));
	}
}

function calculate_price()
{
	var components = {};
	$(".component").each(function(index) {
		components[this.id] = this.value;
	});
	$.getJSON(
		"/ajax/calculate_pc_price.php?pc_id=" + $("input[name='pc_id']").val(),
		components,
		update_price
	);
}

function update_info_link(item)
{
	$("#info_" + item.id.substr(3)).attr("href", "/productinfo.php?id=" + $(item).val());
}

function component_changed()
{
	calculate_price();
	update_info_link(this);
}

$().ready(function() {
	$(".component").change(component_changed)
});