var assoclayer;
var packprodlayer;
var islayerexist = 0;
var islayerexist2 = 0;
var poptmt2;
function mpop_affiche2(idprodlay)
{
	var offset_y_tmp = $('#prodassoc_'+idprodlay).parent().offset().top;
	var offset_x_tmp = $('#prodassoc_'+idprodlay).parent().offset().left;
	assoclayer=findObj('prodassoc_'+idprodlay);
	assoclayer.style.left=(gpagepos_x-offset_x_tmp+100)+"px";
	assoclayer.style.top=(gpagepos_y-offset_y_tmp)+"px";
	assoclayer.style.display='block';
	assoclayer.style.zIndex = 100;
	islayerexist2 = 1;
}
function mpop_close2(typeclose)
{
	if(islayerexist2 > 0)
	{
		assoclayer.style.display='none';
		islayerexist2 = 0;
	}
}
/* Fonctions pour les packs V1 */
var packprodlayer;
var islayerexist=0;
var islayerexist2=0;
var poptmt;
function mpop_affiche(idprodlay,idpacklay)
{
	var offset_y_tmp=$('#pack_'+idpacklay+'prod_'+idprodlay).parent().offset().top;
	var offset_x_tmp=$('#pack_'+idpacklay+'prod_'+idprodlay).parent().offset().left;
 	packprodlayer=findObj('pack_'+idpacklay+'prod_'+idprodlay);
 	packprodlayer.style.left=(gpagepos_x-offset_x_tmp+100)+"px";
	packprodlayer.style.top=(gpagepos_y-offset_y_tmp)+"px";
	packprodlayer.style.display='block';
	packprodlayer.style.zIndex=100;
	islayerexist=1;
}
function mpop_close(typeclose)
{
	if(islayerexist > 0)
	{
		packprodlayer.style.display='none';
		islayerexist=0;
	}
}
function findObj(theObj, theDoc)
{
	var p, i, foundObj;
	if(!theDoc) theDoc = document;
	if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
	{
		theDoc = parent.frames[theObj.substring(p+1)].document;
		theObj = theObj.substring(0,p);
	}
	if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
	for (i=0; !foundObj && i < theDoc.forms.length; i++)
	foundObj = theDoc.forms[i][theObj];
	for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++)
	foundObj = findObj(theObj,theDoc.layers[i].document);
	if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
	return foundObj;
}
var assocquantity = new Array();
function buyItemAssoc2(newItem, newPrice, newPort,newID,newQuantity)
{
	rbuyItem(newItem, newPrice, newPort,newID,newQuantity);
	assocquantity[newID]=1;
	ShowItemAssoc2();
}
// *****************************************************************************
// Fonction buyItemAssoc3 - MK - 04/08/2008
// ***************************************************************************** 
// Pour les fichiers stickersXXXXX.htm
function buyItemAssoc3(newItem, newPrice, newPort,newID,newQuantity) 
{
	// Rajoute le produit sélectionné au panier
	rbuyItem(newItem, newPrice, newPort,newID,newQuantity);
}
function ShowItemAssoc2(){
	var inbprod=0;
	//	[accessoire Film Protecteur pour Ecran LCD - pour PDA/Téléphone/APN/GPS,2.95#0.03!21004|1]
	index = document.cookie.indexOf('TheBasket');
	countbegin = (document.cookie.indexOf('=', index) + 1);
	countend = document.cookie.indexOf(';', index);
	if (countend == -1)
	{
		countend = document.cookie.length+1;
	}
	moreItem=true ;
	fulllist = document.cookie.substring(countbegin, countend);
	newItemList = null;
	itemlist = 0;
	var assocprice=parseFloat('0');
	for (var i = 0; i <= fulllist.length; i++)
	{
		if (fulllist.substring(i,i+1) == '[')
		{
			itemstart = i+1;
		}
		else if (fulllist.substring(i,i+1) == '|')
		{
			qpos= i ;
			qstart = i+1;
		}
		else if (fulllist.substring(i,i+1) == '!')
		{
			var ipos= i ;
			var istart = i+1;
		}
		else if (fulllist.substring(i,i+1) == ',')
		{
			var npos= i ;
			var nstart = i+1;
		}
		else if (fulllist.substring(i,i+1) == '#')
		{
			var ppos= i ;
			var pstart = i+1;
		}
		else if (fulllist.substring(i,i+1) == ']')
		{
			itemend = i;
			theitem = fulllist.substring(itemstart, itemend);
			var theitemid = fulllist.substring(istart, qpos);
			var theitemname = fulllist.substring(itemstart, npos);
			var theitemprice = fulllist.substring(nstart, ppos);
			thequantity = fulllist.substring(qstart, itemend);
			itemlist=itemlist+1;
			if(assocquantity[theitemid]>0)
			{
				inbprod=inbprod+1;
				assocprice=assocprice+parseFloat(theitemprice);
			}
		}
	}
	assocprice=assocprice+parseFloat(prixproduitpere);
	assocprice=assocprice*100;
	assocprice=Math.round(assocprice);
	assocprice=assocprice/100;
	$('#prodassocprice').html(''+number_format(assocprice,2,'&nbsp;')+'&nbsp;&euro;');
	$('#prodassocprice_haut').html(''+number_format(assocprice,2,'&nbsp;')+'&nbsp;&euro;');
	$('#prodassocprice_bas').html(''+number_format(assocprice,2,'&nbsp;')+'&nbsp;&euro;');
}
function RemoveItemAssoc2(rid){
	newItemList = null;
	itemlist = 0;
	index = document.cookie.indexOf('TheBasket');
	countbegin = (document.cookie.indexOf('=', index) + 1);
	countend = document.cookie.indexOf(';', index);
	if (countend == -1)
	{
		countend = document.cookie.length+1;
	}
	moreItem=true ;
	fulllist = document.cookie.substring(countbegin, countend);
	for (var i = 0; i <= fulllist.length; i++)
	{
		if (fulllist.substring(i,i+1) == '[')
		{
			itemstart = i+1;
		}
		else if (fulllist.substring(i,i+1) == '|')
		{
			qpos= i ;
			qstart = i+1;
		}
		else if (fulllist.substring(i,i+1) == '!')
		{
			var ipos= i ;
			var istart = i+1;
		}else if (fulllist.substring(i,i+1) == ']')
		{
			itemend = i;
			theitem = fulllist.substring(itemstart, itemend);
			var theitemid = fulllist.substring(istart, qpos);
			thequantity = fulllist.substring(qstart, itemend);
			itemlist=itemlist+1;
			if (parseInt(theitemid) != parseInt(rid))
			{
				newItemList = newItemList+'['+fulllist.substring(itemstart, itemend)+']';
			}
		}
	}
	// residu qui fout le bordel
	//index = document.cookie.indexOf("TheBasket");
	//document.cookie="TheBasket="+newItemList+';path=/';
	
	indextoto = toto.indexOf('TheBasket');
	countbegintoto = (toto.indexOf('=', indextoto) + 1);
	countendtoto = toto.indexOf(';', indextoto);
	if (countendtoto == -1)
	{
		countendtoto = toto.length;
	}
	document.cookie='TheBasket='+newItemList+';path=/'+';domain=grosbill.com';;
	assocquantity[rid]=0;
	ShowItemAssoc2();
	calc_minipanier();
}
function gobasketp()
{
	stampbasket = new Date();
	location = "/monpanierv2.php3?b="+stampbasket.getMinutes()+stampbasket.getSeconds() ;
}

