/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Mike Hudson :: http://www.afrozeus.com */

function setupFadeLinks() {
  arrFadeLinks[0] = "#";
  arrFadeTitles[0] = "<i>'Physical fitness is the first requisite of happiness.'<br /><span style=\"float:right; color:#0085cc;\">Joseph Pilates</span></i>";
  arrFadeLinks[1] = "#";
  arrFadeTitles[1] = "<i>'It is the mind itself which builds the body.'<br /><span style=\"float:right; color:#0085cc;\">Schiller (Joseph Pilates’s favourite quote)</span></i>";
  arrFadeLinks[2] = "#";
  arrFadeTitles[2] = "<i>'If your spine is inflexibly stiff at thirty, you are old.  If it is completely flexible at sixty, you are young.'<br /><span style=\"float:right; color:#0085cc;\">Joseph Pilates</span></i>";
  arrFadeLinks[3] = "#";
  arrFadeTitles[3] = "<i>The Pilates Method 'is designed to give you suppleness, natural grace and skill that will be unmistakably reflected in the way you walk, in the way you play, and in the way you work.'<br /><span style=\"float:right; color:#0085cc;\">Joseph Pilates</span></i>";
  arrFadeLinks[4] = "#";
  arrFadeTitles[4] = "<i>'Mens sana in corpora sano.' (A sane mind in a sound body.)<br /><span style=\"float:right; color:#0085cc;\">The Roman Motto</span></i>";
  arrFadeLinks[5] = "#";
  arrFadeTitles[5] = "<i>'What is balance of body and mind?<br />It is the conscious control of all muscular movements of the body.'<br /><span style=\"float:right; color:#0085cc;\">Joseph Pilates</span></i>";
}

// 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=128;
var m_Fade = 0;
var m_FadeStep = 5;
var m_FadeWait = 8000;
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)
  {
  }
}
