function confirmErase()	
{	
   if (confirm("Etes vous sûr de vouloir supprimer cet enregistrement?"))
        return(true);
   return(false);
}

function EnvoiForm()
{document.form.submit();}

function checkNull(obj,msg){
  if(obj.value==''){
    alert(msg);
    obj.focus();
    return false;
  }
  return true;
}

function checkSelect(obj,msg){
  if(obj.options[0].selected){
    alert(msg);
    obj.focus();
    return false;
  }
  return true;
}


function checkVal(obj,typeMasque,msg)  //type de masque : Numeric ou Decimal ou Alphanumeric
{ 
  var text;
  var cpt;
  text=obj.value;
  cpt=0;
  if (typeMasque=="Numeric")
  {
   masque="0123456789";
  }
  else if (typeMasque=="Decimal")
  {
   masque="0123456789.,";
  }
  else if (typeMasque=="Alphanumeric")
  {
   masque="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  }  
  var car; 
  var booleen = true;
  for (var i=0;i<text.length;i++)
  {
   if(booleen)
              { 
    		car=text.charAt(i);
               /* if ( (typeMasque=="Decimal") && (car=='.' || car==',') )
                {
                 cpt=cpt+1;
                 
                }*/
                booleen=(masque.indexOf(car) != -1);
              }
  }
 if (cpt>1)
 {booleen=false;}
 
 if(booleen==false)
 {obj.focus();
  alert(msg);}
 
  return booleen;
}


function checkDate(obj,msg) {
	var DateData;
	DateData= obj.value;
	correct = true;
	if (DateData!='' && DateData!=' ' && DateData!='  ' && DateData!='   ' && DateData!='    ')
	{
	  if ( (DateData.length < 11) && (DateData.length > 7) ) {
	    if (DateData.substring(2,3)=="/" && DateData.substring(5,6)=="/"){
	  	j = DateData.substring(0,2);
		m = DateData.substring(3,5);
		a = DateData.substring(6,DateData.length);
		bi = ((parseInt(a) % 4) == 0);


		if (((m == "01")||(m == "03")||(m == "05")||(m == "07")||(m == "08")||(m == "10")||(m == "12"))&&((Math.round(j)>=1)&&(Math.round(j)<=31))){
			correct = true;
		}
		else {
			if (((m == "04")||(m == "06")||(m == "09")||(m == "11"))&&((Math.round(j)>=1)&&(Math.round(j)<=30))){
				correct = true;
			}
			else {
				if (bi){correct=(((Math.round(j)>=1) && (Math.round(j)<=29)) && (m=="02"));}
				else   {correct=(((Math.round(j)>=1) && (Math.round(j)<=28)) && (m=="02"));}
			}
		}
	    }
	    else
	    {correct = false;}
	  }
	  else {  
	  	correct = false;
	  }
          if (correct==false)
          {alert(msg);}
	  return correct;
	}
	else
	{
	 return correct;
	}
}

function FormatteDate(chaine,ZoneDate,NomForm,cache)
{
  var position;
  var positionOLD;	
  position=chaine.length;
  positionOLD=cache.value;
  if(positionOLD<position)
  {
    if(chaine.length=='2')
    {
      ZoneDate.value=chaine+"/";
      position=position+1;
    }
    if(chaine.length=='5')
    {
      ZoneDate.value=chaine+"/";
      position=position+1;
    }
  }
  positionOLD=position;
  cache.value=positionOLD;
}

function alertMsg(msg,obj){
    alert('vous avez une erreur de saisie'+msg);
    obj.focus();
}

function checkText(f)
{
  var txt=f.texte.value;
  var nb=txt.length;
  if (nb>max) {
    alert("Pas plus de "+max+" caractères dans ce champ");
    f.texte.value=txt.substring(0,max);
    nb=max;
  }
  f.nbcar.value=nb+1;
}

