var text = new Array();
var current = 0;
var doc = document.getElementById("quote");
var waiting = document.getElementById("wait");
var fadeTime = 10000;
var stepSize = ((fadeTime/10000));
var curStep = 0;
var numSteps = 1/stepSize;
var fadeBy = 1-(curStep*stepSize);
init();

function init()
{  
  doc.style.color = "white";
  waiting.style.color = "white";
  waiting.style.opacity = "0";
  text[0] = '<p>"Career Investments provided a very tailored, individualized approach to my career transition.  They got to know me and my needs and then made recommendations on good next steps FOR ME.  I\'m more ready than ever for what\'s next, in large part thanks to Career Investments and the invaluable input and services they provided.  My time with Career Investments was personalized, intuitive, observant, poignant, honest, and helpful.  This was no "resumes for dummies" or "finding a job 101" - it was a million times better."<br/><span style="font-size: 13px; line-height: 19px;	">~Amanda C.</span></p>';
  text[1] = '<p>"Thanks so much for being honest and tough with me today; I couldn\'t be more appreciative.  I have new energy for my job search and look forward to what comes next."<br/><br /><br /><span style="font-size: 13px;">~Laura H.</span></p>';
  text[2] = '<p>"Career Investments was a great resource as I made a career transition. They provided honest advice on my resumes, helping to clarify and focus the materials to better communicate my skills and experience to multiple audiences."<br/><br /> <br /><span style="font-size: 13px">~Tony M.</span></p>';
  waiting.innerHTML = text[current+1];
  setOpacity(doc, 1);
  setOpacity(waiting, 0);
  doc.innerHTML = text[current];
  //current++;
  //var timerNum = setTimeout(rotateImage, 2000);
  setTimeout(rotateImage, 2000);
}

function rotateImage()
{
    curStep = 0
    setTimeout(fade, fadeTime/numSteps);        
}

function fade()
{
    fadeBy = 1-(curStep*stepSize);
    setOpacity(doc, fadeBy);
    setOpacity(waiting, (1-fadeBy));
    curStep++;
    if(curStep <=numSteps)
    {
      setTimeout(fade, fadeTime/numSteps);   
    }
    else
    {
      replace();
    }
}

function setOpacity(element, opac)
{
  element.style.opacity = opac;
  element.style.MozOpacity = opac;
  element.style.filter = "alpha(opacity=" + opac*100 + ")";
}

function replace()
{
  current++;  
  if(current == text.length)
  {
   current = 0; 
  }
  doc.innerHTML = text[current];
  setOpacity(doc, 1);
  //doc.style.opacity = 1;
  //doc.style.MozOpacity = 1;
  //doc.style.filter = "alpha(opacity=" + 1 + ")";
  setOpacity(waiting, 0);
  //waiting.style.opacity = 0;
  //waiting.style.MozOpacity = 0;
  //waiting.style.filter = "alpha(opacity=" + 0 + ")";
  if(current == (text.length-1))
  {
    waiting.innerHTML = text[0];
  }
  else
  {
    waiting.innerHTML = text[current+1];
  }  
  setTimeout(rotateImage, 2000);
}