/**
 * The <code>ds_quoter</code> package defines 3 useful objects for placing
 * a random 'quote of the day' style quote on your web page.
 * @author Dave Sag <a href="http://www.davesag.com">www.davesag.com</a>
 */

// -----------------------------------------------------------------------------
/**
 * A DS_Link provides a basic mechanism for writing out a consistant href link.
 * @param url The url string.
 * @param text The text that goes between the tags.
 * @param title The title attribute for the link (shows up as a tooltip usually).
 */
function DS_Link(url,text,title) {
		this.url = url;
		this.text = text;
		this.title = title;
		this.toString = function() {
			var s = '<a href="'+this.url+'"';
			if (this.title != null) {
				s+=' title="'+this.title+'"';
			}
			s+='>'+this.text+'<\/a>';
			return s;
		}
}

// -----------------------------------------------------------------------------
/**
 * A DS_Quote provides a basic mechanism for writing out a consistant quote.
 * @param text The text of the quote.  Html is okay but remember to escape tags.
 * @param who The person to made this quote and any other text you like.
 * @param link A properly populated DS_Link object provides a link to a source.
 */
function DS_Quote(text,who,link) {
	this.text = text;
	this.who = who;
	this.link = link;
	this.toString = function() {
		var s = '"'+this.text+'" - <i>'+this.who+'<\/i>';
		if (this.link != null) {
			s+= ' ('+this.link+')';
		}
		return s;
	}
}

// -----------------------------------------------------------------------------
/**
 * A DS_Quoter maintains an pool of quotes and is able to display one
 * selected at random. Once your DS_Quoter has been populated then simply
 * call it's write() method to document.write it to the page.
 */
function DS_Quoter() {
	this.quotes = new Array();
	this.addQuote = function(quote,who,link) {
		this.quotes[this.quotes.length] = new DS_Quote(quote,who,link);
	}
	this.toString = function() {
		var i = randomInt(this.quotes.length);
		return this.quotes[i];
	}
	this.write = function() {
		document.writeln(this.toString());
	}
}

