function cart_get(ct)
{
	$("#div_cart").ajaxError(function(e,xhr,settings,exception){$(this).text('error: '+xhr.responseText);});
	$.post("/include/cart_process.php",{k:ct,session_id:$("#session_id").val(),op:"1"},function(data){display_result(data)},"text");
	return true;
}
function cart_add(ct,product_id,p1)
{
	if ($("#session_id").val()=='') return false;
	$("#div_cart").ajaxError(function(e,xhr,settings,exception){$(this).text('error: '+xhr.responseText);});
	$.post('/include/cart_process.php',{k:ct,session_id:$("#session_id").val(),op:'2',args:product_id,p01:p1}, function(data){display_result(data);}, 'text');
	return true;
}
function cart_remove(ct,product_id,qty,p1)
{
	if ($("#session_id").val() == '')
		return false;
	$("#div_cart").ajaxError(function() {$(this).text('ajax error - remove');});
	$.post('/include/cart_process.php',{k:ct,session_id:$("#session_id").val(),op:'3',args:product_id,q:qty,p01:p1}, function(data){display_result(data);},'text');
	return true;
}
function cart_reset(ct)
{
	$("#div_cart").ajaxError(function() {$(this).text("ajax error - reset");});
	$.post('/include/cart_process.php',{k:ct,session_id:$("#session_id").val(),op:'4'},function(data){display_result(data);},"text");
	return true;	
}
function display_result(text)
{
	if(text.charAt(0)=="_")
	{
		$("#div_cart").removeAttr("value");
		$("#div_progress").html("");
		alert("Error: " + text.substr(1));
	}
	else
	{
		var session_cookie = text.substr(0, text.indexOf("|"));
		SetSessionCookie("cart_session", session_cookie);
		$("#session_id").attr("value", session_cookie);
		$("#div_progress").html("");
		$("#div_cart").html(text.substr(text.indexOf("|")+1));
	}
}
function show_progress(){$("#div_progress").html('<img src="/images/cart/loading.gif" alt="" />');}
function ConfirmReset(){if(confirm('Aţi ales golirea completă a coşului de cumpărături.\n\nDacă nu aceasta vă era intenţia, apăsaţi butonul "Cancel"\nPentru golire apăsaţi butonul "OK" ')){show_progress();cart_reset(1);} return false;}

