if(debug_mode && firebug)console.log("fonctions.js chargé");


function fond_rose(elmt,actif){
	if(actif)
	{
		elmt.style.backgroundColor='#ffa4c2';
	}
	else
	{
		elmt.style.backgroundColor='#ffffff';
	}
}

function defilement(defiler){
	if(defiler)
	{
		//récupérer les id de tous les articles
		articles = GetElementsByClassName('article','div','defil_prod');
		
		//aligner les articles
		var l = marge;
		//pour chaque élément du tableau, le placer à la droite de l'élément précédent
		for(i = 0; i < articles.length - 1; i++)
		{
			articles[i].style.left = l+articles[i].offsetWidth+'px';
			l += articles[i].offsetWidth+marge;
		}
		
		defil = setInterval('decaler(articles)',vitesse);
	}
	else
	{
		clearInterval(defil);
	}
}

function decaler(tab){
	var swap = false;
	for (var i = 0; i < tab.length; i++) { 
		ob = tab[i]; 
		ob.style.left = (ob.offsetLeft - pas) + 'px'; 
		
		if (- ob.offsetLeft >= ob.offsetWidth) {
			swap = true;
		}
	}
	
	if (swap) {
		tab[0].style.left = tab[articles.length - 1].offsetLeft + tab[articles.length - 1].offsetWidth + marge +'px';
		tab.push(tab.shift());
	}
}

function GetElementsByClassName(classname,tag,parent){

	divs = document.getElementById(parent).getElementsByTagName(tag);
	
	var id_divs = new Array();
	
	for(i=0;i<divs.length;i++)
	{
		if(divs[i].className==classname)
		{
			id_divs.push(divs[i]);
		}
	}
	return id_divs;
}