	/**
	 * JavaScript Tooltip Class
	 * Written by Brian Cline [brian@defined.org].
	 * Updates posted to http://www.defined.org/code/
	 * Version: 1.2.4 (09/16/2005)
	 * 
	 * Dependencies:
	 *    Prototype Javascript framework (http://prototype.conio.net/)
	 * 
	 * Tested and compatible with:
	 *    Microsoft Internet Explorer 6.0
	 *    Mozilla Firefox 1.5 Beta 1
	 *    Mozilla Firefox 1.0.6
	 *    Mozilla 1.7.11
	 * 
	 * 
	 * Change log:
	 * 1.2.4 [20050916]
	 *       - Tooltips can now be created a second way: by tying quickTooltip()
	 *         to an object event (I would recommend onmouseover). For example,
	 *         <div onmouseover="quickTooltip(this, 'Here is my tooltip')">
	 *       - Fixed bug where tooltip began wrapping text towards the right edge
	 *         of the body element, or moving beyond it and causing the window to
	 *         scroll.
	 *       - Added a width property that can be set so the tooltip maintains a
	 *         fixed width. The default is auto, with no text wrapping. Text can
	 *         still be manually wrapped by insering <br /> tags, of course.
	 *       - Added a text alignment property called textAlign.
	 * 
	 * 1.2.3 [20050914]
	 *       - Now supports transparency through the member variable 'opacity.'
	 *       - Fixed a simple bug affecting Mozilla and Firefox transparencies.
	 *       - Added some default display properties to the constructor. These
	 *         can be changed on-the-fly.
	 *       - Developers now have the ability to set display properties upon
	 *         instantiation of the object.
	 * 
	 * 1.2.2 [20050913]
	 *       - Fixed a major bug that only occurred when user scrolled down and
	 *         moved over a tooltip area. The tooltip was not being shifted down
	 *         the same amount of pixels that the user had scrolled.
	 * 
	 * 1.2.1 [20050913]
	 *       - No longer a need for the tooltip div to exist in HTML.
	 * 
	 * 1.2.0 [20050913]
	 *       - Made cross-browser compatibility changes. 
	 *       - Tested and working in Firefox 1.5 Beta 1 and Mozilla 1.7.11.
	 * 
	 * 1.1.1 [20050913]
	 *       - Removed references to getObject() to something standard.
	 * 
	 * 1.1.0 [20050908]
	 *       - Fixed bug where tooltip would extend beyond the edges of the page.
	 * 
	 * 1.0.0 [20050906]
	 *       - Initial version of Tooltip class.
	 *       - Tested and working in MSIE6.
	 */
	
	var TOOLTIP_ID = "__tooltip_area";
	var TOOLTIP_ARRAY = new Array();
	document.write('<div id="' + TOOLTIP_ID + '" style="display: none; position: absolute;"></div>');
	
	function Tooltip(containerID, text, properties) {
		this.version = '1.2.4';
		this.isMSIE = navigator.appName.indexOf('Microsoft') != -1;
		this.visible = false;
		this.text = '';
		
		if(!properties)
			properties = function() {}
		
		// Default display properties
		this.opacity          = (properties.opacity || (100 - properties.transparency) || 100);
		this.windowMargin     = (properties.windowMargin || 5);
		this.width            = (properties.width || 'auto');
		
		this.borderColor      = (properties.borderColor     || 'black');
		this.borderStyle      = (properties.borderStyle     || 'solid');
		this.borderThickness  = (properties.borderThickness || 1);
		
		this.paddingTop       = (properties.paddingTop    || properties.padding || 2);
		this.paddingBottom    = (properties.paddingBottom || properties.padding || 2);
		this.paddingLeft      = (properties.paddingLeft   || properties.padding || 3);
		this.paddingRight     = (properties.paddingRight  || properties.padding || 3);
		
		this.bgColor          = (properties.bgColor   || '#ffffe1');
		this.fontColor        = (properties.fontColor || properties.color || 'black');

		this.fontSize         = (properties.fontSize   || 11);
		this.fontFamily       = (properties.fontFamily || 'Tahoma');
		this.fontHeight       = (properties.fontHeight || Math.ceil(this.fontSize * 1.1));
		this.textAlign        = (properties.textAlign  || 'left');
		
		this.create(containerID, text);
	}
	
	Tooltip.prototype.reposition = function(objEvent) {
		var obj = document.getElementById(TOOLTIP_ID);
		var scrollOffsetX = 0, scrollOffsetY = 0;
		var newX = 0, newY = 0;
		var bodyWidth;
		
		if(obj == null)
			return;
		
		if(window.pageYOffset) {
			scrollOffsetX = window.pageXOffset;
			scrollOffsetY = window.pageYOffset;
		} else if(document.documentElement && document.documentElement.scrollTop) {
			scrollOffsetX = document.documentElement.scrollLeft;
			scrollOffsetY = document.documentElement.scrollTop;
		} else if(document.body) {
			scrollOffsetX = document.body.scrollLeft;
			scrollOffsetY = document.body.scrollTop;
		}
		
		if(this.isMSIE) {
			newX = objEvent.x;
			newY = objEvent.y;
		} else {
			newX = objEvent.clientX;
			newY = objEvent.clientY;
		}
		
		newX = newX - (0.5 * obj.offsetWidth) + scrollOffsetX;
		newY = newY - (obj.offsetHeight + 10) + scrollOffsetY;
		
		if(document.documentElement && document.documentElement.clientWidth)
			bodyWidth = document.documentElement.clientWidth;
		else
			bodyWidth = document.body.clientWidth;
		
		if(newX < this.windowMargin)
			newX =  this.windowMargin;
		if(newY < this.windowMargin)
			newY = this.windowMargin;
		
		if((newX + obj.offsetWidth) > (bodyWidth - this.windowMargin))
			newX = bodyWidth - this.windowMargin - obj.offsetWidth;
		
		if(this.isMSIE) {
			obj.style.pixelLeft = newX;
			obj.style.pixelTop = newY;
		} else {
			obj.style.left = newX + 'px';
			obj.style.top = newY + 'px';
		}
	}
	
	Tooltip.prototype.hide = function() {
		document.getElementById(TOOLTIP_ID).style.display = 'none';
		document.getElementById(TOOLTIP_ID).innerHTML = '';
		this.visible = false;
	}
	
	Tooltip.prototype.show = function(objEvent) {
		var obj = document.getElementById(TOOLTIP_ID);
		
		if(this.width == 'auto') {
			obj.style.width = 'auto';
			obj.style.whiteSpace = 'nowrap';
		}
		else {
			obj.style.width = this.width + 'px';
		}

		if(this.isMSIE) {
			obj.style.filter = 'alpha(opacity=' + this.opacity + ')';
		} else {
			obj.style.MozOpacity = this.opacity / 100;
		}
		
		obj.innerHTML = this.text;
		obj.style.border = this.borderColor + ' ' + this.borderThickness + 'px ' + this.borderStyle;
		obj.style.padding = this.paddingTop + 'px ' + this.paddingRight + 'px ' + this.paddingBottom + 'px ' + this.paddingLeft + 'px';
		obj.style.backgroundColor = this.bgColor;
		obj.style.color = this.fontColor;
		obj.style.font = this.fontSize + 'px ' + this.fontFamily;
		obj.style.lineHeight = this.fontHeight + 'px';
		obj.style.display = 'block';
		obj.style.textAlign = this.textAlign;

		this.visible = true;
		this.reposition(objEvent);
	}
	
	Tooltip.prototype.create = function(containerID, text) {
		var container = document.getElementById(containerID);
		this.text = text.replace(" ", "&nbsp;");
		this.visible = false;
		
		container.onmouseover = this.show.bindAsEventListener(this);
		container.onmousemove = this.reposition.bindAsEventListener(this);
		container.onmouseout = this.hide.bindAsEventListener(this);
	}
	
	function quickTooltip(obj, text, properties) {
		if(!properties)
			properties = function() {}
		
		if(!obj.id)
			obj.id = '__tooltip_object_' + Math.random() * Date.parse(new Date());

		if(!TOOLTIP_ARRAY[obj.id]) {
			TOOLTIP_ARRAY[obj.id] = new Tooltip(obj.id, text, properties);
			obj.onmouseover();
		}
	}
	