var currentProfile = -1;
var currentOpacity = 0;
var t; //timer variable
var tTransition; //timer variable
var attorneys = new Array(8);
/*
0=Name
1=Image
2=Alt Text
3=Active
4=Loaded
*/

for (var i=0; i < attorneys.length; i++)
{
  attorneys[i]=new Array(5);
}

attorneys[0][0]="<a href=\"/attorneys/ronald_aplin.php\" class=\"profileName\">Ron <br />Aplin</a>";
attorneys[0][1]="/images/attorneys/ron_small.jpg";
attorneys[0][2]="Attorney Ronald S. Applin";
attorneys[0][3]=0;
attorneys[0][4]=0;

attorneys[1][0]="<a href=\"/attorneys/steve_cotton.php\" class=\"profileName\">Steve <br />Cotton</a>";
attorneys[1][1]="/images/attorneys/steve_small.jpg";
attorneys[1][2]="Attorney Steve A. Cotton";
attorneys[1][3]=0;
attorneys[1][4]=0;

attorneys[2][0]="<a href=\"/attorneys/jack_ebbott.php\" class=\"profileName\">Jack <br />Ebbott</a>";
attorneys[2][1]="/images/attorneys/jack_small.jpg";
attorneys[2][2]="Attorney Jack Ebbott";
attorneys[2][3]=0;
attorneys[2][4]=0;

attorneys[3][0]="<a href=\"/attorneys/cherie_anne_gon.php\" class=\"profileName\">Cherie <br />Gon</a>";
attorneys[3][1]="/images/attorneys/cherie_small.jpg";
attorneys[3][2]="Attorney Cherie A. Gon";
attorneys[3][3]=0;
attorneys[3][4]=0;

attorneys[4][0]="<a href=\"/attorneys/kevin_mcdonald.php\" class=\"profileName\">Kevin <br />McDonald</a>";
attorneys[4][1]="/images/attorneys/kevin_small.jpg";
attorneys[4][2]="Attorney Kevin McDonald";
attorneys[4][3]=0;
attorneys[4][4]=0;

attorneys[5][0]="<a href=\"/attorneys/mark_ringsmuth.php\" class=\"profileName\">Mark <br />Ringsmuth</a>";
attorneys[5][1]="/images/attorneys/mark_small.jpg";
attorneys[5][2]="Attorney Mark A. Ringsmuth";
attorneys[5][3]=0;
attorneys[5][4]=0;

attorneys[6][0]="<a href=\"/attorneys/matthew_siderits.php\" class=\"profileName\">Matthew <br />Siderits</a>";
attorneys[6][1]="/images/attorneys/matthew_small.jpg";
attorneys[6][2]="Attorney Matthew Siderits";
attorneys[6][3]=0;
attorneys[6][4]=0;

attorneys[7][0]="<a href=\"/attorneys/richelle_ladwig.php\" class=\"profileName\">Richelle <br />Ladwig</a>";
attorneys[7][1]="/images/attorneys/richelle_small.jpg";
attorneys[7][2]="Attorney Richelle Ladwig";
attorneys[7][3]=0;
attorneys[7][4]=0;

function rotateProfile()
{
  for (var i = 0; i < attorneys.length; i++)
  {
    var next = currentProfile + i + 1;
    if (next > (attorneys.length - 1))
    {
      next = next - attorneys.length;
    }
    if (attorneys[next][3] == 1)
    {
      if (next != currentProfile)
      {
        displayProfile(next);
        currentProfile = next;
      }
      t = setTimeout("rotateProfile()",3000);
      return;
    }
  }
}

function displayProfile(attorney)
{
  document.getElementById("attorneyName").innerHTML = attorneys[attorney][0];
  transition(attorneys[attorney][1]);
}

function transition(newImage)
{
  currentOpacity += 1;
  document.getElementById("attorneyImage").src = newImage;
  document.getElementById("attorneyImage").style.visibility = "visible";
  setOpacity(document.getElementById("attorneyImage"),currentOpacity);
  if (currentOpacity == 10)
  {
    document.getElementById("attorneyImageDiv").style.backgroundImage = "url(" + document.getElementById("attorneyImage").src + ")";
    setOpacity(document.getElementById("attorneyImage"),0);
    document.getElementById("attorneyImage").style.visibility = "hidden";
    currentOpacity = 0;
  }
  else
  {
    tTransition = setTimeout("transition('" + newImage + "')",75);
  }
}

function preloadImages()
{
  var imageName;
  for (var i = 0; i < attorneys.length; i++)
  {
    imageName = "image" + i;
    var newImage = document.createElement('img');
    newImage.setAttribute('id',imageName);
    newImage.setAttribute('src',attorneys[i][1]);
  }
}

function setOpacity(element, opacity)
{
  // firefox
  element.style.opacity = opacity * .1;
  
  // ie7
  element.style.filter = "alpha(opacity=" + (opacity * 10) + ")";
}