function Trim(TRIM_VALUE){
	if(!TRIM_VALUE || TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
}
function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;
	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	}
	return strTemp;
}
function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;
	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	}
	return strTemp;
}


function checkBrowser(){
			this.appName = navigator.appName;
            this.ver = navigator.appVersion
            this.dom = document.getElementById?1:0
            this.ie6 = (this.ver.indexOf("MSIE 6") > -1 && this.dom)?1:0;
    		this.ie55 = (this.ver.indexOf("MSIE 5.5") > -1 && this.dom)?1:0;
            this.ie5 = (this.ver.indexOf("MSIE 5") > -1 && this.dom)?1:0;
            this.ie4 = (document.all && !this.dom)?1:0;
            this.ns5 = (this.dom && parseInt(this.ver) >= 5) ?1:0;
            this.ns4 = (document.layers && !this.dom)?1:0;
            this.iw = window.innerWidth?1:0;
			this.IE = (this.appName.toLowerCase().indexOf("microsoft internet explorer") > -1)?true:false;
			this.netscape = (this.appName.toLowerCase().indexOf("netscape") > -1)?true:false;
			this.opera = (this.appName.toLowerCase().indexOf("opera") > -1)?true:false;
            this.bw = (this.ie5 || this.ie4 || this.ns4 || this.ns5 ||  this.ie55 || this.ie6)
            return this
}
var bw=new checkBrowser()
 
if (bw.ie4 || bw.ie5){
  LayerRef = ".all["
  StyleRef = "].style"
  LargeRef = "document.body.clientWidth"
  offset = ".offsetHeight"
  parenthese = "]"
}else{
  if (bw.dom){
    LayerRef = ".getElementById("
    StyleRef = ").style"
    if (bw.iw){
      LargeRef = "window.innerWidth"
    }else{
      LargeRef = "document.body.clientWidth"
    }
    offset = ".offsetHeight"
    parenthese = ")"
  }else{
    LayerRef = ".layers["
    StyleRef = "]"
    LargeRef = "window.innerWidth"
    offset = ".clip.height"
    parenthese = "]"
  }
}
//objet pour concatner une chane de faon optimale
function StringBuffer() {
this.__strings__ = new Array;
}

StringBuffer.prototype.append = function (str) {
this.__strings__.push(str);
}
StringBuffer.prototype.toString = function () {
return this.__strings__.join("");
}

//pour ajouter un item  un listbox
function addItemList(listbox,optionText,optionValue) {
    var optionObject = new Option(optionText,optionValue)
    var optionRank = listbox.options.length
    listbox.options[optionRank]=optionObject
}
//ajouter et affecter un champ cach  un formulaire
function addHiddenField(formulaire,nom,valeur){
	var hiddenField = document.createElement("input");
	hiddenField.setAttribute("type", "hidden");
	hiddenField.setAttribute("name", nom);
	hiddenField.setAttribute("value", valeur);
	formulaire.appendChild(hiddenField);
}

//objet servant  crer une suite de variables sous forme url formatte pour tre prette  poster
function UrlString(){
	this.__element__ = new Array();
}
UrlString.prototype.addElement = function(name,value){
	//si on dtecte une liste... le deuxime argument est alors facultatif
	
	if(name.type == "select-multiple"){//listbox multi select
		for(var t=0;t<name.options.length;t++){
			if(!name.options[t].selected)
				continue;
			this.__element__.push(name.name + "[]" + "=" + encodeURIComponent(name.options[t].value));
		}
		return;
	}else if(name.type == "select-one"){//listbox single select
		this.__element__.push(name.name + "=" + encodeURIComponent(name.options[name.selectedIndex].text));
		return;
	}else if(name.type == "checkbox"){
		if(name.checked){
			this.__element__.push(name.name + "=" + encodeURIComponent("on"));
			return;
		}
		this.__element__.push(name.name + "=" + encodeURIComponent("off"));
		return;
	}
	this.__element__.push(name + "=" + encodeURIComponent(value));
}

