//* Random Quote
//*
//* Randomly select a quote to appear at the top of the page

// The arrays for the quotes
var QuoteText = new Array();

// Quote text 
QuoteText[0]  = "I valued the opportunity to interact with leading thinkers and doers and people who have shaped the present and will influence the future.";
QuoteText[1]  = "Excellent, thought-provoking sessions with great takeaway value.";
QuoteText[2]  = "Superb organization. Thought-provoking topics, excellent list of attendees.";
QuoteText[3]  = "Extraordinarily rich in fresh information.";
QuoteText[4]  = "Fabulous people, great diversity, interesting topics.";
QuoteText[5]  = "The speakers were engaging and the participants were fully engaged.";
QuoteText[6]  = "A fantastic opportunity for reflection and professional development.";


// Randomly chooses a banner ad by finding the modulus of 
// current time's seconds divided by number of quotes.
function getRandomQuoteID() {
	var currentdate = new Date();
	var quoteid = currentdate.getSeconds() % QuoteText.length;
	return quoteid;
}


// Get a new, randomly selected quote id which represents its position
// in the QuoteText array and insert quote text.
function getQuote() {
	// Get random quote id
	var quoteid = -1;
	quoteid = getRandomQuoteID();
	
	// Try to vertically center quote by adjusting top margin based on the 
	// number of characters in the quote. (do this before displaying new quote to minimize flickering.)
	var quoteLength = QuoteText[quoteid].length;
	if (QuoteText[quoteid].length) {
		if (quoteLength < 100) newMargin = 37; // 3 lines of text
		if (quoteLength < 64) newMargin = 47; // 2 lines of text
		if (quoteLength < 38) newMargin = 57; // 2 lines of text
		document.getElementById('quoteBox').style.marginTop = newMargin + "px";
	}

	// Display the new quote
  	if (quoteid != -1 && QuoteText[quoteid]) {
    	document.getElementById('quoteText').innerHTML = QuoteText[quoteid];
	}

}
