var offsetx = 18;
var offsety = 20;

function onCommerce(c, planx, plany)
{
	var etoile = document.getElementById("etoile");
	
	c.insertBefore(etoile, c.firstChild);
	
	loadCible(planx, plany);
}

function loadCible(planx, plany)
{
	var cible  = document.getElementById("cible");
	var plan   = document.getElementById("plan");
	
	cible.style.marginLeft = (planx - 18 + offsetx) + 'px';
	cible.style.marginTop  = (plany + 5 + offsety) + 'px';
	
	plan.insertBefore(cible, plan.firstChild);
}

function addMaison(planx, plany, src, elt, catcode, commcode, commnom, width, height)
{
	
	if( elt == null )
	{
		elt = 'plan';
	}
	
	var maison = document.createElement("div");
	
	if( typeof commcode != 'undefined' )
	{
		var a = document.createElement('a');
		a.href = root + 'guide-shopping/' + catcode + '/' + commcode;
	}
	
	var img    = document.createElement("img");
	img.src    = root + "img/"+src+".png";
	
	width = width == null ? '20' : width;
	height = height == null ? '12' : height;
	
	img.width  = width;
	img.height = height;
	img.style.border = 0;
	
		
	var plan   = document.getElementById(elt);

	if( typeof commcode != 'undefined' )
	{
		var caption = document.createElement('div');
		caption.style.position = 'absolute';
		caption.style.display = 'none';
		caption.style.padding = '5px';
		caption.style.border = '1px solid #ffaf00';
		caption.style.width = '100px';
		caption.style.marginLeft = '25px';
		caption.style.backgroundColor = '#FFEFCC';
		caption.style.color = '#000066';
		caption.style.zIndex = 2000;
		caption.style.textTransform = 'capitalize';
		caption.innerHTML = commnom;
		caption.id = 'maison'+ commcode;
		
		maison.appendChild(caption);

		
		a.appendChild(img);
		maison.appendChild(a);
		maison.onmouseover = function() {this.firstChild.style.display = 'block';};
		maison.onmouseout = function() {this.firstChild.style.display = 'none';};
	}
	else
	{
		maison.appendChild(img);		
	}
	
	
	
	maison.style.position = 'absolute';
	maison.style.marginLeft = (planx + offsetx) + 'px';
	maison.style.marginTop  = (plany + 25 + offsety) + 'px';
	
	plan.insertBefore(maison, plan.firstChild);
}

function outCommerce(c)
{
	
}

