/* Quotation object constructor. */
function Quotation(p_quote, p_citation)		
{
	this.quote = p_quote;
	this.citation = p_citation;
}

// Quotation object's methods.
Quotation.prototype.getQuote = function() { return this.quote; };
Quotation.prototype.getCitation = function() { return this.citation; };

/* QuoteList object constructor. */
function QuoteList()
{
	this.quoteList = new Array();
	this.currentQuote = 0;
	this.numQuotes = 0;
}

// Constant value used for testing.
QuoteList.prototype.testLorem = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Duis euismod. Vivamus nonummy volutpat velit.";

// QuoteList object methods.
QuoteList.prototype.addQuotation = function(p_quote, p_citation)
{
	var q = new Quotation(p_quote, p_citation);
	this.quoteList.push(q);
	this.numQuotes++;
}

QuoteList.prototype.getRandomQuotation = function()
{
	var i = Math.floor(Math.random() * this.quoteList.length);
	return this.quoteList[i];
}

QuoteList.prototype.getNextQuotation = function()
{
	var i = this.currentQuote;
	this.currentQuote++;
	if (this.currentQuote >= this.numQuotes)
	{
		this.currentQuote = 0;
	}
	return this.quoteList[i];
}

QuoteList.prototype.getQuotation = function()
{
	var strQuery = window.location.search;
	if (strQuery != null && strQuery.length > 1)
	{
		var i = strQuery.substring(1) - 1;	// Expect 1-based index.
		i %= this.numQuotes;
		return this.quoteList[i];
	}
	else
	{
		return this.getRandomQuotation();
	}
}

QuoteList.prototype.addTestQuotation = function()
{
	var i = this.quoteList.length + 1;
	var l = Math.max(Math.floor(Math.random() * this.testLorem.length), 15);
	var q = this.testLorem.substr(0, l);
	this.addQuotation(q, "Citation #" + i);
}

/* Document-global breadQuotes object. */
var breadQuotes = new QuoteList();
breadQuotes.addQuotation("Bread is the warmest, kindest of words. Write it always with a capital letter, like your own name.",
						 "Russian caf&eacute; sign");
breadQuotes.addQuotation("Acorns were good until bread was found.",
                         "Francis Bacon");
breadQuotes.addQuotation("Deliberation, <i><abbr title='noun'>n.</abbr></i>: The act of examining one&#8217;s bread to determine which side it is buttered on.",
                         "Ambrose Bierce");
breadQuotes.addQuotation("Bread should be baked in such a way that it will&#8230; require and secure a full exercise of the teeth in mastication.",
                         "Sylvester Graham");
breadQuotes.addQuotation("Here is bread, which strengthens man&#8217;s heart, and therefore is called the staff of Life.",
                         "Mathew Henry");
breadQuotes.addQuotation("No more turkey, but I&#8217;d like some more of the bread it ate.",
                         "Hank Ketcham");
breadQuotes.addQuotation("I judge a restaurant by the bread and by the coffee.",
                         "Burt Lancaster");
breadQuotes.addQuotation("I have to confess that, although I like the idea of hand-kneading bread dough, it does rather sap your strength.",
                         "Delia Smith");
breadQuotes.addQuotation("The first time I tried organic wheat bread I thought I was chewing on roofing material.",
                         "Robin Williams");
breadQuotes.addQuotation("<small>If the divine creator has taken pains to give us delicious and exquisite things to eat, the least we can do is prepare them well and serve them with ceremony.</small>",
                         "Fernand Point (1897-1955)");
breadQuotes.addQuotation("If you are ever at a loss to support a flagging conversation, introduce the subject of eating.",
                         "Leigh Hunt");
breadQuotes.addQuotation("Life is unsure; always eat your dessert first.",
                         "Anonymous");
breadQuotes.addQuotation("You can say this for ready-mixes&#8212;the next generation isn&#8217;t going to have any trouble making pies exactly like mother used to make.",
						 "Earl Wilson");
breadQuotes.addQuotation("A bagel is a doughnut with the sin removed.",
                         "George Rosenbaum");
breadQuotes.addQuotation("We are living in a world today where lemonade is made from artificial flavors and furniture polish is made from real lemons.",
						 "Alfred E. Newman");
breadQuotes.addQuotation("If God had intended us to follow recipes, He wouldn&#8217;t have given us grandmothers.",
                         "Linda Henley");
breadQuotes.addQuotation("We load up on oat bran in the morning so we&#8217;ll live forever.  Then we spend the rest of the day living like there&#8217;s no tomorrow.",
						 "Lee Iacocca");
breadQuotes.addQuotation("Bread deals with living things, with giving life, with growth, with the seed, the grain that nurtures.  It is not coincidence that we say bread is the staff of life.",
						 "Lionel Poilane");
breadQuotes.addQuotation("<small>Eating is not merely a material pleasure. Eating well gives a spectacular joy to life and contributes immensely to goodwill and happy companionship.  It is of great importance to the morale.</small>",
                         "Elsa Schiaparelli");
breadQuotes.addQuotation("Good bread is the most fundamentally satisfying of all foods; and good bread with fresh butter, the greatest of feasts.",
                         "James Beard (1903-1985)");
breadQuotes.addQuotation("How can a nation be great if its bread tastes like Kleenex?",
                         "Julia Child");
breadQuotes.addQuotation("I understand the big food companies are developing a tearless onion. I think they can do it&#8212;after all, they&#8217;ve already given us tasteless bread.",
                         "Robert Orben");
breadQuotes.addQuotation("The smell of good bread baking, like the sound of lightly flowing water, is indescribable in its evocation of innocence and delight.",
                         "M. F. K. Fisher (1908-1992)");
breadQuotes.addQuotation("Bread is like dresses, hats and shoes&#8212;in other words, essential!",
                         "Emily Post");
breadQuotes.addQuotation("The workers who built the pyramids in Egypt were paid in bread.", 
						 "(Trivia)");
breadQuotes.addQuotation("<small>In 1943, the U.S. Secretary of Agriculture banned the sale of sliced bread in an effort to hold down prices during a period of wartime rationing.</small>",
                         "(Trivia)");
breadQuotes.addQuotation("Bread is probably the one food eaten by people of every race, culture and religion.",
                         "(Trivia)");
breadQuotes.addQuotation("The average American student will have consumed upon graduation from high school 1,500 peanut butter &amp; jelly sandwiches.",
                         "Great Food Almanac");
breadQuotes.addQuotation("South Carolina was the first state to require enrichment of grain foods to curb nutrition deficiency.",
                         "(Trivia)");
breadQuotes.addQuotation("<small>I never had a piece of toast<br>Particularly long and wide,<br>But fell upon the sanded floor,<br>And always on the buttered side.</small>",
                         "Unknown");
breadQuotes.addQuotation("<small>If this was adulthood, the only improvement she could detect in her situation was that she could now eat dessert without eating her vegetables.</small>",
                         "Lisa Alther, <cite>Kinflicks</cite>, 1975");
