
var champs = new Array('titre','sous_titre','image','description','lien_fiche','tarif','tarif_avant_promo','id_produit','quantite');
var actions = {
	ajout_panier	: 1, 
	quantite		: 1 
	};//new Array ('ajout_panier','quantite');

var champsPanier  = new Array();
var actionsPanier  = {
	ligne_panier 	: 1,
	valider 		: 1,
	total 			: 1,
	valide_panier	: 1,
	vide_panier		: 1
	};

var champsLignePanier  = new Array('titre','sous_titre','image','description','lien_fiche','tarif','tarif_avant_promo','id_produit');
var actionsLignePanier  = {
	enlever 		: 1,
	quantite		: 1,
	sous_total			: 1
	};

var addedTime=100;
var addedSteps=50;
var addedDelay = 10;


function McProduit () {};

function McBoutique(panier,pere,tpl_produit,prec,next,sel_categ,cols,lines)
	{
	this.panier=panier;
	/* Variables */
	this.vars 					= {};
	this.vars.nbCols			= cols;
	this.vars.nbLines			= lines;
	this.vars.nbProduitActif 	= 0;
	this.vars.categ				= '';
	this.vars.textProduits 		= '';
	this.vars.start				= new Date();
	this.vars.prec      		= false;
	this.vars.next      		= false;
	this.vars.offset      		= 0;
	this.vars.pictoAdded		= false;
	tpl_produit.id='';
	/* Template */
	this.tpl					= {};
	this.tpl.node				= tpl_produit;
	this.tpl.champs				= {};
	this.tpl.nodes				= {};
	
	/* Produits */
	this.produit				= [];
	
	/* RexgExps */
	this.regs={};
	this.regs.regPlein=/plein/g;
	this.regs.regVide=/vide/g;
	this.regs.regActif=/actif/g;
	this.regs.regFirst=/first/g;
	this.regs.regLast=/last/g;
	this.regs.regAdded=/added/g;
	
	/* Nodes */
	this.node					= {};
	this.node.pere				= pere;
	this.node.prec				= prec;
	this.node.next				= next;
	this.node.sel				= sel_categ;
	this.node.table				= document.createElement('TABLE');
	this.node.tbody				= document.createElement('TBODY');
	this.node.tr				= [];
	this.node.td				= [];
	
	var obj=this;
	
	var pp=document.getElementById('picto_added');
	if ((pp) && (panier))
		{
		this.node.pictoAdded=pp;
		this.vars.pictoAdded=true;
		this.node.pictoAdded.style.display='none';
		this.node.pictoAdded.style.position='absolute';
		this.node.pictoAdded.moveNext=function ()
			{
			this.style.left=this.baseX+(this.targetX-this.baseX)*this.step/addedSteps;
			this.style.top=this.baseY+(this.targetY-this.baseY)*this.step/addedSteps;
			this.step=this.step+1;
			if (this.step>addedSteps)
				{
				//alert('FINI '+this.step);
				this.style.display='none';
				if (obj.panier.node.pere.bordure)
					{
					obj.panier.node.pere.bordure.style.backgroundColor='#fff';
					window.setTimeout(function () { obj.panier.node.pere.bordure.style.backgroundColor=''; },addedTime);
					}
				else
					{
					obj.panier.node.pere.style.backgroundColor='#fff';
					window.setTimeout(function () { obj.panier.node.pere.style.backgroundColor=''; },addedTime);
					}
				}
			else
				{
				var pictoA=this;
				window.setTimeout(function () {pictoA.moveNext()},addedDelay);
				}
			}
		}
	
	
	this.node.table.appendChild(this.node.tbody);
	
	this.getCategs();

	for (var i=0;i<this.vars.nbLines;i++)
		{
		this.node.tr[i]	= document.createElement('TR');
		if (i==0)
			this.node.tr[i].className+=' first';
		if (i==this.vars.nbLines-1)
			this.node.tr[i].className+=' last';
		if (Math.floor(i/2)==i/2)
			this.node.tr[i].className+=' pair';
		else
			this.node.tr[i].className+=' impair';
		
		this.node.tbody.appendChild(this.node.tr[i]);
		this.node.tr[i].onmouseover=function ()
			{
			this.className+=' actif';
			}
		this.node.tr[i].onmouseout=function ()
			{
			this.className=this.className.replace(obj.regs.regActif,'');
			}
		for (var j=0;j<this.vars.nbCols;j++)
			{
			var nb=this.vars.nbCols*i+j;
			this.node.td[nb]=document.createElement('TD');
			if (j==0)
				this.node.td[nb].className+=' first';
			if (j==this.vars.nbCols-1)
				this.node.td[nb].className+=' last';
			//this.node.td[nb].innerHTML=nb;
			var nod = this.tpl.node.cloneNode(true);
			this.node.td[nb].appendChild(nod);
			
			var mp = new McProduit(this,nod,nb);
			this.produit.push(mp);
			
			this.node.tr[i].appendChild(this.node.td[nb]);
			this.node.td[nb].onmouseover=function ()
				{
				this.className+=' actif';
				}
			this.node.td[nb].onmouseout=function ()
				{
				this.className=this.className.replace(obj.regs.regActif,'');
				}
			}
		}
	this.node.pere.appendChild(this.node.table);

	this.data={};
	this.data.produit=[];

	for (var i=0;i<champs.length;i++)
		{
		this.tpl.champs[champs[i]]=false;
		}
	
	for (var i=0; i < (this.vars.nbCols*this.vars.nbLines) ; i++)
		{
		this.data.produit[i]={};
		}
	
	
	var cur=this.tpl.node;

	this.getProduits();
	
	
	this.node.next.onclick= function ()
		{
		//alert('HERE'+obj.vars.offset);
		obj.vars.offset+=obj.vars.nbLines*obj.vars.nbCols;
		obj.update();
		}
	this.node.prec.onclick= function ()
		{
		obj.vars.offset-=obj.vars.nbLines*obj.vars.nbCols;
		obj.update();
		}
	this.node.sel.onchange=function ()
		{
		obj.vars.categ=this.value;
		obj.vars.offset=0;
		obj.getProduits();
		}
	//alert('Duree = '+((new Date())-now));
	return this;
	}

