aCellInfo = new Array();
aCellInfo.length = 361;
for(i=0; i<= 361; i++)
{
  aCellInfo[i] = new Array();
  aCellInfo[i]["red"] = 0;
  aCellInfo[i]["green"] = 0;
  aCellInfo[i]["blue"] = 0;
}

redTotal = 0;
blueTotal = 0;
greenTotal = 0;
/*function changeSquare(evtThis)
{
  colour1 = Math.floor(Math.random()*128)+128;
  colour2 = Math.floor(Math.random()*128)+128;
  colour3 = Math.floor(Math.random()*128)+128;
  colour = 'RGB('+colour1+','+colour2+','+colour3+')';
  evtThis.target.style.background = colour;
} */

function generateAura()
{
  redTotal = 0;
  blueTotal = 0;
  greenTotal = 0;
  for(i=1;i< 361; i++)
  {
      currentCell = document.getElementById(i);
      colour1 = Math.floor(Math.random()*128)+128;
      aCellInfo[i]["red"] = colour1;
      colour2 = Math.floor(Math.random()*128)+128;
      aCellInfo[i]["green"] = colour2;
      colour3 = Math.floor(Math.random()*128)+128;
      aCellInfo[i]["blue"] = colour3;
      colour = 'RGB('+colour1+','+colour2+','+colour3+')';
      currentCell.style.background = colour;
  }
  for(i=1;i < 361; i++)
  {
     redTotal+= parseInt(aCellInfo[i]["red"]);
     greenTotal+= parseInt(aCellInfo[i]["green"]);
     blueTotal+= parseInt(aCellInfo[i]["blue"]);
  }
  redAverage = redTotal/360;
  greenAverage = greenTotal/360;
  blueAverage = blueTotal/360;
  auraBasis = generateOutcome();
  sInitial = generateReading(auraBasis)
  sAuraReading = sInitial;
  document.getElementById("auraOutput").innerHTML = sAuraReading;
}

function generateOutcome()
{
  if(redAverage > blueAverage && redAverage > greenAverage)
  {
    return "red";
  }
  else if(greenAverage > blueAverage && greenAverage > redAverage)
  {
    return "green";
  }
  else if(blueAverage > redAverage && blueAverage > greenAverage)
  {
    return "blue";
  }
  else
  {
    return "nothing";
  }
}

function generateReading(colourType)
{
  if(colourType!="nothing")
  {
    adjective1 = aOutcomes[colourType]["adjectives"][Math.floor(Math.random()*aOutcomes[colourType]["adjectives"].length)];
    adjective2 = aOutcomes[colourType]["adjectives"][Math.floor(Math.random()*aOutcomes[colourType]["adjectives"].length)];
    adjective3 = aOutcomes[colourType]["adjectives"][Math.floor(Math.random()*aOutcomes[colourType]["adjectives"].length)];
    adjective4 = aOutcomes[colourType]["adjectives"][Math.floor(Math.random()*aOutcomes[colourType]["adjectives"].length)];
    noun1 = aOutcomes[colourType]["nouns"][Math.floor(Math.random()*aOutcomes[colourType]["nouns"].length)];
    noun2 = aOutcomes[colourType]["nouns"][Math.floor(Math.random()*aOutcomes[colourType]["nouns"].length)];
    sDescription = "Your aura has a distinct feeling of "+noun1+", this is indicated by the subtle "+colourType+" that has proliferated itself in the aura. <br> It gives a very distinct "+adjective1+", "+adjective2+" feeling that correlates with the "+adjective3+" feeling garnered from your mental aura. <br> Overall there is a large feeling of "+adjective4+" "+noun2+".";
    return sDescription;
  }
  else
  {
    sDescription = "<br> Your aura broadcasts a feeling of tranquility and neutrality, you are a person of balance and peace.";
    return sDescription;
  }
}


