

hexa=new Array(16);
for (i=0;i<10;i++)
{
	hexa[i]=i.toString();
}

hexa[10]='A';hexa[11]='B';hexa[12]='C';hexa[13]='D';hexa[14]='E';hexa[15]='F';

function toHexa(n)
{
	n=Number(n);
	return(hexa[Math.floor(n/16)]+hexa[n%16]);
}

function Hexad(decimal)
{
	Hexadec = (toHexa(decimal));
	if ((decimal > 0) & (decimal <= 255))
		document.form1.hex.value = Hexadec;
	if (decimal>255)
	{
		Hexad(255);
	}
	if (decimal<=1)
	{
		Hexad(1);
	}
}

function checkValue(value)
{
	if ((value > 0) & (value <= 255))
		return value;
	if (value>255)
		return 255;
	if (value<1)
		return 0;
}

function convToHex(rouge,vert,bleu)
{
	rouge = checkValue(rouge);
	vert = checkValue(vert);
	bleu = checkValue(bleu);
	r =  rouge;
	v = vert;
	b = bleu;

	result =  '#' + (toHexa(r) +  toHexa(v) + toHexa(b));
	return result;
}

function convToDeci(x)
{
	if (!isNaN(x))
	{
		x=Number(x);
		return x
	}
	else
	{
		switch(x)
		{
			case 'A' : return 10 ;break;
			case 'B' : return 11 ;break;
			case 'C' : return 12 ;break;
			case 'D' : return 13 ;break;
			case 'E' : return 14 ;break;
			case 'F' : return 15 ;break;
			case 'a' : return 10 ;break;
			case 'b' : return 11 ;break;
			case 'c' : return 12 ;break;
			case 'd' : return 13 ;break;
			case 'e' : return 14 ;break;
			case 'f' : return 15 ;break;
		}
	}
}

function convToRGB(hexaString)
{
	hexaList=new Array(6);
	for (i=1;i<7;i++)
		hexaList[i-1]=hexaString.charAt(i);

	red = (convToDeci(hexaList[0])*16) + convToDeci(hexaList[1]);
	green = (convToDeci(hexaList[2])*16) + convToDeci(hexaList[3]);
	blue = (convToDeci(hexaList[4])*16) + convToDeci(hexaList[5]);

	result = red + "," + green + "," + blue;
	return result;
}

function convTohexa(hexaString)
{
	hexaList=new Array(2);
	for (i=1;i<3;i++)
		hexaList[i-1]=hexaString.charAt(i-1);

	hexa = (convToDeci(hexaList[0])*16) + convToDeci(hexaList[1]);

	return hexa;
}


function decoup_decimal(prix)
{
	var partie_entiere="";
	var partie_decimale="";
	var parties = Array(2);
	var pos_pt = prix.indexOf(".");

	if(pos_pt == -1)
		pos_pt = prix.indexOf(",");

	if(pos_pt != -1)
	{
		partie_entiere = prix.substr(0,pos_pt);
		partie_decimale = prix.substr(pos_pt+1,prix.length-pos_pt-1);
	}
	else
	{
		partie_entiere = prix;
		partie_decimale = "";
	}

	parties[0]=partie_entiere;
	parties[1]=partie_decimale;
	return parties;
}

function insert_espaces_prix(prix)
{
	var prix_formate="";
	var partie_entiere="";
	var partie_decimale="";
	var parties = Array(2);

	if(prix != "" && verif_prix(prix,''))
	{
		parties=decoup_decimal(prix);
		partie_entiere=parties[0];
		partie_decimale=parties[1];

		var cpt = partie_entiere.length;
		var cpt2 = 0;

		while(cpt > 0)
		{
			chiffre = partie_entiere.substr(cpt-1,1);
			if(cpt2 % 3 == 0 && prix_formate != "")
				prix_formate = chiffre+" "+prix_formate;
			else
				prix_formate = chiffre+prix_formate;

			cpt--;
			cpt2++;
		}

		if(prix.indexOf(".") != -1)
			prix_formate = prix_formate+"."+partie_decimale;
		else if(prix.indexOf(",") != -1)
			prix_formate = prix_formate+","+partie_decimale;
	}
	return prix_formate;
}

