/**
 * Copyright 2008 - Jeff "Foxxtrot" Craig  http://foxxtrot.net/
 * This Source is licensed under the Apache License
 **/
 
if (typeof YAHOO === "undefined" || !YAHOO)
{
	throw {
		name: "RequiredLibraryNotFound",
		message: "This library depends on YUI (http://developer.yahoo.org/yui/).<br />Please load the YAHOO library prior to loading this library."
	}
}
/*
if (typeof YAHOO.util.Connect === "undefined" || !YAHOO.util.Connect)
{
	throw {
		name: "RequiredLibraryNotFound",
		message: "This library depends on the YUI Connection Library (http://developer.yahoo.org/yui/).<br />Please load the YUI Connection library prior to loading this one.";
	}
}
*/
if (typeof Foxxtrot === "undefined" || !Foxxtrot)
{
	var Foxxtrot = {};
}


if (typeof Foxxtrot.Controls === "undefined" || !Foxxtrot.Controls)
{
	Foxxtrot.Controls = {};
}

Foxxtrot.Controls.Quotes = {
	_default_url: "/get_quotes.php",
	_default_div: "quote-content",
	_default_callback:{
		success: function(response) {
			if (response.responseText !== undefined) {
				var quote, year, author, div, string;
				var root = response.responseXML.documentElement;
				var quotes = root.getElementsByTagName('quote');
				if (quotes.length !== 0) {
					quote = quotes[0].innerText;
					year = quotes[0].getAttribute('year');
					author = quotes[0].getAttribute('author');				
					div = document.getElementById(argument[0]);
				
					string = quote + "<br />" + "--<i>" + author;
					
					if (year) {
						string += "(" + year + ")"
					}
					string += "</i>"{
					div.innerHtml = string;
				}
			}
		},
		
		failure: function(response) {
		},
		argument: [ updateDivId || _default_div ]
	},
	get_quote:function(divId) {
		if (divId) {
			this.updateDivId = divId;
		}
		
		var url = currentURL || _default_url;
		var callback = callbackObject || _default_callback;
		
		var transaction = YAHOO.util.Connect.asyncRequest('GET', url, callback, null);
	}
};

Foxxtrot.Controls.Quotes.get_quote();
