

/* *************************************
Ce fichier JS contient les methodes necessaires a l'affichage de messages d'alerte (alert, prompt, confirm)
************************************* */

function msg_alert(e, input_question, input_function, deactivate_fog, button_validate, double_close_button, color_popup_bg)
{
	/* *************************************
	NAME :
		msg_alert
	INPUT :
		e										=> event
		input_question			=> texte qui sera affiche
		input_function			=> fonction qui sera lancee apres validation de la fenetre
		deactivate_fog			=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
		button_validate			=> true (defaut) si l'unique bouton affiche est libelle "valider" et false sinon ("fermer")
		double_close_button	=> false (defaut) si on affiche 1 bouton "fermer" et true si on en affiche 2 (en haut et en bas)
		color_popup_bg			=> éventuelle couleur de fond à afficher dans la popup
	OUTPUT :
		- (affiche une fenetre de type 'alert' et appelle la fonction specifiee)
	************************************* */
	if (String(button_validate) == "undefined")																	button_validate			= true;
	if (String(double_close_button) == "undefined")															double_close_button	= false;
	if (String(color_popup_bg) == "undefined" && String(color_popup_bg) == "")	color_popup_bg			= "transparent";

	/* objet principal */
	var rnd											= String(Math.random());
	var div_prompt_alert				= document.createElement("div");
	div_prompt_alert.setAttribute("id", "div_prompt_alert" + rnd);
	div_prompt_alert.className	= "css_msg";

	/* contenu personnalise */
	var tmp_string = "";
	tmp_string += "<table cellspacing='0'>";
	tmp_string += "<tr style='background-color:" + color_popup_bg + "'>";
	tmp_string += "<td class='css_form_label_input'>";
	if (double_close_button)
	{
		if (button_validate)
			tmp_string += "<input type='button' id='input_prompt_alert_ok_top" + rnd + "' class='css_form_button' value=\"" + language_msg("00001") + "\" onclick=\"document.getElementById('input_prompt_alert_ok" + rnd + "').click();\"/>";
		else
			tmp_string += "<input type='button' id='input_prompt_alert_ok_top" + rnd + "' class='css_form_button' value=\"" + language_msg("00021") + "\" onclick=\"document.getElementById('input_prompt_alert_ok" + rnd + "').click();\"/>";
	}
	tmp_string += "</td>";
	tmp_string += "</tr>";
	tmp_string += "<tr style='background-color:" + color_popup_bg + "'>";
	tmp_string += "<td class='css_form_label_left'>" + input_question + "</td>"; /* on prend la classe 'css_form_label_input' pour le formateur 'formateur_see_more_text' et eviter que le texte s'affiche a droite */
	tmp_string += "</tr>";
	tmp_string += "<tr style='background-color:" + color_popup_bg + "'>";
	tmp_string += "<td class='css_form_label_input'>";
	if (button_validate)
		tmp_string += "<input type='button' id='input_prompt_alert_ok" + rnd + "' class='css_form_button' value=\"" + language_msg("00001") + "\"/>";
	else
		tmp_string += "<input type='button' id='input_prompt_alert_ok" + rnd + "' class='css_form_button' value=\"" + language_msg("00021") + "\"/>";
	tmp_string += "</td>";
	tmp_string += "</tr>";
	tmp_string += "</table>";
	div_prompt_alert.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_alert);

	/* boutons */
	document.getElementById("input_prompt_alert_ok" + rnd).onclick	= function(){
		document.body.removeChild(document.getElementById("div_prompt_alert" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "()");
	};

	/* gestion de la touche "escape" */
	key_manage_escape = function(e){
		document.getElementById("input_prompt_alert_ok" + rnd).click();
	};

	/* affichage */
	msg_display(e, div_prompt_alert, 3, rnd, false);

	if (double_close_button)
		document.getElementById("input_prompt_alert_ok_top" + rnd).focus();
	else
		document.getElementById("input_prompt_alert_ok" + rnd).focus();
}

function msg_view_catalog_row(e, input_catalog, input_row, input_row_prev, input_row_next, color_popup_bg, color_popup_font, input_function, deactivate_fog)
{
	/* *************************************
	NAME :
		msg_view_catalog_row
	INPUT :
		e									=> event
		input_catalog			=> id du catalogue
		input_row					=> numero de la ligne a consulter
		input_row_prev		=> id de la cellule de la ligne precedente a consulter
		input_row_next		=> id de la cellule de la ligne suivante a consulter
		color_popup_bg		=> cf. propriété du même nom dans le formateur "formateur_catalog_table"
		color_popup_font	=> cf. propriété du même nom dans le formateur "formateur_catalog_table"
		input_function		=> fonction qui sera lancee apres validation de la fenetre
		deactivate_fog		=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
	OUTPUT :
		- (affiche une fenetre de visualisation d'une url passee en parametre)
	************************************* */
	/* objet principal */
	var rnd									= String(Math.random());
	var div_prompt_view_catalog_row	= document.createElement("div");
	div_prompt_view_catalog_row.setAttribute("id", "div_prompt_view_catalog_row" + rnd);
	div_prompt_view_catalog_row.className		= "css_msg";

	/* contenu personnalise */
	var tmp_string	= "";
	tmp_string			+= "<table cellspacing='0'>";
		tmp_string		+= "<tr>";
		tmp_string		+= "<td class='css_form_label_input' style='text-align:right;'>";
	if (input_row_prev != "" || input_row_next != "")
	{
		if (input_row_prev != "")
			tmp_string	+= "<input type='button' id='input_prompt_previous_row" + rnd + "' class='css_form_button' value=\"< " + language_msg("00624") + "\"/>";
		if (input_row_next != "")
			tmp_string	+= "<input type='button' id='input_prompt_next_row" + rnd + "' class='css_form_button' value=\"" + language_msg("00625") + " >\"/>";
	}
	tmp_string			+= "<input type='button' id='input_prompt_print" + rnd + "' class='css_form_button' value=\"" + language_msg("00810") + "\"/>";
		tmp_string		+= "</td>";
		tmp_string		+= "</tr>";
	tmp_string			+= "<tr><td class='css_form_label_left'>";
	tmp_string			+= "<iframe id='iframe_prompt_catalog" + rnd + "' src='" + include_path + "/php/catalog-detail.php?catalog_id=" + input_catalog + "&catalog_row=" + input_row + "&color_popup_bg=" + color_popup_bg + "&color_popup_font=" + color_popup_font + "' class='css_catalog' frameborder='0'></iframe>";
	tmp_string			+= "</td></tr>";
	tmp_string			+= "<tr>";
	tmp_string			+= "<td class='css_form_label_input'>";
	tmp_string			+= "<input type='button' id='input_prompt_catalog_ok" + rnd + "' class='css_form_button' value=\"" + language_msg("00021") + "\"/>";
	tmp_string			+= "</td>";
	tmp_string			+= "</tr>";
	tmp_string			+= "</table>";
	div_prompt_view_catalog_row.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_view_catalog_row);

	/* boutons */
	if (input_row_prev != "")
	{
		document.getElementById("input_prompt_previous_row" + rnd).onclick	= function(){
				var oinput_row_prev = document.getElementById(input_row_prev);
				if(oinput_row_prev) oinput_row_prev.click();
				document.getElementById("input_prompt_catalog_ok" + rnd).click();
		};
	}

	if (input_row_next != "")
	{
		document.getElementById("input_prompt_next_row" + rnd).onclick	= function(){
				var oinput_row_next = document.getElementById(input_row_next);
				if(oinput_row_next) oinput_row_next.click();
				document.getElementById("input_prompt_catalog_ok" + rnd).click();
		};
	}

	/* imprimer */
	document.getElementById("input_prompt_print" + rnd).onclick	= function(){
			/* recuperation de la fenetre de l'iframe */
				var oCurrentFrame= document.getElementById("iframe_prompt_catalog" + rnd).contentWindow;
				if (oCurrentFrame)
				{
					oCurrentFrame.print();
					return false;
				}
	};

	document.getElementById("input_prompt_catalog_ok" + rnd).onclick	= function(){
			document.body.removeChild(document.getElementById("div_prompt_view_catalog_row" + rnd));
			msg_border_remove(rnd);
			if (deactivate_fog)				fog_manage(false);
			if (input_function != "") eval(input_function + "(true)");
	};

	/* gestion de la touche "escape" */
	key_manage_escape = function(e){
		document.getElementById("input_prompt_catalog_ok" + rnd).click();
	};

	/* affichage */
	msg_display(e, div_prompt_view_catalog_row, 3, rnd, false);
}