function getChamps (mcProduit,node)
	{
	ret = [];
	//alert('GC Launch '+node);
	for (var cur=node.firstChild;cur;cur=cur.nextSibling)
		{
		//alert(cur+''+cur.tagName);
		if (cur.tagName)
			{
			for (var ch in mcProduit.champs)
				{
				//alert(ch);
				if (!(mcProduit.champs[ch]))
					{
					var nd=cur.getAttribute(ch);
					if (nd)
						{
						//alert(ch+','+nd);
						mcProduit.champs[ch]=nd;
						mcProduit.node[ch]=cur;
						}
					}
				}
			for (var ch in actions)
				{
				//alert(ch);
				if (!(mcProduit.action[ch]))
					{
					var nd=cur.getAttribute(ch);
					if (nd)
						{
						//alert(ch+','+nd);
						mcProduit.action[ch]=nd;
						mcProduit.node[ch]=cur;
						}
					}
				}
			if ((cur.childNodes) && (cur.childNodes.length>0))
				{
				getChamps(mcProduit,cur);
				}
			}
		}
	
	}

function McProduit (mcBoutique,node,nb)
	{
	this.boutique=mcBoutique;
	
	/* Vars */
	this.vars={};
	this.vars.nb=nb;
	
	/* Nodes */
	this.node={};
	this.node.base=node;
	
	/* Actions */
	this.action					= {};
	
	/* Champs */
	this.champs={};
	this.champsActif={};
	
	this.data={};
	
	for (var i=0;i<champs.length;i++)
		{
		//alert('CHAMP '+i+' '+champs[i]);
		this.champs[champs[i]]=false;
		}
	
	
	getChamps(this,node);
	
	var obj=this;
	
	if (this.node.ajout_panier)
		{
		this.node.ajout_panier.onclick = function ()
			{
			//alert('ihih');
			obj.ajout_panier();
			}
		}
	/*for (var ch in actions)
		{
		if ((this.node[ch]) && (this[ch]))
			{
			//alert(ch);
			this.node[ch].action=ch;
			this.node[ch].onclick = function ()
				{
				//alert(this+''+this.action);
				var ttt=ch;
				alert(2+ttt);
				obj[ch]();
				}
			}
		}
	*/
	}

