/**
 * =======================================================================================
 * 
 * Class: Infobulle
 *  v 0.1
 * ======================================================================================= 
 */ 
var Infobulle = Class.create();
Infobulle.prototype = {
	/**
	 * ====================================
	 * GROUP: Methodes publiques
	 * ====================================	 	 
	 *	 	
	 * Method: initialize
	 *
	 * Parameters:
 	 *  
	 */	 
	initialize: function() {
		if ($('body') == null) {
			alert('!! Erreur fatale : body DOIT avoir l\'id body (<body id="body">) !!');
			return;
		}
		if ($('__infobulle') == null) {
			this.bVisible = false;
			this.MARGE_CURSEUR = 10;
			new Insertion.Top('body', "<div id='__infobulle' style='display: none;'></div>");
			// comme les css AS2, voir http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-ElementCSSInlineStyle
			$('__infobulle').setStyle({
				zIndex: 10000,
				position: 'absolute',
				backgroundColor: '#fff',
				margin: 0,
				padding: '5px',
				top: 0,
				left: 0,
				font: '11px Verdana, Arial, Geneva',
				border: '1px solid #ccc'
			});
			Event.observe(document, 'mousemove', this._bouge.bindAsEventListener(this));
		}		
	},
	/**
	 * Method: affiche
	 *
	 * Parameters:
	 * 	- sHtml, String le contenu (html ou non) de l'infobulle	 	 
	 */	 	 	
	affiche: function(sHtml) {
		$('__infobulle').update(sHtml);
		$('__infobulle').show();
		this.bVisible = true;
	},
	/**
	 * Method: masque
	 *  Masque l'infobulle	 
	 */	
	masque: function() {
		$('__infobulle').hide();
		this.bVisible = false;
	},
	/**
	 * ====================================
	 * GROUP: Methodes privees
	 * ====================================	 	 
	 *	 	
	 * Method: _bouge
	 *
	 * Parameters:
 	 *  MouseEvent e
	 */
	_bouge: function(e) {
		if (this.bVisible) {
			$('__infobulle').style.left = Event.pointerX(e) + this.MARGE_CURSEUR + "px";
			$('__infobulle').style.top = Event.pointerY(e) + this.MARGE_CURSEUR + "px";
		}
	}
};
