//
// dateFormat v0.1 | 2004-04-03 15:10
//
// a : Ante meridiem et Post meridiem en minuscules - am ou pm 
// A : Ante meridiem et Post meridiem en majuscules - AM ou PM 
// B : Heure Internet Swatch - 000 � 999
//     http://www.quirksmode.org/index.html?/js/beat.html
// d : Jour du mois, sur deux chiffres avec z�ro initial - 01 � 31 
// D : Jour de la semaine, en 3 lettres, anglais par d�faut - Mon � Sun 
// F : Mois textuel, version longue, anglais par d�faut - January � December 
// g : Heure au format 12h, sans le z�ro initial - 1 � 12 
// G : Heure au format 24h, sans le z�ro initial - 0 � 23 
// h : Heure au format 12h, avec le z�ro initial - 01 � 12 
// H : Heure au format 24h, avec le z�ro initial - 00 � 23 
// i : Minutes avec le z�ro initial - 00 � 59 
// j : Jour du mois sans le z�ro initial - 1 � 31 
// l : Jour de la semaine, textuel, anglais par d�faut - Sunday � Saturday 
// L : L'ann�e est elle bissextile ? - 0 ou 1 
// m : Mois avec le z�ro intial - 01 � 12 
// M : Mois, en 3 lettres, anglais par d�faut - Jan � Dec 
// n : Mois sans le z�ro intial - 1 � 12 
// O : Diff�rence avec l'heure de Greenwich (GMT), en heures - -1200 � +1200 
// r : Format de date RFC 822 Thu, 1 Apr 2004 12:00:00 - +0200 
// s : Secondes avec le z�ro initial - 00 � 59 
// S : Suffixe ordinal d'un jour, anglais par d�faut - st, nd, rd, th 
// t : Nombre de jours dans le mois - 28 � 31 
// U : Secondes depuis le 1er Janvier 1970, 0h00 00s GMT - Ex: 1081072800 
// w : Jour de la semaine (0 �tant dimanche, 6 samedi) - 0 � 6 
// W : Num�ro de la semaine dans l'ann�e - 1 � 52
//     http://www.asp-php.net/tutorial/asp-php/glossaire.php?glossid=28
// y : Ann�e sur 2 chiffres - Ex: 04 
// Y : Ann�e sur 4 chiffres - Ex: 2004 
// z : Jour de l'ann�e - 1 � 366 
// Z : D�calage horaire en secondes - -43200 � 43200 
// \ : Caract�re d'echappement - Ex: \a, \A, \m

String.prototype.padLeft = function(strChar, intLength)
{
 var str = this + '';
 while (str.length != intLength) {
  str = strChar + str;
 }
 return str;
}

String.prototype.isInt = function()
{
 var oRegExp = new RegExp(/\d+/);
 return oRegExp.test(this);
}

Array.prototype.exists = function(objValue)
{
 var boolReturn = false, i = 0;
 for (i = 0; i < this.length; i++) {
  if (this[i] == objValue) {
   boolReturn = true;
   break;
  }
 }
 return boolReturn;
}

