﻿/* QuoteCycle.js */

var quoteArray = new Array ( 
"A week of solo and chamber music",
"for pianists and string players",
"from age 11, school, music college, post-graduate and amateur" 
); 

var opacity = 10;
var cycleOnTime = 3000;
var cycleFadeInSpeed = 50;
var cycleFadeOutSpeed = 10;
var quoteCount = -1;
var defaultTextColour = "#333333";
var blankTextColour = "#FFFFFF";

function initQuoteCycle()
{
    cycleQuote();
    fadeIn();    
}

function cycleQuote()
{
    quoteCount = quoteCount + 1;
    if ( quoteCount >= quoteArray.length ) quoteCount = 0;
    
    var quote = quoteArray[quoteCount];
    var element = document.getElementById("quotation");
    
    element.innerHTML = quote;
}


function fadeOut()
{
    var element =  document.getElementById("panelQuotation");
   
    opacity = opacity - 1;
    element.style.opacity = opacity/10;
    element.style.filter = 'alpha(opacity=' + opacity*10 + ')';    
    
    if ( opacity <= 0 ) 
    {
        cycleQuote();
        fadeIn();
    }
    else
    {
        setTimeout("fadeOut()", cycleFadeOutSpeed);
    } 
}

function fadeIn()
{
    var element =  document.getElementById("panelQuotation");

    opacity = opacity + 1;
    if ( opacity >= 10 ) 
    {
        opacity = 10;
        element.style.opacity = 1;
        if ( element.style.filter != null )
        {
            element.style.removeAttribute('filter'); /* otherwise text is pixely */
        }
    }
    else
    {
        element.style.opacity = opacity/10;
        element.style.filter = 'alpha(opacity=' + opacity*10 + ')';    
    }
    
    if ( opacity == 10 ) 
    {
        setTimeout("fadeOut()", cycleOnTime);
    }
    else
    {
        setTimeout("fadeIn()", cycleFadeInSpeed);
    } 
}