function msg_catalog(e, input_field, input_function, deactivate_fog)
{
	/* *************************************
	NAME :
		msg_catalog
	INPUT :
		e								=> event
		input_field			=> champ qui sera mis a jour apres validation de la fenetre
		input_function	=> fonction qui sera lancee apres validation de la fenetre
		deactivate_fog	=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
	OUTPUT :
		- (affiche une fenetre de choix d'un filtre de catalogue)
	************************************* */

	/* recuperation de la requete existante */
	var sRequest = escape(document.getElementById(input_field).value);

	/* objet principal */
	var rnd												= String(Math.random());
	var div_prompt_catalog				= document.createElement("div");
	div_prompt_catalog.setAttribute("id", "div_prompt_catalog" + rnd);
	div_prompt_catalog.className	= "css_msg";

	/* contenu personnalise */
	var tmp_string	= "";
	tmp_string			+= "<iframe id='iframe_prompt_catalog" + rnd + "' src='" + include_path + "/php/catalog-param.php?grid_request=1&grid_request_value=" + sRequest + "' class='css_catalog' frameborder='0'></iframe>";
	tmp_string			+= "<table cellspacing='0'>";
	tmp_string			+= "<tr>";
	tmp_string			+= "<td class='css_form_label_input' style='text-align:right;'>";
	tmp_string			+= "<input type='button' id='input_prompt_catalog_ok" + rnd + "' class='css_form_button' value=\"" + language_msg("00001") + "\"/>";
	tmp_string			+= "<input type='button' id='input_prompt_catalog_cancel" + rnd + "' class='css_form_button' value=\"" + language_msg("00002") + "\"/>";
	tmp_string			+= "</td>";
	tmp_string			+= "</tr>";
	tmp_string			+= "</table>";
	div_prompt_catalog.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_catalog);

	/* boutons */
	document.getElementById("input_prompt_catalog_ok" + rnd).onclick	= function(){
		if (input_field != "")
		{
			/* si aucun catalogue n'a été sélectionné on valide qu'aucun filtre n'a été choisi => pas d'erreur */
			if (document.getElementById("iframe_prompt_catalog" + rnd).contentWindow.document.getElementById("catalog_id").value == "")
			{
				tmp_string = "";
			}
			else
			{
				/* recuperation de la selection */
				var oMyGridRequest	= document.getElementById("iframe_prompt_catalog" + rnd).contentWindow.oMyGrid;
				tmp_string					= "";
				if (document.getElementById("iframe_prompt_catalog" + rnd).contentWindow.fnIsInputSelected(document.getElementById("iframe_prompt_catalog" + rnd).contentWindow.document.getElementsByName("col_selected"))=="")
				{
					msg_border_remove(rnd);
					document.getElementById("iframe_prompt_catalog" + rnd).contentWindow.fog_manage(true);
					document.getElementById("iframe_prompt_catalog" + rnd).contentWindow.setTimeout('msg_alert("", language_msg("00401"), "", true);', 100);
					return false;
				}

				if(oMyGridRequest) tmp_string														= oMyGridRequest._fnSaveRequest();
			}

			document.getElementById(input_field).value								= tmp_string;
			/* mise a jour de la previsualisation */
			if (document.getElementById("div_" + input_field))
			{
				tmp_string																							= "";
				var catalog_change_id																		= document.getElementById("iframe_prompt_catalog" + rnd).contentWindow.document.getElementById("catalog_change_id");
				for (var k=0 ; k<catalog_change_id.options.length ; k++)
					if (catalog_change_id.options[k].selected)
						tmp_string																					= catalog_change_id.options[k].text;
				document.getElementById("div_" + input_field).innerHTML	= tmp_string;
			}

			document.body.removeChild(document.getElementById("div_prompt_catalog" + rnd));
			msg_border_remove(rnd);
			if (deactivate_fog)				fog_manage(false);
			if (input_function != "")	eval(input_function + "(true)");
		}
		else
		{
			document.body.removeChild(document.getElementById("div_prompt_catalog" + rnd));
			msg_border_remove(rnd);
			if (deactivate_fog)				fog_manage(false);
			if (input_function != "") eval(input_function + "(true)");
		}
	};

	document.getElementById("input_prompt_catalog_cancel" + rnd).onclick	= function(){
		document.body.removeChild(document.getElementById("div_prompt_catalog" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(false)");
	};

	/* gestion de la touche "escape" */
	key_manage_escape = function(e){
		document.getElementById("input_prompt_catalog_cancel" + rnd).click();
	};

	/* affichage */
	msg_display(e, div_prompt_catalog, 4, rnd, false);
}

function msg_catalog_list(e, input_field, input_function, deactivate_fog)
{
	/* *************************************
	NAME :
		msg_catalog_list
	INPUT :
		e								=> event
		input_field			=> champ qui sera mis a jour apres validation de la fenetre
		input_function	=> fonction qui sera lancee apres validation de la fenetre
		deactivate_fog	=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
	OUTPUT :
		- (affiche une fenetre de choix d'un catalogue du site  parmi ceux disponibles et met a jour le champ specifie)
	************************************* */

	/* objet principal */
	var rnd									= String(Math.random());
	var div_prompt_catalog	= document.createElement("div");
	div_prompt_catalog.setAttribute("id", "div_prompt_catalog" + rnd);
	div_prompt_catalog.className			= "css_msg";

	/* contenu personnalise */
	var tmp_string	= "";
	tmp_string			+= "<table cellspacing='0'>";
	tmp_string			+= "<tr><td class='css_form_label_left'>";
	tmp_string			+= "<iframe id='iframe_prompt_catalog" + rnd + "' src='" + include_path + "/php/catalog-list.php' class='css_page_list' frameborder='0'></iframe>";
	tmp_string			+= "</td></tr>";
	tmp_string			+= "<tr>";
	tmp_string			+= "<td class='css_form_label_input'>";
	tmp_string			+= "<input type='button' id='input_prompt_catalog_ok" + rnd + "' class='css_form_button' value=\"" + language_msg("00001") + "\"/>";
	tmp_string			+= "<input type='button' id='input_prompt_catalog_cancel" + rnd + "' class='css_form_button' value=\"" + language_msg("00002") + "\"/>";
	tmp_string			+= "</td>";
	tmp_string			+= "</tr>";
	tmp_string			+= "</table>";
	div_prompt_catalog.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_catalog);

	/* boutons */
	document.getElementById("input_prompt_catalog_ok" + rnd).onclick	= function(){
		tmp_catalog = "";
		if (input_field != "")
		{
			var iframe						= document.getElementById("iframe_prompt_catalog" + rnd);
			var iframe_assistant	= iframe.contentWindow.document;
			var tmp_string				= "";
			var ml								= iframe_assistant.getElementsByName("input_catalog_list");
			for(var i=0; i<ml.length; ++i)
			{
				if(ml[i].checked)
				{
						tmp_catalog = ml[i].value;
				}
			}
			document.getElementById(input_field).value = tmp_catalog;
		}
		document.body.removeChild(document.getElementById("div_prompt_catalog" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(true)");
	};

	document.getElementById("input_prompt_catalog_cancel" + rnd).onclick	= function(){
		document.body.removeChild(document.getElementById("div_prompt_catalog" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(false)");
	};

	/* gestion de la touche "escape" */
	key_manage_escape = function(e){
		document.getElementById("input_prompt_catalog_cancel" + rnd).click();
	};

	/* affichage */
	msg_display(e, div_prompt_catalog, 3, rnd, false);
}

function msg_color(e, input_field, input_default, input_function, deactivate_fog)
{
	/* *************************************
	NAME :
		msg_color
	INPUT :
		e								=> event
		input_field			=> champ qui sera mis a jour apres validation de la fenetre
		input_default		=> couleur par defaut
		input_function	=> fonction qui sera lancee apres validation de la fenetre
		deactivate_fog	=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
	OUTPUT :
		- (affiche une fenetre de choix d'une couleur et met a jour le champ specifie)
	************************************* */

	/* objet principal */
	var rnd								= String(Math.random());
	var div_prompt_color	= document.createElement("div");
	div_prompt_color.setAttribute("id", "div_prompt_color" + rnd);
	div_prompt_color.className		= "css_msg";

	/* contenu personnalise */
	var tmp_string	= "";
	tmp_string			+= "<table cellspacing='0'>";
	tmp_string			+= "	<tr>";
	tmp_string			+= "		<td class='css_form_label_input' style='width:300px;'>";
	tmp_string			+= "			<div id='div_prompt_color_palette" + rnd + "' style='width:300px;'></div>";
	tmp_string			+= "		</td>";
	tmp_string			+= "		<td class='css_form_label_input' style='width:250px;'>";
	if (window.location.href.indexOf("page-param.php") != -1)
		tmp_string 		+= language_msg("00658");
	tmp_string			+= "			<div id='div_prompt_color_history" + rnd + "' class='css_color_history'></div>";
	tmp_string			+= "			<div id='div_prompt_color_preview" + rnd + "' style='background-color:" + input_default + ";'>";
	tmp_string			+= "				<input type='text' id='input_prompt_color_selected" + rnd + "' class='css_form_param_short' value='" + input_default + "' onkeyup=\"msg_color_select_color(this.value, 'input_prompt_color_selected" + rnd + "', 'div_prompt_color_preview" + rnd + "');\">";
	tmp_string			+= "			</div>";
	tmp_string			+= "		</td>";
	tmp_string			+= "	</tr>";
	tmp_string			+= "<tr>";
	tmp_string			+= "	<td class='css_form_label_input' colspan='2'>";
	tmp_string			+= "		<input type='button' id='input_prompt_color_ok" + rnd + "' class='css_form_button' value=\"" + language_msg("00001") + "\"/>";
	tmp_string			+= "		<input type='button' id='input_prompt_color_cancel" + rnd + "' class='css_form_button' value=\"" + language_msg("00002") + "\"/>";
	tmp_string			+= "	</td>";
	tmp_string			+= "</tr>";
	tmp_string			+= "</table>";
	div_prompt_color.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_color);

	/* affichage de la palette */
	msg_color_draw_colors(rnd);

	/* boutons */
	document.getElementById("input_prompt_color_ok" + rnd).onclick	= function(){
		/* recuperation de la valeur */
		var tmp_string = document.getElementById("input_prompt_color_selected" + rnd).value;
		/* affectation de la valeur dans le champ */
		if (input_field != "")
		{
			document.getElementById(input_field).value = tmp_string;
			/* lancement de l'evenement "onchange" sur le champ appelant */
			if (document.getElementById(input_field).onchange)
				document.getElementById(input_field).onchange();
		}

		document.body.removeChild(document.getElementById("div_prompt_color" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "('" + tmp_string + "')");
	};

	document.getElementById("input_prompt_color_cancel" + rnd).onclick	= function(){
		document.body.removeChild(document.getElementById("div_prompt_color" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(false)");
	};

	/* gestion de la touche "escape" */
	key_manage_escape = function(e){
		document.getElementById("input_prompt_color_cancel" + rnd).click();
	};

	/* affichage */
	msg_display(e, div_prompt_color, 3, rnd, false);
}

function msg_color_draw_colors(rnd)
{
	/* *************************************
	NAME :
		msg_color_draw_colors
	INPUT :
		rnd	=> nombre aleatoire fourni pour l'appelant permettant d'identifier les boutons et la structure de maniere unique
	OUTPUT :
		- (utilise dans le processus msg_color => affiche les couleurs disponibles)
	************************************* */
	var step_luminance	= 0.04;
	var step_hue				= 10;

	var i_hue, i_luminance, i_saturation;

	result = "<table border='0' cellspacing='0' style='cursor:pointer'>";
	for (i_luminance=0 ; i_luminance<=(1+step_luminance) ; i_luminance+=step_luminance)
	{
		result += "<tr>";
		for (i_hue=0 ; i_hue<=360 ; i_hue+=step_hue)
		{
			msg_color_hsltorgb(i_hue, 1, i_luminance);
			r = Math.floor(r * 255).toString(16);
			g = Math.floor(g * 255).toString(16);
			b = Math.floor(b * 255).toString(16);
			if (r.length < 2)
				r = "0" + r;
			if (g.length < 2)
				g = "0" + g;
			if (b.length < 2)
				b = "0" + b;
			c = r+g+b;
			result += "<td style='height:8px;width:8px;background-color:#" + c + ";' onclick=\"msg_color_select_color('#" + c +"', 'input_prompt_color_selected" + rnd + "', 'div_prompt_color_preview" + rnd + "');\"></td>";
		}
		result += "</tr>";
	}
	result += "</table>";
	document.getElementById("div_prompt_color_palette" + rnd).innerHTML = result;

	/* récupération des couleurs déjà utilisées dans la page dans les différents objets et dans la page */
	if (window.location.href.indexOf("page-param.php") != -1)
	{
		var T_colors = new Array();
		var div_objects_location = document.getElementById("div_objects_location");
		if (String(objects_get_all) != "undefined" && div_objects_location != null)
		{
			var tmp_array = objects_get_all(div_objects_location, "div", true);
			for (var i=0 ; i<tmp_array.length ; i++)
			{
				tmp_object = tmp_array[i];
				if (tmp_object.getAttribute("id").substr(0, 10) == "dragndrop_" || tmp_object.getAttribute("id").substr(0, 9) == "readonly_")
				{
					/* recherche des styles proposant une couleur */
					if (tmp_object.style.backgroundColor != "" && tmp_object.style.backgroundColor != "transparent")			T_colors[T_colors.length] = rgb_to_hex(tmp_object.style.backgroundColor);
					if (tmp_object.style.borderBottomColor != "" && tmp_object.style.borderBottomColor != "transparent")	T_colors[T_colors.length] = rgb_to_hex(tmp_object.style.borderBottomColor);
					if (tmp_object.style.borderLeftColor != "" && tmp_object.style.borderLeftColor != "transparent")			T_colors[T_colors.length] = rgb_to_hex(tmp_object.style.borderLeftColor);
					if (tmp_object.style.borderRightColor != "" && tmp_object.style.borderRightColor != "transparent")		T_colors[T_colors.length] = rgb_to_hex(tmp_object.style.borderRightColor);
					if (tmp_object.style.borderTopColor != "" && tmp_object.style.borderTopColor != "transparent")				T_colors[T_colors.length] = rgb_to_hex(tmp_object.style.borderTopColor);
					if (tmp_object.style.color != "" && tmp_object.style.color != "transparent")													T_colors[T_colors.length] = rgb_to_hex(tmp_object.style.color);
				}
			}
			if (document.body.style.backgroundColor != "")	T_colors[T_colors.length] = rgb_to_hex(document.body.style.backgroundColor);
			/* extraction des valeurs uniques */
			T_colors.sort();

			for (var i=0 ; i<T_colors.length ; i++)
			{
				for (var j=i+1 ; j<T_colors.length ; j++)
				{
					if (T_colors[i] == T_colors[j])
					{
						T_colors[i] = "";
					}
				}
			}
			T_colors = trim_array(T_colors);
			/* affichage */
			var tmp_string = "";
			for (var i=0 ; i<T_colors.length ; i++)
			{
				tmp_string	+= "<div class='css_color_history_small'";
				tmp_string	+= " style='background:" + T_colors[i] + ";'";
				tmp_string	+= " title='" + T_colors[i] + "'";
				tmp_string	+= " onclick=\"msg_color_select_color(rgb_to_hex(this.style.backgroundColor), 'input_prompt_color_selected" + rnd + "', 'div_prompt_color_preview" + rnd + "');\">";
				tmp_string	+= "</div>";
			}
		}
		document.getElementById("div_prompt_color_history" + rnd).innerHTML = tmp_string;
	}
}

function msg_color_hsltorgb(h,s,l)
{
	/* *************************************
	NAME :
		msg_color_hsltorgb
	INPUT :
		h	=> hue
		s	=> saturation
		l => luminance
	OUTPUT :
		- (utilise dans le processus msg_color => transforme une couleur hue/saturation/luminance en red/green/blue)
	************************************* */
	r = g = b = 0;
	if (s < 0) s = 0;
	if (s > 1) s = 1;
	if (l < 0) l = 0;
	if (l > 1) l = 1;
	h = h % 360;
	if (h < 0) h = h + 360;
	if (l <= 0.5)
	{
		cmin = l * ( 1 - s );
		cmax = 2 * l - cmin;
	}
	else
	{
		cmax = l * ( 1 - s ) + s;
		cmin = 2 * l - cmax;
	}
	r = msg_color_h2v(h+120,cmin,cmax);
	g = msg_color_h2v(h,cmin,cmax);
	b = msg_color_h2v(h-120,cmin,cmax);
}

function msg_color_h2v(hh,min,max)
{
	/* *************************************
	NAME :
		msg_color_h2v
	INPUT :
		hh
		min
		max
	OUTPUT :
		- (utilise dans le processus msg_color)
	************************************* */
	hh = hh % 360;
	if (hh <	0) hh = hh + 360;
	if (hh <	60) return min + (max - min) * hh / 60;
	if (hh >= 60 && hh < 180) return max;
	if (hh >=180 && hh < 240) return min+(max-min)*(240-hh)/60;
	return min;
}

function msg_color_select_color(color_value, input_object, div_object)
{
	/* *************************************
	NAME :
		msg_color_select_color
	INPUT :
		color_value	=> valeur choisie
	OUTPUT :
		- (selectionne la valeur selectionnee)
	************************************* */
	try
	{
		document.getElementById(input_object).value								= color_value;
		document.getElementById(div_object).style.backgroundColor	= color_value;
	}
	catch(e) {};
	return true;
}

function msg_confirm(e, input_question, input_function, cancel_button, deactivate_fog, yes_button_label, no_button_label)
{
	/* *************************************
	NAME :
		msg_confirm
	INPUT :
		e									=> event
		input_question		=> texte qui sera affiche
		input_function		=> fonction qui sera lancee apres validation de la fenetre
		cancel_button			=> true si on affiche le bouton "annuler" et false sinon
		deactivate_fog		=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
		yes_button_label	=> libellé du bouton "oui"
		no_button_label		=> libellé du bouton "non"
	OUTPUT :
		- (affiche une fenetre de type 'confirm' et appelle la fonction specifiee en renvoyant true/false selon le choix)
	************************************* */
	if (String(yes_button_label) == "undefined" || String(yes_button_label) == "")	yes_button_label	= language_msg("00003");
	if (String(no_button_label) == "undefined" || String(no_button_label) == "")		no_button_label		= language_msg("00004");

	/* objet principal */
	var rnd									= String(Math.random());
	var div_prompt_confirm	= document.createElement("div");
	div_prompt_confirm.setAttribute("id", "div_prompt_confirm" + rnd);
	div_prompt_confirm.className		= "css_msg";

	/* contenu personnalise */
	var tmp_string	= "";
	tmp_string			+= "<table cellspacing='0'>";
	tmp_string			+= "<tr>";
	tmp_string			+= "<td class='css_form_label_left'>" + input_question + "</td>";
	tmp_string			+= "</tr>";
	tmp_string			+= "<tr>";
	tmp_string			+= "<td class='css_form_label_input'>";
	tmp_string			+= "<input type='button' id='input_prompt_confirm_yes" + rnd + "' class='css_form_button' value=\"" + yes_button_label + "\"/>";
	tmp_string			+= "<input type='button' id='input_prompt_confirm_no" + rnd + "' class='css_form_button' value=\"" + no_button_label + "\"/>";
	if (cancel_button)
		tmp_string		+= "<input type='button' id='input_prompt_confirm_cancel" + rnd + "' class='css_form_button' value=\"" + language_msg("00002") + "\"/>";
	tmp_string			+= "</td>";
	tmp_string			+= "</tr>";
	tmp_string			+= "</table>";
	div_prompt_confirm.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_confirm);

	/* boutons */
	document.getElementById("input_prompt_confirm_yes" + rnd).onclick	= function(){
		document.body.removeChild(document.getElementById("div_prompt_confirm" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(true)");
	};

	document.getElementById("input_prompt_confirm_no" + rnd).onclick	= function(){
		document.body.removeChild(document.getElementById("div_prompt_confirm" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(false)");
	};

	if (cancel_button)
	{
		document.getElementById("input_prompt_confirm_cancel" + rnd).onclick	= function(){
			document.body.removeChild(document.getElementById("div_prompt_confirm" + rnd));
			msg_border_remove(rnd);
			fog_manage(false);
			if (input_function != "")	eval(input_function + "(null)");
		};
	}

	/* gestion de la touche "escape" */
	key_manage_escape = function(e){
		if (cancel_button)
			document.getElementById("input_prompt_confirm_cancel" + rnd).click();
		else
			document.getElementById("input_prompt_confirm_no" + rnd).click();
	};

	/* affichage */
	msg_display(e, div_prompt_confirm, 3, rnd, false);
	document.getElementById("input_prompt_confirm_yes" + rnd).focus();
}

/* pour faciliter la sélection des fichiers, on stocke en javascript la sélection courante, et on la modifiera en fonction des choix utilisateur */
var global_msg_file_selection = "";
function msg_file(e, input_field, input_function, deactivate_fog, prefix, suffix, direct_upload)
{
	/* *************************************
	NAME :
		msg_file
	INPUT :
		e								=> event
		input_field			=> champ qui sera mis a jour apres validation de la fenetre
		input_function	=> fonction qui sera lancee apres validation de la fenetre
		deactivate_fog	=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
		prefix					=> prefixe a rajouter devant l'url
		suffix					=> suffixe a rajouter apres l'url
		direct_upload		=> true si on bascule directement sur l'upload et false sinon
	OUTPUT :
		- (affiche une fenetre de choix d'un fichier parmi ceux disponibles et met a jour le champ specifie)
	************************************* */

	/* objet principal */
	var rnd							= String(Math.random());
	var div_prompt_file	= document.createElement("div");
	div_prompt_file.setAttribute("id", "div_prompt_file" + rnd);
	div_prompt_file.className = "css_msg";

	/* contenu personnalise */
	var tmp_string	= "";
	if (direct_upload)
		tmp_string		+= "<iframe id='iframe_file_xplorer' onload='file_xplorer_redraw(false, true);' src='" + include_path + "/html/file_xplorer/swfupload/index.php?upload_only=1' frameborder='0' class='css_file_xplorer' scrolling='yes'></iframe>";
	else
		tmp_string		+= "<iframe id='iframe_file_xplorer' onload='file_xplorer_redraw(false, true);' src='" + include_path + "/html/file_xplorer/index.php?action=list_init' frameborder='0' class='css_file_xplorer' scrolling='yes'></iframe>";
	tmp_string			+= "<table cellspacing='0'>";
	tmp_string			+= "<tr>";
	tmp_string			+= "<td class='css_form_label_input'>";
	tmp_string			+= "<input type='button' id='input_prompt_file_ok" + rnd + "' class='css_form_button' style='display:none;' value=\"" + language_msg("00001") + "\"/>";
	tmp_string			+= "<input type='button' id='input_prompt_file_cancel" + rnd + "' class='css_form_button' style='display:none;' value=\"" + language_msg("00002") + "\"/>";
	tmp_string			+= "</td>";
	tmp_string			+= "</tr>";
	tmp_string			+= "</table>";
	div_prompt_file.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_file);

	/* initialisation de la variable avec les valeurs déjà sélectionnées */
	global_msg_file_selection = "";
	if (input_field != "")
		global_msg_file_selection = document.getElementById(input_field).value.split(/\n/gi);

	/* boutons */
	document.getElementById("input_prompt_file_ok" + rnd).onclick	= function(){
		if (input_field != "")
		{
			/* recuperation de la selection */
			tmp_string = "";
			for (var i=0 ; i<global_msg_file_selection.length ; i++)
			{
				if (document.getElementById(input_field).tagName.toLowerCase() == "input")
				{	/* dernière valeur uniquement */
					tmp_string = global_msg_file_selection[i].replace("../..", ".."); /* reduction des chemins relatifs */
				}
				else
				{
					if (tmp_string != "")
						tmp_string += "\n";
					tmp_string += global_msg_file_selection[i].replace("../..", ".."); /* reduction des chemins relatifs */
				}
			}

			/* suppression de l'image par défaut le cas échéant */
			tmp_string	= tmp_string.replace("../img/img-defaut.jpg\n", "");

			document.getElementById(input_field).value = prefix + tmp_string + suffix;
			/* lancement de l'evenement "onchange" sur le champ appelant */
			if (document.getElementById(input_field).onchange)
				document.getElementById(input_field).onchange();
		}
		document.body.removeChild(document.getElementById("div_prompt_file" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(true)");
	};

	document.getElementById("input_prompt_file_cancel" + rnd).onclick	= function(){
		document.body.removeChild(document.getElementById("div_prompt_file" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(false)");
	};

	/* gestion de la touche "escape" */
	key_manage_escape = function(e){
		document.getElementById("input_prompt_file_cancel" + rnd).click();
	};

	/* affichage */
	msg_display(e, div_prompt_file, 4, rnd, false);
}

function msg_gmap(e, input_field, input_function, interactive_mode, process_type, deactivate_fog)
{
	/* *************************************
	NAME :
		msg_gmap
	INPUT :
		e									=> event
		input_field				=> champ qui sera mis a jour apres validation de la fenetre
		input_function		=> fonction qui sera lancee apres validation de la fenetre
		interactive_mode	=> true/false selon que l'on puisse modifier les points de la map ou non
		process_type			=> voir formateur "formateur_gmap" (type de carte à afficher)
		deactivate_fog		=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
	OUTPUT :
		- (affiche une fenetre de type 'google map' et met a jour le champ specifie avec la liste des points de la map)
	************************************* */

	/* objet principal */
	var rnd										= String(Math.random());
	var div_prompt_gmap				= document.createElement("div");
	div_prompt_gmap.setAttribute("id", "div_prompt_gmap" + rnd);
	div_prompt_gmap.className	= "css_msg";

	/* contenu personnalise */
	var rnd_gmap		= String(Math.random());
	var tmp_string	= "";
	tmp_string += "<table cellspacing='0'>";
	tmp_string += "<tr><td class='css_form_label_left'>";
	tmp_string += "<iframe id='iframe_prompt_gmap" + rnd + "' src='" + include_path + "/php/assistant-gmap.php?rnd=" + rnd_gmap + "&interactive_mode=" + interactive_mode + "&process_type=" + process_type + "' class='css_gmap_param' frameborder='0'></iframe>";
	tmp_string += "<textarea type='text/javascript' id='gmap_script_" + rnd_gmap + "' style='display:none;' cols='1' rows='1'>" + document.getElementById(input_field).value + "</textarea>";
	tmp_string += "</td></tr>";
	tmp_string += "<tr>";
	tmp_string += "<td class='css_form_label_input'>";
	if (interactive_mode)
	{
		tmp_string += "<input type='button' id='input_prompt_gmap_ok" + rnd + "' class='css_form_button' value=\"" + language_msg("00001") + "\"/>";
		tmp_string += "<input type='button' id='input_prompt_gmap_cancel" + rnd + "' class='css_form_button' value=\"" + language_msg("00002") + "\"/>";
	}
	else
		tmp_string += "<input type='button' id='input_prompt_gmap_ok" + rnd + "' class='css_form_button' value=\"" + language_msg("00021") + "\"/>";
	tmp_string += "</td>";
	tmp_string += "</tr>";
	tmp_string += "</table>";
	div_prompt_gmap.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_gmap);

	/* boutons */
	if (interactive_mode)
	{
		document.getElementById("input_prompt_gmap_ok" + rnd).onclick	= function(){
			if (input_field != "")
			{
				/* recuperation des points */
				var tmp_field		= document.getElementById(input_field);
				tmp_field.value	= document.getElementById("iframe_prompt_gmap" + rnd).contentWindow.gmap_get_markers();
				/* mise a jour de la previsualisation */
				if (document.getElementById("div_" + input_field))
				{
					/* récupération du contenu de la map de l'assistant */
					tmp_string																							= document.getElementById("iframe_prompt_gmap" + rnd).contentWindow.document.getElementById("div_gmap").innerHTML;
					document.getElementById("div_" + input_field).innerHTML = tmp_string;
				}
				/* suppression de l'iframe */
				document.body.removeChild(document.getElementById("div_prompt_gmap" + rnd));
			}
			msg_border_remove(rnd);
			if (deactivate_fog)				fog_manage(false);
			if (input_function != "")	eval(input_function + "(true)");
		};

		document.getElementById("input_prompt_gmap_cancel" + rnd).onclick	= function(){
			document.body.removeChild(document.getElementById("div_prompt_gmap" + rnd));
			msg_border_remove(rnd);
			if (deactivate_fog)				fog_manage(false);
			if (input_function != "")	eval(input_function + "(false)");
		};
	}
	else
	{
		document.getElementById("input_prompt_gmap_ok" + rnd).onclick	= function(){
			document.body.removeChild(document.getElementById("div_prompt_gmap" + rnd));
			msg_border_remove(rnd);
			if (deactivate_fog)				fog_manage(false);
			if (input_function != "")	eval(input_function + "(true)");
		};
	}

	/* gestion de la touche "escape" */
	if (interactive_mode)
	{
		key_manage_escape = function(e){
			document.getElementById("input_prompt_gmap_cancel" + rnd).click();
		};
	}
	else
	{
		key_manage_escape = function(e){
			document.getElementById("input_prompt_gmap_ok" + rnd).click();
		};
	}

	/* affichage */
	msg_display(e, div_prompt_gmap, 3, rnd, false);
}

function msg_object(e, input_object, input_function, only_one_button, deactivate_fog, main_button_label, position)
{
	/* *************************************
	NAME :
		msg_object
	INPUT :
		e									=> event
		input_object			=> objet (div...) qui sera affiche
		input_function		=> fonction qui sera lancee apres validation de la fenetre
		only_one_button		=> true on ne souhaite avoir qu'un seul bouton et false sinon (2 boutons pour valider/annuler)
		deactivate_fog		=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
		main_button_label	=> libellé du bouton principal
		position					=> idem fonction "msg_display"
	OUTPUT :
		- (affiche une fenetre contenant l'objet specifie et appelle la fonction specifiee en renvoyant true/false selon le choix)
	************************************* */
	/* objet principal */
	var rnd								= String(Math.random());
	var div_prompt_object	= document.createElement("div");
	/* attention : le changement de l'ID de cet objet a des repercussions sur la fonction "tab_display" (form.js) */
	div_prompt_object.setAttribute("id", "div_prompt_object" + rnd);
	div_prompt_object.className			= "css_msg";

	/* contenu personnalise */
	var tmp_string = "";
	tmp_string += "<table cellspacing='0' cellpadding='0' border='0'>";
	tmp_string += "<tr><td class='css_form_label_left'>";
	tmp_string += "<div id='div_prompt_object_link" + rnd + "'></div>";
	tmp_string += "</td></tr>";
	tmp_string += "<tr>";
	tmp_string += "<td class='css_form_label_input'>";
	if (only_one_button)
	{
		if (String(main_button_label) == "undefined" || String(main_button_label) == "") main_button_label = language_msg("00021");
		tmp_string += "<input type='button' id='input_prompt_object_ok" + rnd + "' class='css_form_button' value=\"" + main_button_label + "\"/>";
	}
	else
	{
		if (String(main_button_label) == "undefined" || String(main_button_label) == "") main_button_label = language_msg("00001");
		tmp_string += "<input type='button' id='input_prompt_object_ok" + rnd + "' class='css_form_button' value=\"" + main_button_label + "\"/>";
		tmp_string += "<input type='button' id='input_prompt_object_cancel" + rnd + "' class='css_form_button' value=\"" + language_msg("00002") + "\"/>";
	}
	tmp_string += "</td>";
	tmp_string += "</tr>";
	tmp_string += "</table>";
	div_prompt_object.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_object);

	/* boutons */
	document.getElementById("input_prompt_object_ok" + rnd).onclick	= function(){
		/* cas special : détection d'une iframe */
		for (var i=0 ; i<document.getElementById("div_prompt_object" + rnd).getElementsByTagName("iframe").length ; i++)
		{
			var iframe = document.getElementById("div_prompt_object" + rnd).getElementsByTagName("iframe")[i];

			/* ****************** */
			/* iframe texte riche */
			/* ****************** */
			if (iframe.getAttribute("id") == "iframe_rte")
			{	/* iframe texte riche => mise a jour du champ appelant par la fonction dediee */
				iframe.contentWindow.RTE_set_value();
			}
		}
		document.body.removeChild(document.getElementById("div_prompt_object" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog) fog_manage(false);
		document.lastChild.lastChild.appendChild(input_object);
		if (input_function != "") eval(input_function + "(true)");
	};

	if (!only_one_button)
	{
		document.getElementById("input_prompt_object_cancel" + rnd).onclick	= function(){
			document.body.removeChild(document.getElementById("div_prompt_object" + rnd));
			msg_border_remove(rnd);
			if (deactivate_fog) fog_manage(false);
			document.lastChild.lastChild.appendChild(input_object);
			if (input_function != "") eval(input_function + "(false)");
		};
	}

	/* liaison de l'objet en input */
	document.getElementById("div_prompt_object_link" + rnd).appendChild(input_object);

	/* gestion de la touche "escape" */
	if (only_one_button)
	{
		key_manage_escape = function(e){
			document.getElementById("input_prompt_object_ok" + rnd).click();
		};
	}
	else
	{
		key_manage_escape = function(e){
			document.getElementById("input_prompt_object_cancel" + rnd).click();
		};
	}

	/* affichage */
	if (String(position) == "undefined") position = 3;
	msg_display(e, div_prompt_object, position, rnd, false);
}

function msg_object_resize(is_new_window, contact_form)
{
	/* *************************************
	NAME :
		msg_object_resize
	INPUT :
		is_new_window	=> true si on est dans une nouvelle popup et false sinon (rechargement)
		contact_form	=> false (défaut) si formulaire classique et true si formulaire de contact
	OUTPUT :
		[nouvelle largeur,nouvelle hauteur] (met a jour un objet contenant une iframe (ex: assistants texte riche ou pages-links) pour l'élargir au maximum et renvoie ses nouvelles dimensions)
		Attention : on considère toujours que l'iframe est le dernier élément dans son assistant (<=> c'est le dernier champ de l'onglet dans lequel il est)
	************************************* */
	var return_width	= 0;
	var return_height	= 0;

	if (String(contact_form) == "undefined")
		contact_form		= false;

	var iframes	= window.parent.document.body.getElementsByTagName("iframe");
	var iframe	= null;
	for(var i=0 ; i<iframes.length ; i++)
	{
		try
		{
			if (iframes[i].contentWindow.location.href == window.document.location.href)
			{	/* on a trouvé l'iframe courante appelant l'objet qui va être redimensionnée */
				iframe = iframes[i];
			}
		}
		catch(e) {};
	}
	if (iframe != null)
	{
		var parent_node	= null;
		/* récupération de la popup */
		var tmp_node		= iframe;
		while (tmp_node.parentNode != null)
		{	/* parcours des elements parents pour chercher un eventuel msg_object ou msg_pages_links... */
			if (tmp_node.getAttribute("id") != null && tmp_node.getAttribute("id").indexOf("div_prompt_object") != -1)
				parent_node = tmp_node;
			if (tmp_node.getAttribute("id") != null && tmp_node.getAttribute("id").indexOf("div_prompt_pages_links") != -1)
				parent_node = tmp_node;
			tmp_node = tmp_node.parentNode;
		}

		if (parent_node != null)
		{
			var margin_x				= 10;
			var margin_y				= 40; /* prendre en compte la hauteur des boutons de l'assistant */

			if (contact_form)
			{
				iframe.style.height	= (b_ie ? 455 : 440);
				iframe.style.width	= 650;
				window.parent.msg_display_redraw("", parent_node, 2, null);
			}
			else
			{	/* redimensionnement de l'assistant pour le maximiser */
				window.parent.msg_display_redraw("", parent_node, 4, null);
			}

			/* récupération des coordonnées de l'assistant */
			var tmp_array				= offset_absolute(parent_node);
			var parent_width		= parseInt(parent_node.offsetWidth);
			var parent_height		= parseInt(parent_node.offsetHeight);
			var parent_left			= tmp_array[0];
			var parent_top			= tmp_array[1];

			/* récupération des coordonnées de l'iframe */
			var tmp_array				= offset_absolute(iframe);
			var iframe_width		= parseInt(iframe.offsetWidth);
			var iframe_height		= parseInt(iframe.offsetHeight);
			var iframe_left			= tmp_array[0];
			var iframe_top			= tmp_array[1];

			/* calcul de la différence pour déterminer l'augmentation de taille possible de l'iframe */
			var add_width				= parent_width + parent_left - (iframe_width + iframe_left);
			var add_height			= parent_height + parent_top - (iframe_height + iframe_top);

			/* réaffichage */
			iframe.style.width	= iframe_width + add_width - margin_x;
			iframe.style.height	= iframe_height + add_height - margin_y;
			iframe.style.left		= 0;

			return_width				= parseInt(iframe.style.width);
			return_height				= parseInt(iframe.style.height);
		}
	}

	if (contact_form)
	{
		/* affichage de la bordure */
		/* récupération de l'identifiant aléatoire de l'objet affiché */
		var tmp_div							= iframe.parentNode;
		var tmp_string					= tmp_div.getAttribute("id");
		var tmp_string					= tmp_string.replace(/[a-z|_|A-Z]/gi, "");
		/* récupération de l'objet à réellement afficher */
		tmp_div									= tmp_div.parentNode;
		while (tmp_div.tagName != "DIV" && tmp_div.tagName != "BODY")
		{
			tmp_div								= tmp_div.parentNode;
		}
		window.parent.msg_border_remove(tmp_string);
		window.parent.msg_border_set(tmp_div, tmp_string);
	}

	return Array(return_height, return_width);
}

function msg_page(e, input_field, input_function, deactivate_fog)
{
	/* *************************************
	NAME :
		msg_page
	INPUT :
		e								=> event
		input_field			=> champ qui sera mis a jour apres validation de la fenetre
		input_function	=> fonction qui sera lancee apres validation de la fenetre
		deactivate_fog	=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
	OUTPUT :
		- (affiche une fenetre de choix d'une page du site  parmi celles disponibles et met a jour le champ specifie)
	************************************* */

	/* objet principal */
	var rnd							= String(Math.random());
	var div_prompt_page	= document.createElement("div");
	div_prompt_page.setAttribute("id", "div_prompt_page" + rnd);
	div_prompt_page.className			= "css_msg";

	/* contenu personnalise */
	var tmp_string = "";
	tmp_string += "<table cellspacing='0'>";
	tmp_string += "<tr><td class='css_form_label_left'>";
	tmp_string += "<iframe id='iframe_prompt_page" + rnd + "' src='" + include_path + "/php/page-list.php?assistant_mode=1' class='css_page_list' frameborder='0'></iframe>";
	tmp_string += "</td></tr>";
	tmp_string += "<tr>";
	tmp_string += "<td class='css_form_label_input'>";
	tmp_string += "<input type='button' id='input_prompt_page_ok" + rnd + "' class='css_form_button' value=\"" + language_msg("00001") + "\"/>";
	tmp_string += "<input type='button' id='input_prompt_page_cancel" + rnd + "' class='css_form_button' value=\"" + language_msg("00002") + "\"/>";
	tmp_string += "</td>";
	tmp_string += "</tr>";
	tmp_string += "</table>";
	div_prompt_page.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_page);

	/* boutons */
	document.getElementById("input_prompt_page_ok" + rnd).onclick	= function(){
		tmp_page = "";
		if (input_field != "")
		{
			var iframe						= document.getElementById("iframe_prompt_page" + rnd);
			var iframe_assistant	= iframe.contentWindow.document;
			var tmp_string				= "";
			var ml								= iframe_assistant.getElementsByName("input_page_list");
			for(var i=0; i<ml.length; ++i)
			{
				if(ml[i].checked)
				{
						tmp_page = ml[i].value;
				}
			}
			document.getElementById(input_field).value = tmp_page;
		}
		document.body.removeChild(document.getElementById("div_prompt_page" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(true)");
	};

	document.getElementById("input_prompt_page_cancel" + rnd).onclick	= function(){
		document.body.removeChild(document.getElementById("div_prompt_page" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(false)");
	};

	/* gestion de la touche "escape" */
	key_manage_escape = function(e){
		document.getElementById("input_prompt_page_cancel" + rnd).click();
	};

	/* affichage */
	msg_display(e, div_prompt_page, 3, rnd, false);
}

function msg_pages_links(e, input_field, input_function, new_pages_links, deactivate_fog)
{
	/* *************************************
	NAME :
		msg_pages_links
	INPUT :
		e								=> event
		input_field			=> champ qui sera mis a jour apres validation de la fenetre
		input_function	=> fonction qui sera lancee apres validation de la fenetre
		new_pages_links	=> true si on demande la création d'une nouvelle page et false sinon
		deactivate_fog	=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
	OUTPUT :
		- (affiche une fenetre de modification d'un enchainement de pages)
	************************************* */
	/* recuperation du catalogue sélectionné */
	var current_pages_links = "";
	if (!new_pages_links)
		current_pages_links = field_get_value(document.getElementById(input_field), '', false);

	/* objet principal */
	var rnd														= String(Math.random());
	var div_prompt_pages_links				= document.createElement("div");
	div_prompt_pages_links.setAttribute("id", "div_prompt_pages_links" + rnd);
	div_prompt_pages_links.className	= "css_msg";

	/* contenu personnalise */
	var tmp_string	= "";
	tmp_string			+= "<iframe id='iframe_pages_links" + rnd + "' src='" + include_path + "/php/pages-links-param.php?pages_links_id=" + current_pages_links + "&field_to_update=" + input_field + "' class='css_pages_links' frameborder='0'></iframe>";
	tmp_string			+= "<table cellspacing='0'>";
	tmp_string			+= "<tr>";
	tmp_string			+= "<td class='css_form_label_input' style='text-align:right;'>";
	tmp_string			+= "<input type='button' id='input_prompt_pages_links_ok" + rnd + "' class='css_form_button' value=\"" + language_msg("00001") + "\"/>";
	tmp_string			+= "<input type='button' id='input_prompt_pages_links_cancel" + rnd + "' class='css_form_button' value=\"" + language_msg("00002") + "\"/>";
	tmp_string			+= "</td>";
	tmp_string			+= "</tr>";
	tmp_string			+= "</table>";
	div_prompt_pages_links.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_pages_links);

	/* boutons */
	document.getElementById("input_prompt_pages_links_ok" + rnd).onclick	= function(){
		if (input_field != "")
		{
			/* récupération de l'enchainement choisi dans le champ (utile dans le cas d'un nouvel enchainement) */
			var iframe							= document.getElementById("iframe_pages_links" + rnd);
			var iframe_pages_links	= iframe.contentWindow.document;
			var pages_links_id			= iframe_pages_links.getElementById("pages_links_id");
			var pages_links_saved		= iframe_pages_links.getElementById("pages_links_saved");

			/* on vérifie ce qu'il faut faire selon le status du champ de l'iframe indiquant où en est la sauvegarde */
			if (pages_links_saved.value == "0")
			{	/* on doit demander à l'utilisateur quoi faire... */
				iframe.contentWindow.fog_manage(true);
				iframe.contentWindow.pages_links_exit();
				/* ...et on relance */
				window.setTimeout("document.getElementById('input_prompt_pages_links_ok" + rnd + "').click();", 500);
				return false;
			}
			if (pages_links_saved.value == "1")
			{	/* la sauvegarde a été demandée et est en cours => on relance */
				window.setTimeout("document.getElementById('input_prompt_pages_links_ok" + rnd + "').click();", 500);
				return false;
			}
			if (pages_links_saved.value == "2")
			{	/* la sauvegarde est terminée ou n'a pas été demandée => on peut continuer */
			}
			if (pages_links_saved.value == "")
			{	/* on indique que le processus est annulé et on ne fait rien */
				pages_links_saved.value = "0";
				return false;
			}

			/* rajout de l'enchainement dans le champ appelant si ce n'est pas déjà fait */
			iframe.contentWindow.pages_links_update_field_to_update(true);
			/* on sélectionne le nouvel enchainement dans la liste */
			for (var k=0 ; k<document.getElementById(input_field).length ; k++)
			{
				if (document.getElementById(input_field)[k].value == pages_links_id.value)
				{	/* l'élément a été trouvé */
					document.getElementById(input_field)[k].selected = true;
				}
			}

			document.body.removeChild(document.getElementById("div_prompt_pages_links" + rnd));
			msg_border_remove(rnd);
			if (deactivate_fog)				fog_manage(false);
			if (input_function != "")	eval(input_function + "(true)");
		}
		else
		{
			document.body.removeChild(document.getElementById("div_prompt_pages_links" + rnd));
			msg_border_remove(rnd);
			if (deactivate_fog)				fog_manage(false);
			if (input_function != "") eval(input_function + "(true)");
		}
	};

	document.getElementById("input_prompt_pages_links_cancel" + rnd).onclick	= function(){
		document.body.removeChild(document.getElementById("div_prompt_pages_links" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(false)");
	};

	/* gestion de la touche "escape" */
	key_manage_escape = function(e){
		document.getElementById("input_prompt_pages_links_cancel" + rnd).click();
	};

	/* affichage */
	msg_display(e, div_prompt_pages_links, 4, rnd, false);
}

function msg_prompt(e, input_type, input_field, input_question, input_default, is_submit_button, input_function, deactivate_fog)
{
	/* *************************************
	NAME :
		msg_prompt
	INPUT :
		e									=> event
		input_type				=> type d'affichage de valeurs ('text' ou 'password' ou 'select' ou 'selectmulti' ou 'textarea')
		input_field				=> champ qui sera mis a jour apres validation de la fenetre
		input_question		=> texte qui sera affiche
		input_default			=> valeur par defaut (si 'text' ou 'password') ou valeurs possibles (si 'select' et dans ce cas il faut passer un new Array('val1','val2'...) si 'selectmulti' les valeurs doivent être sous la forme 'label1|val1¤label2|val2...')
		is_submit_button	=> true si le bouton "Valider" est de type "Submit" ou false sinon (mode classique)
		input_function		=> fonction qui sera lancee apres validation de la fenetre
		deactivate_fog		=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
	OUTPUT :
		- (affiche une fenetre de type 'prompt' et appelle la fonction specifiee en renvoyant la valeur saisie)
	************************************* */

	/* objet principal */
	var rnd								= String(Math.random());
	var div_prompt_prompt	= document.createElement("div");
	div_prompt_prompt.setAttribute("id", "div_prompt_prompt" + rnd);
	div_prompt_prompt.className			= "css_msg";

	/* contenu personnalise */
	var tmp_string = "";
	tmp_string += "<table cellspacing='0'>";
	tmp_string += "<tr>";
	tmp_string += "<td class='css_form_label_left'>" + input_question + (input_type.toLowerCase() == "selectmulti" ? "<br/><br/>" + language_msg("00600") : "") +"</td>";
	tmp_string += "</tr>";
	tmp_string += "<tr><td class='css_form_label_input'>";
	if (input_type.toLowerCase() == "text")					tmp_string += "<input id='input_prompt_prompt" + rnd + "' type='text' class='css_form_param' value=''/>";
	if (input_type.toLowerCase() == "password")			tmp_string += "<input id='input_prompt_prompt" + rnd + "' type='password' class='css_form_param' value=''/>";
	if (input_type.toLowerCase() == "textarea")			tmp_string += "<textarea id='textarea_prompt_prompt" + rnd + "' class='css_form_param' value='' cols='1' rows='1'></textarea>";
	if (input_type.toLowerCase() == "select")				tmp_string += "<select id='select_prompt_prompt" + rnd + "' class='css_form_param' value=''/>";
	if (input_type.toLowerCase() == "selectmulti")	tmp_string += "<select multiple id='selectmulti_prompt_prompt" + rnd + "' class='css_form_param' size='20' value=''/>";
	tmp_string += "</td></tr>";
	tmp_string += "<tr>";
	tmp_string += "<td class='css_form_label_input'>";
	tmp_string += "<input type='" + (is_submit_button ? "submit" : "button") + "' id='input_prompt_prompt_ok" + rnd + "' class='css_form_button' value=\"" + language_msg("00001") + "\"/>";
	tmp_string += "<input type='button' id='input_prompt_prompt_cancel" + rnd + "' class='css_form_button' value=\"" + language_msg("00002") + "\"/>";
	tmp_string += "</td>";
	tmp_string += "</tr>";
	tmp_string += "</table>";
	div_prompt_prompt.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_prompt);

	/* valeurs */
	if (input_type.toLowerCase() == "text")			document.getElementById("input_prompt_prompt" + rnd).value = input_default;
	if (input_type.toLowerCase() == "password")	document.getElementById("input_prompt_prompt" + rnd).value = input_default;
	if (input_type.toLowerCase() == "textarea")	document.getElementById("textarea_prompt_prompt" + rnd).value = input_default;
	if (input_type.toLowerCase() == "select")
	{
		document.getElementById("select_prompt_prompt" + rnd).options.length = 0;
		for (var i=0 ; i <input_default.length ; i++)
		{
			var new_option = document.createElement("OPTION");
			document.getElementById("select_prompt_prompt" + rnd).options.add(new_option);
			new_option.text = input_default[i];
		}
	}
	if (input_type.toLowerCase() == "selectmulti")
	{
		input_default	= input_default.split("¤");
		document.getElementById("selectmulti_prompt_prompt" + rnd).options.length = 0;
		for (var i=0 ; i<input_default.length ; i++)
		{
			input_default[i]		= input_default[i].split("|");
			var new_option			= document.createElement("OPTION");
			document.getElementById("selectmulti_prompt_prompt" + rnd).options.add(new_option);
			new_option.text			= input_default[i][0];
			new_option.value		= input_default[i][1];
			new_option.selected	= true;
		}
	}

	/* boutons */
	document.getElementById("input_prompt_prompt_ok" + rnd).onclick	= function(){
		if (input_type.toLowerCase() == "text")					selected_value = document.getElementById("input_prompt_prompt" + rnd).value;
		if (input_type.toLowerCase() == "password")			selected_value = document.getElementById("input_prompt_prompt" + rnd).value;
		if (input_type.toLowerCase() == "textarea")			selected_value = document.getElementById("textarea_prompt_prompt" + rnd).value;
		if (input_type.toLowerCase() == "select")				selected_value = document.getElementById("select_prompt_prompt" + rnd)[document.getElementById("select_prompt_prompt" + rnd).selectedIndex].text;
		if (input_type.toLowerCase() == "selectmulti")
		{
			selected_value								= "";
			var selectmulti_prompt_prompt	= document.getElementById("selectmulti_prompt_prompt" + rnd);
			for (var i=0 ; i<selectmulti_prompt_prompt.options.length ; i++)
			{
				if (selectmulti_prompt_prompt.options[i].selected)
				{
					if (selected_value != "") selected_value += "¤";
					if (String(selectmulti_prompt_prompt.options[i].value) != "undefined")
						selected_value	+= selectmulti_prompt_prompt.options[i].value;
				}
			}
		}
		if (input_field != "")
			document.getElementById(input_field).value = selected_value;
		document.body.removeChild(document.getElementById("div_prompt_prompt" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(selected_value)");
	};

	document.getElementById("input_prompt_prompt_cancel" + rnd).onclick	= function(){
		document.body.removeChild(document.getElementById("div_prompt_prompt" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(false)");
	};

	/* gestion de la touche "escape" */
	key_manage_escape = function(e){
		document.getElementById("input_prompt_prompt_cancel" + rnd).click();
	};

	/* affichage */
	msg_display(e, div_prompt_prompt, 3, rnd, false);
}

var msg_display_margin	= 25;
var msg_display_last_x	= msg_display_margin;	/* utilise pour msg_display avec position = 2 */
var msg_display_last_y	= msg_display_margin;	/* utilise pour msg_display avec position = 2 */
function msg_display(e, object, position, rnd, redraw)
{
	/* *************************************
	NAME :
		msg_display
	INPUT :
		e					=> event
		object		=> objet affiche
		position	=> 1 (affichage en haut a gauche mais en tenant compte des marges)
							=> 2 (affichage au meme endroit que la derniere fois)
							=> 3 (affichage au curseur de la souris)
							=> 4 (maximisation de la fenêtre)
		rnd				=> nombre aleatoire fourni par l'appelant permettant de retrouver les references des objets affilies
		redraw		=> true si on vient d'un réaffichage et false sinon
	OUTPUT :
		- (affiche l'objet permettant d'interagir avec l'utilisateur)
	************************************* */
	var new_x = 0;
	var new_y = 0;

	/* recuperation du nombre aleatoire utilise pour afficher cet objet */
	if (rnd == null)
	{
		rnd	= object.id.split(".");
		rnd	= "0." + rnd[rnd.length - 1];
	}

	/* affichage en dehors de la page pour que les proprietes "offsetWidth" et "offsetHeight" soient correctes */
	object.style.left				= -5000;
	object.style.top				= -5000;
	object.style.display		= "block";
	object.style.overflowX	= "hidden";

	/* affichage automatique pour éviter de grandes zones vides et redimensionner l'objet au mieux (par exemple après un redraw) */
	object.style.height				= "auto";
	object.style.width				= "auto";

	if (position == 1)
	{
		new_x = window_get_sizes(window, "scroll_x") + msg_display_margin;
		new_y = window_get_sizes(window, "scroll_y") + msg_display_margin;
	}

	if (position == 2)
	{
		new_x = parseInt(msg_display_last_x);
		new_y = parseInt(msg_display_last_y);
	}

	if (position == 3)
	{
		if (String(window.x) == "undefined" || String(window.y) == "undefined")
		{
			new_x	= msg_display_margin;
			new_y	= msg_display_margin;
		}
		else
		{
			new_x = e == "" ? x : mouse_x(e);
			new_y = e == "" ? y : mouse_y(e);
		}
		/* leger decalage (parfois il est necessaire que le curseur ne soit pas positionne exactement dessus) */
		new_x += 2;
		new_y += 2;
		/* prise en compte du scroll */
		new_x	+= window_get_sizes(window, "scroll_x");
		new_y += window_get_sizes(window, "scroll_y");
	}

	if (position == 4)
	{
		new_x								= msg_display_margin + window_get_sizes(window, "scroll_x");
		new_y								= msg_display_margin + window_get_sizes(window, "scroll_y");
		object.style.width	= window_get_sizes(window, "width") - 2 * msg_display_margin;
		object.style.height	= window_get_sizes(window, "height") - 2 * msg_display_margin;
	}

	/* recalcul des coordonnees pour eviter tout depassement hors de la fenetre */
	if (parseInt(object.offsetWidth) > window_get_sizes(window, "width"))
	{
		object.style.width		= "90%";
		object.style.overflow	= "hidden";
	}
	/* dépassement à droite */
	if (new_x + msg_display_margin + object.offsetWidth >= window_get_sizes(window, "scroll_x") + window_get_sizes(window, "width"))
		new_x = window_get_sizes(window, "scroll_x") + window_get_sizes(window, "width") - object.offsetWidth - msg_display_margin;
	/* dépassement en bas */
	if (new_y + msg_display_margin + object.offsetHeight >= window_get_sizes(window, "scroll_y") + window_get_sizes(window, "height"))
	{
		new_y = window_get_sizes(window, "scroll_y") + window_get_sizes(window, "height") - object.offsetHeight - msg_display_margin;
		/* dépassement en haut alors qu'on vient déjà de traiter un dépassement en bas */
		if (new_y - msg_display_margin < window_get_sizes(window, "scroll_y"))
		{
			new_y									= window_get_sizes(window, "scroll_y") + msg_display_margin;
			object.style.height		= window_get_sizes(window, "height") - 2*msg_display_margin;
			object.style.overflow	= "auto";
		}
	}

	msg_display_last_x 	= new_x;
	msg_display_last_y 	= new_y;
	object.style.left		= new_x;
	object.style.top		= new_y;
	object.style.zIndex	= parseInt(document.getElementById('iframe_fog').style.zIndex) + 1;

	/* affichage de la bordure */
	msg_border_remove(rnd);
	msg_border_set(object, rnd);

	/* affichage de l'objet */
	object.style.display	= "block";
}

function msg_display_redraw(e, object, position, rnd)
{
	/* *************************************
	NAME :
		msg_display_redraw
	INPUT :
		e					=> idem fonction "msg_display"
		object		=> idem fonction "msg_display"
		position	=> idem fonction "msg_display"
		rnd				=> idem fonction "msg_display"
	OUTPUT :
		- (reaffiche l'objet)
	************************************* */
	var tmp_node = object;
	while (tmp_node.parentNode != null)
	{	/* parcours des elements parents pour chercher un eventuel msg_object... */
		if (tmp_node.getAttribute("id") != null && tmp_node.getAttribute("id").indexOf("div_prompt_object") != -1)
		{	/* il faut repositionner cet objet */
			msg_display(e, tmp_node, position, rnd, true);
		}
		tmp_node = tmp_node.parentNode;
	}
}

/* 2 fonctions de gestion de la bordure */
function msg_border_remove(rnd)
{
	/* *************************************
	NAME :
		msg_border_remove
	INPUT :
		rnd	=> nombre aleatoire permettant de retrouver les bordures
	OUTPUT :
		- (suppression de la bordure)
	************************************* */
	var div_msg_border_br			= document.getElementById("div_msg_border_br_" + rnd);
	var div_msg_border_bl			= document.getElementById("div_msg_border_bl_" + rnd);
	var div_msg_border_side_b	= document.getElementById("div_msg_border_side_b_" + rnd);
	var div_msg_border_side_l	= document.getElementById("div_msg_border_side_l_" + rnd);
	var div_msg_border_side_r	= document.getElementById("div_msg_border_side_r_" + rnd);
	var div_msg_border_side_t	= document.getElementById("div_msg_border_side_t_" + rnd);
	var div_msg_border_tl			= document.getElementById("div_msg_border_tl_" + rnd);
	var div_msg_border_tr			= document.getElementById("div_msg_border_tr_" + rnd);

	if (div_msg_border_br != null)			document.body.removeChild(div_msg_border_br);
	if (div_msg_border_bl != null)			document.body.removeChild(div_msg_border_bl);
	if (div_msg_border_side_b != null)	document.body.removeChild(div_msg_border_side_b);
	if (div_msg_border_side_l != null)	document.body.removeChild(div_msg_border_side_l);
	if (div_msg_border_side_r != null)	document.body.removeChild(div_msg_border_side_r);
	if (div_msg_border_side_t != null)	document.body.removeChild(div_msg_border_side_t);
	if (div_msg_border_tl != null)			document.body.removeChild(div_msg_border_tl);
	if (div_msg_border_tr != null)			document.body.removeChild(div_msg_border_tr);
}

function msg_border_set(object_ref, rnd)
{
	/* *************************************
	NAME :
		msg_border_set
	INPUT :
		object_ref	=> objet autour duquel mettre la bordure
		rnd					=> nombre aleatoire permettant de retrouver les bordures
	OUTPUT :
		- (affiche une bordure autour de l'objet)
	************************************* */
	var CONST_SIDE	= 5;	/* meme valeur que les width/height identifiés dans "div.css_msg_border_xxx" */
	var iframe_fog	= document.getElementById('iframe_fog');

	/* creation de la bordure (variables) */
	div_msg_border_br								= document.createElement("div");
	div_msg_border_br.className			= "css_msg_border_br";
	div_msg_border_br.setAttribute("id", "div_msg_border_br_" + rnd);
	document.body.appendChild(div_msg_border_br);

	div_msg_border_bl								= document.createElement("div");
	div_msg_border_bl.className			= "css_msg_border_bl";
	div_msg_border_bl.setAttribute("id", "div_msg_border_bl_" + rnd);
	document.body.appendChild(div_msg_border_bl);

	div_msg_border_side_b						= document.createElement("div");
	div_msg_border_side_b.className	= "css_msg_border_side_b";
	div_msg_border_side_b.setAttribute("id", "div_msg_border_side_b_" + rnd);
	document.body.appendChild(div_msg_border_side_b);

	div_msg_border_side_l						= document.createElement("div");
	div_msg_border_side_l.className	= "css_msg_border_side_l";
	div_msg_border_side_l.setAttribute("id", "div_msg_border_side_l_" + rnd);
	document.body.appendChild(div_msg_border_side_l);

	div_msg_border_side_r						= document.createElement("div");
	div_msg_border_side_r.className	= "css_msg_border_side_r";
	div_msg_border_side_r.setAttribute("id", "div_msg_border_side_r_" + rnd);
	document.body.appendChild(div_msg_border_side_r);

	div_msg_border_side_t						= document.createElement("div");
	div_msg_border_side_t.className	= "css_msg_border_side_t";
	div_msg_border_side_t.setAttribute("id", "div_msg_border_side_t_" + rnd);
	document.body.appendChild(div_msg_border_side_t);

	div_msg_border_tl								= document.createElement("div");
	div_msg_border_tl.className			= "css_msg_border_tl";
	div_msg_border_tl.setAttribute("id", "div_msg_border_tl_" + rnd);
	document.body.appendChild(div_msg_border_tl);

	div_msg_border_tr								= document.createElement("div");
	div_msg_border_tr.className			= "css_msg_border_tr";
	div_msg_border_tr.setAttribute("id", "div_msg_border_tr_" + rnd);
	document.body.appendChild(div_msg_border_tr);

	/* creation de la bordure  (affichage) */
	div_msg_border_br.style.left				= (parseInt(object_ref.offsetLeft) + parseInt(object_ref.offsetWidth)) + "px";
	div_msg_border_br.style.top					= (parseInt(object_ref.offsetTop) + parseInt(object_ref.offsetHeight)) + "px";
	div_msg_border_br.style.zIndex			= parseInt(iframe_fog.style.zIndex) + 1;

	div_msg_border_bl.style.left				= (parseInt(object_ref.offsetLeft) - CONST_SIDE) + "px";
	div_msg_border_bl.style.top					= (parseInt(object_ref.offsetTop) + parseInt(object_ref.offsetHeight)) + "px";
	div_msg_border_bl.style.zIndex			= parseInt(iframe_fog.style.zIndex) + 1;

	div_msg_border_side_b.style.left		= (parseInt(object_ref.offsetLeft)) + "px";
	div_msg_border_side_b.style.top			= (parseInt(object_ref.offsetTop) + parseInt(object_ref.offsetHeight)) + "px";
	div_msg_border_side_b.style.width		= (parseInt(object_ref.offsetWidth)) + "px";
	div_msg_border_side_b.style.zIndex	= parseInt(iframe_fog.style.zIndex) + 1;

	div_msg_border_side_l.style.height	= (parseInt(object_ref.offsetHeight)) + "px";
	div_msg_border_side_l.style.left		= (parseInt(object_ref.offsetLeft) - CONST_SIDE) + "px";
	div_msg_border_side_l.style.top			= (parseInt(object_ref.offsetTop)) + "px";
	div_msg_border_side_l.style.zIndex	= parseInt(iframe_fog.style.zIndex) + 1;

	div_msg_border_side_r.style.height	= (parseInt(object_ref.offsetHeight)) + "px";
	div_msg_border_side_r.style.left		= (parseInt(object_ref.offsetLeft) + parseInt(object_ref.offsetWidth)) + "px";
	div_msg_border_side_r.style.top			= (parseInt(object_ref.offsetTop)) + "px";
	div_msg_border_side_r.style.zIndex	= parseInt(iframe_fog.style.zIndex) + 1;

	div_msg_border_side_t.style.left		= (parseInt(object_ref.offsetLeft)) + "px";
	div_msg_border_side_t.style.top			= (parseInt(object_ref.offsetTop) - CONST_SIDE) + "px";
	div_msg_border_side_t.style.width		= (parseInt(object_ref.offsetWidth)) + "px";
	div_msg_border_side_t.style.zIndex	= parseInt(iframe_fog.style.zIndex) + 1;

	div_msg_border_tl.style.left				= (parseInt(object_ref.offsetLeft) - CONST_SIDE) + "px";
	div_msg_border_tl.style.top					= (parseInt(object_ref.offsetTop) - CONST_SIDE) + "px";
	div_msg_border_tl.style.zIndex			= parseInt(iframe_fog.style.zIndex) + 1;

	div_msg_border_tr.style.left				= (parseInt(object_ref.offsetLeft) + parseInt(object_ref.offsetWidth)) + "px";
	div_msg_border_tr.style.top					= (parseInt(object_ref.offsetTop) - CONST_SIDE) + "px";
	div_msg_border_tr.style.zIndex			= parseInt(iframe_fog.style.zIndex) + 1;

	return true;
}

/* pour faciliter la sélection ddes urls des médias, on stocke en javascript la sélection courante, et on la modifiera en fonction des choix utilisateur */
var msg_search_media_selection = "";
function msg_search_media(e, input_field, input_function, deactivate_fog, source)
{
	/* *************************************
	NAME :
		msg_search_media
	INPUT :
		e								=> event
		input_field			=> champ qui sera mis a jour apres validation de la fenetre
		input_function	=> fonction qui sera lancee apres validation de la fenetre
		deactivate_fog	=> true/false selon que l'on veuille ou non que la validation de la fenetre desactive le voile
		source					=> source à consulter (1=google image search,2=google video search, 3=Yahoo! Images search, 4=Yahoo! Vidéo, 6=mon ordinateur)
	OUTPUT :
		- (affiche une fenetre de recherche de media et met a jour le champ specifie)
	************************************* */

	/* si source==-1 on ne fait rien */
	if(parseInt(source)==-1){fog_manage(false);return false;};
	/* si source==0 on ouvre le gestionnaire de fichier */
	if(parseInt(source)==0)
	{
    msg_file("", input_field, "", true, "", "", false);
    return false;
  }
	/* si source==6 on ouvre le gestionnaire de fichier directement sur l'interface d'upload */
	if(parseInt(source)==6)
	{
    msg_file("", input_field, "", true, "", "", true);
    return false;
  }

	/* objet principal */
	var rnd											= String(Math.random());
	var div_prompt_search_media	= document.createElement("div");
	div_prompt_search_media.setAttribute("id", "div_prompt_search_media" + rnd);
	div_prompt_search_media.className = "css_msg";

	/* contenu personnalise */
	var tmp_string	= "";
	tmp_string			+= "<table cellspacing='0'>";
	tmp_string			+= "<tr><td class='css_form_label_left'>";
	tmp_string			+= "<iframe id='iframe_prompt_search_media" + rnd + "' src='" + include_path + "/php/assistant-search-media.php?source=" + source + "' class='css_search_media_param' frameborder='0' scrolling='no'></iframe>";
	tmp_string			+= "</td></tr>";
	tmp_string			+= "<tr>";
	tmp_string			+= "<td class='css_form_label_input'>";
	tmp_string			+= "<input type='button' id='input_prompt_search_media_ok" + rnd + "' class='css_form_button' value=\"" + language_msg("00001") + "\"/>";
	tmp_string			+= "<input type='button' id='input_prompt_search_media_cancel" + rnd + "' class='css_form_button' value=\"" + language_msg("00002") + "\"/>";
	tmp_string			+= "</td>";
	tmp_string			+= "</tr>";
	tmp_string			+= "</table>";
	div_prompt_search_media.innerHTML = tmp_string;
	document.body.appendChild(div_prompt_search_media);

	/* initialisation de la variable avec les valeurs déjà sélectionnées */
	msg_search_media_selection = "";
	if (input_field != "")
		msg_search_media_selection = document.getElementById(input_field).value;

	/* boutons */
	document.getElementById("input_prompt_search_media_ok" + rnd).onclick	= function(){
		if (input_field != "")
		{
			/* recuperation de la selection */
			var iframe						= document.getElementById("iframe_prompt_search_media" + rnd);
			var iframe_assistant	= iframe.contentWindow.document;
			var ml								= iframe_assistant.getElementsByName("urls_media_copy");
			var tmp_sep = (msg_search_media_selection == "" ||msg_search_media_selection == "\n")? "" : "\n";

			var tmp_string				= msg_search_media_selection + tmp_sep + (ml[0].value).substr(0, (ml[0].value).length - 1)

			/* suppression de l'image par défaut le cas échéant */
			tmp_string						= tmp_string.replace("../img/img-defaut.jpg\n", "");

			if(ml[0]) document.getElementById(input_field).value = tmp_string;

			/* lancement de l'evenement "onchange" sur le champ appelant */
			if (document.getElementById(input_field).onchange)
				document.getElementById(input_field).onchange();
		}
		document.body.removeChild(document.getElementById("div_prompt_search_media" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(true)");
	};

	  document.getElementById("input_prompt_search_media_cancel" + rnd).onclick	= function(){
		document.body.removeChild(document.getElementById("div_prompt_search_media" + rnd));
		msg_border_remove(rnd);
		if (deactivate_fog)				fog_manage(false);
		if (input_function != "")	eval(input_function + "(false)");
	};

	  /* gestion de la touche "escape" */
	  key_manage_escape = function(e){
		document.getElementById("input_prompt_search_media_cancel" + rnd).click();
	};

	/* affichage */
	msg_display(e, div_prompt_search_media, 3, rnd, false);
}