McProduit.prototype.ajout_panier=function()
	{
	//alert(1);
	this.node.base.className+=' added';
	//this.node.base.style.backgroundColor='pink';
	
	if ((this.data.id_produit) && (this.node.quantite.value>0))
		{
		this.boutique.panier.addProduits(this.data.id_produit+';+'+this.node.quantite.value)
		}
	//alert(this.boutique.panier+' '+this.boutique.vars.pictoAdded);
	if ((this.boutique.panier) && (this.boutique.vars.pictoAdded))
		{
		this.boutique.node.pictoAdded.targetX=getRealLeft(this.boutique.panier.node.pere)+Math.floor(this.boutique.panier.node.pere.offsetWidth/2);
		this.boutique.node.pictoAdded.targetY=getRealTop(this.boutique.panier.node.pere)+Math.floor(this.boutique.panier.node.pere.offsetHeight/2);;
		this.boutique.node.pictoAdded.baseX=getRealLeft(this.node.base)+Math.floor(this.node.base.offsetWidth/2);
		this.boutique.node.pictoAdded.baseY=getRealTop(this.node.base)+Math.floor(this.node.base.offsetHeight/2);
		this.boutique.node.pictoAdded.step=0;
		this.boutique.node.pictoAdded.style.left = this.boutique.node.pictoAdded.baseX;
		this.boutique.node.pictoAdded.style.top = this.boutique.node.pictoAdded.baseY;
		this.boutique.node.pictoAdded.style.display='block';
		this.boutique.node.pictoAdded.moveNext();
		}
	var base = this.node.base;
	var obj=this.boutique;
	
	window.setTimeout(function ()
		{
		base.className=base.className.replace(obj.regs.regAdded,'');
		//base.style.backgroundColor='';
		},addedTime);
	}


McBoutique.prototype.update=function ()
	{
	this.parseProduits();
	for (var i=0;i<this.vars.nbProduitActif;i++)
		{
		this.produit[i].update();
		}
	for (var i=0;i<this.vars.nbLines*this.vars.nbCols;i++)
		{
		//alert('ff');
		this.produit[i].hideInactif();
		}
	if (this.vars.next)
		{
		//alert(this.node.next.ctrl+' ');
		if (this.node.next.ctrl)
			this.node.next.ctrl.style.display='';
		else
			this.node.next.style.display='';
		this.node.next.noDisplay=false;
		}
	else
		{
		if (this.node.next.ctrl)
			this.node.next.ctrl.style.display='none';
		else
			this.node.next.style.display='none';
		this.node.prec.noDisplay=true;
		}
	if (this.vars.prec)
		{
		if (this.node.prec.ctrl)
			this.node.prec.ctrl.style.display='';
		else
			this.node.prec.style.display='';
		this.node.prec.noDisplay=false;
		}
	else
		{
		if (this.node.prec.ctrl)
			this.node.prec.ctrl.style.display='none';
		else
			this.node.prec.style.display='none';
		this.node.prec.noDisplay=true;
		}
	/*
	for (var i=0;i<this.produit.length;i++)
		{
		this.produit[i].hideInactif();
		}
	*/
	}

McProduit.prototype.hideInactif = function ()
	{
	var n=0;
	
	for (var ch in this.champsActif)
		{
		if ((!(this.champsActif[ch])) && (this.node[ch]))
			{
			this.node[ch].style.display='none';
			if (this.node[ch].ctrl)
				{
				this.node[ch].ctrl.style.display='none'; 
				}
			}
		else if ((this.champsActif[ch]) && (this.node[ch]))
			{
			this.node[ch].style.display='';
			n++;
			}
		}
	if (n>0)
		{
		this.node.base.className+=' plein';
		this.node.base.className=this.node.base.className.replace(this.boutique.regs.regVide,'');
		for (var ch in actions)
			{
			if (this.node[ch])
				{
				if (this.node[ch].ctrl)
					{
					this.node[ch].ctrl.style.display=''; 
					}
				else
					this.node[ch].style.display='';
				}
			}
		}
	else
		{
		this.node.base.className+=' vide';
		this.node.base.className=this.node.base.className.replace(this.boutique.regs.regPlein,'');
		for (var ch in actions)
			{
			if (this.node[ch])
				{
				if (this.node[ch].ctrl)
					{
					this.node[ch].ctrl.style.display='none'; 
					}
				else
					this.node[ch].style.display='none';
				}
			}
		}
	if (this.data.ajout_unitaire>0)
		{
		this.node.quantite.value=1;
		this.node.quantite.style.display='none';
		this.node.quantite.noDisplay=true;
		if (this.node.quantite.ctrl)
			{
			this.node.quantite.ctrl.style.display='none';
			//alert('hide');
			}
		}
	else
		{
		this.node.quantite.style.display='';
		this.node.quantite.noDisplay=false;
		if (this.node.quantite.ctrl)
			{
			this.node.quantite.ctrl.style.display='';
			//alert('hide');
			}
		}
	}

