  
  // vérifie si la touche envoyée est un chiffre
  function isNumberKey(evt)
  {
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57) && !(charCode == 37 || charCode == 39)) {
        return false;
    }
    return true;
  }
  
  // ouverture popup
  function openPP(urlPP, largPP, hautPP)
  {        
    var xx = ((screen.width - largPP) / 2);
    var yy = ((screen.height - hautPP) / 2);
    
    this.open(urlPP, 'script', 
                 'top='+yy+', left='+xx+', height='+hautPP+',width='+largPP+', toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes');     
  }

  
  // maj vignette ampoule visibilité rubrique
  function rubrique_update_visible_vignette(nom, statut, chemin)
  {     
     if (statut == 0)
       MM_findObj(nom).src = chemin + "images/light_24_off.gif";
     else if (statut == 1)
       MM_findObj(nom).src = chemin + "images/light_24_on.gif";     
  }

  // maj d'une image
  function update_picture(nom, image)
  {     
    MM_findObj(nom).src = image;
  }
  

  // Gere les formulaires de recherche
  function rechercher(rechercher_depuis,recherche_order_by)
  {
  	if (recherche_order_by=='' || recherche_order_by=="undefined")
  	{ 
  		document.formulaire.recherche_order_by.value='';
  	}
  	else
  	{
  		document.formulaire.recherche_order_by.value=recherche_order_by;
  	}
  	document.formulaire.rechercher_depuis.value=rechercher_depuis;	
  	document.formulaire.submit();
  }

  // Gere les formulaires de recherche
  function rechercherBackOffice(rechercher_depuis,recherche_order_by,nomForm)
  {
  	if (recherche_order_by=='' || recherche_order_by=="undefined")
  	{ 
  		document.forms[nomForm].recherche_order_by.value='';
  	}
  	else
  	{
  		document.forms[nomForm].recherche_order_by.value=recherche_order_by;
  	}
  	document.forms[nomForm].rechercher_depuis.value=rechercher_depuis;	
  	document.forms[nomForm].submit();
  }
  
  // focus sur le champs login du formulaire de connexion
  function LoginFocus() 
	{
		document.formulaire.login.select();
		document.formulaire.login.focus();
	}

	
  // GENERAL : sélection de tous les checkbox  
  function checkAllCB(form, namePrefix, checkAll)
  {
    if (typeof checkAll == "undefined") checkAll = true;
    for (i = 0; i < form.elements.length; i++)
    {
      e = form.elements[i];
      if (e.name.slice(0, namePrefix.length) == namePrefix)
      {
        e.checked = checkAll;
      }
    }
  }

  
  // met a jour le contenu d'un div
  function SetDiv(ID,Content) {  
      document.getElementById(ID).innerHTML = Content;
      return;
   }
   

  // DREAMWEAVER
  
  function MM_showHideLayers() { //v3.0
    var i,p,v,obj,args=MM_showHideLayers.arguments;
    for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
      if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
      obj.visibility=v; }
  }  
  
  function MM_reloadPage(init) {  //reloads the window if Nav4 resized
    if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
      document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
    else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
  }
  MM_reloadPage(true);
  
  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_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;
  }
  
    // méthode dw de recherche d'obj à partir de son id/nom
  function MM_findObj(n, d) { //v4.01
    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);
    if(!x && d.getElementById) x=d.getElementById(n); 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];}
  }
  
  // GENERAL : submit touche enter
  function submitenter(myfield,e)
  {
    var keycode;
    if (window.event)
    keycode = window.event.keyCode;
    else if (e)
    keycode = e.which;
    else
    return true;
  
    if (keycode == 13)
    {
      myfield.form.submit();
      return false;
    }
      else
      return true;
  }
  
  function afficherPopupLayer ( parent , enfant , tblChampSelect )
  {
		
	  var myWidth = 0, myHeight = 0;
	  if( typeof( window.innerWidth ) == 'number' ) {
	    //Non-IE
	    myWidth = window.innerWidth;
	    myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
	    myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
	    myHeight = document.body.clientHeight;
	  }

		if( tblChampSelect.constructor == Array )
		{
			for (var i=0; i < tblChampSelect.length; ++i)
			{
				var item = tblChampSelect[i];
				document.getElementById(tblChampSelect[i]).style.visibility = "hidden";
			}
		}

  	document.getElementById(parent).style.width      = myWidth + 'px';
  	document.getElementById(parent).style.height     = myHeight + 'px';
		document.getElementById(parent).style.visibility = "visible";
		document.getElementById(parent).style.display    = "block";
		
  	document.getElementById(enfant).style.width      = myWidth/2 + 'px';
  	document.getElementById(enfant).style.height     = myHeight/2 + 'px';
  	document.getElementById(enfant).style.left     	= myWidth/4 + 'px';
  	document.getElementById(enfant).style.top     	= myHeight/4 + 'px';
		document.getElementById(enfant).style.visibility = "visible";
		document.getElementById(enfant).style.display    = "block";
  }

  function masquerPopupLayer ( parent , enfant , tblChampSelect)
  {
		if( tblChampSelect.constructor == Array )
		{
			for (var i=0; i < tblChampSelect.length; ++i)
			{
				var item = tblChampSelect[i];
				document.getElementById(tblChampSelect[i]).style.visibility = "visible";
			}
		}

		document.getElementById(parent).style.visibility = "hidden";
		document.getElementById(parent).style.display    = "none";
		document.getElementById(enfant).style.visibility = "hidden";
		document.getElementById(enfant).style.display    = "none";
  }
  
  // Fonction de stockage des scripts à charger
  FuncOL = new Array();
	function StkFunc(Obj)
	{
		FuncOL[FuncOL.length] = Obj;
	}
				
	// Execution des scripts au chargement de la page
	window.onload = function() 
	{
		for(i=0; i<FuncOL.length; i++)
			{FuncOL[i]();}
	}
	
	
// OVERTRAIL
var OverTrailHeight, OverTrailWidth;

function OverTrail(html,width,height,padding) 
{
	OverTrailWidth = width+padding*2+2;
	OverTrailHeight = height+padding*2+2;
	ObjTrail = document.getElementById("overtrail");
	ObjTrail.style.width = (document.all?OverTrailWidth:width)+"px";
	ObjTrail.style.padding = padding+"px";
	ObjTrail.innerHTML = html;
	document.onmousemove = FollowMouse;
}

function OverTrail_Img(imagename,width,height) { OverTrail('<img src="' + imagename + '" border="0" style="display: block;">',width,height,5); }
function OverTrail_Txt(html,width,height) { OverTrail(html,width,height,5); }
function HideTrail() {
	document.getElementById("overtrail").style.visibility="hidden";
	document.onmousemove="";
}

function FollowMouse(e) {
	x=15, y=15;
	xmax=document.all? document.body.clientWidth+document.body.scrollLeft : window.innerWidth+window.pageXOffset-15;
	ymax=document.all? document.body.clientHeight+document.body.scrollTop : window.innerHeight+window.pageYOffset-15;
	if (typeof e != "undefined") {
		x+=e.pageX; y+=e.pageY;
	} else if (typeof window.event !="undefined") {
		x+=document.body.scrollLeft+event.clientX; y+=document.body.scrollTop+event.clientY;
	}
	if (x+OverTrailWidth>xmax) x=x-OverTrailWidth-30;
	if (y+OverTrailHeight>ymax) y=y-OverTrailHeight-15;
	document.getElementById("overtrail").style.left=x+"px";
	document.getElementById("overtrail").style.top=y+"px";
	document.getElementById("overtrail").style.visibility="visible";
}	
  