/**
 * (c) Square Connect 2010
 */
// Set the quotes
var quote = new Array();
quote[0] = "&quot;SQ Remote brings all of the customization and control literally to my fingertips...&quot;";
quote[1] = "&quot;This truly is one of the most customizable apps I have ever used!&quot;"
quote[2] = "&quot;...I constantly hear this is so cool! The product is very ingenious and simple to use.&quot;"
quote[3] = "&quot;Without a doubt, SQ Remote is the best iPhone based Z-wave controller on the market.&quot;"
quote[4] = "&quot;SQ Remote helped improve the &quot;Family Acceptance Factor&quot; of my home automation project.&quot;"
quote[5] = "&quot;I'm really looking forward to future iterations as I am sure it can only get better from here!&quot;"
quote[6] = "&quot;From the power user to the technically challenged, this app is well worth the price of admission.&quot;"


var author = new Array();
author[0] = "T.Noble";
author[1] = "J.Hawley";
author[2] = "W.Severino";
author[3] = "R.Glover";
author[4] = "W.Severino";
author[5] = "T.Noble";
author[6] = "R.Glover";

var lines = new Array();
lines[0] = 2;
lines[1] = 2;
lines[2] = 2;
lines[3] = 3;
lines[4] = 3;
lines[5] = 2;
lines[6] = 3;


var numberOfQuotes = quote.length
var element = document.getElementById('rollingQuote');
var duration = 1000; /* 1000 millisecond fade = 1 sec */
var steps = 20; /* number of opacity intervals   */
var delay = 6000; /* 6 sec delay before fading out */
var quoteNumber = 0; /* count variable for the quote to be displayed */


/* set the opacity of the element (between 0.0 and 1.0) */
function setOpacity(level){
    document.getElementById("rollingQuote").style.opacity = level;
    document.getElementById("rollingQuote").style.MozOpacity = level;
    document.getElementById("rollingQuote").style.KhtmlOpacity = level;
    document.getElementById("rollingQuote").style.filter = "alpha(opacity=" + (level * 100) + ");";
}

function fadeIn(){
    for (i = 0; i <= 1; i += (1 / steps)) {
        setTimeout("setOpacity(" + i + ")", i * duration);
    }
    setTimeout("fadeOut()", delay);
}

function fadeOut(){
    quoteNumber++;
	if (quoteNumber > numberOfQuotes -1){
		quoteNumber =0;
	}
        newQuote = quote[quoteNumber];
        newAuthor = author[quoteNumber];
		if (lines[quoteNumber] > 2) {
			lineBreak = false;
		}
		else{
			lineBreak = true;
		}
	for (i = 0; i <= 1; i += (1 / steps)) {
        setTimeout("setOpacity(" + (1 - i) + ")", i * duration);
    }
   setTimeout(function(){
   		htmlText = '<p class = "quote">' + newQuote + '<br/>';
		if (lineBreak == true){
			htmlText = htmlText + '<br/>';
		}
		htmlText = htmlText + '<span class="gold">- ' + newAuthor + '</span></p>';
		document.getElementById("rollingQuote").innerHTML = htmlText;
   }, duration);
        
	
    setTimeout("fadeIn()", duration);
}

