<!--

//*************************************************************/
// Affichage de l'heure					                                      */
//*************************************************************/


function AffHorloge()
{
	var d=new Date();
	var heure=d.getHours();
	var min=d.getMinutes();
	var sec=d.getSeconds();
	if (heure<10) heure="0"+heure;
	if (min<10) min="0"+min;
	if (sec<10) sec="0"+sec;
	document.getElementById("espacetemps").innerHTML=heure+":"+min+":"+sec;
	setTimeout("AffHorloge()",1000);
}

//*************************************************************/
// Insertion du BBCode                          					              */
//*************************************************************/

function insertion(repdeb, repfin)
{
  var input = document.forms['edition'].elements['contenu'];
  input.focus();
  /* pour l'Explorer Internet */
  if(typeof document.selection != 'undefined')
  {
    /* Insertion du code de formatage */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = repdeb + insText + repfin;
    /* Ajustement de la position du curseur */
    range = document.selection.createRange();
    if (insText.length == 0)
    {
      range.move('character', -repfin.length);
    }
    else
    {
      range.moveStart('character', repdeb.length + insText.length + repfin.length);
    }
    range.select();
  }
  /* pour navigateurs plus récents basés sur Gecko*/
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Insertion du code de formatage */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + repdeb + insText + repfin + input.value.substr(end);
    /* Ajustement de la position du curseur */
    var pos;
    if (insText.length == 0)
    {
      pos = start + repdeb.length;
    }
    else
    {
      pos = start + repdeb.length + insText.length + repfin.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* pour les autres navigateurs */
  else
  {
    /* requête de la position d'insertion */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos))
    {
      pos = prompt("Insertion à la position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length)
    {
      pos = input.value.length;
    }
    /* Insertion du code de formatage */
    var insText = prompt("Veuillez entrer le texte à formater:");
    input.value = input.value.substr(0, pos) + repdeb + insText + repfin + input.value.substr(pos);
  }
}

//*************************************************************/
// Ligne d'aide au BBCode                                     */
//*************************************************************/

function ligneaide(text)
{
  document.getElementById('aide').innerHTML = text;
}

//*************************************************************/
// Affichage de la carte en fonction du département                            */
//*************************************************************/

function enlight_dep(dep)
{
  document.getElementById('carte').innerHTML ='<img src="images/france/'+dep+'.gif" />';
}

//-->

//*************************************************************/
// BBcode tableau							                            */
//*************************************************************/

function tab(colonnes, lignes, width, border)
{
	var contenu_cellule='[table width='+width+' border='+border+']';
	for(i=1; i<=lignes; i++)
		{
		for(j=1; j<=colonnes; j++)
			{
			var numero_champ='l'+i+':c'+j;
			contenu_cellule=contenu_cellule+document.tableau.elements[numero_champ].value;
			if(j!=colonnes)
				{
				contenu_cellule+='[/fc]';
				}
			}
		if(i!=lignes)
			{
			contenu_cellule=contenu_cellule+'[/fl]';
			}
		}
	contenu_cellule=contenu_cellule+'[/table]';
	
	window.opener.document.forms['edition'].elements['contenu'].value+=contenu_cellule;
	window.close();
}

//***************************************************************/
// Confirmation											*/
//***************************************************************/

function confirmation(phrase, form)
	{
	var chaine='Etes-vous sur de vouloir '+phrase+' ?';
	if(confirm(chaine))
		{
		document.forms[form].submit();
		}
	}

//-->