// include required libraries
var libraries = [
	'/js/prototip.js'
];
IncludeLibraries(libraries);

// add tool tips when ready
Event.observe(window, 'load', function() {
	AddToolTips();
});
function AddToolTips() {
	$$('a').each(function(e) {
		if (e.rel.startsWith('tooltip|')) {
			// set input and type
			input   = e.rel.split('|');
			type    = input[1];
			content = input[2];
			
			// which type?
			if (type == 'glossary') {
				AddGlossaryToolTip(e, content);
				e.addClassName('tooltip-link');
			} else if (type == 'general') {
				AddGeneralToolTip(e, content);
				e.addClassName('tooltip-link');
			}
		}
	});
}
function AddGeneralToolTip(e, content) {
	new Tip(e, content, {effect:'appear', hook:{target:'topLeft', tip:'bottomLeft'}, offset:{x:10, y:-5}});
}
function AddGlossaryToolTip(e, id) {
	var url  = '/ajax/get_glossary_term';
	var pars = {id:id};
	new Ajax.Request(url, {
		method:'post',
		parameters:pars,
		onSuccess:function(transport) {
			var data = transport.responseText.evalJSON();
			new Tip(e, data.definition, {title:data.term, effect:'appear', hook:{target:'topLeft', tip:'bottomLeft'}, offset:{x:10, y:-5}});
		}
	});
}
