////////////////////////////////////////////////////////////////////////////////////////
// "Gradation Script 2"  Written by ƒˆƒVƒ’     http://plaza2.mbn.or.jp/~yoshio2/      //
////////////////////////////////////////////////////////////////////////////////////////

function grad2(str,gradstr)
{
	r = new Array();
	g = new Array();
	b = new Array();

	colors = (gradstr.length + 1) / 7;

	for (j = 1; j <= colors; j++)
	{
		base = (j - 1) * 7;
		r[j] = valueOfHex(gradstr.substring(base  ,base+2));
		g[j] = valueOfHex(gradstr.substring(base+2,base+4));
		b[j] = valueOfHex(gradstr.substring(base+4,base+6));
	}

	for (j = 0; j < str.length; j++)
	{
		pos = j / (str.length - 1) * (colors - 1);
		c1 = Math.floor(pos) + 1;
		c2 = Math.ceil(pos) + 1;
		if (c1 == c2)
		{
			if (j < (str.length / 2))
			{
				c2 ++;
			}
			else
			{
				c1 --;
			}
		}
		c1con = (c2 - 1) - pos;
		c2con = pos - (c1 - 1);

		R = Math.round(r[c1] * c1con + r[c2] * c2con);
		G = Math.round(g[c1] * c1con + g[c2] * c2con);
		B = Math.round(b[c1] * c1con + b[c2] * c2con);

		document.write("<FONT COLOR=\"");
		document.write("#" + toHexString2(R,2) + toHexString2(G,2) + toHexString2(B,2));
		document.write("\">");
		document.write(str.substring(j,j + 1));
		document.write("</FONT>");
	}
}

