function reloadCart(data)
{
	 $("#shopping_cart").html(data);
}

function getRelatedProducts() {
	  var boxes = $("#productDetailsForm input[type=checkbox]:checked");
	  var count = boxes.size();
	  if ( count != 0)
	  {
		boxes.each(
			function() {
				var item = $(this).attr("name");
				var itemID = item.replace("additionalProductCheck_", "");
				
				addToCartSilently(itemID,1);
			}
		);
	  }
}

function addToCartSilently(item,quant) {
	$.ajax({
		   type: "POST",
		   url: "/ecom/cart/add",
		   data: "id=" + item + "&quantity=" + quant,
		 });
	}

function addToCart(item,quant) {
		document.location.href="#top";
$.ajax({
	   type: "POST",
	   url: "/ecom/cart/add",
	   data: "id=" + item + "&quantity=" + quant,
	   success: function(msg){
		getRelatedProducts();     
		reloadCart(msg);
	     id='#prod'+item;
	     foto=$(id+' .productFoto').attr('src');
	    $("#prodFotoCart img").attr('src',foto);
		$("#prodNameCart").text($(id+' .productName').text());
	    $("#prodPriceCart").text('Cena: '+$(id+' #productPriceSpanTop').text());
		$("#added").show("slow");
		setTimeout("hideAdded ()",3500);
	   }
	 });
}


function hideAdded () {
	$("#added").hide("slow");
}
