// testimonials which will be rotated.
var _testimonials = [
	"The course brought to my awareness so many rich tasks and activities, and a sequence of learning that makes sense of why kids are or are not learning.",
	"I really like using the STEPS resource because it helps me to hone in on the skills that are necessary for my students to be successful in my classroom.",
	"First Steps in Mathematics works so well with our current mathematics curriculum.  It has really brought our goals into focus, and motivated me in the classroom."
	];

//randomly start with one of testimonials.
var test_idx=Math.floor(Math.random()*_testimonials.length);

//sets the page testimonial
function setTestimonial()
{
	var ele = document.getElementById("customer_testimonial");
	
	if(ele){
		ele.innerHTML = "<img src='/_images/left_quote.gif'>" +  _testimonials[test_idx] + "<img src='/_images/right_quote.gif'>";
	}
}

// You can also play with these variables to control fade speed, fade color, and how fast the colors jump.
var m_FadeOut = 255;

var m_FadeIn_R=30;
var m_FadeIn_G=29;
var m_FadeIn_B=75;

var m_Fade_R = 0;
var m_Fade_G = 0;
var m_Fade_B = 0;

var m_FadeStep = 3;
var m_FadeWait = 5000;
var m_bFadeOut = true;

var m_iFadeInterval;
var arrFadeMax;

function getTestimonial() {
  arrFadeMax = _testimonials.length-1;
  setTestimonial();
  setTimeout(Faderesume, m_FadeWait);
}

function fade_ontimer() {
  if (m_bFadeOut) {
	if(m_Fade_R < m_FadeOut)
		m_Fade_R+=m_FadeStep;
	if(m_Fade_G < m_FadeOut)
		m_Fade_G+=m_FadeStep;
	if(m_Fade_B < m_FadeOut)
		m_Fade_B+=m_FadeStep;
    
	if ((m_Fade_R>=m_FadeOut)&&(m_Fade_G>=m_FadeOut)&&(m_Fade_B>=m_FadeOut)) {
      test_idx++;
      if (test_idx>arrFadeMax)
        test_idx=0;
	  
      setTestimonial();
      m_bFadeOut = false;
    }
  } else {
	if(m_Fade_R > m_FadeIn_R)
		m_Fade_R-=m_FadeStep;
	if(m_Fade_G > m_FadeIn_G)
		m_Fade_G-=m_FadeStep;
	if(m_Fade_B > m_FadeIn_B)
		m_Fade_B-=m_FadeStep;

    if ((m_Fade_R<=m_FadeIn_R)&&(m_Fade_G<=m_FadeIn_G)&&(m_Fade_B<=m_FadeIn_B)) {
		m_Fade_R = m_FadeIn_R;m_Fade_G = m_FadeIn_G;m_Fade_B = m_FadeIn_B;
	
     	clearInterval(m_iFadeInterval);
     	setTimeout(Faderesume, m_FadeWait);
     	m_bFadeOut=true;
    }
  }
  var ele = document.getElementById("customer_testimonial");
  if (((m_Fade_R<=m_FadeOut)&&(m_Fade_G<=m_FadeOut)&&(m_Fade_B<=m_FadeOut))
	&&((m_Fade_R>=m_FadeIn_R)&&(m_Fade_G>=m_FadeIn_G)&&(m_Fade_B>=m_FadeIn_B))){
	ele.style.color = "rgb(" + m_Fade_R+","+m_Fade_G+","+m_Fade_B+")";
  }
}

function Faderesume() {
  m_iFadeInterval = setInterval(fade_ontimer, 10);
}

AddOnload(getTestimonial);