// testimonials which will be rotated.
var _testimonials = [
	"I agree with the judges that this is the best resource for all teachers whether they are beginners or experienced.",
	"I am really enjoying using the resource and love the rich language and thinking that the children are displaying.",
	"It isn’t often that you can attend a workshop which is so relevant to all learning areas. Well Done!",
	"Very engaging course. Great ideas, easy to apply/modify to suit different learning areas.",
	"An absolute delight to present. Everything seems to be so intuitive in terms of the sequencing of ideas and activities. The participants agreed that the Course Books were excellent and will provide great support 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);