﻿/* QuoteCycle.js */

var quoteArray = new Array ( 
"The playing is selflessly beautiful... everything seems to be just right.<br /><b>Tully Potter, The Strad May 2005</b>",
"...the engineers and any one else attending the sessions surely having had to bite their lips at the end to avoid a shouted and thundered applause. <br><b>Rob Barnett, Music Web</b>",
"...the gloriously natural and unforced interpretative approach of the Primrose Quartet<br/><b>Julian Haylock, Classic FM Magazine, 5 star award</b>" 
);  


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);
    } 
}