<!-- this file was stolen from http://www.1pagedesign.com -->

<!-- Script by Jim Stiles 01.12.2001 -->
function GiveDec(Hex)
{
   if(Hex == "A")
      Value = 10;
   else
   if(Hex == "B")
      Value = 11;
   else
   if(Hex == "C")
      Value = 12;
   else
   if(Hex == "D")
      Value = 13;
   else
   if(Hex == "E")
      Value = 14;
   else
   if(Hex == "F")
      Value = 15;
   else
      Value = eval(Hex);

   return Value;
}

function GiveHex(Dec)
{
   if(Dec == 10)
      Value = "A";
   else
   if(Dec == 11)
      Value = "B";
   else
   if(Dec == 12)
      Value = "C";
   else
   if(Dec == 13)
      Value = "D";
   else
   if(Dec == 14)
      Value = "E";
   else
   if(Dec == 15)
      Value = "F";
   else
      Value = "" + Dec;

   return Value;
}

function HexToDec()
{
   Input = window.document.forms['ColorForm'].elements['HexInput'].value;

   Input = Input.toUpperCase();

   a = GiveDec(Input.substring(0, 1));
   b = GiveDec(Input.substring(1, 2));
   c = GiveDec(Input.substring(2, 3));
   d = GiveDec(Input.substring(3, 4));
   e = GiveDec(Input.substring(4, 5));
   f = GiveDec(Input.substring(5, 6));

   x = (a * 16) + b;
   y = (c * 16) + d;
   z = (e * 16) + f;

   window.document.forms['ColorForm'].elements['RedOutput'].value = x;
   window.document.forms['ColorForm'].elements['GreenOutput'].value = y;
   window.document.forms['ColorForm'].elements['BlueOutput'].value = z;
   window.document.bgColor = Input;
}

function DecToHex()
{
   Red = window.document.forms['ColorForm'].elements['RedInput'].value;
   Green = window.document.forms['ColorForm'].elements['GreenInput'].value;
   Blue = window.document.forms['ColorForm'].elements['BlueInput'].value;

   a = GiveHex(Math.floor(Red / 16));
   b = GiveHex(Red % 16);
   c = GiveHex(Math.floor(Green / 16));
   d = GiveHex(Green % 16);
   e = GiveHex(Math.floor(Blue / 16));
   f = GiveHex(Blue % 16);

   z = a + b + c + d + e + f;

   window.document.forms['ColorForm'].elements['HexOutput'].value = z;
   window.document.bgColor = z;
}




<!-- Copyright (C) 1999, Eric L Cochran, a.k.a. Sigma. Enter Sigma's Realm @ http://skyscraper.fortunecity.com/binary/0/index.html  Color Validator, ver. 1.0.-->
var error;
var digits = "0123456789ABCDEF";
window.onerror = recoverError;

function recoverError() {
	document.form.rgb.value=" - ERROR -";
	return true;
}

function getValueOf(digit) {
	if ((digits.indexOf(digit) < 1) && (!((digit + 0) == 0))) {
		error = true;
		return true;
	}
	else return digits.indexOf(digit);
}

function hexToDec(hex) {
	hex = hex.toUpperCase();
	return ((16*(getValueOf(hex.charAt(0))))+(getValueOf(hex.charAt(1))));
}

function decToHex(dec) {
	return (digits.charAt(parseInt(dec/16))+""+digits.charAt(dec-(parseInt(dec/16)*16)));
}

function validateComponent(value) {
	if (!(parseInt(value/51)==(value/51))) {
		if (value>25) {
			if (value>76) {
				if (value>127) {
					if (value>178) {
							if (value>229) value = 255;
							else value = 204;
					}
					else value = 153;
				}
				else value = 102;
			}
			else value = 51;
		}
		else value = 0;
	}
	return value;
}

function validate() {
	error = false;
	var rgb = document.form.rgb.value;
	if (!(rgb.charAt(0)=="#")) rgb = "#" + rgb;
	var r = rgb.charAt(1) + "" + rgb.charAt(2);
	var g = rgb.charAt(3) + "" + rgb.charAt(4);
	var b = rgb.charAt(5) + "" + rgb.charAt(6);
	r = decToHex(validateComponent(hexToDec(r)));
	g = decToHex(validateComponent(hexToDec(g)));
	b = decToHex(validateComponent(hexToDec(b)));
	if (error) recoverError();
	else document.form.rgb.value="#"+r+g+b;
}



function convert_H2V(input_num) {
   var x, new_num;

   if(input_num <= 'ff')
    {
      x = parseInt(input_num, 16);
      new_num = x/255;
    }
   return(new_num);
 }

 function convert (form) {
   form.VRMLred.value = convert_H2V(form.red.value)
   form.VRMLgreen.value = convert_H2V(form.green.value)
   form.VRMLblue.value = convert_H2V(form.blue.value)

 }
