function bulle_aide() {
	this.image_triangle_gauche = 'images/bulle_aide_triangle_gauche.png';
	this.image_triangle_droite = 'images/bulle_aide_triangle_droite.png';
	this.position = 'droite';
	this.decalage_vertical = 0;
	this.decalage_horizontal = 0;
	
	this.id = '';
	this.id_local = '';
	this.obj = null;
	this.div_bulle_aide = null;
	this.div_bulle_aide_triangle = null;
	this.image_triangle = null;
	this.e = null;
	this.souris_x = -1;
	this.souris_y = -1;
		
	this.decalage_horizontal_triangle = 8;

	// Initialisation
	this.init = function() {
		var css;
		css = '<style type="text/css">';
		css += '	.bulle_aide {';
		css += '		border: solid #000000 1px;';
		css += '		background-color:#FFFFCC;';
		css += '		font-family:Arial, Helvetica, sans-serif;';
		css += '		padding: 2px;';
		css += '	}';
		css += '	.bulle_aide_triangle {';
		css += '	}';
		css += '</style>';
		document.write(css);
		
		this.id_local = this.random_id();
		eval(this.id_local + " = this;");
		
		this.image_triangle = new Image();
		this.image_triangle.src = this.image_triangle_gauche;
	}
/*
	// Afficher la bulle d'aide
	this.afficher = function(id, message) {
		alert(this.id_test);
		this.repositionner_bulle_aide();
	}


	// Repositionner la bulle d'aide (au depart, puis si la fenetre a ete redemensionnee)
	function repositionner_bulle_aide() {
		var tabPosition, obj;
		alert(this.id_test);

	}
*/
	// Afficher la bulle d'aide
	this.afficher = function(id, message, position, decalage_horizontal, decalage_vertical, e) {
		var afficher, obj_nouveau_div, str_contenu_div, obj_nouveau_divTriangle, image_triangle;
		this.id = id;
		this.position = position;
		this.decalage_horizontal = decalage_horizontal;
		this.decalage_vertical = decalage_vertical;
		this.e = e;

		// On cache par defaut (si il y avait une bulle affichee)
		this.cacher();
		
		switch(this.position) {
			case 'gauche':
				afficher = true;
				image_triangle = this.image_triangle_droite;
				break;
			case 'droite':
				afficher = true;
				image_triangle = this.image_triangle_gauche;
				break;
			case 'souris_droite':
				afficher = true;
				image_triangle = this.image_triangle_gauche;
				break;
			default:
				afficher = false;
		}


		if(afficher) {

			this.obj = document.getElementById(this.id);
			this.taille_police = 12;
			
			// Si on a trouve l'objet
			if(this.obj) {
			
				// Creer le div de la description
				obj_nouveau_div = document.createElement('div');
				obj_nouveau_div.setAttribute('id', "bulle_aide");
				obj_nouveau_div.setAttribute('name', "bulle_aide");
				obj_nouveau_div.className = "bulle_aide";
				obj_nouveau_div.style.position = "absolute";
				obj_nouveau_div.style.zIndex="10";	
				//obj_nouveau_div.style.display="none";	
				
				// Contenu du div
				str_contenu_div  = '<table border="0" cellspacing="0" cellpadding="0">';
				str_contenu_div += '    <tr>';
				str_contenu_div += '        <td valign="middle" style="font-size:' + this.taille_police + 'px;" nowrap="nowrap">';
				str_contenu_div += '			' + message;
				str_contenu_div += '        </td>';
				str_contenu_div += '    </tr>';
				str_contenu_div += '</table>';
				
				// Ajouter le contenu DIV
				obj_nouveau_div.innerHTML = str_contenu_div;
				
				// Ajouter le DIV au document				
				document.body.appendChild(obj_nouveau_div);	
				this.div_bulle_aide = obj_nouveau_div;
				
				// Creer le div du triangle (fleche)
				obj_nouveau_divTriangle = document.createElement('div');
				obj_nouveau_divTriangle.setAttribute('id', "bulle_aide_triangle");
				obj_nouveau_divTriangle.setAttribute('name', "bulle_aide_triangle");
				obj_nouveau_divTriangle.className = "bulle_aide_triangle";
				obj_nouveau_divTriangle.style.position = "absolute";
				obj_nouveau_divTriangle.style.zIndex="11";	
				//obj_nouveau_divTriangle.style.display="none";	
				
				// Contenu du div
				str_contenu_div  = '<table border="0" cellspacing="0" cellpadding="0">';
				str_contenu_div += '    <tr>';
				str_contenu_div += '        <td valign="middle" colspan="2" nowrap="nowrap">';
				str_contenu_div += '			<img src="' + image_triangle + '" border="0">';
				str_contenu_div += '        </td>';
				str_contenu_div += '    </tr>';
				str_contenu_div += '</table>';
	
				// Ajouter le contenu DIV
				obj_nouveau_divTriangle.innerHTML = str_contenu_div;
				
				// Ajouter le DIV au document				
				document.body.appendChild(obj_nouveau_divTriangle);		
				this.div_bulle_aide_triangle = obj_nouveau_divTriangle;
				
				// Repositionner la bulle d'aide (en dessous de l'objet)
				this.repositionner_bulle_aide();
				this.repositionner_bulle_aide(); // 2eme appels pour le bug du decalage sur les images
				eval('timeout_bulle_aide_' + this.id_local + " = setInterval(\"" + this.id_local + ".repositionner_bulle_aide()\", 200)");
				//eval('timeout_bulle_aide_' + this.id_local + " = setTimeout(\"" + this.id_local + ".repositionner_bulle_aide()\", 1000)");
				
				
			} else {
				//alert("pas trouvé");
			}
			
		}
	}


	// Repositionner la bulle d'aide (au depart, puis si la fenetre a ete redemensionnee)
	//function repositionner_bulle_aide() {
	this.repositionner_bulle_aide = function() {
		var tabPosition, obj;

		if(this.obj) {
			
			// Position actuelle de l'objet
			tabPosition = this.lire_dimensions(this.id);
			
			switch(this.position) {
				case 'gauche':
			
					// Repositionner le div de la bulle
					this.div_bulle_aide.style.top = (tabPosition["top"] + tabPosition["height"] + this.image_triangle.height + this.decalage_vertical) + "px";
					this.div_bulle_aide.style.left = (tabPosition["left"] - this.div_bulle_aide.offsetWidth + this.decalage_horizontal) + "px";	
					// Repositionner le div du triangle
					this.div_bulle_aide_triangle.style.top = ( parseInt(this.div_bulle_aide.style.top, 10) - 14) + "px";
					this.div_bulle_aide_triangle.style.left = ( parseInt(this.div_bulle_aide.style.left, 10) + parseInt(this.div_bulle_aide.offsetWidth, 10) - this.decalage_horizontal_triangle) + "px";	
					
					// Montrer les deux div
					this.div_bulle_aide.style.display = "";
					this.div_bulle_aide_triangle.style.display = "";
					
					break;
				
				case 'droite':
			
					// Repositionner le div de la bulle
					this.div_bulle_aide.style.top = (parseInt(tabPosition["top"], 10) + parseInt(tabPosition["height"], 10) + parseInt(this.image_triangle.height, 10) + parseInt(this.decalage_vertical, 10)) + "px";
					this.div_bulle_aide.style.left = (tabPosition["left"] + tabPosition["width"] + this.decalage_horizontal) + "px";	
					// Repositionner le div du triangle
					this.div_bulle_aide_triangle.style.top = ( parseInt(this.div_bulle_aide.style.top, 10) - 14) + "px";
					this.div_bulle_aide_triangle.style.left = ( parseInt(this.div_bulle_aide.style.left, 10) - this.decalage_horizontal_triangle) + "px";	
					
					// Montrer les deux div
					this.div_bulle_aide.style.display = "";
					this.div_bulle_aide_triangle.style.display = "";

					break;

				case 'souris_droite':
				
					if(this.souris_x == -1 || this.souris_x == -1) {
						pos_souris = this.souris_lire_position(this.e);
						this.souris_x = pos_souris.x;
						this.souris_y = pos_souris.y;
					}
					this.div_bulle_aide.style.top = (this.souris_y + this.image_triangle.height) + 'px';
					this.div_bulle_aide.style.left = (this.souris_x + this.decalage_horizontal_triangle)+ 'px';
					
					// Repositionner le div du triangle
					this.div_bulle_aide_triangle.style.top = ( parseInt(this.div_bulle_aide.style.top, 10) - 14) + "px";
					this.div_bulle_aide_triangle.style.left = ( parseInt(this.div_bulle_aide.style.left, 10) - this.decalage_horizontal_triangle) + "px";	
					
					// Montrer les deux div
					this.div_bulle_aide.style.display = "";
					this.div_bulle_aide_triangle.style.display = "";
					break;
				
				default:
					this.cacher();
			}
			
		}
	}


	// Cacher la bulle d'aide
	this.cacher = function () {
		
		if(this.div_bulle_aide) {
			this.souris_x = -1;
			this.souris_y = -1;

			// Cacher le message
			try {
				document.body.removeChild(this.div_bulle_aide);
				eval(" res = clearInterval(timeout_bulle_aide_" + this.id_local + ");");
			}
			catch(e) {
			}
			
			try {
				document.body.removeChild(this.div_bulle_aide_triangle);
			}
			catch(e) {
			}
				
		}
	}


	// Generer un id unique
	this.random_id = function () {
		var str_available_char = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
		var i;
		var str_id = "";
		var int_pos;
		for(i=1;i<=32;i++) {
			int_pos = Math.floor((16)*Math.random()) + 0;
			str_id += str_available_char[int_pos];
		}
		return("_" + str_id);
	}

	// Lire la position d'un objet ainsi que les dimensions de la fenetre et du document
	// Valeurs retournees :
	//		- tab["left"] : x position of the object
	//		- tab["top"] : y position of the object
	//		- tab["width"] : width of the object
	//		- tab["height"] : height of the object
	//		- tab["window_width"] : width of the window		
	//		- tab["window_height"] : height of the window		
	//		- tab["document_width"]	 : width of the document	
	//		- tab["document_height"] : height of the document		
	//		- tab["scroll_width"] : x scroll position
	//		- tab["scroll_height"] : y scroll position
	this.lire_dimensions = function (id) {
		var curleft = curtop = 0;
		var res=Array();
		
		var curleft = curtop = 0;
		var res=Array();
		
		var window_x;
		var window_y;
		var document_x;
		var document_y;
		var scroll_x;
		var scroll_y;
		
		if(id != "") {
			obj =document.getElementById(id);
	
			if(obj) {
				if (obj.offsetParent) {
					try {
						curleft_tmp = obj.offsetLeft;
					}
					catch(e) {
						curleft_tmp = 0;
					}
					curleft = curleft_tmp;
					try {
						curtop_tmp = obj.offsetTop;
					}
					catch(e) {
						curtop_tmp = 0;
					}
					curtop = curtop_tmp;
					valid = true;
					try {
						obj = obj.offsetParent;
					}
					catch(e) {
						valid = false;
					}
					
					while (valid) {
			
						try {
							curleft_tmp = obj.offsetLeft;
						}
						catch(e) {
							curleft_tmp = 0;
						}
						try {
							curtop_tmp = obj.offsetTop;
						}
						catch(e) {
							curtop_tmp = 0;
						}
			
			
						curleft += curleft_tmp;
						curtop += curtop_tmp;
						
						try {
							obj = obj.offsetParent;
						}
						catch(e) {
							valid = false;
						}
			
					}
				}
				
				try {
					var html_elemento = document.getElementById(id);
					curwidth = parseInt(html_elemento.offsetWidth,10);
				}
				catch(e) {
					curwidth = 0;
				}
				
				try {
					var html_elemento = document.getElementById(id);
					curheight = parseInt(html_elemento.offsetHeight,10);
				}
				catch(e) {
					curheight = 0;
				}
				
				try {
					
					if (navigator.appName == "Microsoft Internet Explorer"){
						window_x = document.body.clientWidth;
						window_y = document.body.clientHeight;
						document_x = document.body.clientWidth;
						document_y = document.body.clientHeight;
						if(window_x == 0) {
							window_x = document.documentElement.clientWidth;
							window_y = document.documentElement.clientHeight;
							document_x = document.body.clientWidth;
							document_y = document.body.clientHeight;		
						}
					} else {
						window_x = document.documentElement.clientWidth;
						window_y = document.documentElement.clientHeight;
						document_x = document.body.clientWidth;
						document_y = document.body.clientHeight;		
					}
					
					//alert("window_x=" + this.window_x);
				}
				catch(err) {
					window_x = 0;
					window_y = 0;
					document_x = 0;
					document_y = 0;
				}
			} else {
				window_x = 0;
				window_y = 0;
				document_x = 0;
				document_y = 0;
			}
		} else {
			window_x = 0;
			window_y = 0;
			document_x = 0;
			document_y = 0;
		}
		
		// Get maximum x dimension
		if(window_x>document_x) {
			res["window_width"]=document_x;
			res["document_width"]=window_x;
		} else {
			res["window_width"]=window_x;
			res["document_width"]=document_x;
		}
	
		// Get maximum y dimension
		if(window_y>document_y) {
			res["window_height"]=document_y;
			res["document_height"]=window_y;
		} else {
			res["window_height"]=window_y;
			res["document_height"]=document_y;
		}		
		
		// Calcul de la hauteur de la fenetre (multi-navigateur)
		var windowHeight
		if (self.innerHeight) {// all except Explorer
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowHeight = document.body.clientHeight;
		}
		res["window_height"]=windowHeight;
		
		// Calcul de la largeur de la fenetre (multi-navigateur)
		var windowWidth
		if (self.innerWidth) {// all except Explorer
			windowWidth = self.innerWidth;
		} else if (document.documentElement && document.documentElement.clientWidth) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
		}
		res["window_width"]=windowWidth;
		
		// Recuperer la position des ascenseurs
		if (navigator.appName == "Microsoft Internet Explorer"){
			scroll_x = document.documentElement.scrollLeft;
			if(scroll_x == 0) {
				scroll_x = document.body.scrollLeft;
			}
			scroll_y = document.documentElement.scrollTop;
			if(scroll_y == 0) {
				scroll_y = document.body.scrollTop;
			}
		} else { 
			scroll_x = window.pageXOffset; 
			scroll_y = window.pageYOffset; 
		}
		
		// Envoyer les donnees
		res["left"]=curleft;
		res["top"]=curtop;
		res["width"]= parseInt(curwidth,10);
		res["height"]= parseInt(curheight,10);
		res["scroll_width"] = scroll_x;
		res["scroll_height"] = scroll_y;
		
		return res;
	}	


	// Lire la position de la souris
	// Valeurs retournees :
	//		- obj.x : position x de la souris
	//		- obj.y : position y de la souris
	this.souris_lire_position = function (e) {
		
		var int_pos_x = 0;
		var int_pos_y = 0;
		
		if(document.all)
		{
			if (event.pageX || event.pageY) 	{
				int_pos_x = event.pageX;
				int_pos_y = event.pageY;
			}
			else if (event.clientX || event.clientY) 	{
				int_pos_x = event.clientX + document.body.scrollLeft
					+ document.documentElement.scrollLeft;
				int_pos_y = event.clientY + document.body.scrollTop
					+ document.documentElement.scrollTop;
			}
		}
		else 
		{
			if (e.pageX || e.pageY) 	{
				int_pos_x = e.pageX;
				int_pos_y = e.pageY;
			}
			else if (e.clientX || e.clientY) 	{
				int_pos_x = e.clientX + document.body.scrollLeft
					+ document.documentElement.scrollLeft;
				int_pos_y = e.clientY + document.body.scrollTop
					+ document.documentElement.scrollTop;
			}
		}	
		return({ x : int_pos_x, y : int_pos_y});

	
	}				



}