/* ******************************************** 
 Sujet : 	Affichage de "titre en dégradés"
 Auteur	:	CONRAD Damien
 Propriété :	Amis de l'Orgue de Vendée
********************************************** */

//detection des versions :

// pour les conversion hexadécimales
var tabH = new Array(16);
for (i=1;i<=10;i++) tabH[i]=i+'';
tabH[10]="A";
tabH[11]="B";
tabH[12]="C";
tabH[13]="D";
tabH[14]="E";
tabH[15]="F";

function conv(C) {
// convertion nombre->hexa (h1 et h2 : dizaine et unité en hexa)
	h2=tabH[(C%16)];
	h1=tabH[parseInt(C/16)];
	if (h2==null) h2="0";
	if (h1==null) h1="0";
	return(h1 + h2);
}

function degrade(texte, taille, police, C1, C2) {
// Affiche un dégradé <html> : couleur de départ(C1) et d'arrivée(C2)
	taille = 5 * taille;
	R1=parseInt(C1.substring(1,3),16);
	R2=parseInt(C2.substring(1,3),16);
	G1=parseInt(C1.substring(3,5),16);
	G2=parseInt(C2.substring(3,5),16);
	B1=parseInt(C1.substring(5,7),16);
	B2=parseInt(C2.substring(5,7),16);
	//R1,G1... st les composantes rgb de C1 et C2

	n=texte.length;
	facteurR=parseInt((R2-R1)/n);
	facteurG=parseInt((G2-G1)/n);
	facteurB=parseInt((B2-B1)/n);
	//facteurX définit l'interval de progression pour X
		
	var i;
	var r,v,b,t;
	t='<span style="font-weight:bold;font-size:'+taille+'px;font-family:"'+police+';">';
	for (i=0;i<n;i++) {
		R1+=facteurR
		G1+=facteurG
		B1+=facteurB
		r=conv(R1);
		v=conv(G1);
		b=conv(B1);
		t+='<span style="color:#'+r+v+b+'">' + texte.substring (i,i+1) + '</span>';
	}
	document.write (t+'</span><br/>');
}

//------------- Spécificités -----------------

function degrade1(texte) {
	degrade(texte,6,'Times New Roman','#4040F0','#e0e0F0');
}
function degrade2(texte) {
	degrade(texte,5,'Times New Roman','#4040E0','#E0E0FF');
}
function degrade3(t1,t2,t3) {
	degrade(t1,6,'Times New Roman',"#000000","#EED0D0");
	degrade(t2,6,'Times New Roman',"#200000","#DDC0C0");
	degrade(t3,6,'Times New Roman',"#000000","#EED0D0");
}