McProduit.prototype.update=function ()
	{
	for (var i=0;i<champs.length;i++)
		{
		this.champsActif[champs[i]]=false;
		}
	
	for (var ch in this.data)
		{
		if (this.node[ch]) 
			{
			//alert(ch+' '+this.data[ch]);
			this.node[ch][this.champs[ch]]=this.data[ch];
			this.champsActif[ch]=true;
			}
		}
	this.node.base.style.display='';
	}



McBoutique.prototype.parseProduits = function ()
	{
	var lignes=this.vars.textProduits.split('\n');
	var np=0;
	var i=0;
	var offset=0;
	this.vars.nbProduitActif=1;
	for (var i=0;i<this.produit.length;i++)
		{
		this.produit[i].data={};
		for (var j=0;j<champs.length;j++)
			{
			this.produit[i].champsActif[champs[j]]=false;
			}
		}
		
	this.produit[np].data= new Object();
	
	for (i=0;i<lignes.length;i++)
		{
		var li=lignes[i];
		//alert(li);
		if (li=='')
			{
			offset++;
			
			if (this.vars.offset>=offset)
				continue;
			
			if (i+1<lignes.length)
				{
				np++;
				if (!(np<(this.vars.nbLines*this.vars.nbCols)))
					break;
			
				this.vars.nbProduitActif++;
				}
			continue;
			}
		if (!(np<(this.vars.nbLines*this.vars.nbCols)))
			break;
		
		if (this.vars.offset>offset)
			continue;
			
		var datas=li.split('\t');
		this.produit[np].data[datas[0]]=datas[1];
		}
	
	if (lignes.length-i>1)
		{
		this.vars.next=true;
		}
	else
		{
		this.vars.next=false;
		}
	
	//alert(this.vars.offset);
	if (this.vars.offset>0)
		{
		this.vars.prec=true;
		}
	else
		{
		this.vars.prec=false;
		}
		
	}

McBoutique.prototype.getProduits = function ()
 	{
	var http = new getHTTP();
	var obj=this;
	
	http.open("GET", '/McAjax/get_produits.cgi?categ='+this.vars.categ , true);
	http.onreadystatechange = function ()
		{
		if (http.readyState == 4 && http.status==200)
			{
			obj.vars.textProduits=(http.responseText);
			obj.update();
			}
		}
	http.send(null);
	
	return ;
	}

McBoutique.prototype.getCategs = function ()
 	{
	var http = new getHTTP();
	var obj=this;
	
	http.open("GET", '/McAjax/get_categs.cgi' , true);
	http.onreadystatechange = function ()
		{
		if (http.readyState == 4 && http.status==200)
			{
			var n=0;
			var lis=http.responseText.split('\n');
			for (var i=0;i<lis.length;i++)
				{
				var li=lis[i];
				var data=li.split('\t');
				if (data[1])
					{
					var opt=document.createElement('OPTION');
					opt.value=data[0];
					opt.innerHTML=data[1];
					obj.node.sel.appendChild(opt);
					n++;
					}
				}
			if (n<2)
				obj.node.sel.style.display='none';
			}
		}
	http.send(null);
	
	return ;
	}

