/****************************************
Buttons.js
Affichage des boutons d'actions
Site web Perval 2006
Auteur : E. Martin
*****************************************/


function displayBtn(type, action, path, label, title, isBold, formName)

/*	Cette fonction affiche un bouton d'action cliquable sous la forme d'un tableau HTML
conforme à la charte web Perval 2006.

Paramètres :
- type :		0 = bouton inactif (fond grisé)
				1 = bouton de navigation "action" (fond bleu)
				2 = bouton de navigation "retour" (fond bleu clair)
				3 = bouton de navigation "action payante" (fond vert)
				4 = bouton "Voir plan" (fond orange)
- action :		Action à effectuer (paramètre PHP)
- path :		Chemin (paramètre PHP)
- label :		Libellé du bouton
- title :		Paramètre "title" du lien hypertexte = message bulle d'aide
- isBold :		Si == true, le libellé est affiché en gras
- formName :	Si != "", les champs obligatoires du formulaire portant ce nom
				doivent être vérifiés non vides (plusieurs noms de formulaires
				peuvent être spécifiés ici séparés par des tirets).
*/

{
	var classPrefix = "btn" + type;
	var imgPrefix = "Btn" + type + "_";
	var boldOpenTag = "";
	var boldCloseTag = "";
	var titleParam = "";
	var url = "javascript:";
	
	if (formName != "")
		url += "checkForm('" + formName + "', '" + action + "', '" + path + "');";
	else
	{
		if (action == "reset")
			url += "document.forms[0].reset();";
		else if (action == "back")
			url += "history.go(-1);";
		else if (action == "backback")
			url += "history.go(-2);";
		else if (action == "mySubmit")
			url += "mySubmit();";
		else if (action == "mySubmit2")
			url += "mySubmit2();";
		else
		{
			url += "document.forms[0].action.value = '" + action + "';";
			if (path != "")
				url += "document.forms[0].path.value = '" + path + "';";
			url += "document.forms[0].target = '_self';"
			url += "document.forms[0].submit();";
		}
	}
	
	if (isBold)
	{
		boldOpenTag = "<strong>";
		boldCloseTag = "</strong>";
	}
	
	if (title != "")
		titleParam = ' title="' + title + '"';

	
	document.write('<table cellspacing="0" cellpadding="0" border="0">\r\n<tr>\r\n');
	document.write('\t<td><img src="/img/' + imgPrefix + 'HG.gif" width="8" height="8" border="0" alt="" /></td>\r\n');
	document.write('\t<td class="' + classPrefix + 'H"><img src="/img/Blank.gif" width="1" height="8" border="0" alt="" /></td>\r\n');
	document.write('\t<td><img src="/img/' + imgPrefix + 'HD.gif" width="10" height="8" border="0" alt="" /></td>\r\n</tr>\r\n');
	
	document.write('<tr>\r\n\t<td class="' + classPrefix + 'G"><img src="/img/Blank.gif" width="8" height="1" border="0" alt="" /></td>\r\n');
	if (type == '0')	/*	Bouton inactif	*/
		document.write('\t<td class="' + classPrefix + '"' + titleParam + '>' + boldOpenTag + label + boldCloseTag + '</td>\r\n');
	else			/*	Bouton actif	*/
		document.write('\t<td class="' + classPrefix + '">' + boldOpenTag + '<a href="' + url + '" class="btnLink"' + titleParam + '>' + label + '</a>' + boldCloseTag + '</td>\r\n');
	
	document.write('\t<td class="' + classPrefix + 'D"><img src="/img/Blank.gif" width="10" height="1" border="0" alt="" /></td>\r\n</tr>\r\n');

	document.write('\t<td><img src="/img/' + imgPrefix + 'BG.gif" width="8" height="10" border="0" alt="" /></td>\r\n');
	document.write('\t<td class="' + classPrefix + 'B"><img src="/img/Blank.gif" width="1" height="10" border="0" alt="" /></td>\r\n');
	document.write('\t<td><img src="/img/' + imgPrefix + 'BD.gif" width="10" height="10" border="0" alt="" /></td>\r\n</tr>\r\n</table>\r\n');
}