Date.prototype.dateFormat = function(strFormat, strLang, intTime)
{

 var arrayLang = ['en', 'fr'];
 var arrayFunctions = ['a', 'A', 'B', 'd', 'D', 'F', 'g', 'G', 'h', 'H', 'i', 'j', 'l', 'L', 'm', 'M', 'n', 'O', 'r', 's', 'S', 't', 'U', 'w', 'W', 'y', 'Y', 'z', 'Z'];

 if (intTime) {
  if (!intTime.toString().isInt()) {
   intTime = null;
  } else {
   intTime *= 1000;
  }
 }
 if (strLang) {
  if (strLang.toString().isInt()) {
   intTime = strLang * 1000;
   strLang = 'en';
  } else {
   if (!arrayLang.exists(strLang)) {
    strLang = 'en';
   }
  }
 } else {
  strLang = 'en';
 }

 var arrayDays_en = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
 var arrayMonths_en = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
 var arraySuffix_en = ['st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'st'];

 var arrayDays_fr = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];
 var arrayMonths_fr = ['Janvier', 'F�vrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Ao�t', 'Septembre', 'Octobre', 'Novembre', 'D�cembre'];
 var arraySuffix_fr = ['er', 'nd', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me', '�me'];

 // a : Ante meridiem et Post meridiem en minuscules - am ou pm 
 fct_a = function()
 {
  return (self.getHours() > 11) ? 'pm' : 'am';
 }

 // A : Ante meridiem et Post meridiem en majuscules - AM ou PM 
 fct_A = function()
 {
  return (self.getHours() > 11) ? 'PM' : 'AM';
 }

 // B : Heure Internet Swatch - 000 � 999
 //     http://www.quirksmode.org/index.html?/js/beat.html
 fct_B = function() {
  var intGMTOffset = (self.getTimezoneOffset() + 60) * 60;
  var intSeconds = (self.getHours() * 3600) + (self.getMinutes() * 60) + self.getSeconds() + intGMTOffset;
  var intBeat = Math.floor(intSeconds / 86.4);
  if (intBeat > 1000) {intBeat -= 1000;}
  if (intBeat < 0) {intBeat += 1000;}
  return intBeat.toString().padLeft('0', 3);
 }

 // d : Jour du mois, sur deux chiffres avec z�ro initial - 01 � 31 
 fct_d = function()
 {
  return self.getDate().toString().padLeft('0', 2);
 }

 // D : Jour de la semaine, en 3 lettres, anglais par d�faut - Mon � Sun 
 fct_D = function()
 {
  return eval('arrayDays_' + strLang)[self.getDay()].substring(0, 3);
 }

 // F : Mois textuel, version longue, anglais par d�faut - January � December 
 fct_F = function()
 {
  return eval('arrayMonths_' + strLang)[self.getMonth()];
 }

 // g : Heure au format 12h, sans le z�ro initial - 1 � 12 
 fct_g = function()
 {
  return (self.getHours() > 12) ? self.getHours() - 12 : self.getHours();
 }

 // G : Heure au format 24h, sans le z�ro initial - 0 � 23 
 fct_G = function()
 {
  return self.getHours();
 }

 // h : Heure au format 12h, avec le z�ro initial - 01 � 12 
 fct_h = function()
 {
  return (self.getHours() > 12) ? (self.getHours() - 12).toString().padLeft('0', 2) : self.getHours().toString().padLeft('0', 2);
 }

 // H : Heure au format 24h, avec le z�ro initial - 00 � 23 
 fct_H = function()
 {
  return self.getHours().toString().padLeft('0', 2);
 }

 // i : Minutes avec le z�ro initial - 00 � 59 
 fct_i = function()
 {
  return self.getMinutes().toString().padLeft('0', 2);
 }

 // j : Jour du mois sans le z�ro initial - 1 � 31 
 fct_j = function()
 {
  return self.getDate();
 }

 // l : Jour de la semaine, textuel, anglais par d�faut - Sunday � Saturday 
 fct_l = function()
 {
  return eval('arrayDays_' + strLang)[self.getDay()];
 }

 // L : L'ann�e est elle bissextile ? - 0 ou 1 
 fct_L = function()
 {
  var intFullYear = fct_Y();
  return ((intFullYear % 4 == 0 && intFullYear % 100 != 0) || (intFullYear % 4 == 0 && intFullYear % 100 == 0 && intFullYear % 400 == 0)) ? 1 : 0;
 }

 // m : Mois avec le z�ro intial - 01 � 12 
 fct_m = function()
 {
  return (self.getMonth() + 1).toString().padLeft('0', 2);
 }

 // M : Mois, en 3 lettres, anglais par d�faut - Jan � Dec 
 fct_M = function()
 {
  return eval('arrayMonths_' + strLang)[self.getMonth()].substring(0, 3);
 }

 // n : Mois sans le z�ro intial - 1 � 12 
 fct_n = function()
 {
  return (self.getMonth() + 1);
 }

 // O : Diff�rence avec l'heure de Greenwich (GMT), en heures - -1200 � +1200 
 fct_O = function()
 {
  var intTimezone = self.getTimezoneOffset();
  var intTimezoneAbs = Math.abs(intTimezone);
  var strTimezone = Math.floor(intTimezoneAbs / 60).toString().padLeft('0', 2) + (intTimezoneAbs % 60).toString().padLeft('0', 2);
  return (intTimezone < 0) ? '+' + strTimezone : '-' + strTimezone ;
 }

 // r : Format de date RFC 822 Thu, 1 Apr 2004 12:00:00 - +0200 
 fct_r = function()
 {
  return fct_D() + ', ' + fct_j() + ' ' + fct_M() + ' ' + fct_Y() + ' ' + fct_H() + ':' + fct_i() + ':' + fct_s() + ' ' + fct_O();
 }

 // s : Secondes avec le z�ro initial - 00 � 59 
 fct_s = function()
 {
  return (self.getSeconds()).toString().padLeft('0', 2);
 }

 // S : Suffixe ordinal d'un jour, anglais par d�faut - st, nd, rd, th 
 fct_S = function()
 {
  return eval('arraySuffix_' + strLang)[self.getDate() - 1];
 }

 // t : Nombre de jours dans le mois - 28 � 31 
 fct_t = function()
 {
  var intDays = 0;
  if (self.getMonth() == 1) {
   intDays = 28 + fct_L();
  } else {
   switch (self.getMonth() % 2) {
    case 0 : intDays = 31; break;
    default : intDays = 30;
   }
  }
  return intDays;
 }

 // U : Secondes depuis le 1er Janvier 1970, 0h00 00s GMT - Ex: 1081072800 
 fct_U = function()
 {
  return Math.round(self.getTime() / 1000);
 }

 // w : Jour de la semaine (0 �tant dimanche, 6 samedi) - 0 � 6 
 fct_w = function()
 {
  return self.getDay();
 }

 // W : Num�ro de la semaine dans l'ann�e - 1 � 52
 //     http://www.asp-php.net/tutorial/asp-php/glossaire.php?glossid=28
 fct_W = function()
 {
  return Math.floor((fct_z() - 1 - self.getDay()) / 7) + 2;
 }

 // y : Ann�e sur 2 chiffres - Ex: 04 
 fct_y = function()
 {
  var strFullYear = fct_Y().toString();
  return strFullYear.substring(strFullYear.length - 2, strFullYear.length);
 }

 // Y : Ann�e sur 4 chiffres - Ex: 2004 
 fct_Y = function()
 {
  return self.getFullYear();
 }

 // z : Jour de l'ann�e - 1 � 366 
 fct_z = function()
 {
  var datePremierJanvier = new Date('January 1 ' + fct_Y().toString() + ' 00:00:00');
  var intDifference = self.getTime() - datePremierJanvier.getTime();
  return Math.floor(intDifference / 1000 / 60 / 60 / 24);
 }

 // Z : D�calage horaire en secondes - -43200 � 43200 
 fct_Z = function()
 {
  var intTimezone = self.getTimezoneOffset();
  var intTimezoneAbs = Math.abs(intTimezone);
  var strTimezone = intTimezoneAbs * 60;
  return (intTimezone < 0) ? strTimezone : -strTimezone ;
 }

 var self = this;
 if (intTime) {
  var intMyTime = self.getTime();
  self.setTime(intTime);
 }
 var arrayFormat = strFormat.split(''), i = 0;
 for (i = 0; i < arrayFormat.length; i++) {
  if (arrayFormat[i] == '\\') {
   arrayFormat.splice(i, 1);
  } else {
   if (arrayFunctions.exists(arrayFormat[i])) {
    arrayFormat[i] = eval('fct_' + arrayFormat[i] + '();');
   }
  }
 }
 if (intMyTime) {
  self.setTime(intMyTime);
 }
 return arrayFormat.join('');

}

/*
arrTest = new Array("red", "green", "blue", "yellow", "orange");
arrTest = arrTest.remove("yellow");
trace(arrTest);
*/
Array.prototype.remove = function(obj) {
  var a = [];
  for (var i=0; i<this.length; i++) {
    if (this[i] != obj) {
      a.push(this[i]);
    }
  }
  return a;
}

if(typeof Array.prototype.copy=='undefined')
Array.prototype.copy=function(a){
	var	i=0,
		b=[];
	for(i;i<this.length;i++) {
		b[i]=(typeof this[i].copy!='undefined')
			? this[i].copy()
			: this[i];
	}
	return b
};

// valide une date jj/mm/aaaa 
function validerDate(dateVal, bIsFuture) {
	datej= new Date()
	anneej=datej.getFullYear()+"*";
	anneej=anneej.substring(0,2)
	
	dateWork = dateVal;
	
	if (dateVal.length ==6) { 
		dateWork=dateVal.substring(0,2)+"/"+dateVal.substring(4,2)+"/"+anneej+dateVal.substring(6,4);
	}
	if (dateVal.length ==8) { 
		dateWork=dateVal.substring(0,2)+"/"+dateVal.substring(4,2)+"/"+dateVal.substring(8,4);
	}
	if(!isValidDate(dateWork)) {
		alert("la date n'est pas valide ou n'est pas au bon format.\n format : jjmmaa ou jjmmaaaa ou jj/mm/aaaa");
		return false;
	}
	
	if (bIsFuture == 1) {
		dateUser=dateWork.substr(6,4)+"-"+dateWork.substr(3,2)+"-"+dateWork.substr(0,2);
		dateNow=datej.getFullYear()+"-"+dateFormat(datej.getMonth() + 1)+"-"+dateFormat(datej.getDate());
		diff = dateDiff(dateUser, dateNow);
		if (diff < 1) {
			return false;
		}
	}
	return true;
}

function isValidDate(d) {
	var dateRegEx = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;
	return d.match(dateRegEx);
} 

Date.prototype.add = function (sInterval, iNum) {
  var dTemp = this;
  if (!sInterval || iNum == 0) return dTemp;
  switch (sInterval.toLowerCase()){
    case "ms":	dTemp.setMilliseconds(dTemp.getMilliseconds() + iNum);	break;
    case "s":	dTemp.setSeconds(dTemp.getSeconds() + iNum);			break;
    case "mi":	dTemp.setMinutes(dTemp.getMinutes() + iNum);			break;
    case "h":	dTemp.setHours(dTemp.getHours() + iNum);				break;
    case "d":	dTemp.setDate(dTemp.getDate() + iNum);					break;
    case "mo":	dTemp.setMonth(dTemp.getMonth() + iNum);				break;
    case "y":	dTemp.setFullYear(dTemp.getFullYear() + iNum);			break;
  }
  return dTemp;
}

// retourne le dernier jours d'un mois
function GetLastDayOfThisMonth(theDateFR) {
	var tab = theDateFR.split('/');
	
	var myDate = new Date ();
	myDate.setDate(tab[0]);
	myDate.setMonth(tab[1]);
	myDate.setYear(tab[2]);
	
	var myMonth = myDate.setMonth(myDate.getMonth() + 1);
	var theDay = myDate.setDate(0);
	var lastDay = myDate.getDate();
	
	return lastDay;
}

// Met le 0 Initial dans les dates...
function dateFormat(intVal) {
	if (intVal<10) {
		return '0'+intVal; 
	} else {
		return intVal;
	}
}

function dateDiff(date1, date2) {
  date1 = date1.split("-");
  date2 = date2.split("-");
  var sDate = new Date(date1[0]+"/"+date1[1]+"/"+date1[2]);
  var eDate = new Date(date2[0]+"/"+date2[1]+"/"+date2[2]);
  var daysApart = Math.round((sDate-eDate)/86400000);
  return daysApart;
}


// Met la fin du mois donn� dans le input de destination
function getFinMoisTo(valueDateFr, destInputId) {
	if (valueDateFr == '') {
		return;
	}
	var Tab = valueDateFr.split('/');
	date = GetLastDayOfThisMonth(valueDateFr)+'/'+Tab[1]+'/'+Tab[2];
	$(destInputId).value = date;
}

// Met la fin de l'exercice de l'ann�e dans l'input de destination
function getFinExerciceTo(valueDateFr, destInputId) {
	if (valueDateFr == '') {
		return;
	}
	var Tab = valueDateFr.split('/');
	var Mois = Tab[1];
	var Annee = Tab[2];
	if (Mois>=7) {
		Annee++;
	}
	$(destInputId).value = '30/06/'+Annee;
}

function getEvents(event) {
	if (!event) {
		var event = window.event;
	}
	return event;
}

function getEventsSourceId(event) {
	event = getEvents(event);
	HandleName = Event.element(event);
	if (!HandleName.id) {
		return '';
	}
	return String(HandleName.id);
}

// retourne true si right click
function isRightClick(event) {
	var rightclick;
	if (!event) {
		var event = window.event;
	}
	if (event.which) {
		rightclick = (event.which == 3);
	} else {
		if (event.button) {
			rightclick = (event.button == 2);
		}
	}
	return rightclick;
}

// retourne true si right click
function isDoubleClick(event) {
	var rightclick;
	if (!event) {
		var event = window.event;
	}
	if (event.which) {
		rightclick = (event.which == 3);
	} else {
		if (event.button) {
			rightclick = (event.button == 2);
		}
	}
	return rightclick;
}

//vide un input s'il contient str
function voidIf(HandleElt, str) {
	if (HandleElt) {
		if (HandleElt.value == str) {
			HandleElt.value = '';
		}
	}
}

// Ajoute un listener sur un element pour le rafraichir an ajax (xml response optionnel):
// ajout du listener sur le div hop : $('hop').onReload = addRefreshDivWithUrl('hop', 'module', 'action', 'foo/bar', true);");
// appel de l'evenement : $('hop').Reload();
function addRefreshDivWithUrl(divId, module, action, params, XmlResponse) {
	if (XmlResponse) {
		// params /foo/bar/foo1/bar1 => foo=bar&foo1=bar1 
		var aParams = params.split('/');
		var lght = aParams.length;
		var params = '';
		var and = '';
		for(i = 0 ; i < lght ; i+=2){
			params = and + params + aParams[i] + '=' + aParams[i + 1]
			and = '&';
		}
		$(divId).Reload = function() {doRequestAndXmlResponse(module, action, params);}
	} else {
		Url = url_site+fc_name+'/'+module+'/'+action+'/'+params
		$(divId).Reload = function() {new Ajax.Updater(divId , Url, {asynchronous:false, evalScripts:true});}
	}
}


/** Fonction popup / Ajax */

/**
SetFocus(id)
*/
function sfs(InputId) {
	$(InputId).focus();
}


/* show-hide a div */
function intervertDivDisplay(div_id) {
	try {
		if ($(div_id).style.display=='none') {
			showDiv(div_id);
		} else {
			hideDiv(div_id);
		}
	} catch (e) {
		alert('intervertDivDisplay : ' + div_id + ', failed !' + "\n" + e);
	}
}

/* Intervertis les display d'une liste de div jusqu'a une limite */
function intervertListDisplay(DivIds) {
	lgth = DivIds.length;
	for (var i = 0 ; i<lgth ; i++) {
		intervertDivDisplay($(DivIds[i]));
	}
}

function showDiv(div_id) {
	if ($(div_id)) {
		$(div_id).style.display='';
	}
}

function hideDiv(div_id) {
	if ($(div_id)) {
		$(div_id).style.display='none';
	}
}


/* Affiche / cache les lignes de la classes LineClasses du tableau TableId */
function manageDisplayTableBottomLines(TableId, LineClasses) {
	var table = $(TableId);
	for (var i = 0; i < table.rows.length; i ++) {
		var row = table.rows[i];
		if (row.className.indexOf(LineClasses) >= 0) {
			row.style.display = (row.style.display == "none" ? "" : "none" )
		}
	}
}

/* 
 * Remplis le contenu d'une div en ajax au premier click.
 * Puis prend le comportement toogle
 */
var TabDivUrlToggle = Array();
function CheckDisplayWith(divId, url, force) {
	if (force == 'undefined') {
		force = false;
	}
	if (!force) {
		intervertDivDisplay(divId);
	} else {
		showDiv(divId);
	}
	if (isNaN(TabDivUrlToggle[divId])) {
		TabDivUrlToggle[divId] = 1;
		return new Ajax.Updater(divId, url_site+fc_name+url, {asynchronous:true, evalScripts:true, onComplete:function(request, json){hideDiv('divMsg');}});
	}
	return true;
}

/**
Copie la valeur d'un champ vers l'autre
*/ 
function CopyFieldValue(DivFromID, DivToId) {
	$(DivToId).value = $(DivFromID).value;
}

/**
	test s'il s'agit d'une function
**/
function isFunction(object) {
	if(object.length == 0 && object.toString().indexOf('function ') == 0) {
		return true;
	} else {
		return false;
	}
}



// affiche dans indicId le nombre de caract�res restant dans texteId 
function LimitSize(texteId, indicId, nbmax){
	try {
	   var iLongueur, iLongueurRestante;
	   
	   iLongueur = $(texteId).value.length;
	   
	   if (iLongueur>nbmax) {
	      document.getElementById(texteId).innerHTML = document.getElementById(texteId).value.substring(0,nbmax);
	      iLongueurRestante = 0;
	   }
	   else {
	      iLongueurRestante = nbmax - iLongueur;
	   }
	   document.getElementById(indicId).innerHTML = iLongueurRestante;
	} catch (e) {
		alert(e);
	}
}


// Copy data to clipboard
function clipboardCopy(data) {
   window.clipboardData.setData('Text', data);
} 




//------------------------------------------------------------------------------

/*
Mettre en rouge, enlever le rouge
*/
function unColorise(FieldHandle) {
	if (FieldHandle.hasClassName('erreur')) {
		FieldHandle.removeClassName('erreur');
		
		try {
			removeInfoBulle(FieldHandle.id);
		} catch (e) {
		}
		RemoveFromDisplay(FieldHandle.id);
	}
}

function colorise(aField, aMessage) {
	
	var lght = aField.length;
	//alert('colorise '+lght);
	for (var i=0; i<lght; i++) {
		
		try {
			
			var field = $(aField[i]);
			var fieldId = field.getAttribute('id');
			
			var errorMessage = aMessage[i];
			
			if(		$(fieldId) && $(fieldId).type != 'radio'
				&&  $(fieldId) && $(fieldId).type != 'checkbox')
			{
				$(fieldId).addClassName('erreur');
				
				addInfoBulle(fieldId, '<b>Attention !</b><br />' + errorMessage);
				addEvent($(fieldId), 'focus', unColoriseOnEvent);
			}
			else
			{
				//cas des boutons radios, on cherche si un bouton a cet "id" en name
				$$('input[name="'+fieldId+'"]').each(function(radioButton)
				{
					radioButton.addClassName('erreur');
					addInfoBulle(radioButton.id, '<b>Attention !</b><br />' + errorMessage);
					addEvent(radioButton, 'focus', unColoriseOnEvent);
				});
			}
		} catch (e) {
			//alert(aField[i] + ' not found : ' + aMessage[i]);
		}
	}
}


function RemoveFromDisplay(ErrorId) {
	if ($('Error_Li_'+ ErrorId)) {
		var item = 'Error_Li_'+ ErrorId;
		
		var UlTag = $(item).parentNode;
		
		$(item).remove();
		
		if (UlTag.getElementsByTagName('li').length == 0) {
			UlTag.style.display='none';
		}
	}
}

function espion(msg) {
	dbg = true;
	if (!dbg) {
		return ;
	} else {
		if (!$('espion')) {
			temp = document.createElement('div');
			temp = $('LeftSide').appendChild(temp);
			temp.innerHTML = '<textarea id="espion" cols="40" rows="30" style="float:left"></textarea><div class="separateur"></div>';
		}
	}
	elmt=$('espion');
	elmt.value=msg+'\n'+elmt.value;
	if (msg=='new') {elmt.value='';}
	return ;
}

	/**
	 * Permet d'envoyer des donn�es en GET ou POST en utilisant les XmlHttpRequest
	 */
	function sendData(data, page, method, place){
		if (place=='') {place='contenu';}
		
		//alert(data+' '+page+' '+method+' '+place);
		
		new Ajax.Updater(place,
				page+"?"+data, 
				{
					asynchronous:true, 
					evalScripts:true,
					onException:function(e,d) {
						alert('Erreur : '+d.message);
					}
				}
			)
	}//fin fonction SendData
	
	function postFile(prms,page,place) {
		sendData(prms, page, 'POST', place);
	}//fin fonction getFile  
	
	/**
	 * Permet de r�cup�rer les donn�es d'un fichier via les XmlHttpRequest:
	 */
	function getFile(page, place) {
	 try {
		sendData('direct_call=no', page, 'GET', place);
	} catch (e) {
    alert(page + ' ' + place +' ' +"\n"+e);
  }
	}//fin fonction getFile  

	//fonction de switch reservé à acceneo.com
function changeMeTo(elmt, imageName) {
	elmt.src="/sites/www/images/acceneo/"+imageName+".png";
}


