// ***************
// * Vocabulaire *
// ***************

/*
var COLOR_PICKER_VOC_RVB = 'Rvb';
var COLOR_PICKER_VOC_WEB = 'Web';
var COLOR_PICKER_VOC_NOM = 'Nom.';
var COLOR_PICKER_VOC_SAV = 'Sav.';
var COLOR_PICKER_VOC_ABOUT = 'About';
var COLOR_PICKER_VOC_R = '(R) ';
var COLOR_PICKER_VOC_V = '(V) ';
var COLOR_PICKER_VOC_B = '(B) ';
var COLOR_PICKER_VOC_TRANS = '(Trans.)';
var COLOR_PICKER_VOC_HEXA = ' (Hexa)';
var COLOR_PICKER_VOC_REC = 'Rec';
var COLOR_PICKER_VOC_VALIDER = 'Valider';
var COLOR_PICKER_VOC_ANNULER = 'Annuler';
*/

var COLOR_PICKER_VOC_RVB = 'Rgb';
var COLOR_PICKER_VOC_WEB = 'Web';
var COLOR_PICKER_VOC_NOM = 'Name';
var COLOR_PICKER_VOC_SAV = 'Rec.';
var COLOR_PICKER_VOC_ABOUT = 'About';
var COLOR_PICKER_VOC_R = '(R) ';
var COLOR_PICKER_VOC_V = '(G) ';
var COLOR_PICKER_VOC_B = '(B) ';
var COLOR_PICKER_VOC_TRANS = '(Trans.)';
var COLOR_PICKER_VOC_HEXA = ' (Hexa)';
var COLOR_PICKER_VOC_REC = 'Rec';
var COLOR_PICKER_VOC_VALIDER = 'Choose';
var COLOR_PICKER_VOC_ANNULER = 'Cancel';


// **************************************************************
// * Fonction universelle pour découvrir la position d'un objet *
// **************************************************************
function FindPos(AObject)
{
	var posX = 0, posY = 0;
	
	do
	{
		posX += AObject.offsetLeft;
		posY += AObject.offsetTop;
		AObject = AObject.offsetParent;
	}
	
	while( AObject != null );
	var pos = [];
	pos['X'] = posX;
	pos['Y'] = posY;
	
	return pos;
}

// ***************************************************************
// * Fonction pour définir l'élément insertAfter manquant du DOM *
// ***************************************************************
function insertAfter(newElement, targetElement)
{
	var parent = targetElement.parentNode;
	if (parent.lastchild == targetElement)
	{
		parent.appendChild(newElement);
	}
	else
	{
		parent.insertBefore(newElement, targetElement.nextSibling);
	}
}


// *************************************************
// * Fonction d'application de styles sur un objet *
// *************************************************
function applique_style(Objet, Style)
{
	if (window.attachEvent && !window.opera)
	{
		Objet.style.setAttribute('cssText', Style);
	}
	else
	{
		Objet.setAttribute('style', Style);
	}
}


// ****************************************************
// * Fonctions de désactivation de sélection du texte *
// ****************************************************
function empeche_select_texte (e)
{
	return false;
}

function autorise_select_texte (e)
{
	return true;
}

// *****************************************
// * Fonctions de conversion hexa <==> dec *
// *****************************************
function d2h(d)
{
	var result = d.toString(16);
	
	if (d <= 15)
	{
		result = '0' + result;
		return result.toUpperCase();
	}
	else
	{
		return result.toUpperCase();
	}
}
function h2d(h)
{
	return parseInt(h,16);
}

// ************************************************
// * fonction : Cookie et sauvegarde des couleurs *
// ************************************************
function ecrit_cookie(nom_cookie, valeur_cookie)
{
	var expire = new Date();
	var annee = expire.getTime() + (365*24*60*60*1000);
	expire.setTime(annee);
	document.cookie = nom_cookie + '=' + valeur_cookie + '; expires=' + expire.toGMTString();
}

// *****************************************
// * Initialisation des variables globales *
// *****************************************
var color_picker_cours;
var color_picker;
var couleur_hexa;
var temoin;
var trans_check;
var trans_text;
var champ_color_picker_cours;
var R;
var V;
var B;
var input_R;
var input_V;
var input_B;
var couleur_actuelle;
var tableau_couleurs_save = new Array();
var tableau_inputs_save = new Array();
var tableau_temoins_save = new Array();
var record;

