// Class Definitions ----------------------------------------------------------------------------------------------------------

	function WordOfTheDayBox (id)
		{	this.id = id;
		}; // class WordOfTheDayBox (id)

	WordOfTheDayBox.prototype.getTodaysWord	= word_of_the_day_box_get_todays;
	WordOfTheDayBox.prototype.render		= word_of_the_day_box_render;
	WordOfTheDayBox.prototype.setData		= word_of_the_day_box_set_data;
	WordOfTheDayBox.prototype.onAJaxSuccess	= word_of_the_day_box_ajax_success;
	WordOfTheDayBox.prototype.onAJaxFailure	= word_of_the_day_box_ajax_failure;
	WordOfTheDayBox.prototype.onAJaxUpdate	= word_of_the_day_box_ajax_update;

// Method Definitions ---------------------------------------------------------------------------------------------------------

	function word_of_the_day_box_ajax_failure (ajax)
		{	this.setData("wordulous", "adjective", "Anonymous", ": given to inventing creative new words because one's large vocabulary needs sustenance");
		}; 

	// ------------------------------------------------------------------------------------------------------------------------

	function word_of_the_day_box_ajax_success (ajax)
		{	// Get the XML document root node.
			var xml	= ajax.responseXML;
			var xml	= xml.getElementsByTagName("wod");
			var xml	= xml ? xml.item(0) : false;

			// Get the headword.
			var data		= xml? xml.getElementsByTagName("headword") : false;
			data			= data ? data.item(0) : false;
			var headword	= data && data.firstChild ? data.firstChild.nodeValue : "";

			// Get the audio.
			data			= xml? xml.getElementsByTagName("audio") : false;
			data			= data ? data.item(0) : false;
			var audio		= data && data.firstChild ? data.firstChild.nodeValue : "";
			audio			= audio.replace('=', '&word=').replace(/\/cgi-bin\/audio\.pl\?/, '/audio.php?file=');

			// Get the publication date.
			data			= xml? xml.getElementsByTagName("pub-date") : false;
			data			= data ? data.item(0) : false;
			var pub_date	= data && data.firstChild ? data.firstChild.nodeValue : "";

			// Get the function label.
			data			= xml? xml.getElementsByTagName("function") : false;
			data			= data ? data.item(0) : false;
			var func		= data && data.firstChild ? data.firstChild.nodeValue : "";

			// Get the facts.
			data			= xml? xml.getElementsByTagName("facts") : false;
			data			= data ? data.item(0) : false;
			var facts		= data && data.firstChild ? data.firstChild.nodeValue : "";

			// Get the pronunciation.
			data			= xml? xml.getElementsByTagName("pronunc") : false;
			data			= data ? data.item(0) : false;
			var pronunc		= data && data.firstChild ? data.firstChild.nodeValue : "";

			// Get the definition.
			data	= xml? xml.getElementsByTagName("short") : false;
			data	= data ? data.item(0) : false;
			var def	= data && data.firstChild ? data.firstChild.nodeValue : "";
			def		= def.replace(/\s+/, " ");
			def		= def.replace(/^\s+/, "");
			def		= def.replace(/\s+$/, "");

			// Set the data.
			this.setData(headword, func, pronunc, def, pub_date, audio, facts);
		}; 

	// ------------------------------------------------------------------------------------------------------------------------

	function word_of_the_day_box_ajax_update (ajax)
		{	// Set the definition text.
			if ( (control = document.getElementById(this.id + "_def")) )
				{	control.innerHTML = "LOADING...";
				}; // if ( (control = document.getElementById(this.id + "_def")) )
		}; 

	// ------------------------------------------------------------------------------------------------------------------------

	/** This methods gets today's word.                                                                                     **/
	function word_of_the_day_box_get_todays ()
		{	makeAJaxRequest("/word/content/daily/active.xml", "GET", this);
		}; 

	// ------------------------------------------------------------------------------------------------------------------------

	/** This methods sets the data to appear in a word of the day box.                                                      **/
	function word_of_the_day_box_render (entry, pspeech, pronunc, def, date, audio, facts)
		{	// The next control to set.
			var control = false;

			// Set the entry text.
			if ( (control = document.getElementById(this.id + "_entry")) )
				{	control.innerHTML = "<a href=\"/word-of-the-day/\">" + entry + "</a> <a href=\"#\" class=\"audio\" target=\"wod_audio\"><img src=\"/styles/default/images/home/speaker.jpg\" alt=\"Hear it\"></a>";
					control.getElementsByTagName('a').item(1).onclick = new Function("au('" + audio.replace(/^.*?file=/, '').replace('&word=', "', '") + "', '" + pronunc + "'); return false;");
				}; // if ( (control = document.getElementById(this.id + "_entry")) )

			// Set the part of speech/pronunciation text.
			if ( (control = document.getElementById(this.id + "_pspeech")) )
				{	control.innerHTML = "\\" + pronunc + "\\ " + pspeech;
				}; // if ( (control = document.getElementById(this.id + "_pspeech")) )

			// Set the definition text.
			if ( (control = document.getElementById(this.id + "_def")) )
				{	//var max_len			= isScreen800x600() ? 90 : 120;
					//def					= chompText(def, max_len);
					//def					= ( def.substring(0, 1) != "<" && def.substring(0, 1) != ":" ) ?
					//						( "<strong>:</strong> " + def ) : def;
					control.innerHTML	= def;
				}; // if ( (control = document.getElementById(this.id + "_def")) )

			// Set the entry date.
			if ( (control = document.getElementById(this.id + "_date")) )
				{	var date_values		= date.split("/");
					var month			= date_values[0];
					var day				= date_values[1];
					var year			= date_values[2];
					month				= month.replace(/^0/, "");
					var months			= Array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
					month				= months[parseInt(month)].toUpperCase();
					control.innerHTML	= month + " " + day + ", " + year;
				}; // if ( (control = document.getElementById(this.id + "_entry")) )

			// Set the part of facts text.
			if ( (control = document.getElementById(this.id + "_facts")) )
				{	var max_len		= 75;
					var last_char	= facts.length > max_len ? facts[max_len] : '';
					var dots		= facts.length > max_len ? '...' : '';
					facts			= facts.length > max_len ? facts.substring(0, max_len) : facts;					
					facts			= (last_char !== ' ' ? facts.replace(/\s+[^\s]+$/, '') : facts).replace(/\s+$/, '') + dots;
					control.innerHTML = '<a href="/word-of-the-day/">' + 'Did You Know? ' + facts + ' <span>more&nbsp;&raquo;</span>';
				}; // if ( (control = document.getElementById(this.id + "_pspeech")) )
		}; 

	// ------------------------------------------------------------------------------------------------------------------------

	/** This methods sets the data to appear in a word of the day box.                                                      **/
	function word_of_the_day_box_set_data (entry, pspeech, pronunc, def, date, audio, facts)
		{	this.render(entry, pspeech, pronunc, def, date, audio, facts);
		}; 


