    $(function() {  
        $("#cart tr .remove input").click(function() {  
            var orderCode = $(this).val();  
            $.ajax({  
                type: "GET",  
                url: "cart_action.php",  
                data: "remove[]=" + orderCode,  
                success: function() {  
                    $("#cart tr .remove input[value=" + orderCode + "]").parent().parent().fadeOut(500, function() {  
                       $(this).remove();  
                       calcPrice();  
                   });  
               },  
               error: function() {  
                   window.location("cart_action.php?remove[]="+orderCode);  
               }  
           });  
       });  
         
       $("#cart tr .quantity input").change(function() {  
           var orderCode = $(this).attr("name").slice(9, -1);  
           var quantity = $(this).val();  
           $.ajax({  
               type: "GET",  
               url: "cart_action.php",  
               data: "quantity[" + orderCode + "]=" + quantity,  
               success: function() {  
                   var startColor = $("#cart tr .quantity input[name*=" + orderCode + "]").parent().parent().hasClass("odd") ? "#eee" : "#fff";  
                   $("#cart tr .quantity input[name*=" + orderCode + "]").parent().parent().find("td").animate({ backgroundColor: "#ff8" }, 100).animate({ backgroundColor: startColor }, 800);  
                   calcPrice();  
               },  
               error: function() {  
                   window.location("cart_action.php?quantity[" + orderCode + "]=" + quantity);  
               }  
           });  
       });  
   });  
     
   function calcPrice() {  
     	var totalPrice = "";  
	var avgiftSum = 0;
	var total = 0;


	$("#cart tr .quantity").parent().each(function() {  
		var quantity =  parseInt( $(".quantity input", this).val() );  
		var unitPrice = parseFloat( $(".unit_price", this).text().slice(3) );  
		var postoppkrav = parseFloat( $("#postoppkrav").text().slice(3) );
		var extendedPrice = quantity * parseFloat(unitPrice); 
		
		if( totalPrice == "")
			totalPrice = 0;


		if(unitPrice > 2000)
		{
			$("#kunstavgiftLinje", this).html("Kr." + (parseFloat(unitPrice) * 0.05) * parseInt(quantity));  
			avgiftSum = parseFloat(avgiftSum) + ((unitPrice * 0.05) * quantity);  
			extendedPrice = parseFloat(extendedPrice) * 1.05;
		}
		else
		{
			$("#kunstavgiftLinje", this).html("Kr.0");
		}		

		totalPrice += parseFloat(extendedPrice);  

		$(".extended_price", this).html("Kr." +  extendedPrice.toFixed(2));
		$("#sum").html("Kr." + parseFloat(totalPrice));
		$("#kunstSkatt").html("Kr." + avgiftSum);	

		total = parseFloat(totalPrice) + parseFloat(postoppkrav);
		$("#total_price").html("Kr." + total.toFixed(2));
		
	});  
	
	

	if ( totalPrice == "" ) {
		$("#cart").parent().replaceWith("<p class='center'>Handlekurven er tom.</p>");  
	}  
   }  