function to_decimal(hex) {
	if(hex=='F') return 255; else if(hex=='E') return 238;
	if(hex=='D') return 221; else if(hex=='C') return 204;
	if(hex=='B') return 187; else if(hex=='A') return 170;
	else return Math.round((hex/3)*51);
}
function boxcolor(c) {
	document.getElementById('blackbox').style.backgroundColor = c;
}
function info(c, alertbox) {
	var red = c.substring(0,1); var green = c.substring(2,3); var blue = c.substring(4,5);
	var info = '#'+ c +'  RGB=('+ to_decimal(red) +', '+ to_decimal(green) +', '+ to_decimal(blue) +')';
	if(alertbox) alert(info); else document.inform.box.value = info;
	document.inform.sample.style.backgroundColor = '#'+c;
}
function matrix_init() {
var list = new Array('00','11','22','33','44','55','66','77','88','99','AA','BB','CC','DD','EE','FF');
var red, green, blue;
// -----
document.write('<table cellpadding="0" cellspacing="0" border="0" id="matrix">');
for(r=0; r<16; r++)
{
	document.write('<tr>');
	red = list[r];
	for(g=0; g<16; g++)
	{
		green = list[g];
		for(b=0; b<16; b++)
		{
			blue=list[b]; bg=''+red+green+blue;
			document.write('<td class="x" bgcolor="#'+ bg +'" title="#'+ bg +'" onmouseover="info(\''+ bg +'\',0);" onclick="boxcolor(\''+bg+'\');info(\''+ bg +'\',1);">&nbsp;</td>');
		}
	}
	document.write('</tr>\n');
}
document.write('</table>');
// -----
}
