﻿/* QuoteCycle.js */

var quoteArray = new Array (
"'...stunningly assured performance by a little-known soprano'<br/><b>The Press</b>", 
"'Viki Hart...shone like a beacon above the mighty forces below'</br><b>The Press</b>",
"'The bright young voice of Viki Hart matched perfectly with the outstanding mezzo...'<br/><b>Yorkshire Post</b>"
);  


var opacity = 10;
var cycleOnTime = 4000;
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);
    } 
}
