// FancyTips, an (not quite) extension of mootools Tips
// Enables more formatting of the tip contents than what xhtml validation
// with Tips allows.
//
// Example HTML:
//
// <a href="link.html" class="tooltips">
//		Link text
//		<span class="tipcontents">
//			<img src="images/an_image.jpg" alt="An image" />
//			<strong>More formatting is allowed here</strong>
//		</span>
//	</a>
//
// Javascript:
//	
//	var my_tips = new FancyTips($$('.tooltips'));
//
var FancyTips = new Class({

	Implements: [Options],

	options : {
		tipcontents: '.tipcontents'
	},

	initialize: function (elements, options) {

		this.setOptions(options);

		// Set up the fancy tips by inserting the tip contents element
		// into the title attribute of the element that is to have the tooltip
		elements.each(function (element) {
			contents_element = element.getElement(this.options.tipcontents);
			if (contents_element) {
				element.set('title', contents_element.get('html'));
			}
		}, this);

		this.tips = new Tips(elements, options);
	}
});

window.addEvent('domready', function() {
		var mytips = new FancyTips($$('.tips'));
});

