var COTO = {};

COTO.Quotes = function(){
	
	return {
		init: function() {
			var tBlocks, i;

			tBlocks = $$("div.randomQuotes");
			
			for(i = 0; i < tBlocks.length; i++) {
				if(tBlocks[i].hasClassName("showOne")) {
					COTO.Quotes.showOne(tBlocks[i]);
				}else if (tBlocks[i].hasClassName("showAll")) {
					COTO.Quotes.showAll(tBlocks[i]);
				}
			}
		},

		showAll: function(el){
			var tQuote = "", i, text, name, title, org;

			for(i = 0; i < COTO.Quotes.list.length; i++) {
				text = COTO.Quotes.list[i].text || "";
				name = COTO.Quotes.list[i].name || "";
				title = COTO.Quotes.list[i].title || "";
				org = COTO.Quotes.list[i].organization || "";

				if (text != "" || name != "") {
					tQuote += "<blockquote class='single'>\n";
					tQuote += "<p>\n";
					tQuote += COTO.Quotes.list[i].text;
					tQuote += "</p>\n<cite>-- ";
					tQuote += name;
					if (title != "") {
						tQuote += ", " + title;
					}
					if (org != "") {
						tQuote += "<br />" + org;
					}
					tQuote += "</cite>\n";
					tQuote += "</blockquote>\n";
				}
			}

			el.innerHTML = tQuote;
		},

		showOne: function(el){
			var i, tQuote = "", text, name, title, org;

			i = Math.floor(Math.random() * COTO.Quotes.list.length);

			quote = COTO.Quotes.list[i].quote || "";
			author = COTO.Quotes.list[i].author || "";

			if (text != "" || name != "") {
				tQuote = "<blockquote class='single'>\n";
				tQuote += "<p>\n";
				tQuote += COTO.Quotes.list[i].quote;
				tQuote += "</p>\n<cite>-- ";
				tQuote += author;
				tQuote += "</cite>\n";
				tQuote += "</blockquote>\n";

				el.innerHTML = tQuote;				
			}			
		}
	}
}();

COTO.Quotes.list = [
	{
		quote: "Our deepest fear is not that we are inadequate. Our deepest fear is that we are powerful beyond measure. It is our light, not our darkness that most frightens us. We ask ourselves, Who am I to be brilliant, gorgeous, talented, fabulous? Actually, who are you not to be? You are a child of God. Your playing small does not serve the world. There is nothing enlightened about shrinking so that other people won't feel insecure around you. We are all meant to shine, as children do. We were born to make manifest the glory of God that is within us. It's not just in some of us; it's in everyone. And as we let our own light shine, we unconsciously give other people permission to do the same. As we are liberated from our own fear, our presence automatically liberates others.",
		author: 'Marianne Williamson from "A Return to Love"'
	},
	{
		quote: "Your living is determined not so much by what life brings to you as by the attitude you bring to life; not so much as by what happens to you as by the way your mind looks at what happens. Circumstances and situations do color life, but you have been given the mind to choose what the color should be",
		author: "John Homer Miller"
	},
	{
		quote: "Life is not measured by the number of breaths we take, but by the moments that take our breath away.",
		author: "Maya Angelou"
	},
	{
		quote: "Don’t cry because it’s over, smile because it happened.",
		author: "Dr. Seuss"
	},
	{
		quote: "Joy is the most infallible sign of the presence of God.",
		author: "Pierre Teilhard de Chardin"
	},
	{
		quote: "At any moment, you have a choice, that either leads you closer to your spirit or further away from it.",
		author: "Thich Nhat Hanh"
	},
	{
		quote: 	"Forgiveness is the fragrance the violet sheds on the heel that has crushed it.",
		author: "Mark Twain"
	},
	{
		quote: 	"The Guest House<br /><br/>" +
				"This being human is a guest house<br /> Every morning a new arrival.<br/>" +
				"A joy, a depression, a meanness,<br />some momentary awareness comes as an unexpected visitor.<br/><br/>" +
				"Welcome and entertain them all!<br />Even if they are a crowd of sorrows,<br />who voilently sweep your house empty of its furniture,<br />" +
				"still, treat each guest honorably.<br />He may be clearing you out for some new delight.<br /><br />" +
				"The dark thought, the shame, the malice.<br />meet them at the door laughing and invite them in.</br /><br />" +
				"Be grateful for whatever comes<br />because each has been sent as a guide from beyond.",
		author: "Rumi"
	},
	{
		quote: 	"We are what we think.  All that we are arises with our thoughts.  With our thoughts we make our world.",
		author: "The Buddha"
	},
	{
		quote: "Our greatest glory is not in never failing, but in rising up every time we fail.",
		author: "Ralph Waldo Emerson"
	},
	{
		quote: "If you find yourself in a hole, the first thing to do is stop diggin.",
		author: "Will Rogers"
	},
	{
		quote: "I hold it as a changeless law,<br />" +
				"From which no soul can sway or swerve,<br />" +
				"We have that in us which will draw<br />" +
				"Whatever we need and most deserve",
		author: "Walt Whitman"
	},
	{
		quote: "The thing always happens that you really believe in; and the belief in a thing makes it happen.",
		author: "Frank Lloyd Wright"
	},
	{
		quote: "The greatest weapon against stress is our ability to choose one thought over another.",
		author: "William James"
	},
	{
		quote: "You can't do anything about the length of your life but you can do something about its width and depth.",
		author: "Evan Essar"
	},
	{
		quote: "What is hateful to you, do not to your fellow man. That is the entire law; all the rest is commentary.",
		author: "The Talmud"
	},
	{
		quote: "I spring out of bed and fairly sizzle with zeal and enthusiasm to go forth this day and do the things that ought to be done by me.",
		author: "Charles Fillmore (on his 90th birthday)"
	},
	{
		quote: "I can't wait to see the good that comes out of this mess.",
		author: "Unknown"
	},
	{
		quote: "Twenty years from now you will be more disappointed by the things that you did not do than by the ones you did. So throw off the bow lines, sail away from the safe harbor, catch the trade winds in your sails, explore, dream and discover.",
		author: "Mark Twain"
	},
	{
		quote: "It isn’t joy that makes you feel grateful, it’s being grateful that makes you feel joy.",
		author: "Unknown"
	}
];

Event.observe(window, 'load', COTO.Quotes.init);
