$(document).ready(function() {
  mojKoszyk();
});


function doKoszykaZoferty(idProduct,nIlosc)
{
	$.ajax({
			method: "get",
			url: "index.php?add/sacechy/"+idProduct+"/",
  			cache: false,
			beforeSend: function(){},
			complete: function(){},
  			success: function(html)
			{
				if(html=="success")
					doKoszyka(idProduct,nIlosc,'');
				else
					doKoszyka(idProduct,nIlosc,html);
			}
		}); 
}

function animKoszyk(idProduct,nIlosc)
{
	var position = $("#koszyk"+idProduct).position();
	
	$("#produkt"+idProduct).css("position","absolute");
	$("#produkt"+idProduct).css("width","100px");
	$("#produkt"+idProduct).css("text-align","right");
	$("#produkt"+idProduct).css("font-size","18px");
	$("#produkt"+idProduct).html("+"+nIlosc);
	$("#produkt"+idProduct).animate({ 
    top: "-=50px",opacity: 0
  }, "slow", function(){
		$("#produkt"+idProduct).css({opacity:"",top:position.top});
		$("#produkt"+idProduct).html("");
		mojKoszyk();
	} );
	
}

function mojKoszyk()
{
	$.ajax({
			method: "get",
			url: "index.php?show/koszyk/ajax/",
  			cache: false,
			beforeSend: function(){},
			complete: function(){},
  			success: function(html)
			{
				$("#koszyk").html(html);
			}
		});
}

function doKoszyka(idProduct,nIlosc)
{
	
	$.ajax({
			method: "get",
			url: "index.php?add/dokoszyka/"+idProduct+"//"+nIlosc+"/",
  			cache: false,
			beforeSend: function(){},
			complete: function(){},
  			success: function(html)
			{
			
			animKoszyk(idProduct,nIlosc);
			}
		}); 
}

function usunZKoszyka(idProduct,konfig,nIlosc)
{	
	$.ajax({
			method: "get",
			url: "index.php?add/dokoszyka/"+idProduct+"/"+konfig+"/-"+nIlosc+"/",
  			cache: false,
			beforeSend: function(){},
			complete: function(){},
  			success: function(html)
			{
				window.open('index.php?show/koszyk/','_self');
			}
		}); 
}
