<!--
//      -*- coding: utf-8 -*-
function showhideText(box,id)  
{ 
 var elm = document.getElementById(id)
 elm.style.display = box.checked? "inline":"none"
}



function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}



function showhideMenu(id)
{
	var d = document.getElementById(id);
	if (d) {
		if (d.style.display=="none") {
			d.style.display="block";
		} else {
			d.style.display="none";
		}
	}
}

function showNoneMenu(nb)
{
	for (i=0; i<= nb; i++) 
	{
		var d = document.getElementById('menu_numero_' + i);
		if (d) {
			if (d.style.display=="block") {
				d.style.display="none";
			}
		}
	}
}
function showAllMenu(nb)
{
	for (i=0; i<= nb; i++) 
	{
		var d = document.getElementById('menu_numero_' + i);
		if (d) {
			if (d.style.display=="none") {
				d.style.display="block";
			}
		}
	}
}


//Fonction d'activation/desactivation d'éléments
function activ() 
{
	var args=activ.arguments;
   
	for (i=0; i<(args.length); i++) 
	{
		if (document.getElementById(args[i]).disabled == true)
			document.getElementById(args[i]).disabled = false;
		else
			document.getElementById(args[i]).disabled = true;
	}
}



//Fontion sur les touches pressées
function codeTouche(evenement)
{
        for (prop in evenement)
        {
                if(prop == 'which') return(evenement.which);
        }
        return(evenement.keyCode);
}

function scanTouche(evenement, expression)
{
        //var reCarValides = /\w/;
        var reCarValides = expression;

        var codeDecimal  = codeTouche(evenement);
        var car = String.fromCharCode(codeDecimal);
        
		if (codeTouche(evenement) != 8 && codeTouche(evenement) != 0)
			var autorisation = reCarValides.test(car);
		else
			var autorisation = true;

        return autorisation;
}

//Bridage du nombre de caractères dans un textarea
function limitcar(texte, nb, maxi) {
 if (texte.value.length > maxi)
   texte.value = texte.value.substring(0, maxi);
 else 
   nb.value = maxi - texte.value.length;
}

function storeCaret(text)
{ // voided
}

function AddText(startTag,defaultText,endTag,champ) 
{
 if (champ.createTextRange) 
 {
  var text;
  champ.focus(champ.caretPos);
  champ.caretPos = document.selection.createRange().duplicate();
  if(champ.caretPos.text.length>0)
  {
   champ.caretPos.text = startTag + champ.caretPos.text + endTag;
  }
  else
  {
   champ.caretPos.text = startTag+defaultText+endTag;
  }
 }
 else champ.value += startTag+defaultText+endTag;
}

function confirmSuppression(nomform, chk)
{
	var t=0;
	var c=nomform[chk+'[]'];
	var cpt=c.length;
	for(var i=0;i<c.length;i++)
	{
		c[i].checked?t++:null;
	}
	if (t > 0)
	{
		if (t == 1)
			question = 'Êtes-vous sur de vouloir supprimer l\'enregistrement ?'
		else
			question = 'Êtes-vous sur de vouloir supprimer ces '+t+' enregistrements ?'

		if (confirm(question))
		{
			nomform.submit();
		}
	}
}
-->
