var timerCnt=0;
var num=0;
colorTbl=new Array();

var i=0;
var j=101;


//-----------------------------------------------------------------------------
function RGB2HTML(B, G, R)
{
    redx=eval(R);
    greenx=eval(G);
    bluex=eval(B);

    var decColor = redx + 256 * greenx + 65536 * bluex;
    return decColor.toString(16);
}



//-----------------------------------------------------------------------------
function buildGradient()
{
	one=new Array();
	two=new Array();
	var a=10;var b=11;var c=12;var d=13;var e=14;var f=15;
	var byte="";
	var newcolor="";


//width and height of gradient
	var width1 = 600;
	var height1 = 50;

//no of pixels between colours
	var gap = 3;
	num = width1 / gap;

//colour number 1 - enter 1st, 3rd and 5th numbers/letters of colour code
	one[0]=8;
	one[1]=c;
	one[2]=f 
	
//colour number 2 - enter 1st, 3rd and 5th numbers/letters of colour code
	two[0]=0;
	two[1]=0;
	two[2]=3;

	red1=new Array();
	green1=new Array();
	blue1=new Array();

	color2=new Array();
	color1=new Array();
	diff=new Array();

	for(i=0;i<3;i++)
	{
		diff[i] = two[i] - one[i];
		diff[i] = diff[i] / num;
	}

	for(i=0;i<3;i++)
	{
		color1[i] = Math.round(diff[i] * Math.pow(10, 0));
		if(color1[i] > diff[i])color1[i] = color1[i] - 1;
		color2[i] = diff[i] - color1[i];
		color2[i] = color2[i] * 15;
		color2[i] = Math.round(color2[i] * Math.pow(10, 0));
	}

	x=new Array();
	two[0]=0;
	two[1]=0;
	two[2]=0;


	for(i=0;i<=num;i++)
	{
		newcolor="#";
		for(j=0;j<3;j++)
		{
			if(one[j]==a){byte="a";}
			if(one[j]==b){byte="b";}
			if(one[j]==c){byte="c";}
			if(one[j]==d){byte="d";}
			if(one[j]==e){byte="e";}
			if(one[j]==f){byte="f";}
			if(one[j]<10){byte=one[j].toString();}
			if (byte==""){byte="0"}
			newcolor=newcolor + byte
	
			if(two[j]==a){byte="a";}
			if(two[j]==b){byte="b";}
			if(two[j]==c){byte="c";}
			if(two[j]==d){byte="d";}
			if(two[j]==e){byte="e";}
			if(two[j]==f){byte="f";}
			if(two[j]<10){byte=two[j].toString();}
			if (byte==""){byte="0"}
			newcolor=newcolor + byte
	
			one[j] = one[j] + color1[j];
			two[j] = two[j] + color2[j];
			if (two[j]>15){ 	two[j] = two[j] - 15; one[j]++;}
			if (one[j]>15) one[j]=15;
			if (one[j]<0)  one[j]=0;
			if (two[j]<0)  two[j]=0;
	
		}
	
	colorTbl[i]=newcolor
	}
}