function McPanier (div)
	{
	this.vars={};
	this.vars.lignesPanier='';
	this.vars.newp=[];
	
	this.produit={};
	
	this.node={};
	this.node.pere=div;
	
	this.champs={};
	for (var i=0;i<champsPanier.length;i++)
		{
		this.champs[champsPanier[i]]=false;
		}
	
	this.action={};
	for (var i in actionsPanier)
		{
		this.action[i]=false;
		}
	
	this.analyze(div);
	//alert(this.node.ligne_produit);
	this.node.ligne_panier.style.display='none';
	this.update();
	//alert(document.cookie);
	var cc=document.cookie.match(/panier=(.*)/);
	if (cc)
		{
		//alert('CC'+cc[1]);
		pds=cc[1];
		pds=pds.replace(/\//g,'\n');
		pds=pds.replace(/,/g,';');
		//alert(pds);
		this.addProduits(pds);
		}
	
	var obj=this;
	
	if (this.node.vide_panier)
		{
		this.node.vide_panier.onclick = function ()
			{
			for (var prod in obj.produit)
				{
				obj.produit[prod].vars.qte=0;
				}
			obj.saveCook();
			obj.update();
			}
		}
	
	/*var test='';
	for (var n in this.node)
		test+=n+' ';
	alert(test);*/
	//alert(this.node.ligne_panier);
	}

function McLignePanier (mcPanier)
	{
	this.exist=true;
	this.panier=mcPanier;
	this.vars={};
	this.vars.qte=0;
	
	this.node={};
	this.node.base=this.panier.node.ligne_panier.cloneNode(true);
	this.panier.node.ligne_panier.parentNode.appendChild(this.node.base);
	//alert(this.node.base);
	this.node.base.style.display='';
	
	this.data={};

	this.champs={};
	for (var i=0;i<champsLignePanier.length;i++)
		{
		this.champs[champsLignePanier[i]]=false;
		}
	
	this.champsActif={};
	for (var i=0;i<champsLignePanier.length;i++)
		{
		this.champsActif[champsLignePanier[i]]=false;
		}
	
	this.action={};
	for (var i in actionsLignePanier)
		{
		this.action[i]=false;
		}
	
	this.analyze(this.node.base);
	
	var obj = this;
	
	if (this.node.enlever)
		{
		this.node.enlever.onclick = function ()
			{
			obj.vars.qte=0;
			obj.panier.update();
			obj.panier.saveCook();
			}
		}
	
	
	/*var test='';
	for (var n in this.node)
		test+=n+' ';
	alert(test);*/
	//alert(this.node.ligne_panier);
	}

McPanier.prototype.analyze = function (node)
	{
	for (var cur=node.firstChild;cur;cur=cur.nextSibling)
		{
		//alert(cur+''+cur.tagName);
		if (cur.tagName)
			{
			for (var ch in this.champs)
				{
				//alert(ch);
				if (!(this.champs[ch]))
					{
					var nd=cur.getAttribute(ch);
					if (nd)
						{
						//alert(ch+','+nd);
						this.champs[ch]=nd;
						this.node[ch]=cur;
						}
					}
				}
			for (var ch in this.action)
				{
				//alert(ch);
				if (!(this.action[ch]))
					{
					var nd=cur.getAttribute(ch);
					if (nd)
						{
						//alert(ch+','+nd);
						this.action[ch]=nd;
						this.node[ch]=cur;
						}
					}
				}
			if ((cur.childNodes) && (cur.childNodes.length>0))
				{
				this.analyze(cur);
				}
			
			}
		}
	}
	
McLignePanier.prototype.analyze = function (node)
	{
	//ret = [];
	//alert('GC Launch '+node);
	for (var cur=node.firstChild;cur;cur=cur.nextSibling)
		{
		//alert(cur+''+cur.tagName);
		if (cur.tagName)
			{
			for (var ch in this.champs)
				{
				//alert(ch);
				if (!(this.champs[ch]))
					{
					var nd=cur.getAttribute(ch);
					if (nd)
						{
						//alert(ch+','+nd);
						this.champs[ch]=nd;
						this.node[ch]=cur;
						}
					}
				}
			
			for (var ch in this.action)
				{
				//alert(ch);
				if (!(this.action[ch]))
					{
					var nd=cur.getAttribute(ch);
					if (nd)
						{
						//alert(ch+','+nd);
						this.action[ch]=nd;
						this.node[ch]=cur;
						}
					}
				}
			if ((cur.childNodes) && (cur.childNodes.length>0))
				{
				this.analyze(cur);
				}
			}
		}
		}


McPanier.prototype.addProduits = function (str)
	{
	var lignes=str.split('\n');
	
	for (var i=0;i<lignes.length;i++)
		{
		var data=lignes[i].split(';');
		var id=data[0];
		var qt=data[1];
		if (!(qt>0))
			continue;
		if ((this.produit[id]) && (this.produit[id].exist))
			{
			//alert(id+'\n'+this.produit[id].data.titre+'\n'+qt);
			this.produit[id].setQte(qt);
			}
		else
			{
			this.vars.newp.push(id);
			this.produit[id]=new McLignePanier(this);
			//alert(id+'\n'+this.produit[id].data.titre+'\n'+qt);
			this.produit[id].setQte(qt);
			}
		}
	this.getNewProduits();
	this.saveCook();
	this.update();
	}

McPanier.prototype.getNewProduits = function ()
	{
	if (!(this.vars.newp.length>0))
		{
		//this.update();
		return;
		}
	
	var http = new getHTTP();
	var obj=this;
	var url='/McAjax/get_produits.cgi?produits='+this.vars.newp.join(',');
	//alert(url);	
	//for (var i=0;i<this.newp.length;i++) { }
	
	http.open("GET", url, true);
	http.onreadystatechange = function ()
		{
		if (http.readyState == 4 && http.status==200)
			{
			//alert(http.responseText);
			var n=0;
			var pds=http.responseText.split('\n\n');
			for (var j=0;j<pds.length;j++)
				{
				var lis=pds[j].split('\n');
				//alert((lis[0].split('\t'))[1]);
				var prod=obj.produit[(lis[0].split('\t'))[1]] ;
				if ((prod) && (prod.exist))
					{
					for (var i=0;i<champsLignePanier.length;i++)
						{
						prod.champsActif[champsLignePanier[i]]=false;
						}
					for (var i=0;i<lis.length;i++)
						{
						var data=lis[i].split('\t');
						if ((data[1]) && (data[1].length>0))
							{
							prod.data[data[0]]=data[1];
							prod.champsActif[data[0]]=true;
							}
						}
					
					for (var ch in prod.champs)
						{
						if ((prod.node[ch]) && (prod.champsActif[ch]))
							{
							prod.node[ch].style.display='';
							}
						else if ((prod.node[ch]) && (!prod.champsActif[ch]))
							{
							prod.node[ch].style.display='none';
							}
						}
					}
				}
			obj.vars.newp= new Array();
			obj.update();
			}
		}
	http.send(null);
	
	return ;
	}


McPanier.prototype.update = function ()
	{
	var tt=0;
	for (var prod in this.produit)
		{
		this.produit[prod].update();
		tt+=Number(this.produit[prod].vars.qte)*Number(this.produit[prod].data.tarif);
		
		}
	if (this.node.total)
		{
		this.node.total.innerHTML=tt;
		//alert('tt'+tt);
		}
	}

McPanier.prototype.saveCook = function ()
	{
	var cook='';
	for (var prod in this.produit)
		{
		if (Number(this.produit[prod].vars.qte)>0)
			cook+=prod+','+Number(this.produit[prod].vars.qte)+'/';
		
		}
		
	var dom = ''+window.location;
	dom=dom.replace(/http:\/\//,'');
	dom=dom.replace(/\/.*/,'');
	//alert('panier='+cook+';domain='+dom);
	document.cookie='panier='+cook+';domain='+dom;
	}

McLignePanier.prototype.update = function ()
	{
	//alert(this.vars.qte);
	if (this.vars.qte>0)
		{
		this.node.base.style.display='';
		for (var ch in this.champs)
			{
			if ((this.champsActif[ch]) && (this.champs[ch]) && (this.node[ch]))
				{
				//alert(ch+' '+this.data[ch]+' '+this.node[ch]);
				this.node[ch][this.champs[ch]]=this.data[ch];
				}
			}
		var st=Number(this.vars.qte)*Number(this.data.tarif);
		if (!(st>0))
			st=0;
		if (this.node.quantite)
			{
			//alert(this.vars.qte+' QTE');
			this.node.quantite.innerHTML=this.vars.qte;
			}
		if (this.node.sous_total)
			{
			this.node.sous_total.innerHTML=st;
			}
		}
	else
		this.node.base.style.display='none';
	}

McLignePanier.prototype.setQte= function (qt)
	{
	if (!(this.vars.qte>0))
		this.vars.qte=0;
	var nu = Number(qt.replace(/[^0-9]/g,''));
	//alert('NU='+nu);	
	if (qt.match(/^\+/))
		{
		this.vars.qte+=nu;
		}
	else
		{
		this.vars.qte=nu;
		}
		
	}

function getRealTop (node)
  {
  var Y=1;
  var top=0;
  var parent=node;
  while (parent)
	{
	Y=parent.offsetTop;
	if (Y>0)
	  top+=Y;
	//      alert(typeof(top));
	parent=parent.offsetParent;
	}
  return top;
  }

function getRealLeft (node)
  {
  var X=1;
  var left=0;
  var parent=node;
  while (parent)
	{
	X=parent.offsetLeft;
	if (X>0)
	  left+=X;
	//      alert(typeof(top));
	parent=parent.offsetParent;
	}
  return left;
  }