UrlString.prototype.getUrlString = function(){
	return this.__element__.join("&");
}
UrlString.prototype.count = function(){
	return this.__element__.length;	
}
UrlString.prototype.clearUrlString = function(){
	//on vide les lments du tableau de chaines
	this.__element__.splice(0,this.__element__.length);
}
var chaineURL = new UrlString();//sert  crer l'url pour passer les variables

//classe qui sert à envoyer des informations sur une page en post
function PostToAddress(adresse){
	this.adresse = adresse;
	this.nom = new Array();
	this.value = new Array();
	this.form = document.createElement("form");
	this.form.action = this.adresse;
	this.form.method="post";
	
}
PostToAddress.prototype.addHiddenField = function(nom,valeur){
	var hiddenField = document.createElement("input");
	hiddenField.setAttribute("type", "hidden");
	hiddenField.setAttribute("name", nom);
	hiddenField.setAttribute("value", valeur);
	this.form.appendChild(hiddenField);
}
PostToAddress.prototype.post = function(){
	document.documentElement.appendChild(this.form);
	this.form.submit();
}
//Description : Arrondi un nombre  2 chiffre aprs la virgule et ajoute les 0 manquant pour former un chiffre correct
//entre :
//		value: la valeur  arrondir
function arrondir(value){
	var chiffre = (Math.round(value*100))/100;
	var tabt = String(chiffre).split('.');
	if(tabt[1] == undefined)
	{
		chiffre += ".00";
	}
	else if(tabt[1].length == 1)
	{
		chiffre += "0";
	}
	return chiffre;
}
//Description : Retourne la valeur d'un input text
//entre :
//		name: le id du input text
function getValue(name)
{
	return document.getElementById(name).value;
}
/*
	son
*/
/*function VerifPlugIn(ExtensionFile)
  {
  var IsEnabled = true;
  if (navigator.appVersion.indexOf("MSIE")== -1)
    {
    IsEnabled = false;
    for(var x=0;(x<navigator.mimeTypes.length && !IsEnabled);x++)
      {
      if(navigator.mimeTypes[x].suffixes.indexOf(ExtensionFile)>=0)
      IsEnabled = navigator.mimeTypes[x].enabledPlugin;
      }
    }
    return IsEnabled;
  }

function PlaySound(MyName,MyExtension,MyLoop)
  {
  var AudioEnable = VerifPlugIn(MyExtension),TheLoop = '';
  if (navigator.appName == "Netscape" && MyLoop==1)     TheLoop='true';
  if (AudioEnable)     eval('document.'+MyName+'.play('+TheLoop+')');
  }

function StopSound(MyName,MyExtension)
  {
  var AudioEnable = VerifPlugIn(MyExtension);
  if (AudioEnable) eval('document.'+MyName+'.stop()');
  }*/
/*
//////////////////////////////////////////////////
//	ajout de fonctions  l'objet natif Array...//
/////////////////////////////////////////////////
Array.prototype.cloneThis = function(){
	var merde = new Array();
	for (i in this) {
        merde[i] = this[i];
    }
	return merde;
}
//ajout d'un vrificateur de doublons qui retourne l'index du tableau o il trouve un doublon
Array.prototype.doublonExist = function(){
	var thisArray = this.cloneThis();
	thisArray.sort();
	var previousValue;
	var doublonValue;
	var doublonFound = false;
	for(var t = 0; t < thisArray.length; t++){
		if(t != 0){
			//doublon trouv
			if(previousValue == thisArray[t]){
				doublonFound = true;
				break;
			}
		}
		previousValue = thisArray[t];
	 }
	//si un doublon est trouv, on retourne l'index
	if(doublonFound)
		return this.indexDe(previousValue)
	else
		return -1;
	
}

Array.prototype.indexDe = function(valeur){
	if(this.indexOf){
		return this.indexOf(valeur);
	}
	//internet explorer est trop cave pour comprendre indexOf sur un tableau
	for(var t=0;t<this.length;t++){
		if(this[t] == valeur)
			return t;
	}
	return -1;
}*/