// testimonials which will be rotated.
var _testimonials = [
	"This resource is just what��s needed to support teachers in the delivery of oral language.  We had a chance to experiment and share our learning as we thoroughly explored the resource.",
	"The Facilitator Course has supported out school to achieve our goals for Writing, developing our teachers�� professional knowledge through using the First Steps Writing resources.",
	"The First Steps Writing Resources have really helped our staff to improve the teaching and learning of writing across our school.  Any school needing to improve writing should consider using these resources."
	];

//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); 
