
function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}

function	addval(valeur)
{
if (valeur.checked) {return(valeur.value);} else {return(-1);}
}

function	getVal(valeur)
{
    var		tmp = "";
    var		i;

    for (i = 0;i < valeur.length; i++)
	{
	    if (valeur[i].checked)
		{
		    tmp += " " + valeur[i].value;
		}
	}
    return (tmp);
}

function	GetXmlHttpObject()
{
    var		xmlHttp = null;

    try
	{
	    // Firefox, Opera 8.0+, Safari
	    xmlHttp = new XMLHttpRequest();
	}
    catch (e)
	{
	    //Internet Explorer
	    try
		{
		    xmlHttp = new ActiveXObject('msxml2.XMLHTTP');
		}
	    catch (e)
		{
		    xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
		}
	}
    return (xmlHttp);
}

function	reload_page()
{
    setTimeout("location.reload()", 2000);
}

function	replace_esper(content)
{
var tmp = "";

for (var i = 0; i < content.length; i++)
{
	tmp = tmp + content.charAt(i);
	if (content.charAt(i) == '&')
	{
		tmp = tmp.replace("&", "$1");
	}
}
return (tmp);
}

function	replace_retour(content)
{
var tmp = "";

for (var i = 0; i < content.length; i++)
{
	tmp = tmp + content.charAt(i);
	if (content.charAt(i) == '\n')
	{
		tmp = tmp.replace("\n", "$2");
	}
}
return (tmp);
}

function	replace_chariot(content)
{
var tmp = "";

for (var i = 0; i < content.length; i++)
{
	tmp = tmp + content.charAt(i);
	if (content.charAt(i) == '\r')
	{
		tmp = tmp.replace("\r", "$2");
	}
}
return (tmp);

}

function	replace_inverse_retour(content)
{
var tmp = "";

for (var i = 0; i < content.length; i++)
{
	tmp = tmp + content.charAt(i);
	if (content.charAt(i) == '<br>')
	{
		tmp = tmp.replace("<br>", "\n\r");
	}
}
return (tmp);

}

function	aff_other(input, champ)
{
	if (document.getElementById(champ).value == '-2')
	{
		    document.getElementById(input).style.visibility = 'visible';
	}
	else
	{
		    document.getElementById(input).style.visibility = 'hidden';	
	}
}

function redimImage(inImg, inMW, inMH)
{
  // Cette function recoit 3 parametres
  // inImg : Chemin relatif de l'image
  // inMW  : Largeur maximale
  // inMH   : Hauteur maximale
  var maxWidth = inMW;
  var maxHeight = inMH;
  // Declarations des variables "Nouvelle Taille"
  var dW = 0;
  var dH = 0;
  // Declaration d'un objet Image
  var oImg = new Image();
  // Affectation du chemin de l'image a l'objet
  oImg.src = inImg;
  // On recupere les tailles reelles
  var h = dH = oImg.height;
  var w = dW = oImg.width;
  // Si la largeur ou la hauteur depasse la taille maximale
  if ((h >= maxHeight) || (w >= maxWidth)) {
    // Si la largeur et la hauteur depasse la taille maximale
    if ((h >= maxHeight) && (w >= maxWidth)) {
      // On cherche la plus grande valeur
      if (h > w) {
        dH = maxHeight;
        // On recalcule la taille proportionnellement
        dW = parseInt((w * dH) / h, 10);
      } else {
        dW = maxWidth;
        // On recalcule la taille proportionnellement
        dH = parseInt((h * dW) / w, 10);
      }
    } else if ((h > maxHeight) && (w < maxWidth)) {
      // Si la hauteur depasse la taille maximale
      dH = maxHeight;
        // On recalcule la taille proportionnellement
      dW = parseInt((w * dH) / h, 10);
    } else if ((h < maxHeight) && (w > maxWidth)) {
      // Si la largeur depasse la taille maximale
      dW = maxWidth;
        // On recalcule la taille proportionnellement
      dH = parseInt((h * dW) / w, 10);
    }
  }
  // On ecrit l'image dans le document
  document.writeln("<img src=\"" + inImg + "\" width=\"" + dW + "\" height=\"" + dH + "\" border=\"0\">");
};

function cacher_montrer() {
  j = document.getElementById('port');
  if (!j) { return; }
 if(document.getElementById('port').style.visibility == 'hidden')
 {
 setTimeout("document.getElementById('port').style.visibility = 'visible';",100);
 return;
 }
 if(document.getElementById('port').style.visibility == 'visible')
 {
 setTimeout("document.getElementById('port').style.visibility = 'hidden';",100);
 return;
 }

 }

