﻿function shop_basket()
{
	advAJAX.get({
		url: url + "index.php/shop/shop_basket_box/db/",
   	onSuccess : function(obj) 
   	{
			document.getElementById("shop_basket").innerHTML = obj.responseText;
      }		
	});
}
function shop_basket_list()
{
	advAJAX.get({
		url: url + "index.php/shop/shop_basket/list/",
   	onSuccess : function(obj) 
   	{
			document.getElementById("shop_basket_list").innerHTML = obj.responseText;
      }		
	});
}
function shop_basket_product_add(pid)
{
	var quantity = prompt('Ile sztuk chcesz dodać do koszyka?', 1);
	if(quantity)
	{
	advAJAX.get({
    	url: url + "index.php/shop/shop_basket/product_add/" + pid + "/" + quantity+ "/",
    	onSuccess : function(obj) { shop_basket(); alert(obj.responseText); }
	});
	}
}
function shop_basket_product_quantity(pid, qua)
{
	var quantity = prompt('Ilość sztuk w koszyku', qua);
	if(quantity)
	{
	advAJAX.get({
    	url: url + "index.php/shop/shop_basket/change_quantity/" + pid + "/" + quantity+ "/",
    	onSuccess : function(obj) { shop_basket_list(); alert(obj.responseText); }
	});
	}
}
function shop_form() 
{
	advAJAX.assign(document.getElementById("shop_form"), 
	{
   	onSuccess : function(obj) 
   	{
			alert(obj.responseText);
		}
   });
}
function shop_basket_product_remove(product, order)
{
	if(confirm('Czy na pewno chcesz usunąć wybrany produkt z koszyka?'))
	{
		advAJAX.get
		({
			url: url + "index.php/shop/shop_basket/product_remove/" + product + "/" + order + "/",
   		onSuccess : function(obj) 
   		{
				shop_basket_list();
				shop_basket();
				alert(obj.responseText);			
      	}		
		});
	}
}
function shop_basket_clear(order)
{
	if(confirm('Czy na pewno chcesz usunąć wszystkie produkty z koszyka?'))
	{
		advAJAX.get
		({
			url: url + "index.php/shop/shop_basket/clear_basket/" + order + "/",
   		onSuccess : function(obj) 
   		{
				shop_basket_list();
				shop_basket();
				alert(obj.responseText);			
      	}		
		});
	}
}
function popImage(photo)
{
	window.open (url + "popup.php?photo=" + photo,
"mywindow","menubar=0,resizable=0,width=200,height=200"); 
}

