/**
 * =======================================================================================
 * 
 * Class: Infobulle
 *  v 0.1
 * ======================================================================================= 
 */ 
var Infobulle = Class.create();
Infobulle.prototype = {
	/**
	 * ====================================
	 * GROUP: Methodes publiques
	 * ====================================	 	 
	 *	 	
	 * Method: initialize
	 *
	 * Parameters:
 	 *  
	 */	 
	initialize: function() {
		if ($('__infobulle') == null) {
			this.bAffAGauche = 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'
			});
		}
	},
	/**
	 * Method: affiche
	 *
	 * Parameters:
	 * 	- sHtml, String le contenu (html ou non) de l'infobulle	 	 
	 */	 	 	
	affiche: function(sHtml, bAffAGauche) {
		this.bAffAGauche = bAffAGauche;
		Event.observe(document, 'mousemove', this._bouge.bindAsEventListener(this));
		$('__infobulle').update(sHtml);
		$('__infobulle').show();
	},
	/**
	 * Method: masque
	 *  Masque l'infobulle	 
	 */	
	masque: function() {
		Event.stopObserving(document, 'mousemove', this._bouge.bindAsEventListener(this));
		$('__infobulle').hide();
	},
	/**
	 * ====================================
	 * GROUP: Methodes privees
	 * ====================================	 	 
	 *	 	
	 * Method: _bouge
	 *
	 * Parameters:
 	 *  MouseEvent e
	 */
	_bouge: function(e) {
		$('__infobulle').style.top = Event.pointerY(e) -$('__infobulle').getHeight()/2 + "px";
		$('__infobulle').style.left = Event.pointerX(e) + ((this.bAffAGauche) ? -this.MARGE_CURSEUR-$('__infobulle').getWidth() : this.MARGE_CURSEUR) + "px";
	}
};
