
function subm(champ, sub, doc_verif, doc_enreg, path_recherche )
{
    with (champ.form )
    {
         if (sub =='ok' && window.document.soumettre == 1)
         {
            action="../enreg/"+doc_enreg;
			method="post";
            submit();
         }
         else if (sub =='no')
         {
              action=doc_verif;
              submit();
         }
         else if (sub == 'menu')
         {
             if (confirm('Etes-vous s\u00FBr de vouloir abandonner la saisie ?') == true)
             {
                 document.location=path_recherche+'connect.php';
             }
         }
    }
}

function effacer_donnees(champ,doc_enreg)
{
	with (champ.form)
	{
		window.document.soumettre = 1;
    	msg= "ATTENTION !\n";
		msg+= "Si vous avez apporté des modifications à cette page depuis la dernière validation\n";
		msg+="celles-ci ne seront pas enregistrées si vous ne les avez pas \'Re-Valider\' !\n";
     	msg+="Elles vont donc etre éffacées de la page.\n";
		msg+="Etes vous s\u00FBr de vouloir continuer ?" ;
     	if ( confirm(msg) == true)
     	{
			reset();
	 	}
	 	else
	 	{
			window.document.soumettre = 0;
	 	}
		var nav = navigator.appName.charAt(0);
		if (nav=="N" ) 
  		{
			//Netscape, on ne fait rien on fera tout dans subm
  		}
  		else if (nav=="M" ) 
  		{
			//IE
         	if (window.document.soumettre == 1)
         	{
				// on lance l'action car l'evenement onClick est incompris
            	action="../enreg/"+doc_enreg;
				method="post";
            	submit();
				window.document.soumettre = 0;
         	}
  		}	
	} 
}

//NE PAS DEPLACER CES FONCTIONS!

