	function $2(id) {
		if (!document.getElementById)
			return;

		if (document.all)
			return eval("document.all." + id);
		else
			return document.getElementById(id);
	}

	function gest_image(img) {
		if (img.width <= 500)
			return;
		img.realWidth = img.width;
		img.width = 500;
		img.style.cursor = "pointer";
		img.onmouseover = function() {
			if (img.imageChild)
				return;
			node = document.createElement("img");
			node.style.position = "absolute";
			node.style.cursor = "pointer";
			node.style.width = img.realWidth + "px";
			node.src = img.src;
			node.alt = img.alt;
			node.imageSource = img;
			img.imageChild = node;
			img.parentNode.insertBefore(node, img);
			node.onmouseout = function() {
				img.imageChild = null;
				node.parentNode.removeChild(node);
			};
		};
	}

	function toggle_msg(id) {
		$2("inf" + id).style.display = ($2("inf" + id).style.display == "none" ? "block" : "none");
		$2("txt" + id).style.display = ($2("txt" + id).style.display == "none" ? "block" : "none");
		$2("dat" + id).style.display = ($2("dat" + id).style.display == "none" ? "inline" : "none");
		$2("fct" + id).style.display = ($2("fct" + id).style.display == "none" ? "inline" : "none");
	}

	function txt_insert(balise_gauche, balise_droite, txt_defaut) {
		elt_texte = document.getElementById('texte');
		if (document.selection) {
			elt_texte.focus();
    	    var sel = document.selection.createRange();
			if (txt_defaut != '' && sel.text == '')
				selTexte = txt_defaut;
			else
				selTexte = sel.text;
			sel.text = balise_gauche + selTexte + balise_droite;
		} else if (elt_texte.selectionStart || elt_texte.selectionStart == 0) {
			texte = elt_texte.value;
			selStart = elt_texte.selectionStart;
			selEnd = elt_texte.selectionEnd;
			texteScrollTop = elt_texte.scrollTop;
			selTexte = texte.substring(selStart, selEnd);
			if (txt_defaut != '' && selTexte == '')
				selTexte = txt_defaut;
			elt_texte.value = texte.substring(0, selStart) + balise_gauche + 
				selTexte + balise_droite + 
				texte.substring(selEnd, texte.length);
			elt_texte.selectionStart = selStart;
			elt_texte.selectionEnd = selStart + balise_gauche.length + selTexte.length + balise_droite.length;
			elt_texte.focus();
			elt_texte.scrollTop = texteScrollTop;
		}
		if (elt_texte.onchange != null)
			elt_texte.onchange();
	}

	function query_replace(source_string, search_string, query_string) {
		var pos = source_string.indexOf(search_string);
		if (pos >= 0) {
			var replace_string = prompt(query_string, '');
			if (replace_string != null) {
				return source_string.substring(0, pos) + replace_string + 
				source_string.substring(pos + search_string.length, source_string.length);
			} else
				return null;
		} else
			return source_string;
	}

	function txt_query_insert(balise_gauche, balise_droite, query_string, txt_defaut) {
		balise_gauche = query_replace(balise_gauche, '#', query_string);
		balise_droite = query_replace(balise_droite, '#', query_string);
		if (balise_gauche != null && balise_droite != null)
			txt_insert(balise_gauche, balise_droite, txt_defaut);
		return false;
	}