function addToCart(pIdProduct)
{
	var qteProducts = 1;
	if (document.getElementById('selectqte') != null)
		qteProducts = document.getElementById('selectqte').value;
	new Ajax.Request(
		'ajax_ajout_panier.php',
		{
			onSuccess:openContinueBuyingBox,
			method: 'post',
			parameters: {idCommand:pIdProduct,qte:qteProducts}
		}
	);
	return false;
}
function openContinueBuyingBox(pResponse)
{
	document.getElementById("panier_bandeau").innerHTML = pResponse.responseText;
	displayCartBox();
}

function displayCartBox()
{
	var d = document.getElementById('displaycontinuerachats');
	CartBox.display(d.innerHTML);
}

function CartBox(){}
CartBox.created = false;
CartBox.display = function(pHtml)
{
	if(!CartBox.created)
		CartBox.create();
	var a = document.getElementById("CartBoxHide");
	var b = document.getElementById("CartBox");
	b.innerHTML = "";
	b.style.width = "auto";
	b.innerHTML = pHtml;
	a.style.display = "block";
	b.style.display = "block";
	b.style.filter = "alpha(opacity=0)";
	M4Tween.to("CartBoxHide", .2, {"opacity":.65});
	M4Tween.to("CartBox", .3, {"opacity":1});
	$("CartBox").style.left = "50%";
	$("CartBox").style.marginLeft = "-"+($("CartBox").getStyle("width").replace(/(px|\%)/,"") * .5)+"px";
	$("CartBox").fire("CartBox:loaded");
};

CartBox.hide = function()
{
	var a = document.getElementById("CartBoxHide");
	var b = document.getElementById("CartBox");
	M4Tween.to("CartBoxHide", .3, {"opacity":0}).onComplete(function(){a.style.display="none";b.style.display="none";});
	M4Tween.to("CartBox", .2, {"opacity":0});
};

CartBox.create = function()
{
	var hide = document.createElement("div");
	hide.setAttribute("id", "CartBoxHide");
	document.body.appendChild(hide);
	var box = document.createElement("div");
	box.setAttribute("id","CartBox");
	document.body.appendChild(box);
	CartBox.created = true;
	Event.observe(hide, "click", CloseCartBoxHandler)
};

function CloseCartBox()
{
	CartBox.hide();
	return false;
}
function CloseCartBoxHandler(e)
{
	CartBox.hide();
	Event.stop(e);
}