function MM_swapImgRestore() 
{ 
//v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() 
{ 
//v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) 
{ 
//v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() 
{ 
//v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function test_ordre_remplissage_select(champ, champ1, champ2, champ3, champ4,nom)
{
         with( champ.form )
         {
     		   if ((champ == champ1 )&&(champ1.selectedIndex == "" || champ1.selectedIndex == 0) 
					&& ( champ2.selectedIndex != "" || champ3.selectedIndex != "" || champ4.selectedIndex != "") )
               {
                  champ2.selectedIndex = 0 ;
   				  champ3.selectedIndex = 0 ;
				  champ4.selectedIndex = 0 ;
				  return -1;
               }
	   		   if ((champ == champ2 )&&(champ2.selectedIndex == "" || champ2.selectedIndex == 0) 
					&& ( champ3.selectedIndex != "" || champ4.selectedIndex != "" ) )
               {
   				  champ3.selectedIndex = 0 ;
				  champ4.selectedIndex = 0 ;
				  return -1;
               }
   			   if ((champ == champ3 )&&(champ3.selectedIndex == "" || champ3.selectedIndex == 0) 
					&& ( champ4.selectedIndex != "" ) )
               {
				  champ4.selectedIndex = 0 ;
				  return -1;
               }
			   if ((champ == champ2 )&&(champ1.selectedIndex == ""))
               {
                  alert('Veuillez renseigner d\'abord '+nom+' 1 ') ;
                  champ2.selectedIndex = 0 ;
				  return -1;
               }
               else if ((champ==champ3)&&(champ2.selectedIndex==""))
               {
                   alert('Veuillez renseigner d\'abord '+nom+' 2 ') ;
                   champ3.selectedIndex=0 ;
 				   return -1;
               }
               else if ((champ==champ4)&&(champ3.selectedIndex==""))
               {
                    alert('Veuillez renseigner d\'abord '+nom+' 3 ') ;
                    champ4.selectedIndex=0 ;
					return -1;
               }
			   return 0;
         }
}



function test_ordre_remplissage_et_valeur_identique_select(champ, champ1, champ2, champ3, champ4,nom)
{
	res = test_ordre_remplissage_select(champ, champ1, champ2, champ3, champ4,nom);
	if ( res == 0 )
	{
   		with( champ.form )
        {
  			if ( champ == champ1  && champ1.selectedIndex != "" 
			 	&& (   champ1.selectedIndex == champ2.selectedIndex
				 || champ1.selectedIndex == champ3.selectedIndex
				 ||	champ1.selectedIndex == champ4.selectedIndex ) )
        	{
                  alert('Deux valeurs pour le parametre '+nom+' sont égales ') ;
                  champ1.selectedIndex = 0;
				  return -1;
        	}
			if ( champ == champ2  && champ2.selectedIndex != "" 
			 	&& (   champ2.selectedIndex == champ1.selectedIndex
				 || champ2.selectedIndex == champ3.selectedIndex
				 ||	champ2.selectedIndex == champ4.selectedIndex ) )
        	{
                  alert('Deux valeurs pour le parametre '+nom+' sont égales ') ;
                  champ2.selectedIndex = 0;
				  return -1;
        	}
       	 	else if (champ == champ3  && champ3.selectedIndex != "" 
				     && (   champ3.selectedIndex == champ1.selectedIndex
				 || champ3.selectedIndex == champ2.selectedIndex
				 ||	champ3.selectedIndex == champ4.selectedIndex ))
        	{
                  alert('Deux valeurs pour le parametre '+nom+' sont égales ') ;
                  champ3.selectedIndex = 0;
				  return -1;
        	}
        	else if (champ == champ4  && champ4.selectedIndex != "" 
			      	&& (   champ4.selectedIndex == champ1.selectedIndex
				 || champ4.selectedIndex == champ2.selectedIndex
				 ||	champ4.selectedIndex == champ3.selectedIndex ))
        	{
                   alert('Deux valeurs pour le parametre '+nom+' sont égales ') ;
                  champ4.selectedIndex = 0;
				  return -1;
        	}
		}
	}
	return 0;
}

function test_ordre_remplissage_text(champ, champ1, champ2, champ3, champ4,nom)
{
         with( champ.form )
         {
			   if ((champ == champ1 )&&(champ1.value == "") 
					&& ( champ2.value != "" || champ3.value != "" || champ4.value != "") )
               {
                  champ2.value = "" ;
   				  champ3.value = "" ;
				  champ4.value = "" ;
				  return -1;
               }
	   		   if ((champ == champ2 )&&(champ2.value == "") 
					&& ( champ3.value != "" || champ4.value != "" ) )
               {
   				  champ3.value = "" ;
				  champ4.value = "" ;
				  return -1;
               }
   			   if ((champ == champ3 )&&(champ3.value == "") 
					&& ( champ4.value != "" ) )
               {
				  champ4.value = "" ;
				  return -1;
               }
               if ((champ == champ2 )&&(champ1.value == ""))
               {
                  alert('Veuillez renseigner d\'abord '+nom+' 1 ') ;
                  champ2.value = "" ;
                  champ1.focus();
				  return -1;
               }
               else if ((champ==champ3)&&(champ2.value==""))
               {
                   alert('Veuillez renseigner d\'abord '+nom+' 2 ') ;
                   champ3.value="" ;
                   champ2.focus();
 				   return -1;
               }
               else if ((champ==champ4)&&(champ3.value==""))
               {
                    alert('Veuillez renseigner d\'abord '+nom+' 3 ') ;
                    champ4.value="" ;
                    champ3.focus();
					return -1;
               }
			   return 0;
         }
}

function test_ordre_remplissage_text_nom(champ, champ1, champ2, champ3, champ4,nom)
{
         with( champ.form )
         {
			   if ((champ == champ1 )&&(champ1.value == "") 
					&& ( champ2.value != "" || champ3.value != "" || champ4.value != "") )
               {
                  champ2.value = "" ;
   				  champ3.value = "" ;
				  champ4.value = "" ;
				  return -1;
               }
	   		   if ((champ == champ2 )&&(champ2.value == "") 
					&& ( champ3.value != "" || champ4.value != "" ) )
               {
   				  champ3.value = "" ;
				  champ4.value = "" ;
				  return -1;
               }
   			   if ((champ == champ3 )&&(champ3.value == "") 
					&& ( champ4.value != "" ) )
               {
				  champ4.value = "" ;
				  return -1;
               }
               if ((champ == champ2 )&&(champ1.value == ""))
               {
                  alert('Veuillez renseigner d\'abord '+nom) ;
                  champ2.value = "" ;
				  return -1;
               }
               else if ((champ==champ3)&&(champ2.value==""))
               {
                   alert('Veuillez renseigner d\'abord '+nom) ;
                   champ3.value="" ;
 				   return -1;
               }
               else if ((champ==champ4)&&(champ3.value==""))
               {
                    alert('Veuillez renseigner d\'abord '+nom) ;
                    champ4.value="" ;
					return -1;
               }
			   return 0;
         }
}


function test_ordre_remplissage_et_valeur_identique_text(champ, champ1, champ2, champ3, champ4,nom)
{
	res = test_ordre_remplissage_text_nom(champ, champ1, champ2, champ3, champ4,nom);
	if ( res == 0 )
	{
   		with( champ.form )
        {
  			if ( champ == champ1  && champ1.value != "" 
			 	&& (   champ1.value == champ2.value
				 || champ1.value == champ3.value
				 ||	champ1.value == champ4.value ) )
        	{
                  alert('Deux valeurs pour le parametre '+nom+' sont égales ') ;
                  champ1.value = '';
				  return -1;
        	}
			if ( champ == champ2  && champ2.value != "" 
			 	&& (   champ2.value == champ1.value
				 || champ2.value == champ3.value
				 ||	champ2.value == champ4.value ) )
        	{
                  alert('Deux valeurs pour le parametre '+nom+' sont égales ') ;
                  champ2.value = '';
				  return -1;
        	}
       	 	else if (champ == champ3  && champ3.value != "" 
				     && (   champ3.value == champ1.value
				 || champ3.value == champ2.value
				 ||	champ3.value == champ4.value ))
        	{
                  alert('Deux valeurs pour le parametre '+nom+' sont égales ') ;
                  champ3.value = '';
				  return -1;
        	}
        	else if (champ == champ4  && champ4.value != "" 
			      	&& (   champ4.value == champ1.value
				 || champ4.value == champ2.value
				 ||	champ4.value == champ3.value ))
        	{
                   alert('Deux valeurs pour le parametre '+nom+' sont égales ') ;
                  champ4.value = '';
				  return -1;
        	}
		}
	}
	return 0;
}




