var sCodeLibelleStatus;   // permet de stocker le code du message a afficher dans la status bar

var DETAIL = "LoadingDetail"; // Chargement des details
var SEARCHING = "Searching"; // Recherche en cours
var CANCELING = "Canceling"; // annulation en cours
var VALIDATING = "Validating"; // Validation en cours
var DELETING = "Deleting";  // suppression en cours
var LOADING = "Loading";  // Chargement en cours
var WAITING = "Waiting";  // Chargement en cours


var oMessage = new GestMess();

function GetMessagesForJavascript ( bIsGeneral){

var _oMessage ;
var sFrame = "" ;

_oMessage = oMessage;

if (bIsGeneral) {
if (bIsGeneral == true || bIsGeneral == "true") {
if (parent.frames['HiddenFields']){
if(parent.frames['HiddenFields'].oMessage){
_oMessage = parent.frames['HiddenFields'].oMessage;
}
}
}
}

return _oMessage;
}

function AddMessage(aInfosMess) {
oMessage.Add( new Message(aInfosMess));
}

function Message(aInfosMess) {

function mBuildSQL(aParam) {
var indice = 0 ;
var iNext = 0;
var sRes = this.L_MESSAGE;
while(sRes.indexOf("$s",iNext) != -1)
{
var iFind = sRes.indexOf("$s",iNext) ;
var sBefore = sRes.substring(0,iFind) ;
var sAfter = sRes.substring(iFind+2,sRes.length) ;
var sRes = sBefore + aParam[indice] + sAfter ;
iNext = sBefore.length + aParam[indice].length + 1 ;
indice++ ;
}
return sRes ;
}
this.BuildSQL = mBuildSQL ;

this.C_MESSAGE = aInfosMess[0] ;
this.L_MESSAGE = aInfosMess[1] ;
this.T_MESSAGE = aInfosMess[2] ;
this.IsUnEscaped = false ;

return this;
}

function GestMess() {

function mAdd (oMess) {
if (!this.tableau) {
this.tableau = new Array();
}
this.tableau.push(oMess);
}

function mGetMessage(sCodeMessage) {
var i = 0;
var bTrouve = false;
var o = new Message("") ;

if (this.tableau) {
while (!bTrouve && i < this.tableau.length) {
if (this.tableau[i].C_MESSAGE == sCodeMessage) {
bTrouve = true;
o = UnEscapeThisMess(this.tableau[i]);
}
++i;
}
}
if (bTrouve) {
return o;
} else {
o.C_MESSAGE = sCodeMessage;
o.L_MESSAGE = sCodeMessage;
return o;
}
}

function mCompare(a, b) {
if (a.sCodeMessage < b.sCodeMessage) {
return -1
}
else{
return 1
}
}

function mGetAllSorted() {
if (this.tableau) {
this.tableau.sort(mCompare)
return this.tableau
}
}

function mSerialize() {
var s = ""
var oMess
if (this.tableau) {
for (var i=0 ; i < this.tableau.length ; ++i) {
oMess = UnEscapeThisMess(this.tableau[i]);
if (oMess.bChange) {
s += oMess.C_MESSAGE + ";"
s += oMess.L_MESSAGE + ";"
s += oMess.T_MESSAGE + ";"
s += "+";
}
}
}
return s;
}

function UnEscapeThisMess(oMess){
if(!oMess.IsUnEscaped){
oMess.L_MESSAGE = i_unEscapeCarac(oMess.L_MESSAGE);
oMess.IsUnEscaped = true;
}
return oMess;
}

this.Add = mAdd;
this.GetMessage = mGetMessage;
this.Serialize = mSerialize;
this.GetAllSorted = mGetAllSorted;

this.tableau = new Array();
this.bIsScreenList = false;

return this;
}
