﻿  /*
  	Author:		Rob Brunskill

  	call by: startQuoteScroll()

  */
  
var scrollSpeed = 15; /* 1 px per <scrollSpeed> miliseconds */
var runScroll = 'TRUE'; /* set to 'TRUE' to turn on scrolling, any other value for off */

/* Starting X coordinate for background */
var xPosition = 100; 

/* X,Y coordinate for quote 1 */
var quote1PositionX = 120; 
var quote1PositionY = 20;
/* X,Y coordinate for quote 2 */
var quote2PositionX = 440;
var quote2PositionY = 10;
/* X,Y coordinate for quote 3 */
var quote3PositionX = 700;
var quote3PositionY = 10;
/* X,Y coordinate for quote 4 */
var quote4PositionX = 955;
var quote4PositionY = 40;
/* X,Y coordinate for quote 5 */
var quote5PositionX = 1290;
var quote5PositionY = 20;
/* X,Y coordinate for quote 6 */
var quote6PositionX = 1590;
var quote6PositionY = 10;
/* X,Y coordinate for quote 7 */
var quote7PositionX = 1795;
var quote7PositionY = 20;

var scrollTimerId;

function startQuoteScroll ()/* Main function to start, or resume scroll */
{
    clearInterval(scrollTimerId); /* Just to make sure we don't double up */
    if (runScroll == 'TRUE') {
        scrollTimerId = setInterval("quoteScroll()", scrollSpeed);
    }
}
function pauseQuoteScroll ()/* Pause or stop the scroll */
{
    clearInterval(scrollTimerId);
}
function quoteBackgroundScroll() { /* Controls the scrolling of the background */
    document.getElementById("quoteBannerContent").style.backgroundPosition=xPosition+"px "+0+"px";
    xPosition -= 1;
    if (xPosition == -1013) {
        xPosition = 1012;
    }
}
function singleQuoteScroll(quoteNumber,isLong) { /* Controls the scrolling of a single quote */
    if (isLong == "TRUE") {
        var quoteShort = "Short";
        var quoteLong = "Full";
    } else {
        var quoteShort = "";
        var quoteLong = "";
    }
    quotePositionX = eval('quote' + quoteNumber + 'PositionX');
    quotePositionY = eval('quote' + quoteNumber + 'PositionY');
    
    quoteStyle = document.getElementById("quote" + quoteNumber + quoteShort).style;
    quoteLongStyle = document.getElementById("quote" + quoteNumber + quoteLong).style;
    quoteStyle.left = quotePositionX + "px";
    quoteStyle.top = quotePositionY + "px";
    if (quoteLong != "") {
        quoteLongStyle.left = (quotePositionX - 10) + "px";
    }
    quotePositionX -= 1;
    if (quotePositionX == -1013) {
        quotePositionX = 1012;
    }
    return quotePositionX;
}        
function quoteScroll() { /* Any new quotes must be added or removed here */
    quoteBackgroundScroll();
    quote1PositionX = singleQuoteScroll("1","TRUE");
    quote2PositionX = singleQuoteScroll("2","TRUE");
    quote3PositionX = singleQuoteScroll("3","TRUE");
    quote4PositionX = singleQuoteScroll("4","TRUE");
    quote5PositionX = singleQuoteScroll("5","TRUE");
    quote6PositionX = singleQuoteScroll("6","TRUE");
    quote7PositionX = singleQuoteScroll("7","TRUE");
}
function getNextSibling(startBrother){ /* Make sibling address work with FireFox */
  endBrother=startBrother.nextSibling;
  while(endBrother.nodeType!=1){
    endBrother = endBrother.nextSibling;
  }
  return endBrother;
} 
function getPreviousSibling(startBrother){ /* Make previous address work with FireFox */
  endBrother=startBrother.previousSibling;
  while(endBrother.nodeType!=1){
    endBrother = endBrother.previousSibling;
  }
  return endBrother;
} 
function getFirstChild(startParent){ /* Make first child address work with FireFox */
  endChild=startParent.firstChild;
  while(endChild.nodeType!=1){
    endChild = endChild.nextSibling;
  }
  return endChild;
} 
function showFullQuote(currentNode){ 
/* Placed on the short quote node. On Mouseover, hide short quote, show full quote, and pause scroll */
    getNextSibling(currentNode).style.display='block';
    getFirstChild(currentNode).style.display='none';
    pauseQuoteScroll();
}
function keepShowFullQuote(currentNode){ 
/* Placed on the full quote node, keeps full quote showing */
    currentNode.style.display='block';
    getFirstChild(getPreviousSibling(currentNode)).style.display='none';
    pauseQuoteScroll();
}
function showShortQuote(currentNode){
/* Placed on the full quote node. On Mouseout, hide full quote, show short quote, resume scroll */
    currentNode.style.display='none'; 
    getFirstChild(getPreviousSibling(currentNode)).style.display='block';
    startQuoteScroll();
}

