/*
## Avec IE , vous devez inclure lapel de la fonction en dessous du DIV souhaité
## Syntax --> getErr()"nom-du-div","nom-de-lerreur-du-fichier"
*/


function getErr(id,erreur)
{
var xhr_object = null;
var position = id;
var ker = erreur;

var xhr_object;
		try
		  {
		  // Firefox, Opera 8.0+, Safari
		  xhr_object=new XMLHttpRequest();
		  }
		catch (e)
		  {
		  // Internet Explorer
		  try
		    {
		    xhr_object=new ActiveXObject("Msxml2.XMLHTTP");
		    }
		  catch (e)
		    {
		    try
		      {
		      xhr_object=new ActiveXObject("Microsoft.XMLHTTP");
		      }
		    catch (e)
		      {
		      alert("Your browser does not support AJAX!");
		      }
		    }
		  }
          
          xhr_object.open("GET","JSON/erreur.json",true);
		  //xhr_object.setRequestHeader('Content-Type','application/json;charset=iso-8859-1')
          xhr_object.onreadystatechange=function() { traitementJSON(xhr_object,position,erreur) };
		  xhr_object.send(null);
		  }
		  
		  
	function traitementJSON(xhr_object,position,erreur)
               {
			   
                   if (xhr_object.readyState == 4)
                              {
 
									  
									   
									   //r donnees = xhr_object.responseText
									   var repl = xhr_object.responseText;

									   var donnees = eval("(" + repl + ")");

												var parse = eval('donnees.' + erreur);
                                                   getID("erreur").innerHTML = parse;

												
												
												}
												}
												
												
	function validateForm(theForm)
{
	// champ numerique
	// parametre - form.champ, description du champ, champ requis(true ou false)
if ( theForm.txtID.value == "" && theForm.txtRBQID.value == "" )
	{
	getErr('erreur' , 'noval');
	return false;	
	}
if ( theForm.txtID.value != "" && theForm.txtRBQID.value != "" )
	{
	getErr('erreur' , 'both');
    return false;	
	}
	document.frmFicheWebDirect.submit();
  return true;
}

   function getID(id) {  
   document._getElementById = document.getElementById;
        var a = [];  
        var o = document._getElementById(id);  
        if (!o) return o;  
        while (o.id != id) {  
          a.push({i:o.id,e:o});  
         o.id='';  
         o = document._getElementById(id);  
         if (!o) return o;  
    }  
     for (j=0,jj=a.length; j<jj; j++) a[j].e.id = a[j].i;  
     a = null;  
     return o;  
	 
 } 



 
		