// JavaScript Document

function setColor(color)
{
	var name = "TZH_Color";
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+8);
	document.cookie = name+ "=" +escape(color)+ ";expires="+exdate.toGMTString();
	window.location.reload();
}
function getRGB()
{
	var one = document.f.one.value;
	var two = document.f.two.value;
	var three = document.f.three.value;
	var input = "good";
	if (isNaN(one) || isNaN(two) || isNaN(three))
	{
		input = "bad";
	}
	if ((input == "good") && ((one < 0) || (one > 255) || (two < 0) || (two > 255) || (three < 0) || (three > 255)))
	{
		input = "bad";
	}
	if (input == "good")
	{
		var correction = "0";
		var onehex = Number(one).toString(16);
		if (onehex.length < 2)
		{
			onehex = correction + onehex;
		}
		var twohex = Number(two).toString(16);
		if (twohex.length < 2)
		{
			twohex = correction + twohex;
		}
		var threehex = Number(three).toString(16);
		if (threehex.length < 2)
		{
			threehex = correction + threehex;
		}
		var colorhex = onehex+twohex+threehex;
		setColor(colorhex);
	}
	else
	{
		alert ("Input must contain only decimal numbers 0 - 255");
	}
}