// ****************************
// * Création du color picker *
// ****************************
function color_picker()
{
	// Initialisation des variables
	var Style;
	var menu_items = new Array();
	var cont_items = new Array();
	var id_items = new Array('rvb', 'web', 'name', 'save', 'about');
	var text_items = new Array(COLOR_PICKER_VOC_RVB, COLOR_PICKER_VOC_WEB, COLOR_PICKER_VOC_NOM, COLOR_PICKER_VOC_SAV, COLOR_PICKER_VOC_ABOUT);
	
	// Color-picker
	color_picker = document.createElement("div");
	Style = 'position : absolute; width : 340px; height : 250px; background-color : #BBBBBB; border : 1px solid #000000; font-family : Verdana, Helvetica, sans-serif; font-size : 11px; display : none;';
	applique_style(color_picker, Style);
	
	// Menu
	var menu = document.createElement("ul");
	Style = 'position : absolute; padding : 0px; margin-left : 0px; margin-top : 0px; width : 340px; height : 22px; list-style : none; line-height : 22px; z-index : 2;';
	applique_style(menu, Style);
	
	// Items du menu
	for (var cpt = 0; cpt < text_items.length; cpt++)
	{
		menu_items[cpt] = document.createElement("li");
		menu_items[cpt].setAttribute('id', id_items[cpt]);
		Style = 'margin : 0px; padding-left : 5px; padding-right : 5px; float : left; border-right : 1px solid #000000; cursor : pointer';
		applique_style(menu_items[cpt], Style);
		cont_items[cpt] = document.createTextNode(text_items[cpt]);
		menu_items[cpt].appendChild(cont_items[cpt]);
		
		menu.appendChild(menu_items[cpt]);
		
		menu_items[cpt].onclick = function (event)
		{
			for (var i = 0; i < menu_items.length; i++)
			{
				menu_items[i].style.borderBottom = '1px solid #000000';
				menu_items[i].style.backgroundColor = '#BBBBBB';
			}
			
			this.style.backgroundColor = '#DDDDDD';
			this.style.borderBottom = '1px solid #DDDDDD';
			
			web.style.display = 'none';
			rvb.style.display = 'none';
			nom.style.display = 'none';
			save.style.display = 'none';
			about.style.display = 'none';
			
			switch (this.id)
			{
				case 'rvb' :
				rvb.style.display = 'block';
				if (!trans_check.checked)
				{
					bouge_curseurs(couleur_hexa.value);
				}
				break;
				
				case 'web' :
				web.style.display = 'block';
				if (!trans_check.checked)
				{
					couleur_actuelle = couleur_hexa.value;
				}
				break;
				
				case 'name' :
				nom.style.display = 'block';
				if (!trans_check.checked)
				{
					couleur_actuelle = couleur_hexa.value;
				}
				break;
				
				case 'save' :
				save.style.display = 'block';
				break;
				
				case 'about' :
				about.style.display = 'block';
				break;
			}
		}
	}
	
	// Rvb
	var rvb = document.createElement("div");
	Style = 'position : absolute; margin-top : 22px; margin-left : 0px; width : 340px; height : 178px; border-top : 1px solid #000000; border-bottom : 1px solid #000000; background-color : #DDDDDD; z-index : 1; display : none;';
	applique_style(rvb, Style);
	
	var table_rvb = document.createElement("table");
	Style = 'margin-left : auto; margin-right : auto; margin-top : 28px; width : 320px; height : auto; border : 0px solid #000000; border-collapse : collapse;';
	applique_style(table_rvb, Style);
	var tbody_rvb = document.createElement("tbody");
	table_rvb.appendChild(tbody_rvb);
		
	var table_rvb_lignes = new Array();
	var table_rvb_colonnes = new Array();
	
	for (cpt = 0; cpt < 3; cpt++)
	{
		table_rvb_lignes[cpt] = document.createElement("tr");
		
		for (var i = 0; i < 2; i++)
		{
			table_rvb_colonnes[cpt] = document.createElement("td");
			Style = 'border : 0px solid #000000; padding-top : 10px; padding-bottom : 10px; font-family : Verdana, Helvetica, sans-serif; font-size : 11px;';
			applique_style(table_rvb_colonnes[cpt], Style);
			table_rvb_lignes[cpt].appendChild(table_rvb_colonnes[cpt]);
		}
		
		tbody_rvb.appendChild(table_rvb_lignes[cpt]);
	}
	
	// Curseur R
	var cursor_R = document.createElement("div");
	Style = 'width : 254px; height : 10px; overflow : hidden; border : 1px solid #000000; background-color : #EEEEEE; z-index : 3;';
	applique_style(cursor_R, Style);
	tbody_rvb.getElementsByTagName('td')[0].appendChild(cursor_R);
	
	var text_R = document.createTextNode(COLOR_PICKER_VOC_R);
	tbody_rvb.getElementsByTagName('td')[1].appendChild(text_R);
	
	input_R = document.createElement("input");
	Style = 'width : 28px; height : 15px; border : 1px solid #000000;';
	applique_style(input_R, Style);
	input_R.setAttribute('type', 'text');
	input_R.setAttribute('size', '3');
	input_R.setAttribute('maxLength', 3);
	input_R.setAttribute('readOnly', "readOnly");
	tbody_rvb.getElementsByTagName('td')[1].appendChild(input_R);
	
	// Curseur V
	var cursor_V = document.createElement("div");
	Style = 'width : 254px; height : 10px; overflow : hidden; border : 1px solid #000000; background-color : #EEEEEE; z-index : 3;';
	applique_style(cursor_V, Style);
	tbody_rvb.getElementsByTagName('td')[2].appendChild(cursor_V);
	
	var text_V = document.createTextNode(COLOR_PICKER_VOC_V);
	tbody_rvb.getElementsByTagName('td')[3].appendChild(text_V);
	
	input_V = document.createElement("input");
	Style = 'width : 28px; height : 15px; border : 1px solid #000000;';
	applique_style(input_V, Style);
	input_V.setAttribute('type', 'text');
	input_V.setAttribute('size', '3');
	input_V.setAttribute('maxLength', 3);
	input_V.setAttribute('readOnly', "readOnly");
	tbody_rvb.getElementsByTagName('td')[3].appendChild(input_V);
	
	// Curseur B
	var cursor_B = document.createElement("div");
	Style = 'width : 254px; height : 10px; overflow : hidden; border : 1px solid #000000; background-color : #EEEEEE; z-index : 3;';
	applique_style(cursor_B, Style);
	tbody_rvb.getElementsByTagName('td')[4].appendChild(cursor_B);
	
	var text_B = document.createTextNode(COLOR_PICKER_VOC_B);
	tbody_rvb.getElementsByTagName('td')[5].appendChild(text_B);
	
	input_B = document.createElement("input");
	Style = 'width : 28px; height : 15px; border : 1px solid #000000;';
	applique_style(input_B, Style);
	input_B.setAttribute('type', 'text');
	input_B.setAttribute('size', '3');
	input_B.setAttribute('maxLength', 3);
	input_B.setAttribute('readOnly', "readOnly");
	tbody_rvb.getElementsByTagName('td')[5].appendChild(input_B);
	
	// R
	R = document.createElement("div");
	Style = 'position : absolute; width : 5px; height : 12px; margin-left : -4px; margin-top : -2px; overflow : hidden; border : 1px solid #000000; background-color : #AAAAAA; cursor : pointer;';
	applique_style(R, Style);
	cursor_R.appendChild(R);
	
	input_R.value = 0;
	
	cursor_R.onmousedown = function ()
	{
		cursor_R.style.cursor = "move";
	}
	
	R.onmousedown = function (event)
	{
		R.style.cursor = "move";
		
		if (window.attachEvent && !window.opera)
		{
			rvb.onselectstart = function ()
			{
				return false;
			}
		}
		else
		{
			if (event.preventDefault)
			{
				event.preventDefault();
			}
		}
		
		if (window.attachEvent && !window.opera)
		{
			var prov_R = window.event.x - input_R.value;
		}
		else
		{
			var prov_R = event.clientX - input_R.value;
		}
		
		cursor_R.onmousemove = function (event)
		{
			if (window.attachEvent && !window.opera)
			{
				input_R.value = window.event.x - prov_R;
			}
			else
			{
				input_R.value = event.clientX - prov_R;
			}
			
			R.style.marginLeft = (input_R.value - 4) + 'px';
			
			if (input_R.value <= 0)
			{
				cursor_R.onmousemove = null;
				input_R.value = 0;
				R.style.marginLeft = "-4px";
			}
			
			if (input_R.value >= 255)
			{
				cursor_R.onmousemove = null;
				input_R.value = 255;
				R.style.marginLeft = "251px";
			}
			
			couleur_hexa.value = d2h(eval(input_R.value)) + d2h(eval(input_V.value)) + d2h(eval(input_B.value));
			temoin.style.backgroundColor = '#' + couleur_hexa.value;
		}
	}
	
	// V
	V = document.createElement("div");
	Style = 'position : absolute; width : 5px; height : 12px; margin-left : -4px; margin-top : -2px; overflow : hidden; border : 1px solid #000000; background-color : #AAAAAA; cursor : pointer;';
	applique_style(V, Style);
	cursor_V.appendChild(V);
	
	input_V.value = 0;
	
	cursor_V.onmousedown = function ()
	{
		cursor_V.style.cursor = "move";
	}
	
	V.onmousedown = function (event)
	{
		V.style.cursor = "move";
		
		if (window.attachEvent && !window.opera)
		{
			rvb.onselectstart = function ()
			{
				return false;
			}
		}
		else
		{
			if (event.preventDefault)
			{
				event.preventDefault();
			}
		}
		
		if (window.attachEvent && !window.opera)
		{
			var prov_V = window.event.x - input_V.value;
		}
		else
		{
			var prov_V = event.clientX - input_V.value;
		}
		
		cursor_V.onmousemove = function (event)
		{
			if (window.attachEvent && !window.opera)
			{
				input_V.value = window.event.x - prov_V;
			}
			else
			{
				input_V.value = event.clientX - prov_V;
			}
			
			V.style.marginLeft = (input_V.value - 4) + 'px';
			
			if (input_V.value <= 0)
			{
				cursor_V.onmousemove = null;
				input_V.value = 0;
				V.style.marginLeft = "-4px";
			}
			
			if (input_V.value >= 255)
			{
				cursor_V.onmousemove = null;
				input_V.value = 255;
				V.style.marginLeft = "251px";
			}
			
			couleur_hexa.value = d2h(eval(input_R.value)) + d2h(eval(input_V.value)) + d2h(eval(input_B.value));
			temoin.style.backgroundColor = '#' + couleur_hexa.value;
		}
	}
	
	// B
	B = document.createElement("div");
	Style = 'position : absolute; width : 5px; height : 12px; margin-left : -4px; margin-top : -2px; overflow : hidden; border : 1px solid #000000; background-color : #AAAAAA; cursor : pointer;';
	applique_style(B, Style);
	cursor_B.appendChild(B);
	
	input_B.value = 0;
	
	cursor_B.onmousedown = function ()
	{
		cursor_B.style.cursor = "move";
	}
	
	B.onmousedown = function (event)
	{
		B.style.cursor = "move";
		
		if (window.attachEvent && !window.opera)
		{
			rvb.onselectstart = function ()
			{
				return false;
			}
		}
		else
		{
			if (event.preventDefault)
			{
				event.preventDefault();
			}
		}
		
		if (window.attachEvent && !window.opera)
		{
			var prov_B = window.event.x - input_B.value;
		}
		else
		{
			var prov_B = event.clientX - input_B.value;
		}
		
		cursor_B.onmousemove = function (event)
		{
			if (window.attachEvent && !window.opera)
			{
				input_B.value = window.event.x - prov_B;
			}
			else
			{
				input_B.value = event.clientX - prov_B;
			}
			
			B.style.marginLeft = (input_B.value - 4) + 'px';
			
			if (input_B.value <= 0)
			{
				cursor_B.onmousemove = null;
				input_B.value = 0;
				B.style.marginLeft = "-4px";
			}
			
			if (input_B.value >= 255)
			{
				cursor_B.onmousemove = null;
				input_B.value = 255;
				B.style.marginLeft = "251px";
			}
			
			couleur_hexa.value = d2h(eval(input_R.value)) + d2h(eval(input_V.value)) + d2h(eval(input_B.value));
			temoin.style.backgroundColor = '#' + couleur_hexa.value;
		}
	}
	
	rvb.onmouseup = function ()
	{
		cursor_R.onmousemove = null;
		cursor_V.onmousemove = null;
		cursor_B.onmousemove = null;
		
		cursor_R.style.cursor = "default";
		R.style.cursor = "pointer";
		cursor_V.style.cursor = "default";
		V.style.cursor = "pointer";
		cursor_B.style.cursor = "default";
		B.style.cursor = "pointer";
	}
	
	rvb.appendChild(table_rvb);
	
	// Web
	var web = document.createElement("div");
	
	Style = 'position : absolute; margin-top : 22px; margin-left : 0px; width : 340px; height : 178px; border-top : 1px solid #000000; border-bottom : 1px solid #000000; background-color : #DDDDDD; z-index : 1; display : none;';
	applique_style(web, Style);
	
	var table_couleur_web = document.createElement("table");
	Style = 'margin-top : 10px; margin-left : auto; margin-right : auto; width : 306px; height : 156px; border : 1px solid #000000; border-collapse : collapse; z-index : 3;';
	applique_style(table_couleur_web, Style);
	web.appendChild(table_couleur_web);
	var tbody_table_couleur_web = document.createElement("tbody");
		
	var tableau_lignes_table_couleurs_web = new Array();
	var tableau_cellules_table_couleurs_web = new Array();
	var tableau_id_cellules = new Array('000000', '000033', '000066', '330000', '330033', '330066', '660000', '660033', '660066', '990000', '990033', '990066', 'CC0000', 'CC0033', 'CC0066', 'FF0000', 'FF0033', 'FF0066', '000099', '0000CC', '0000FF', '330099', '3300CC', '3300FF', '660099', '6600CC', '6600FF', '990099', '9900CC', '9900FF', 'CC0099', 'CC00CC', 'CC00FF', 'FF0099', 'FF00CC', 'FF00FF', '003300', '003333', '003366', '333300', '333333', '333366', '663300', '663333', '663366', '993300', '993333', '993366', 'CC3300', 'CC3333', 'CC3366', 'FF3300', 'FF3333', 'FF3366', '003399', '0033CC', '0033FF', '333399', '3333CC', '3333FF', '663399', '6633CC', '6633FF', '993399', '9933CC', '9933FF', 'CC3399', 'CC33CC', 'CC33FF', 'FF3399', 'FF33CC', 'FF33FF', '006600', '006633', '006666', '336600', '336633', '336666', '666600', '666633', '666666', '996600', '996633', '996666', 'CC6600', 'CC6633', 'CC6666', 'FF6600', 'FF6633', 'FF6666', '006699', '0066CC', '0066FF', '336699', '3366CC', '3366FF', '666699', '6666CC', '6666FF', '996699', '9966CC', '9966FF', 'CC6699', 'CC66CC', 'CC66FF', 'FF6699', 'FF66CC', 'FF66FF', '009900', '009933', '009966', '339900', '339933', '339966', '669900', '669933', '669966', '999900', '999933', '999966', 'CC9900', 'CC9933', 'CC9966', 'FF9900', 'FF9933', 'FF9966', '009999', '0099CC', '0099FF', '339999', '3399CC', '3399FF', '669999', '6699CC', '6699FF', '999999', '9999CC', '9999FF', 'CC9999', 'CC99CC', 'CC99FF', 'FF9999', 'FF99CC', 'FF99FF', '00CC00', '00CC33', '00CC66', '33CC00', '33CC33', '33CC66', '66CC00', '66CC33', '66CC66', '99CC00', '99CC33', '99CC66', 'CCCC00', 'CCCC33', 'CCCC66', 'FFCC00', 'FFCC33', 'FFCC66', '00CC99', '00CCCC', '00CCFF', '33CC99', '33CCCC', '33CCFF', '66CC99', '66CCCC', '66CCFF', '99CC99', '99CCCC', '99CCFF', 'CCCC99', 'CCCCCC', 'CCCCFF', 'FFCC99', 'FFCCCC', 'FFCCFF', '00FF00', '00FF33', '00FF66', '33FF00', '33FF33', '33FF66', '66FF00', '66FF33', '66FF66', '99FF00', '99FF33', '99FF66', 'CCFF00', 'CCFF33', 'CCFF66', 'FFFF00', 'FFFF33', 'FFFF66', '00FF99', '00FFCC', '00FFFF', '33FF99', '33FFCC', '33FFFF', '66FF99', '66FFCC', '66FFFF', '99FF99', '99FFCC', '99FFFF', 'CCFF99', 'CCFFCC', 'CCFFFF', 'FFFF99', 'FFFFCC', 'FFFFFF');
	
	var compteur_cellules = 0;
	
	for (var cpt_lignes = 0; cpt_lignes < 12; cpt_lignes++)
	{
		tableau_lignes_table_couleurs_web[cpt_lignes] = document.createElement("tr");
		tbody_table_couleur_web.appendChild(tableau_lignes_table_couleurs_web[cpt_lignes]);
		
		for (var cpt_cellules = 0; cpt_cellules < 18; cpt_cellules++)
		{
			tableau_cellules_table_couleurs_web[compteur_cellules] = document.createElement("td");
			
			if (window.opera)
			{
				Style = 'width : 12px; height : 13px; border : 1px solid #000000; background-color : #' + tableau_id_cellules[compteur_cellules] + '; cursor : pointer;';
			}
			else
			{
				Style = 'width : 12px; height : auto; border : 1px solid #000000; background-color : #' + tableau_id_cellules[compteur_cellules] + '; cursor : pointer;';
			}
			
			applique_style(tableau_cellules_table_couleurs_web[compteur_cellules], Style);
			tableau_cellules_table_couleurs_web[compteur_cellules].setAttribute('id', tableau_id_cellules[compteur_cellules]);
			tableau_lignes_table_couleurs_web[cpt_lignes].appendChild(tableau_cellules_table_couleurs_web[compteur_cellules]);
						
			tableau_cellules_table_couleurs_web[compteur_cellules].onmouseover = function ()
			{
				couleur_hexa.value = this.id;
				temoin.style.backgroundColor = '#' + this.id;
			}
			
			tableau_cellules_table_couleurs_web[compteur_cellules].onmouseout = function ()
			{
				if (couleur_actuelle != '')
				{
					couleur_hexa.value = couleur_actuelle;
					temoin.style.backgroundColor = '#' + couleur_actuelle;
				}
				else
				{
					couleur_hexa.value = '';
					temoin.style.backgroundColor = '#FFFFFF';
				}
			}
			
			tableau_cellules_table_couleurs_web[compteur_cellules].onclick = function ()
			{
				if (!trans_check.checked)
				{
					couleur_actuelle = this.id;
					couleur_hexa.value = couleur_actuelle;
					temoin.style.backgroundColor = '#' + couleur_actuelle;
				}
			}
			
			compteur_cellules++;
		}
	}
	
	table_couleur_web.appendChild(tbody_table_couleur_web);
	
	// Nom.
	var nom = document.createElement("div");
	Style = 'position : absolute; margin-top : 22px; margin-left : 0px; width : 340px; height : 178px; border-top : 1px solid #000000; border-bottom : 1px solid #000000; background-color : #DDDDDD; z-index : 1; display : none;';
	applique_style(nom, Style);
	
	var div_scroll = document.createElement("div");
	Style = 'margin-left : auto; margin-right : auto; margin-top : 10px; width : 306px; height : 156px; overflow : auto;';
	applique_style(div_scroll, Style);
	
	var table_couleur_nom = document.createElement("table");
	Style = 'margin-top : 2px; margin-left : 2px; width : 280px; height : auto; border-collapse : collapse; border : 1px solid #000000;';
	applique_style(table_couleur_nom, Style);
	div_scroll.appendChild(table_couleur_nom);
	
	var tbody_couleur_nom = document.createElement("tbody");
	table_couleur_nom.appendChild(tbody_couleur_nom);
	
	var tableau_lignes_couleurs_nom = new Array();
	var tableau_cellules_couleurs_nom = new Array();
	var tableau_text_couleurs_nom = new Array();
	var tableau_text_hexa_couleurs = new Array();
	var tableau_noms_couleurs = new Array('aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood' ,'cadetblue' ,'chartreuse' ,'chocolate' ,'coral' ,'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan' ,'darkgoldenrod' ,'darkgray' ,'darkgreen' ,'darkkhaki' ,'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon' ,'darkseagreen' ,'darkslateblue' ,'darkslategray' ,'darkturquoise' ,'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategray', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'snow', 'springgreen', 'steelblue', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen');
	var id_noms_couleurs = new Array('nomF0F8FF', 'nomFAEBD7', 'nom00FFFF', 'nom7FFFD4', 'nomF0FFFF', 'nomF5F5DC', 'nomFFE4C4', 'nom000000', 'nomFFEBCD', 'nom0000FF' ,'nom8A2BE2' ,'nomA52A2A', 'nomDEB887' ,'nom5F9EA0' ,'nom7FFF00' ,'nomD2691E' ,'nomFF7F50' ,'nom6495ED', 'nomFFF8DC', 'nomCC0033', 'nom00FFFF', 'nom000088', 'nom009C9C' ,'nomB8860B' ,'nomAAAAAA' ,'nom006400' ,'nomBDB76B' ,'nom990099', 'nom556B2F', 'nomFF8C00', 'nom9932CC', 'nom880000', 'nomE9967A' ,'nom8FBC8F' ,'nom483D8B' ,'nom2F4F4F' ,'nom00CED1' ,'nom9400D3', 'nomFF1493', 'nom00BFFF', 'nom696969', 'nom1E90FF', 'nomB22222', 'nomFFFAF0', 'nom228B22', 'nomFF00FF', 'nomDCDCDC', 'nomF8F8FF', 'nomFFD700', 'nomDAA520', 'nomBEBEBE', 'nomADFF2F', 'nomADFF2F', 'nomF0FFF0', 'nomFF69B4', 'nomCD5C5C', 'nom000099', 'nomFFFFF0', 'nomF0E68C', 'nomFFF0F5', 'nomFFF0F5', 'nom7CFC00', 'nomFFFACD', 'nomADD8E6', 'nomF08080', 'nomE0FFFF', 'nomFAFAD2', 'nom99FF99', 'nomD3D3D3', 'nomFFB6C1', 'nomFFA07A', 'nom20B2AA', 'nom87CEFA', 'nom778899', 'nomB0C4DE', 'nomFFFFE0', 'nom32CD32', 'nom32CD32', 'nomFAF0E6', 'nomFF00FF', 'nomB03060', 'nom66CDAA', 'nom0000CD', 'nomBA55D3', 'nom9370DB', 'nom3CB371', 'nom7B68EE', 'nom7B68EE', 'nom00FA9A', 'nom48D1CC', 'nomC71585', 'nom191970', 'nomF5FFFA', 'nomFFE4E1', 'nomFFE4B5', 'nomFFDEAD', 'nom000080', 'nomFDF5E6', 'nom6B8E23', 'nom6B8E23', 'nomFF4500', 'nomFF4500', 'nomDA70D6', 'nomEEE8AA', 'nom98FB98', 'nomAFEEEE', 'nomDB7093', 'nomFFEFD5', 'nomFFDAB9', 'nomCD853F', 'nomFFC0CB', 'nomDDA0DD', 'nomB0E0E6', 'nomA020F0', 'nomBC8F8F', 'nom4169E1', 'nom8B4513', 'nomFA8072', 'nomF4A460', 'nom2E8B57', 'nomFFF5EE', 'nomA0522D', 'nomCCCCCC', 'nom87CEEB', 'nom6A5ACD', 'nom708090', 'nomFFFAFA', 'nom00FF7F', 'nom4682B4', 'nom009999', 'nomD8BFD8', 'nomFF6347', 'nom40E0D0', 'nomEE82EE', 'nomF5DEB3', 'nomFFFFFF', 'nomF5F5F5', 'nomFFFF00', 'nom9ACD32');
	var compteur = 0;
	
	for (cpt_lignes = 0; cpt_lignes < 139; cpt_lignes++)
	{
		tableau_lignes_couleurs_nom[cpt_lignes] = document.createElement("tr");
		Style = 'background-color : #CCCCCC; cursor : pointer;';
		applique_style(tableau_lignes_couleurs_nom[cpt_lignes], Style);
		tableau_lignes_couleurs_nom[cpt_lignes].setAttribute('id', id_noms_couleurs[cpt_lignes]);
		
		tableau_cellules_couleurs_nom[compteur] = document.createElement("td");
		Style = 'border : 1px solid #000000; padding-left : 4px;';
		applique_style(tableau_cellules_couleurs_nom[compteur], Style);
		tableau_text_couleurs_nom[cpt_lignes] = document.createTextNode(tableau_noms_couleurs[cpt_lignes]);
		tableau_cellules_couleurs_nom[compteur].appendChild(tableau_text_couleurs_nom[cpt_lignes]);
		
		tableau_lignes_couleurs_nom[cpt_lignes].appendChild(tableau_cellules_couleurs_nom[compteur]);
		
		compteur++;
		
		tableau_cellules_couleurs_nom[compteur] = document.createElement("td");
		Style = 'border : 1px solid #000000; padding-left : 4px;';
		applique_style(tableau_cellules_couleurs_nom[compteur], Style);
		tableau_text_hexa_couleurs[cpt_lignes] = document.createTextNode(id_noms_couleurs[cpt_lignes].replace('nom', '#'));
		tableau_cellules_couleurs_nom[compteur].appendChild(tableau_text_hexa_couleurs[cpt_lignes]);
		
		tableau_lignes_couleurs_nom[cpt_lignes].appendChild(tableau_cellules_couleurs_nom[compteur]);
		
		compteur++;
		
		tableau_cellules_couleurs_nom[compteur] = document.createElement("td");
		Style = 'width : 80px; border : 1px solid #000000; background-color : ' + id_noms_couleurs[cpt_lignes].replace('nom', '#') + ';';
		applique_style(tableau_cellules_couleurs_nom[compteur], Style);
		
		tableau_lignes_couleurs_nom[cpt_lignes].appendChild(tableau_cellules_couleurs_nom[compteur]);
		
		compteur++;
				
		tbody_couleur_nom.appendChild(tableau_lignes_couleurs_nom[cpt_lignes]);
		
		tableau_lignes_couleurs_nom[cpt_lignes].onmouseover = function ()
		{
			couleur_hexa.value = this.id.replace('nom', '');
			temoin.style.backgroundColor = '#' + this.id.replace('nom', '');
			document.getElementById(this.id).style.backgroundColor = "#EEEEEE";
		}
		
		tableau_lignes_couleurs_nom[cpt_lignes].onmouseout = function ()
		{
			if (couleur_actuelle != '')
			{
				couleur_hexa.value = couleur_actuelle;
				temoin.style.backgroundColor = '#' + couleur_actuelle;
			}
			else
			{
				couleur_hexa.value = '';
				temoin.style.backgroundColor = '#FFFFFF';
			}
			document.getElementById(this.id).style.backgroundColor = "#CCCCCC";
		}
		
		tableau_lignes_couleurs_nom[cpt_lignes].onclick = function ()
		{
			if (!trans_check.checked)
			{
				couleur_actuelle = this.id.replace('nom', '');
				couleur_hexa.value = couleur_actuelle;
				temoin.style.backgroundColor = '#' + couleur_actuelle;
			}
		}
	}
 	
	nom.appendChild(div_scroll);
	
	// Sav.
	var save = document.createElement("div");
	Style = 'position : absolute; margin-top : 22px; margin-left : 0px; width : 340px; height : 178px; border-top : 1px solid #000000; border-bottom : 1px solid #000000; background-color : #DDDDDD; z-index : 1; display : none;';
	applique_style(save, Style);
	
	var table_save = document.createElement("table");
	Style = 'background-color : #CCCCCC; margin-left : auto; margin-right : auto; margin-top : 10px; width : 306px; height : 156px; border : 1px solid #000000; border-collapse : collapse;';
	applique_style(table_save, Style);
	
	var tbody_save = document.createElement("tbody");
	table_save.appendChild(tbody_save);
	
	if (!navigator.cookieEnabled)
	{
		var tr_save = document.createElement("tr");
		tbody_save.appendChild(tr_save);
		
		var td_save = document.createElement("td");
		Style = 'text-align : center; font-weight : bold;';
		applique_style(td_save, Style);
		var text_td_save = document.createTextNode('Coockies désactivés - Fonction désactivée');
		td_save.appendChild(text_td_save);
		tr_save.appendChild(td_save);
	}
	else
	{
		tableau_couleurs_save = Array('000000', '000000', '000000', '000000', '000000', '000000' ,'000000' ,'000000');
		
		if (document.cookie.substring(0, 12) != "color_picker")
		{
			ecrit_cookie('color_picker', 'C-#000000|C-#000000|C-#000000|C-#000000|C-#000000|C-#000000|C-#000000|C-#000000');
			var tableau_prov_couleurs_sav = new Array ('C-#000000', 'C-#000000', 'C-#000000', 'C-#000000', 'C-#000000', 'C-#000000', 'C-#000000', 'C-#000000');
			var chaine_prov_couleurs_sav = document.cookie.replace('color_picker=', '');
			var tableau_prov_couleurs_sav = chaine_prov_couleurs_sav.split("|");
			tableau_prov_couleurs_sav[7] = tableau_prov_couleurs_sav[7].substring(0, 9);
		}
		else
		{
			var chaine_prov_couleurs_sav = document.cookie.replace('color_picker=', '');
			var tableau_prov_couleurs_sav = chaine_prov_couleurs_sav.split("|");
			tableau_prov_couleurs_sav[7] = tableau_prov_couleurs_sav[7].substring(0, 9);
		}
		
		var tableau_lignes_save = new Array();
		var tableau_cellules_save = new Array();
		var cpt_cases_save = 0;
				
		for (var cpt_lignes_save = 0; cpt_lignes_save < 4; cpt_lignes_save++)
		{
			tableau_lignes_save[cpt_lignes_save] = document.createElement("tr");
			
			for (var cpt_cellules_save = 0; cpt_cellules_save < 2; cpt_cellules_save++)
			{
				tableau_cellules_save[cpt_cases_save] = document.createElement("td");
				Style = 'width : 153px; height : 39px; text-align : center;';
				applique_style(tableau_cellules_save[cpt_cases_save], Style);
				
				tableau_inputs_save[cpt_cases_save] = document.createElement("input");
				Style = 'width : 68px; height : 15px; border : 1px solid #000000;';
				applique_style(tableau_inputs_save[cpt_cases_save], Style);
				tableau_inputs_save[cpt_cases_save].setAttribute('type', 'text');
				tableau_inputs_save[cpt_cases_save].setAttribute('size', '7');
				tableau_inputs_save[cpt_cases_save].setAttribute('readOnly', "readOnly");
				tableau_inputs_save[cpt_cases_save].setAttribute('id', 'txt-sav-' + cpt_cases_save);
				tableau_inputs_save[cpt_cases_save].value = tableau_prov_couleurs_sav[cpt_cases_save].replace('C-', '');
				tableau_cellules_save[cpt_cases_save].appendChild(tableau_inputs_save[cpt_cases_save]);
				
				tableau_couleurs_save[cpt_cases_save] = tableau_prov_couleurs_sav[cpt_cases_save].replace('C-#', '');
				
				tableau_temoins_save[cpt_cases_save] = document.createElement("input");
				Style = 'margin-left : 4px; width : 38px; height : 15px; border : 1px solid #000000; text-align : center; cursor : pointer; background-color : ' + tableau_inputs_save[cpt_cases_save].value + ';';
				applique_style(tableau_temoins_save[cpt_cases_save], Style);
				tableau_temoins_save[cpt_cases_save].setAttribute('type', 'text');
				tableau_temoins_save[cpt_cases_save].setAttribute('size', '1');
				tableau_temoins_save[cpt_cases_save].setAttribute('id', 'temoin-sav-' + cpt_cases_save);
				tableau_temoins_save[cpt_cases_save].setAttribute('readOnly', "readOnly");
				
				tableau_temoins_save[cpt_cases_save].onclick = function ()
				{
					if (!trans_check.checked)
					{
						couleur_hexa.value = document.getElementById(this.id.replace('temoin-sav-', 'txt-sav-')).value.replace('#', '');
						temoin.style.backgroundColor = '#' + document.getElementById(this.id.replace('temoin-sav-', 'txt-sav-')).value.replace('#', '');
					}
				}
				
				tableau_cellules_save[cpt_cases_save].appendChild(tableau_temoins_save[cpt_cases_save]);
								
				tableau_lignes_save[cpt_lignes_save].appendChild(tableau_cellules_save[cpt_cases_save]);
				cpt_cases_save++;
			}
			
			tbody_save.appendChild(tableau_lignes_save[cpt_lignes_save]);
		}
	}
	
	save.appendChild(table_save);
	
	// About
	var about = document.createElement("div");
	Style = 'position : absolute; margin-top : 22px; margin-left : 0px; width : 340px; height : 178px; border-top : 1px solid #000000; border-bottom : 1px solid #000000; background-color : #DDDDDD; z-index : 1; display : none;';
	applique_style(about, Style);
	about.innerHTML = '<div style="text-align : center; padding-top : 20px; line-height : 20px;">HermesPicker<br />GNU Color-picker<br />by HermesDev.net</div>';
	
	// Pied
	var pied = document.createElement("div");
	Style = 'position : absolute; padding-top : 2px; margin-top : 202px; margin-left : 0px; width : 340px; height : 46px; background-color : #CCCCCC; text-align : center; line-height : 22px; vertical-align : middle; z-index : 2;';
	applique_style(pied, Style);
	trans_check = document.createElement("input");
	trans_check.setAttribute('type', 'checkbox');
	trans_check.style.verticalAlign = 'bottom';
	pied.appendChild(trans_check);
	trans_text = document.createTextNode(COLOR_PICKER_VOC_TRANS);
	pied.appendChild(trans_text);
	couleur_hexa = document.createElement("input");
	couleur_hexa.setAttribute('type', 'text');
	couleur_hexa.setAttribute('size', '6');
	couleur_hexa.setAttribute('maxLength', 6);
	Style = 'margin-left : 10px; border : 1px solid #000000; width : 56px; height : 15px;';
	applique_style(couleur_hexa, Style);
	pied.appendChild(couleur_hexa);
	var text_hexa = document.createTextNode(COLOR_PICKER_VOC_HEXA);
	pied.appendChild(text_hexa);
	temoin = document.createElement("input");
	temoin.setAttribute('type', 'text');
	temoin.setAttribute('size', '1');
	temoin.setAttribute('readOnly', 'readonly');
	Style = 'margin-left : 10px; border : 1px solid #000000; width : 38px; height : 15px; cursor : default;';
	applique_style(temoin, Style);
	pied.appendChild(temoin);
	record = document.createElement("input");
	record.setAttribute('type', 'button');
	record.value = COLOR_PICKER_VOC_REC;
	Style = 'margin-left : 4px; border : 1px solid #FF0000; color : #FF0000; height : 19px;';
	applique_style(record, Style);
	pied.appendChild(record);
	var saut = document.createElement("br");
	pied.appendChild(saut);
	var valider = document.createElement("input");
	valider.setAttribute('type', 'button');
	valider.value = COLOR_PICKER_VOC_VALIDER;
	Style = 'border : 1px solid #000000; height : 19px;';
	applique_style(valider, Style);
	pied.appendChild(valider);
	var annuler = document.createElement("input");
	annuler.setAttribute('type', 'button');
	annuler.value = COLOR_PICKER_VOC_ANNULER;
	Style = 'margin-left : 10px; border : 1px solid #000000; height : 19px;';
	applique_style(annuler, Style);
	pied.appendChild(annuler);
	
	// Annuler
	annuler.onclick = function ()
	{
		// color_picker.style.visibility = "hidden";
		color_picker.style.display = "none";
		document.getElementById(champ_color_picker_cours).readOnly = false;
	}
	
	// Valider
	valider.onclick = function ()
	{
		champ_color_picker_cours = color_picker_cours.replace('temoin-', '');
		document.getElementById(champ_color_picker_cours).value = couleur_hexa.value;
		if (document.getElementById(champ_color_picker_cours).value == '')
		{
			document.getElementById(color_picker_cours).style.backgroundColor = 'transparent';
		}
		else
		{
			document.getElementById(color_picker_cours).style.backgroundColor = '#' + couleur_hexa.value;
		}
		// color_picker.style.visibility = "hidden";
		color_picker.style.display = "none";
		document.getElementById(champ_color_picker_cours).readOnly = false;
	}
	
	// Transparence
	trans_check.onclick = function ()
	{
		if (trans_check.checked)
		{
			couleur_hexa.value = '';
			couleur_hexa.disabled = true;
			record.disabled = true;
			temoin.style.backgroundColor = "#FFFFFF";
			R.style.display = "none";
			R.style.marginLeft = "-4px";
			input_R.value = "0";
			V.style.display = "none";
			V.style.marginLeft = "-4px";
			input_V.value = "0";
			B.style.display = "none";
			B.style.marginLeft = "-4px";
			input_B.value = "0";
			temoin.disabled = true;
		}
		else
		{
			couleur_hexa.disabled = false;
			record.disabled = false;
			couleur_hexa.value = '000000';
			temoin.style.backgroundColor = "#000000";
			R.style.display = "block";
			V.style.display = "block";
			B.style.display = "block";
			temoin.disabled = false;
		}
	}
	
	// Enregistrement des couleurs
	record.onclick = function ()
	{
		var chaine_ecriture = '';
		tableau_couleurs_save.unshift(couleur_hexa.value);
		
		for (cpt = 0; cpt < 8; cpt++)
		{
			tableau_inputs_save[cpt].value = '#' + tableau_couleurs_save[cpt];
			tableau_temoins_save[cpt].style.backgroundColor = '#' + tableau_couleurs_save[cpt];
			
			if (cpt == 0)
			{
				chaine_ecriture += 'C-#' + tableau_couleurs_save[cpt];
			}
			else
			{
				chaine_ecriture += '|C-#' + tableau_couleurs_save[cpt];
			}
		}
		
		ecrit_cookie('color_picker', chaine_ecriture);
	}
	
	// Trace le color-picker
	document.body.appendChild(color_picker);
	color_picker.appendChild(menu);
	color_picker.appendChild(rvb);
	color_picker.appendChild(web);
	color_picker.appendChild(nom);
	color_picker.appendChild(save);
	color_picker.appendChild(about);
	color_picker.appendChild(pied);
	
	if (window.attachEvent && !window.opera)
	{
		menu.onselectstart = function ()
		{
			return false;
		}
	}
	else
	{
		menu.onmousedown = empeche_select_texte;
		menu.onclick = autorise_select_texte;
	}
		
	rvb.style.display = 'block';
	document.getElementById('rvb').style.backgroundColor = '#DDDDDD';
	document.getElementById('rvb').style.borderBottom = '1px solid #DDDDDD';
}

// **************************************************************************************
// * Détecte la présence des inputs nécessitant un color-picker et création des témoins *
// **************************************************************************************
function start_pickers()
{
	var cpt_colorpickers = 0;
	var table_id_colorpickers = new Array();
	var table_temoins_colorpickers = new Array();
	
	for (var cpt = 0; cpt < document.getElementsByTagName('input').length; cpt++)
	{
		if (document.getElementsByTagName('input')[cpt].id.substr(0, 12) == 'color-picker')
		{
			table_id_colorpickers[cpt_colorpickers] = document.getElementsByTagName('input')[cpt].id;
			
			document.getElementById(table_id_colorpickers[cpt_colorpickers]).onkeyup = function ()
			{
				var id_colorpicker_cours = 'temoin-' + this.id;
				
				if (document.getElementById(this.id).value.length == 6)
				{
					var expreg = new RegExp("[a-fA-F0-9]{6}$");
										
					if (!expreg.test(document.getElementById(this.id).value))
					{
						document.getElementById(this.id).value = '';
						document.getElementById(id_colorpicker_cours).style.backgroundColor = 'transparent';
					}
					else
					{
						document.getElementById(this.id).value = document.getElementById(this.id).value.toUpperCase();
					}
					
					var id_colorpicker_cours = 'temoin-' + this.id;
					document.getElementById(id_colorpicker_cours).style.backgroundColor = '#' + document.getElementById(this.id).value;
				}
				else
				{
					document.getElementById(id_colorpicker_cours).style.backgroundColor = 'transparent';
				}
			}
			
			document.getElementById(table_id_colorpickers[cpt_colorpickers]).onchange = function ()
			{
				var expreg = new RegExp("[a-fA-F0-9]{6}$");
				var id_colorpicker_cours = 'temoin-' + this.id;
				
				if (!expreg.test(document.getElementById(this.id).value))
				{
					document.getElementById(this.id).value = '';
					document.getElementById(id_colorpicker_cours).style.backgroundColor = 'transparent';
				}
				else
				{
					document.getElementById(this.id).value = document.getElementById(this.id).value.toUpperCase();
				}
				
				if (document.getElementById(this.id).value.length == 6)
				{
					document.getElementById(id_colorpicker_cours).style.backgroundColor = '#' + document.getElementById(this.id).value;
				}
			}
			
			cpt_colorpickers++;
		}
	}
	
	for (cpt = 0; cpt < table_id_colorpickers.length; cpt++)
	{
		var id_colorpicker_cours = 'temoin-' + table_id_colorpickers[cpt];
		table_temoins_colorpickers[cpt] = document.createElement("input");
		table_temoins_colorpickers[cpt].setAttribute('type', 'text');
		table_temoins_colorpickers[cpt].setAttribute('size', 1);
		table_temoins_colorpickers[cpt].setAttribute('readOnly', 'readonly');
		table_temoins_colorpickers[cpt].setAttribute('id', id_colorpicker_cours);
		var Style = 'margin-left : 1px; border : 1px solid #000000; cursor : pointer; height : ' + (document.getElementById(table_id_colorpickers[cpt]).offsetHeight - 4)  + 'px; width : ' + (document.getElementById(table_id_colorpickers[cpt]).offsetHeight - 4) + 'px;';
		applique_style(table_temoins_colorpickers[cpt], Style);
		insertAfter(table_temoins_colorpickers[cpt], document.getElementById(table_id_colorpickers[cpt]));
		
		var expreg = new RegExp("[a-fA-F0-9]{6}$");
		if (!expreg.test(document.getElementById(table_id_colorpickers[cpt]).value))
		{
			document.getElementById(id_colorpicker_cours).style.backgroundColor = "transparent";
		}
		else
		{
			document.getElementById(id_colorpicker_cours).style.backgroundColor = "#" + document.getElementById(table_id_colorpickers[cpt]).value;
		}
		
		table_temoins_colorpickers[cpt].onclick = function ()
		{
			if (document.getElementById(champ_color_picker_cours))
			{
				document.getElementById(champ_color_picker_cours).readOnly = false;
			}
			color_picker_cours = this.id;
			champ_color_picker_cours = color_picker_cours.replace('temoin-', '');
						
			var expreg = new RegExp("^[a-fA-F0-9]{6}$");
			if (!expreg.test(document.getElementById(champ_color_picker_cours).value) || document.getElementById(champ_color_picker_cours).value == '')
			{
				if (champ_color_picker_cours.substr(0, 15) == "color-picker-tr")
				{
					couleur_hexa.value = '';
					couleur_hexa.disabled = true;
					record.disabled = true;
					temoin.style.backgroundColor = "#FFFFFF";
					R.style.display = "none";
					R.style.marginLeft = "-4px";
					input_R.value = "0";
					V.style.display = "none";
					V.style.marginLeft = "-4px";
					input_V.value = "0";
					B.style.display = "none";
					B.style.marginLeft = "-4px";
					input_B.value = "0";
					temoin.disabled = true;
					trans_check.checked = true;
				}
				else
				{
					couleur_hexa.value = document.getElementById(champ_color_picker_cours).value.toUpperCase();
					temoin.style.backgroundColor = '#000000';
					couleur_hexa.value = "000000";
					trans_check.checked = false;
					couleur_hexa.disabled = false;
					record.disabled = false;
					R.style.display = "block";
					V.style.display = "block";
					B.style.display = "block";
					R.style.marginLeft = "-4px";
					V.style.marginLeft = "-4px";
					B.style.marginLeft = "-4px";
					input_R.value = "0";
					input_V.value = "0";
					input_B.value = "0";
				}
			}
			else
			{
				couleur_hexa.value = document.getElementById(champ_color_picker_cours).value.toUpperCase();
				temoin.style.backgroundColor = '#' + couleur_hexa.value;
				trans_check.checked = false;
				couleur_hexa.disabled = false;
				R.style.display = "block";
				V.style.display = "block";
				B.style.display = "block";
				
				bouge_curseurs(couleur_hexa.value);
			}
			
			var largeur_page = document.body.offsetWidth;
					
			var pos_x_picker = FindPos(document.getElementById(this.id))['X'];
			var pos_y_picker = FindPos(document.getElementById(this.id))['Y'];
			
			if (pos_x_picker + 345 > largeur_page)
			{
				color_picker.style.left = (((pos_x_picker - 340) + document.getElementById(this.id).offsetWidth) - 2) + "px";
			}
			else
			{
				color_picker.style.left = pos_x_picker + "px";
			}
			
			if (champ_color_picker_cours.substr(0, 15) == "color-picker-tr")
			{
				trans_check.style.display = "inline";
				trans_text.data = '(Trans.)';
			}
			else
			{
				trans_check.style.display = "none";
				trans_text.data = '';
			}
			
			color_picker.style.top = pos_y_picker + (document.getElementById(this.id).offsetHeight + 2) + "px";
			// color_picker.style.visibility = "visible";
			color_picker.style.display = "block";
			document.getElementById(champ_color_picker_cours).readOnly = true;
			
			couleur_hexa.onchange = function ()
			{
				var expreg = new RegExp("^[a-fA-F0-9]{6}$");
				if (!expreg.test(couleur_hexa.value) || couleur_hexa.value == '')
				{
					if (champ_color_picker_cours.substr(0, 15) == "color-picker-tr")
					{
						couleur_hexa.value = '';
						couleur_hexa.disabled = true;
						temoin.style.backgroundColor = "#FFFFFF";
						R.style.display = "none";
						R.style.marginLeft = "-4px";
						input_R.value = "0";
						V.style.display = "none";
						V.style.marginLeft = "-4px";
						input_V.value = "0";
						B.style.display = "none";
						B.style.marginLeft = "-4px";
						input_B.value = "0";
						temoin.disabled = true;
						trans_check.checked = true;
					}
					else
					{
						temoin.style.backgroundColor = '#000000';
						couleur_hexa.value = "000000";
						trans_check.checked = false;
						couleur_hexa.disabled = false;
						R.style.display = "block";
						V.style.display = "block";
						B.style.display = "block";
						R.style.marginLeft = "-4px";
						V.style.marginLeft = "-4px";
						B.style.marginLeft = "-4px";
						input_R.value = "0";
						input_V.value = "0";
						input_B.value = "0";
					}
				}
				else
				{
					temoin.style.backgroundColor = '#' + couleur_hexa.value;
					trans_check.checked = false;
					couleur_hexa.disabled = false;
					couleur_hexa.value = couleur_hexa.value.toUpperCase();
					R.style.display = "block";
					V.style.display = "block";
					B.style.display = "block";
					
					bouge_curseurs(couleur_hexa.value);
				}
			}
			
			couleur_actuelle = couleur_hexa.value;
		}
	}
}

function bouge_curseurs(couleur)
{
	var r_prov = couleur.substr(0,2);
	input_R.value = h2d(r_prov);
	var v_prov = couleur.substr(2,2);
	input_V.value = h2d(v_prov);
	var b_prov = couleur.substr(4,2);
	input_B.value = h2d(b_prov);
	
	R.style.marginLeft = (input_R.value - 4) + 'px';
	V.style.marginLeft = (input_V.value - 4) + 'px';
	B.style.marginLeft = (input_B.value - 4) + 'px';
}

// *************
// * Demarrage *
// *************
function demarrage()
{
	color_picker();
	start_pickers();
}

window.onload = demarrage;