var help = {
	helpText: {},
	active: null,

	prep: function () {
		this.helpElems = $('content').getElements('.help');

		this.helpElems.each(function(elem, i) {
			this.helpText[i] = elem.get('html');
			elem.empty();

			var helpLink = new Element('a', {
				html: '<img src="/static/images/icons/help.png" alt="Help" />'
			});
			helpLink.inject(elem);
			
			var clickItem = helpLink;
			
			
			
			clickItem.addEvent('click', this.showHelp.bind(this, [i, elem]));
			
		}, this);
	},

	showHelp: function (i, elem) {
		this.hideHelp();

		var pos = elem.getPosition();

		var div = new Element('div', {
			html: this.helpText[i],
			'class': 'help-float',
			'styles': {
				'top': pos.y,
				'left': pos.x+10
			}
		}).adopt(
			new Element('a', {
				href: '#',
				'text': 'close',
				'class': 'close',
				events: {
					click: this.hideHelp.bind(this)
				}
			})
		);

		div.inject($(document.body));

		this.active = div;

		return false;
	},

	hideHelp: function () {
		if ($defined(this.active))
			this.active.destroy();

		return false;
	}
};



window.addEvent('domready', function() {
	help.prep();


});