function testSiren(siren)
{
  if( siren.length != 9 ) { document.F.SIREN.value="!9"; return false; }
  var tmp="";
  var num=0;
  for( var i=0; i<9; i++ )
   {
 if( (siren.charCodeAt(i)>="0".charCodeAt(0)) && (siren.charCodeAt(i)<="9".charCodeAt(0)) )
  num=siren.charCodeAt(i)-"0".charCodeAt(0);
 else
  { document.F.SIREN.value=i+" "+(siren.charCodeAt(i)-"0".charCodeAt(0)); return false; }
 tmp=tmp+(num*((i+1)%2==0?2:1));
 }
  var cumul=0;
  for( var i=0; i<(""+tmp.length); i++ )
   cumul+=(tmp.charCodeAt(i)-"0".charCodeAt(0));
 
  return (cumul%10==0);
}
 

function testSiret(siret)
{
  if( siret.length!=14 ) return false;
  var i=testSiren(siret.substring(0,9));
  if( i )
   return (!isNaN(siret.substring(9)));
  else return false;
}
