/*******************************************************************************************
 * abbr
 * Written by Craig Francis
 * Allow the user to click on the <abbr> tags to expand them - going on the basis that
 * some users may think that the dotted underline looks like a link.
 *******************************************************************************************/

	var abbr = new function () {

		//--------------------------------------------------
		// Do not allow older browsers to run this script

			if (!document.getElementById || !document.getElementsByTagName) {
				return;
			}

		//--------------------------------------------------
		// Initialisation function used for setup

			this.init = function () {

				//--------------------------------------------------
				// Prepare all of the <abbrs> tags

					var abbrs = document.getElementsByTagName('abbr');
					for (var k = (abbrs.length - 1); k >= 0; k--) {
						if (abbrs[k].title && abbrs[k].title != '') {
							
							addLinkEvent(abbrs[k], abbr.expand);

							try {
								abbrs[k].style.cursor = 'help';
							} catch (e) {
							}

						}
					}

			}

		//--------------------------------------------------
		// Expand the abbreviation

			this.expand = function () {

				var nextNode = this.nextSibling;

				if (nextNode && cssjs('check', nextNode, 'abbrFull')) {

					//--------------------------------------------------
					// Remove the abbreviation expansion

						nextNode.parentNode.removeChild(nextNode);

				} else {

					//--------------------------------------------------
					// Add the expanded version of the abbreviation

						var span = createElement('span');
						span.appendChild(document.createTextNode(' [' + this.title + ']'));

						cssjs('add', span, 'abbrFull')

						this.parentNode.insertBefore(span, nextNode);

				}

			}

		//--------------------------------------------------
		// When the page has loaded, run the init function

			addLoadEvent (function() {
				abbr.init();
			});

	}
