var greycolor = new Array();
var orange = new Array();

function setGrey() {
  greycolor[1]  = "#EAEAEA";
  greycolor[2]  = "#E0E0E0";
  greycolor[3]  = "#F5F5F5";
  greycolor[4]  = "#E9E9E9";
  greycolor[5]  = "#E3E3E3";
  greycolor[6]  = "#DEDEDE";
  greycolor[7]  = "#EEEEEE";
  greycolor[8]  = "#E5E5E5";
  greycolor[9]  = "#F1F1F1";
  greycolor[10] = "#E8E8E8";
}

function setOrange() {
  orange[1]  = "#FFC900"
  orange[2]  = "#FFD800"
  orange[3]  = "#FFC602"
  orange[4]  = "#FDB333"
  orange[5]  = "#FBE000"
  orange[6]  = "#FFC000"
  orange[7]  = "#FFC61A"
  orange[8]  = "#FAD000"
  orange[9]  = "#FABC00"
  orange[10] = "#FABF00"
}

function setPosition(oid) {
  var iw = document.body.offsetWidth - (document.body.offsetWidth - document.body.clientWidth) -1;
  var ih = document.body.offsetHeight - (document.body.offsetHeight - document.body.clientHeight) -1;
  if (iw == null) iw = window.innerWidth;
  if (ih == null) ih = window.innerHeight;
  var elem = document.getElementById(oid);
  if (elem != null) {
    elem.style.width  = iw;
    elem.style.height = ih;
  }
  return true;
}

function setNewStyle(i,n) {
  var aid = 'c' + i.toString();
  var acell = document.getElementById(aid);
  if (acell != null) acell.style.backgroundColor = greycolor[n];
}

function animateStyle() {
  var pindex = Math.round((Math.random() * 109) + 1);
  var aindex = Math.round((Math.random() * 9) + 1);
  setNewStyle(pindex,aindex);
  setTimeout(animateStyle,65);
}

function setupPage() {
  setPosition('boxes');
  setGrey();
  setOrange();
  if (document.images) setTimeout(animateStyle,0);
}

function rollon(oid) {
   var acell = document.getElementById(oid);
   if (acell != null) acell.style.backgroundColor = orange[Math.round((Math.random() * 9) + 1)];  
}
