function GetHRObject()
{
	var HttpReq = null;

	if (typeof(XMLHttpRequest) != 'undefined')
	{
		HttpReq = new XMLHttpRequest();
	}
	else
	{
		try
		{
			HttpReq = new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch (e)
		{
			HttpReq = null;
		}
	}

	return HttpReq;
}

function waitplease()
{
				var BasketMsgHold2 = document.createElement("div");
				BasketMsgHold2.style.backgroundColor = '#999999';
				BasketMsgHold2.style.width = '340px';
				BasketMsgHold2.style.height = '200px';
				BasketMsgHold2.id = 'ProdBasketAlert2';
				BasketMsgHold2.style.position = 'absolute';

				var BasketMsg2 = document.createElement("div");
				BasketMsg2.style.width = '340px';
				BasketMsg2.style.height = '200px';
				BasketMsg2.style.position = 'relative';
				BasketMsg2.style.background = '#FFFFFF';
				BasketMsg2.style.border = '2px solid #333333';
				BasketMsg2.style.left = '-5px';
				BasketMsg2.style.top = '-5px';

				var HTML = '<div>'
+ '<table width="100%" border="0" cellspacing="0" cellpadding="2">'
+ '<tr>'
+ '<td height="70" colspan="3" valign="middle" style="font-family: Verdana, Arial; font-size:14px; padding:3px; color:#333333; padding-left:0px;"><div align="center"><br>Chargement de la page...<br><br><br><img src="./charte/load.gif" width="100" height="100"></div>';
HTML += '</td>'
+ '</tr>'
+ '</table>'
+ '</div>'
;
				BasketMsg2.innerHTML = HTML;

				BasketMsgHold2.appendChild(BasketMsg2);
				document.body.appendChild(BasketMsgHold2);

				if (navigator.appName=="Microsoft Internet Explorer")
				{
					ScrollY = document.documentElement.scrollTop + document.body.scrollTop;
					ScrollX = document.documentElement.scrollLeft + document.body.scrollLeft;
				}
				else
				{
					ScrollY = window.pageYOffset;
					ScrollX = window.pageXOffset;
				}

				BasketMsgHold2.style.top = (screen.availHeight / 2 - BasketMsgHold2.offsetHeight / 2 + ScrollY) + "px";
				BasketMsgHold2.style.left = (screen.availWidth / 3) + "px";

//				UpdateBasket();
//			}

}


function ChangeAmount3(ItemID, Qte, Name, Pict, PictHeight)
{

				var BasketMsgHold = document.createElement("div");
				BasketMsgHold.style.backgroundColor = '#999999';
				BasketMsgHold.style.width = '340px';
				//BasketMsgHold.style.height = '200px';
				BasketMsgHold.style.height = Math.round(PictHeight+200-35) + 'px';
				BasketMsgHold.id = 'ProdBasketAlert';
				BasketMsgHold.style.position = 'absolute';

				var BasketMsg = document.createElement("div");
				BasketMsg.style.width = '340px';
//				BasketMsg.style.height = '200px';
				BasketMsg.style.height = Math.round(PictHeight+200-35) + 'px';
				BasketMsg.style.position = 'relative';
				BasketMsg.style.background = '#FFFFFF';
				BasketMsg.style.border = '2px solid #333333';
				BasketMsg.style.left = '-5px';
				BasketMsg.style.top = '-5px';

				var HTML = '<div style="font-family: Verdana, Arial; font-size:14px; padding:3px; color:#B71800; font-weight:bold;">Ajouter au panier ?</div>'
+ '<div>'
+ '<table width="100%" border="0" cellspacing="0" cellpadding="2">'
+ '<tr>'
+ '<td height="70" colspan="3" valign="middle" style="color:#333333; padding-left:0px;">';
if (Pict)
{
	HTML += '<div align="center"><img src="../images/' + ItemID + '-0_mini.' + Pict + '" border=0></div>';
}
if (Name)
{
	HTML += '<div style="font-family: Verdana, Arial; font-size:14px;" align="center">' + Name + '</div>';
}
HTML += '</td>'
+ '</tr>'
+ '<tr>'
+ '<td width="33%" height="48" valign="bottom" style="font-family: Verdana, Arial; font-size:11px;padding-left:20px;"><div align="center"><a href="#" onclick="ProdAlertValidate(true); return false;"><img src="./charte/close.gif" width="39" height="39" border="0" alt="Annuler" title="Annuler" /><br>Annuler<br><br></a></div></td>'
+ '<td width="33%" height="48" align="center" valign="bottom" style="font-family: Verdana, Arial; font-size:11px;padding-right:20px;"><a href="#" onclick="ProdAlertValidate(false); return false;"><img src="./ref-img/afficherpaniersmall.gif" width="48" height="41" border="0" alt="Afficher le panier" title="Afficher le panier" /><br>Afficher le panier<br></a></td>'
+ '<td width="33%" height="48" valign="bottom" style="font-family: Verdana, Arial; font-size:11px;padding-right:20px; color:#B71800"><div align="center"><a href="#" onclick=\'ProdAlertValidate(true);ChangeAmount3V("' + ItemID + '", "' + Qte + '", "'+ Name+ '", "' + Pict + '",' + PictHeight + '); return false;\'><img src="./ref-img/ajouterpanier.gif" width="70" height="61" border="0" alt="Ajouter au panier" title="Ajouter au panier" /><br><font color="#B71800"><b>Ajouter au panier</b></font></div></td>'
+ '</tr>'
+ '</table>'
+ '</div>'
;
				BasketMsg.innerHTML = HTML;

				BasketMsgHold.appendChild(BasketMsg);
				document.body.appendChild(BasketMsgHold);

				if (navigator.appName=="Microsoft Internet Explorer")
				{
					ScrollY = document.documentElement.scrollTop + document.body.scrollTop;
					ScrollX = document.documentElement.scrollLeft + document.body.scrollLeft;
				}
				else
				{
					ScrollY = window.pageYOffset;
					ScrollX = window.pageXOffset;
				}

				BasketMsgHold.style.top = (screen.availHeight / 2 - BasketMsgHold.offsetHeight / 2 + ScrollY) + "px";
				BasketMsgHold.style.left = (screen.availWidth / 3) + "px";

//				UpdateBasket();
//			}

}

function ChangeAmount3V(ItemID, Qte, Name, Pict, PictHeight)
{
	var HttpReq = GetHRObject();

	if (!HttpReq)
	{
		document.location.href='fiche_article.php?id_interne=' + ItemID + '&qte=' + Qte + '&alea=' + Math.random(1);
		return;
	}

	HttpReq.onreadystatechange = function()
	{
		if (HttpReq.readyState == 4 && HttpReq.status == 200)
		{
			if (HttpReq.responseText > 0)
			{
				ProdAlert2 = document.getElementById('ProdBasketAlert2');
				ProdAlert2.parentNode.removeChild(ProdAlert2);
	
				var BasketMsgHold = document.createElement("div");
				BasketMsgHold.style.backgroundColor = '#999999';
				BasketMsgHold.style.width = '340px';
//				BasketMsgHold.style.height = '220px';
				BasketMsgHold.style.height = Math.round(PictHeight+220-35) + 'px';
				BasketMsgHold.id = 'ProdBasketAlert';
				BasketMsgHold.style.position = 'absolute';

				var BasketMsg = document.createElement("div");
				BasketMsg.style.width = '340px';
//				BasketMsg.style.height = '220px';
				BasketMsg.style.height = Math.round(PictHeight+220-35) + 'px';
				BasketMsg.style.position = 'relative';
				BasketMsg.style.background = '#FFFFFF';
				BasketMsg.style.border = '2px solid #333333';
				BasketMsg.style.left = '-5px';
				BasketMsg.style.top = '-5px';
				var messagearticle = '';
				if (HttpReq.responseText>1){
					messagearticle=HttpReq.responseText + ' articles dans votre votre panier.';
				} else {
					messagearticle=HttpReq.responseText + ' article dans votre votre panier.';
				}

				var HTML = ''
+ '<div>'
+ '<table width="100%" border="0" cellspacing="0" cellpadding="2">'
+ '<tr>'
+ '<td height="70" colspan="3" valign="middle" style="color:#333333; padding-left:0px;"><br>';
if (Pict)
{
	HTML += '<div align="center"><img src="../images/' + ItemID + '-0_mini.' + Pict + '" border=0></div>';
}
if (Name)
{
	HTML += '<div style="font-family: Verdana, Arial; font-size:14px;" align="center">' + Name + '</div>'
	+ '<div style="font-family: Verdana, Arial; font-size:14px; color:#B71800" align="center"><br/>' + messagearticle + '<br><br></div>';
}
HTML += '</td>'
+ '</tr>'
+ '<tr>'
+ '<td width="33%" height="48" align="center" valign="bottom" style="font-family: Verdana, Arial; font-size:11px;padding-left:20px; color:#B71800"><div align="center"><a href="#" onclick="ProdAlertValidate(true); return false;"><img src="./charte/close.gif" width="39" height="39" border="0" alt="Fermer" title="Fermer" /><br>Fermer<br><br><br></a></div></td>'
+ '<td width="33%" height="48" valign="bottom"></td>'
+ '<td width="33%" height="48" align="center" valign="bottom" style="font-family: Verdana, Arial; font-size:11px;padding-right:20px;"><a href="#" onclick="ProdAlertValidate(false); return false;"><img src="./ref-img/afficherpanier.gif" width="70" height="61" border="0" alt="Afficher le panier" title="Afficher le panier" /><font color="#B71800"><br><b>Afficher le panier</b><br><br></font></a></td>'
+ '</tr>'
+ '</table>'
+ '</div>'
;
				BasketMsg.innerHTML = HTML;

				BasketMsgHold.appendChild(BasketMsg);
				document.body.appendChild(BasketMsgHold);

				if (navigator.appName=="Microsoft Internet Explorer")
				{
					ScrollY = document.documentElement.scrollTop + document.body.scrollTop;
					ScrollX = document.documentElement.scrollLeft + document.body.scrollLeft;
				}
				else
				{
					ScrollY = window.pageYOffset;
					ScrollX = window.pageXOffset;
				}

				BasketMsgHold.style.top = (screen.availHeight / 2 - BasketMsgHold.offsetHeight / 2 + ScrollY) + "px";
				BasketMsgHold.style.left = (screen.availWidth / 3) + "px";

//				UpdateBasket();
			}
		}
	}
	waitplease();
	HttpReq.open('GET', 'ajaxajoutpanierv2.php?id=' + ItemID + '&qte=' + Qte + '&alea=' + Math.random(1), true);
	HttpReq.send(null);

}

function ProdAlertValidate(Stay)
{
	ProdAlert = document.getElementById('ProdBasketAlert');
	ProdAlert.parentNode.removeChild(ProdAlert);

	if (!Stay){
		waitplease();
		document.location.href = 'fiche_article.php?action=affiche' + '&alea=' + Math.random(1);
	}
}
