
function melange() {
 Melanger();
 setTimeout("affiche()",3000);
}

function melangeAnim() {
 Melanger();
 setTimeout("afficheAnim()",1000);
}

function afficheAnim() {
 affiche();
 setTimeout("melangeAnim()",4000);
}

function afficheAnimer() {
 affiche();
 setTimeout("afficheAnimer()",3000);
}

function setX(width,max) {
 do {	ret = Math.round(Math.random()*max*1.5) } while (ret>max-width)
 return ret;
}
function setY(height,max) {
 do {	ret = Math.round(Math.random()*max*1.5) } while (ret>max-height)
 return ret;
}

function Melanger() {
 var item;
 x = page.offsetLeft;	maxX = page.clientWidth-5;
 y = page.offsetTop;	maxY = page.clientHeight-5;
 for ( i=max; i>0; i-- ) {
	p = eval("p"+i);
	if (p) {
		p.style.display ='block';
		p.style.left = x+setX(p.clientWidth+2,maxX);
		p.style.top = y+ setY(p.clientHeight+2,maxY);
	}
 }
}

function affiche() {
 var item;
 x = page.offsetLeft+1;	maxX = x+ page.clientWidth-4; xoff = x;
//alert('x:'+x+' y:'+y);
 y = page.offsetTop+1;
 for ( i=1; i<max+1; i++ ) {
	p = eval("p"+i);
	if (p) {
		if (p.getAttribute('br')) { y +=p.clientHeight+9; xoff=x; }
		xoff =xoff+ (Math.round(Math.random()*4));
		if (xoff+p.clientWidth+2>=maxX) {  y +=p.clientHeight+9; xoff=x+(Math.round(Math.random()*4)); }
		p.style.left = xoff;
		p.style.top = y+ (Math.round(Math.random()*8));
		p.style.visibility ='visible'
		p.style.display ='block'
		xoff += (p.clientWidth+8);
	}
 }
}

function setMots(chaine) {
// a utiliser : setMots('Un petit test pour ... $un grand moment&nbsp;!')
 var Tab = chaine.split(' ');
 var taille = Tab.length;	
 var s, ret='';
 if (taille>0) {
	for (i=0; i<taille; i++) {
		s = Tab[i];
		ret +='<span id="p'+eval(i+1)+'" class="papier"';
		if (s.substr(0,1)=='$') {	// retour ligne
			s = s.substring(1);
			ret += ' br="1"';
		}
		ret +='>'+s+'</span>';
	}
 }
 document.writeln(ret);
 max = taille;	
}

function statut(text) {
window.defaultStatus ='Dominique SALLÉ - 69250 Albigny-sur-Saône - tel : 04 78 91 73 52 - portable : 06 16 84 46 28'
 //if(self.name==top.name) { location.href="index.html" }
}

function stopError() { return true; }
 
window.onerror = stopError;
window.onload=statut;