﻿function setupFadeLinks() {
  arrFadeLinks[0] = "CS_NeathPort.html";
  arrFadeTitles[0] = '&quot; We have been a user of SDMS software for managing Schools Training since the early 1990s and have progressed through all its versions to the very latest.  We have now completed a Schools Pilot of SDMS V e-Training and in the coming months are rolling it out to all Schools.  The Pilot has enabled us to iron out issues and to build a basis for extending it to all Schools under our own steam. &quot;<br><br>Steve Davies, Neath Port Talbot LEA';
  arrFadeLinks[1] = "CS_PortsmouthFC.html";
  arrFadeTitles[1] = '&quot; In the last Football League inspection we were highly commended by the Football League for our Administration of the Youth Development Programme, this was in no small way due to SDMS software. &quot;<br><br>Marina Emberson, Portsmouth FC';
}

// 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 = 0;
var m_Fade = 0;
var m_FadeStep = 2;
var m_FadeWait = 6400;
var m_bFadeOut = true;

var m_iFadeInterval;

window.onload = Fadewl;

var arrFadeLinks;
var arrFadeTitles;
var arrFadeCursor = 0;
var arrFadeMax;

function Fadewl() {
  m_iFadeInterval = setInterval(fade_ontimer, 10);
  arrFadeLinks = new Array();
  arrFadeTitles = new Array();
  setupFadeLinks();
  arrFadeMax = arrFadeLinks.length-1;
  setFadeLink();
}

function setFadeLink() {
  var ilink = document.getElementById("fade_link");
  ilink.innerHTML = arrFadeTitles[arrFadeCursor];
  ilink.href = arrFadeLinks[arrFadeCursor];
}

function fade_ontimer() {
  if (m_bFadeOut) {
    m_Fade+=m_FadeStep;
    if (m_Fade>m_FadeOut) {
      arrFadeCursor++;
      if (arrFadeCursor>arrFadeMax)
        arrFadeCursor=0;
      setFadeLink();
      m_bFadeOut = false;
    }
  } else {
    m_Fade-=m_FadeStep;
    if (m_Fade<m_FadeIn) {
      clearInterval(m_iFadeInterval);
      setTimeout(Faderesume, m_FadeWait);
      m_bFadeOut=true;
    }
  }
  var ilink = document.getElementById("fade_link");
  if ((m_Fade<m_FadeOut)&&(m_Fade>m_FadeIn))
    ilink.style.color = "#" + ToHex(m_Fade);
}

function Faderesume() {
  m_iFadeInterval = setInterval(fade_ontimer, 10);
}

function ToHex(strValue) {
  try {
    var result= (parseInt(strValue).toString(16));

    while (result.length !=2)
            result= ("0" +result);
    result = result + result + result;
    return result.toUpperCase();
  }
  catch(e)
  {
  }
}