function decode_spec_car_html(txt)
{
	txt = txt.replace(/&mdash;/g,"—");
	txt = txt.replace(/&ndash;/g,"–");
	txt = txt.replace(/&shy;/g,"-");
	txt = txt.replace(/&quot;/g,"\"");
	txt = txt.replace(/&amp;/g,"&");
	txt = txt.replace(/&circ;/g,"ˆ");
	txt = txt.replace(/&iexcl;/g,"¡");
	txt = txt.replace(/&brvbar;/g,"¦");
	txt = txt.replace(/&uml;/g,"¨");
	txt = txt.replace(/&macr;/g,"¯");
	txt = txt.replace(/&acute;/g,"´");
	txt = txt.replace(/&cedil;/g,"¸");
	txt = txt.replace(/&iquest;/g,"¿");
	txt = txt.replace(/&tilde;/g,"˜");
	txt = txt.replace(/&lsquo;/g,"‘");
	txt = txt.replace(/&rsquo;/g,"’");
	txt = txt.replace(/&sbquo;/g,"‚");
	txt = txt.replace(/&ldquo;/g,"“");
	txt = txt.replace(/&rdquo;/g,"”");
	txt = txt.replace(/&bdquo;/g,"„");
	txt = txt.replace(/&lsaquo;/g,"‹");
	txt = txt.replace(/&rsaquo;/g,"›");
	txt = txt.replace(/&lt;/g,"<");
	txt = txt.replace(/&gt;/g,">");
	txt = txt.replace(/&plusmn;/g,"±");
	txt = txt.replace(/&laquo;/g,"«");
	txt = txt.replace(/&raquo;/g,"»");
	txt = txt.replace(/&times;/g,"×");
	txt = txt.replace(/&divide;/g,"÷");
	txt = txt.replace(/&cent;/g,"¢");
	txt = txt.replace(/&pound;/g,"£");
	txt = txt.replace(/&curren;/g,"¤");
	txt = txt.replace(/&yen;/g,"¥");
	txt = txt.replace(/&sect;/g,"§");
	txt = txt.replace(/&copy;/g,"©");
	txt = txt.replace(/&not;/g,"¬");
	txt = txt.replace(/&reg;/g,"®");
	txt = txt.replace(/&deg;/g,"°");
	txt = txt.replace(/&micro;/g,"µ");
	txt = txt.replace(/&para;/g,"¶");
	txt = txt.replace(/&middot;/g,"·");
	txt = txt.replace(/&dagger;/g,"†");
	txt = txt.replace(/&Dagger;/g,"‡");
	txt = txt.replace(/&permil;/g,"‰");
	txt = txt.replace(/&euro;/g,"€");
	txt = txt.replace(/&frac14;/g,"¼");
	txt = txt.replace(/&frac12;/g,"½");
	txt = txt.replace(/&frac34;/g,"¾");
	txt = txt.replace(/&sup1;/g,"¹");
	txt = txt.replace(/&sup2;/g,"²");
	txt = txt.replace(/&sup3;/g,"³");
	txt = txt.replace(/&aacute;/g,"á");
	txt = txt.replace(/&Aacute;/g,"Á");
	txt = txt.replace(/&acirc;/g,"â");
	txt = txt.replace(/&Acirc;/g,"Â");
	txt = txt.replace(/&agrave;/g,"à");
	txt = txt.replace(/&Agrave;/g,"À");
	txt = txt.replace(/&aring;/g,"å");
	txt = txt.replace(/&Aring;/g,"Å");
	txt = txt.replace(/&atilde;/g,"ã");
	txt = txt.replace(/&Atilde;/g,"Ã");
	txt = txt.replace(/&auml;/g,"ä");
	txt = txt.replace(/&Auml;/g,"Ä");
	txt = txt.replace(/&ordf;/g,"ª");
	txt = txt.replace(/&aelig;/g,"æ");
	txt = txt.replace(/&AElig;/g,"Æ");
	txt = txt.replace(/&ccedil;/g,"ç");
	txt = txt.replace(/&Ccedil;/g,"Ç");
	txt = txt.replace(/&eth;/g,"ð");
	txt = txt.replace(/&ETH;/g,"Ð");
	txt = txt.replace(/&eacute;/g,"é");
	txt = txt.replace(/&Eacute;/g,"É");
	txt = txt.replace(/&ecirc;/g,"ê");
	txt = txt.replace(/&Ecirc;/g,"Ê");
	txt = txt.replace(/&egrave;/g,"è");
	txt = txt.replace(/&Egrave;/g,"È");
	txt = txt.replace(/&euml;/g,"ë");
	txt = txt.replace(/&Euml;/g,"Ë");
	txt = txt.replace(/&fnof;/g,"ƒ");
	txt = txt.replace(/&iacute;/g,"í");
	txt = txt.replace(/&Iacute;/g,"Í");
	txt = txt.replace(/&icirc;/g,"î");
	txt = txt.replace(/&Icirc;/g,"Î");
	txt = txt.replace(/&igrave;/g,"ì");
	txt = txt.replace(/&Igrave;/g,"Ì");
	txt = txt.replace(/&iuml;/g,"ï");
	txt = txt.replace(/&Iuml;/g,"Ï");
	txt = txt.replace(/&ntilde;/g,"ñ");
	txt = txt.replace(/&Ntilde;/g,"Ñ");
	txt = txt.replace(/&oacute;/g,"ó");
	txt = txt.replace(/&Oacute;/g,"Ó");
	txt = txt.replace(/&ocirc;/g,"ô");
	txt = txt.replace(/&Ocirc;/g,"Ô");
	txt = txt.replace(/&ograve;/g,"ò");
	txt = txt.replace(/&Ograve;/g,"Ò");
	txt = txt.replace(/&ordm;/g,"º");
	txt = txt.replace(/&oslash;/g,"ø");
	txt = txt.replace(/&Oslash;/g,"Ø");
	txt = txt.replace(/&otilde;/g,"õ");
	txt = txt.replace(/&Otilde;/g,"Õ");
	txt = txt.replace(/&ouml;/g,"ö");
	txt = txt.replace(/&Ouml;/g,"Ö");
	txt = txt.replace(/&oelig;/g,"œ");
	txt = txt.replace(/&OElig;/g,"Œ");
	txt = txt.replace(/&scaron;/g,"š");
	txt = txt.replace(/&Scaron;/g,"Š");
	txt = txt.replace(/&szlig;/g,"ß");
	txt = txt.replace(/&thorn;/g,"þ");
	txt = txt.replace(/&THORN;/g,"Þ");
	txt = txt.replace(/&uacute;/g,"ú");
	txt = txt.replace(/&Uacute;/g,"Ú");
	txt = txt.replace(/&ucirc;/g,"û");
	txt = txt.replace(/&Ucirc;/g,"Û");
	txt = txt.replace(/&ugrave;/g,"ù");
	txt = txt.replace(/&Ugrave;/g,"Ù");
	txt = txt.replace(/&uuml;/g,"ü");
	txt = txt.replace(/&Uuml;/g,"Ü");
	txt = txt.replace(/&yacute;/g,"ý");
	txt = txt.replace(/&Yacute;/g,"Ý");
	txt = txt.replace(/&yuml;/g,"ÿ");
	txt = txt.replace(/&Yuml;/g,"Ÿ");


	txt = txt.replace(/&#34;/g,"\"");
	txt = txt.replace(/&#38;/g,"&");
	txt = txt.replace(/&#128;/g,"€");
	txt = txt.replace(/&#129;/g,"?");
	txt = txt.replace(/&#130;/g,"‚");
	txt = txt.replace(/&#131;/g,"ƒ");
	txt = txt.replace(/&#132;/g,"„");
	txt = txt.replace(/&#133;/g,"…");
	txt = txt.replace(/&#134;/g,"†");
	txt = txt.replace(/&#135;/g,"‡");
	txt = txt.replace(/&#136;/g,"ˆ");
	txt = txt.replace(/&#137;/g,"‰");
	txt = txt.replace(/&#138;/g,"Š");
	txt = txt.replace(/&#139;/g,"‹");
	txt = txt.replace(/&#140;/g,"Œ");
	txt = txt.replace(/&#141;/g,"?");
	txt = txt.replace(/&#142;/g,"Ž");
	txt = txt.replace(/&#143;/g,"?");
	txt = txt.replace(/&#144;/g,"?");
	txt = txt.replace(/&#145;/g,"‘");
	txt = txt.replace(/&#146;/g,"’");
	txt = txt.replace(/&#147;/g,"“");
	txt = txt.replace(/&#148;/g,"”");
	txt = txt.replace(/&#149;/g,"•");
	txt = txt.replace(/&#150;/g,"–");
	txt = txt.replace(/&#151;/g,"—");
	txt = txt.replace(/&#152;/g,"˜");
	txt = txt.replace(/&#153;/g,"™");
	txt = txt.replace(/&#154;/g,"š");
	txt = txt.replace(/&#155;/g,"›");
	txt = txt.replace(/&#156;/g,"œ");
	txt = txt.replace(/&#157;/g,"?");
	txt = txt.replace(/&#158;/g,"ž");
	txt = txt.replace(/&#159;/g,"Ÿ");
	txt = txt.replace(/&#160;/g,"");
	txt = txt.replace(/&#161;/g,"¡");
	txt = txt.replace(/&#162;/g,"¢");
	txt = txt.replace(/&#163;/g,"£");
	txt = txt.replace(/&#164;/g,"¤");
	txt = txt.replace(/&#165;/g,"¥");
	txt = txt.replace(/&#166;/g,"¦");
	txt = txt.replace(/&#167;/g,"§");
	txt = txt.replace(/&#168;/g,"¨");
	txt = txt.replace(/&#169;/g,"©");
	txt = txt.replace(/&#170;/g,"ª");
	txt = txt.replace(/&#171;/g,"«");
	txt = txt.replace(/&#172;/g,"¬");
	txt = txt.replace(/&#173;/g,"­");
	txt = txt.replace(/&#174;/g,"®");
	txt = txt.replace(/&#175;/g,"¯");
	txt = txt.replace(/&#176;/g,"°");
	txt = txt.replace(/&#177;/g,"±");
	txt = txt.replace(/&#178;/g,"²");
	txt = txt.replace(/&#179;/g,"³");
	txt = txt.replace(/&#180;/g,"´");
	txt = txt.replace(/&#181;/g,"µ");
	txt = txt.replace(/&#182;/g,"¶");
	txt = txt.replace(/&#183;/g,"·");
	txt = txt.replace(/&#184;/g,"¸");
	txt = txt.replace(/&#185;/g,"¹");
	txt = txt.replace(/&#186;/g,"º");
	txt = txt.replace(/&#187;/g,"»");
	txt = txt.replace(/&#188;/g,"¼");
	txt = txt.replace(/&#189;/g,"½");
	txt = txt.replace(/&#190;/g,"¾");
	txt = txt.replace(/&#191;/g,"¿");
	txt = txt.replace(/&#192;/g,"À");
	txt = txt.replace(/&#193;/g,"Á");
	txt = txt.replace(/&#194;/g,"Â");
	txt = txt.replace(/&#195;/g,"Ã");
	txt = txt.replace(/&#196;/g,"Ä");
	txt = txt.replace(/&#197;/g,"Å");
	txt = txt.replace(/&#198 /g,"Æ");
	txt = txt.replace(/&#199;/g,"Ç");
	txt = txt.replace(/&#200;/g,"È");
	txt = txt.replace(/&#201;/g,"É");
	txt = txt.replace(/&#202;/g,"Ê");
	txt = txt.replace(/&#203;/g,"Ë");
	txt = txt.replace(/&#204;/g,"Ì");
	txt = txt.replace(/&#205;/g,"Í");
	txt = txt.replace(/&#206;/g,"Î");
	txt = txt.replace(/&#207;/g,"Ï");
	txt = txt.replace(/&#208;/g,"Ð");
	txt = txt.replace(/&#209;/g,"Ñ");
	txt = txt.replace(/&#210;/g,"Ò");
	txt = txt.replace(/&#211;/g,"Ó");
	txt = txt.replace(/&#212;/g,"Ô");
	txt = txt.replace(/&#213;/g,"Õ");
	txt = txt.replace(/&#214;/g,"Ö");
	txt = txt.replace(/&#215;/g,"×");
	txt = txt.replace(/&#216;/g,"Ø");
	txt = txt.replace(/&#217;/g,"Ù");
	txt = txt.replace(/&#218;/g,"Ú");
	txt = txt.replace(/&#219;/g,"Û");
	txt = txt.replace(/&#220;/g,"Ü");
	txt = txt.replace(/&#221;/g,"Ý");
	txt = txt.replace(/&#222;/g,"Þ");
	txt = txt.replace(/&#223;/g,"ß");
	txt = txt.replace(/&#224;/g,"à");
	txt = txt.replace(/&#225;/g,"á");
	txt = txt.replace(/&#226;/g,"â");
	txt = txt.replace(/&#227;/g,"ã");
	txt = txt.replace(/&#228;/g,"ä");
	txt = txt.replace(/&#229;/g,"å");
	txt = txt.replace(/&#230;/g,"æ");
	txt = txt.replace(/&#231;/g,"ç");
	txt = txt.replace(/&#232;/g,"è");
	txt = txt.replace(/&#233;/g,"é");
	txt = txt.replace(/&#234;/g,"ê");
	txt = txt.replace(/&#235;/g,"ë");
	txt = txt.replace(/&#236;/g,"ì");
	txt = txt.replace(/&#237;/g,"í");
	txt = txt.replace(/&#238;/g,"î");
	txt = txt.replace(/&#239;/g,"ï");
	txt = txt.replace(/&#240;/g,"ð");
	txt = txt.replace(/&#241;/g,"ñ");
	txt = txt.replace(/&#242;/g,"ò");
	txt = txt.replace(/&#243;/g,"ó");
	txt = txt.replace(/&#244;/g,"ô");
	txt = txt.replace(/&#245;/g,"õ");
	txt = txt.replace(/&#246;/g,"ö");
	txt = txt.replace(/&#247;/g,"÷");
	txt = txt.replace(/&#248;/g,"ø");
	txt = txt.replace(/&#249;/g,"ù");
	txt = txt.replace(/&#250;/g,"ú");
	txt = txt.replace(/&#251;/g,"û");
	txt = txt.replace(/&#252;/g,"ü");
	txt = txt.replace(/&#253;/g,"ý");
	txt = txt.replace(/&#254;/g,"þ");
	txt = txt.replace(/&#255;/g,"ÿ");

	return txt;
}

function noHtml(txt)
{
   a = txt.indexOf('<');
   b = txt.indexOf('>');
   len = txt.length;
   c = txt.substring(0, a);
   if(b == -1) {
      b = a;
   }
   d = txt.substring((b + 1), len);
   txt = c + d;
   cont = txt.indexOf('<');
   if (cont != -1) {
     txt = noHtml(txt);
   }
   return txt;
}
