/**
 * @version $Id: bulle_aide.js,v 1.3 2009-09-07 16:08:47 cch Exp $
 * @package umc
 * @copyright Copyright (C) 2008 BROCELIA. All rights reserved.
 */

id_bubulle = ''

/* ************************* BULLES D AIDE *********************** */

// affiche une bulle d'aide
function showBulleAide(e){
// title : idcontent_width_xxx_idspecial
	var id_content = this.title.split('_')[0];
	var width=this.title.split('_')[1];
	id_bubulle=this.title.split('_')[2];
	if (typeof(id_bubulle) == 'undefined') id_bubulle = "bulle_aide";

	if ($(id_content)){
		var pos = this.getCoordinates().right - width;
		var options = {
			'opacity' : 0,
			'position' : 'absolute',
			'float' : 'left',
			'left' : pos
		}
		var div = new Element('div',{'id':id_bubulle,'styles':options});
		var table = new Element('table',{'style':'width:'+width+'px'});
		table.cellPadding ='0';
		table.cellSpacing ='0';
		table.border ='0';

		var tbody = new Element('tbody').injectInside(table);
			var tr1 = new Element('tr').injectInside(tbody);
				new Element('td', {'class' : 'aide_tl'}).injectInside(tr1);
				new Element('td', {'class' : 'aide_t'}).injectInside(tr1);
				new Element('td', {'class' : 'aide_tr'}).injectInside(tr1);
			var tr2 = new Element('tr').injectInside(tbody);
				new Element('td', {'class' : 'aide_l'}).injectInside(tr2);
				var cont = new Element('td', {'class' : 'aide_c'}).injectInside(tr2);
					new Element('a',{'class' : 'aide_close'}).injectInside(cont);
					cont.innerHTML += $(id_content).innerHTML;
				new Element('td', {'class' : 'aide_r'}).injectInside(tr2);
			var tr3 = new Element('tr').injectInside(tbody);
				new Element('td', {'class' : 'aide_bl'}).injectInside(tr3);
				new Element('td', {'class' : 'aide_b'}).injectInside(tr3);
				new Element('td', {'class' : 'aide_br'}).injectInside(tr3);

		div.setStyle('top', this.getCoordinates().top + this.getCoordinates().height);
		table.injectInside(div);
		div.injectInside(document.body);
		$E('a.aide_close', div).addEvent('click', hideBulleAide);
		div.setStyle('opacity', 1);
	}
}

// cache une bulle d'aide
function hideBulleAide(e){
	$(id_bubulle).parentNode.removeChild($(id_bubulle));
}

/* ************************* FIN BULLES D AIDE *********************** */
