// JavaScript Document
var counters=new Array();
var whos = new Array();

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function menucellover(whol){
//who.style.backgroundColor='#E68600';
from1 = 0;
from2 = 75;
from3 = 147;
to1=247;
to2=178;
to3=33;
nr = whos.push(whol);
cnr=counters.push(0);

fade(from1,from2,from3,to1,to2,to3,nr-1,cnr-1);
}
function menucellout(whol){
//who.style.backgroundColor='#176EB9';
to1 = 0;
to2 = 75;
to3 = 147;
from1=247;
from2=178;
from3=33;
nr = whos.push(whol);
cnr=counters.push(0);
fade(from1,from2,from3,to1,to2,to3,nr-1,cnr-1);
}

function makearray(n) {
    this.length = n;
    for(var i = 1; i <= n; i++)
        this[i] = 0;
    return this;
}

hexa = new makearray(16);
for(var i = 0; i < 10; i++)
    hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

function hex(i) {
    if (i < 0)
        return "00";
    else if (i > 255)
        return "ff";
    else
        return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}

function setbgColor(r, g, b,whatcell) {
    var hr = hex(r); var hg = hex(g); var hb = hex(b);
    whatcell.style.backgroundColor = "#"+hr+hg+hb;
}

function fade(sr, sg, sb, er, eg, eb,whonr,cnr) {
		step=15;
        setbgColor(
        Math.floor(sr * ((step-counters[cnr])/step) + er * (counters[cnr]/step)),
        Math.floor(sg * ((step-counters[cnr])/step) + eg * (counters[cnr]/step)),
        Math.floor(sb * ((step-counters[cnr])/step) + eb * (counters[cnr]/step)),
		whos[whonr]);
		counters[cnr]++;
		newfadestring="fade("+sr+","+sg+","+sb+","+er+","+eg+","+eb+","+whonr+","+cnr+")";
//		newfadestring="fade()";
//		alert(newfadestring);
		if (counters[cnr]<=step){
			window.setTimeout(newfadestring,3);
		}else{
			counters[cnr]=0;	
		}
}


