// testimonials which will be rotated.
var _testimonials = [
	"This has been the most professionally run, in-depth course I have ever attended.  It took my mathematics knowledge to a whole new level.",
	"The course addressed out literacy needs and helps towards our school literacy target, as the content is relevant and immediately applicable to the classroom.",
	"I love the resource and use it all the time. The tools are comprehensive and make the direct link between theory and practice so easy."
	];


//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); 
