var Akstips = {
	_Move: function(e) {
		var tip = $('akstips_label');
		tip.style.left = Event.pointerX(e) + 'px';
		tip.style.top = Event.pointerY(e) - tip.getHeight() - 5 + 'px';
	},
		
	_Show: function(text, effect, suffixe) {
		switch(suffixe)
		{
		case '_form' : var tip = '<img src="/js/ajaks/akstips_pointer_top.gif" alt="" class="akstips_pointer_top" />'; break;
		default : var tip = ''; suffixe = '_info';
		}
		tip += '<div class="akstips_titre' + suffixe + '">Information<a href="javascript:;" onclick="Akstips._Hide();" title="Fermer" class="akstips_fermer">x</a></div><div class="akstips_content">' + text + '</div>';
		$('akstips_label').update(tip); // on copie notre texte dans l'élément html
		if(effect == undefined) $('akstips_label').show(); // Si il est cacher (la verif n'est qu'une securité) on le rend visible.
		else new Effect.Appear('akstips_label', {duration: 0.5, to: 1});
	},
		
	_Hide: function(effect) {
		if(effect == undefined) $('akstips_label').hide(); // Si la bulle est visible on la cache
		else new Effect.Fade('akstips_label');
	},
		
	_Form: function(el, text) {
		var elXY = el.cumulativeOffset();
		var elW	  = el.getWidth();
		var elH	  = el.getHeight();
		/*$('akstips_label').style.top = elXY.top + 'px';
		$('akstips_label').style.left = elXY.left + elW + 10 + 'px';*/
		$('akstips_label').style.top = elXY.top + elH + 1 + 'px';
		$('akstips_label').style.left = elXY.left + 'px';
		Akstips._Show(text, 'appear', '_form');
		new Event.observe(el, 'keypress', function(){ Akstips._Hide('fade'); });
	},
	
	_Load: function() {
		$$('[akstips]').each(function(el) {
			new Event.observe(el, 'mousemove', Akstips._Move);
			new Event.observe(el, 'mouseover', function(){ Akstips._Show($(el.getAttribute('akstips')).innerHTML); });
			new Event.observe(el, 'mouseout', function(){ Akstips._Hide(); });				  
		});	
	},
	
	load: function() {
		new Event.observe(window, 'load', function() {
			Akstips._Load();	
		});
	}
}

Akstips.load();