
function trim(strValue)
{
     var ichar = strValue.length - 1,ch;
     while(ichar >= 0 && ((ch = strValue.charAt(ichar))==' '||ch == '\t'||ch == '\r'||ch == '\n'))
         --ichar;
     if (ichar<(strValue.length-1))
         strValue = strValue.slice(0,ichar+1);
     ichar = 0;
     var icount = strValue.length - 1;
     while (ichar < icount && ((ch = strValue.charAt(ichar))==' '||ch == '\t'||ch == '\r'||ch == '\n'))
         ++ichar;
     if (ichar>0)
         strValue = strValue.slice(ichar,strValue.length);
     return strValue;
}

function _epr(oLocale,errorIco,modifiedIco)
{
	this.tUtils={};
	this.tHiddens={};
	this.locale=oLocale;
	this.errorIco=errorIco;
	this.modifiedIco=modifiedIco;
	this.sty={txt:"bos_fieldtext", lst:"bos_fieldselect", nrm:"bos_fieldenabled", loc:"bos_fielddisabled", err:"bos_fielderror"};

	this.Init=_Init;
	this.CreateFmtText=_CreateFmtText;
	this.CreateFmtSelect=_CreateFmtSelect;
	this.Clear=_ClearScr;
	this.ClearScr=_ClearScr;
	this.ClearVal=_ClearVal;
	this.Reset=_ResetScr;
	this.ResetScr=_ResetScr;
	this.ResetVal=_ResetVal;
	this.Check=_CheckScr;
	this.CheckScr=_CheckScr;
	this.CheckVal=_CheckVal;
	this.PutError=_PutError;
	this.PutModified=_PutModified;
	this.FldError=_FldError;
    this.SendRemote=_SendRemoteScr;
    this.SendAll=_SendAllScr;
	this.ExecuteResponse = _ExecuteResponse;
	this.PutScr=_PutScr;
	this.PutVal=_PutVal;
	this.GetScr=_GetScr;
	this.GetVal=_GetVal;
	this.GetEleVal=_GetEleVal;
	this.LockScr=_LockScr;
	this.LockVal=_LockVal;
	this.ActifScr=_ActifScr;
	this.ActifVal=_ActifVal;
	this.LstAdd=_LstAdd;
	this.LstAddAll=_LstAddAll;
	this.LstClear=_LstClear;
	this.AddField=_AddField;
    this.FldFocus=_FldFocus;
    this.RemoveFields=_RemoveFields;
	this.AddFieldHidden=_AddFieldHidden;

    this.ReplParam = _ReplParam;
    this.ReplParamSep = _ReplParamSep;
    this.Srv_Err=_SrvError;
    this.Srv_Msg=_SrvMessage;

}

//	<--- Functions de création de la liste des `utils` (zones à utiliser) et validité de l'attribut `fmt` --->

function _Init()
{
/*	var oTag,oElem,oFocus,sMsg;
	var sError="";

	if (document.all)
	{
		for(var iCtr=0; iCtr<document.all.length; iCtr++)
		{
			oTag=document.all[iCtr];
			if(!oTag.type || !oTag.fmt)
			{
//				if (oTag.type=='hidden')
//					oTag.name = oTag.id;
				continue;
			}
			oElem={src:oTag, newsrc:true};
			if(this.tUtils[oTag.id])
			{
				if(this.tUtils[oTag.id].src==oTag)
				{
					if(this.tUtils[oTag.id].fmt==oTag.fmt)
					{
						this.tUtils[oTag.id].newsrc=false;
						continue;
					}
					oElem.newsrc=false;
				}
				delete this.tUtils[oTag.id];
			}
			sMsg="";
			if(oTag.type.match( /^text|hidden|password|textarea$/ ))
			{
				//oTag.onfocus=Function("this.select()");//
				sMsg=this.CreateFmtText(oElem);
			}
			else if(oTag.type.match( /^select/ ))
				sMsg=this.CreateFmtSelect(oElem);
			else continue;
			if(sMsg)
			{
				this.FldError(oElem,sMsg);
				if(!sError)
				{
					sError=sMsg;
					oFocus=oTag;
				}
			}
			else
			{
				oElem.src.value=(((oElem.fctToScr)&&(oElem.typ!="P")) ? oElem.fctToScr(oElem.defaultValue,oElem.Info) : oElem.defaultValue);
				this.FldError(oElem);
				this.tUtils[oTag.id]=oElem;
			}
		}
		for(var sCtr in this.tUtils)
			if(this.tUtils[sCtr].newsrc==null)
				delete this.tUtils[sCtr];
			else
				delete this.tUtils[sCtr].newsrc;
		if(sError)
		{
			alert(this.ReplParamSep(sError));
			if (!oFocus.readOnly) _FldFocus(oFocus);
		}
		return;
	}

	var body = document.getElementById("bosbody");

	for(var iCtr=0; iCtr<body.length; iCtr++)
	{
		oTag=body.Item(iCtr);
		if(!oTag.type || !oTag.fmt) continue;
		oElem={src:oTag, newsrc:true};
		if(this.tUtils[oTag.id])
		{
			if(this.tUtils[oTag.id].src==oTag)
			{
				if(this.tUtils[oTag.id].fmt==oTag.fmt)
				{
					this.tUtils[oTag.id].newsrc=false;
					continue;
				}
				oElem.newsrc=false;
			}
			delete this.tUtils[oTag.id];
		}
		sMsg="";
		if(oTag.type.match( /^text|hidden|password|textarea$/ ))
		{
			//oTag.onfocus=Function("this.select()");//
			sMsg=this.CreateFmtText(oElem);
		}
		else if(oTag.type.match( /^select/ ))
			sMsg=this.CreateFmtSelect(oElem);
		else continue;
		if(sMsg)
		{
			this.FldError(oElem,sMsg);
			if(!sError)
			{
				sError=sMsg;
				oFocus=oTag;
			}
		}
		else
		{
			oElem.src.value=(((oElem.fctToScr)&&(oElem.typ!="P")) ? oElem.fctToScr(oElem.defaultValue,oElem.Info) : oElem.defaultValue);
			this.FldError(oElem);
			this.tUtils[oTag.id]=oElem;
		}
	}

	for(var sCtr in this.tUtils)
		if(this.tUtils[sCtr].newsrc==null)
			delete this.tUtils[sCtr];
		else
			delete this.tUtils[sCtr].newsrc;
	if(sError)
	{
		alert(this.ReplParamSep(sError));
		if (!oFocus.readOnly) _FldFocus(oFocus);
	}
	return;
*/
}

function _AddField(fldName,fldFmt,fldArg)
{
	var oTag = document.getElementById(fldName);
	if (!oTag)
	{
		//alert(fldName+ " not found !");
		return;
	}
/*	if(this.tUtils[oTag.id])
	{
		alert(fldName+ " defined more than one time !");
		return;
	}*/

	if (typeof(fldArg) == 'undefined')
		fldArg = oTag.value;

	var sError="";
	var oElem={src:oTag, newsrc:true, fmt:fldFmt, defaultValue:fldArg};
	var sMsg="";
	if(oTag.type.match( /^text|hidden|password|textarea$/ ))
	{
		//oTag.onfocus=Function("this.select()");//
		sMsg=this.CreateFmtText(oElem);
	}
	else if(oTag.type.match( /^select/ ))
		sMsg=this.CreateFmtSelect(oElem);
	else
	{
		alert(fldName+ " has a bad type !");
		return;
	}

	if(sMsg)
	{
		this.FldError(oElem,sMsg);
	}
	else
	{
		oElem.src.value=(((oElem.fctToScr)&&(oElem.typ!="P")) ? oElem.fctToScr(oElem.defaultValue,oElem.Info) : oElem.defaultValue);
		this.FldError(oElem);
		this.tUtils[oTag.id]=oElem;
	}
}

function _AddFieldHidden(fldName)
{
	var oTag = document.getElementById(fldName);
	if (!oTag)
	{
		//alert(fldName+ " not found !");
		return;
	}

	var oElem={src:oTag, newsrc:true};
	this.tHiddens[oTag.id]=oElem;
}

function _CreateFmtText(oElem)
{
	var tRes=oElem.fmt.match( /^#([+-]?)(N|D|H|T|SC|SH|M|B|L|IP|ID|IN|P|X)(.*)$/ );
	if(!tRes) return "fieldFormatInvalid@"+oElem.fmt;
	var tOptions=tRes[3].split("#");
	var sError="";
	oElem.objtyp="T";
	oElem.typ=tRes[2];
	oElem.sw={NULL:"", A:"", BR:"", O:"", TI:"", CL:""};
	oElem.maj={};
	oElem.layout="";
	oElem.defaultClass=oElem.src.className;
	oElem._editor = null;
	switch(oElem.typ)
	{
		case "N":	sError=_checkFmtNumeric(oElem,tOptions[0],tRes[1],this.locale); break;
		case "D":	sError=_checkFmtDate(oElem,tOptions[0],this.locale); break;
		case "H":	sError=_checkFmtTime(oElem,tOptions[0],this.locale); break;
		case "T":	sError=_checkFmtText(oElem,tOptions[0],msgLang_fieldFormatMaxChar); break;
		case "SC":	sError=_checkFmtScript(oElem,tOptions[0],msgLang_fieldFormatMaxChar);
						break;
		case "SH":	sError=_checkFmtScript(oElem,tOptions[0],msgLang_fieldFormatMaxChar);
						//if (oElem.type == "textarea")
						{
							oElem._editor = new HTMLArea(oElem.src);
							oElem._editor.generate();
						}
						break;
		case "X":	sError=_checkFmtFmt(oElem,tOptions[0],msgLang_fieldFormatMaxChar); break;
		case "ID":	sError=_checkFmtID(oElem,tOptions[0],msgLang_fieldFormatMaxChar); break;
		case "IP":	sError=_checkFmtIP(oElem,tOptions[0]); break;
		case "IN":	sError=_checkFmtIN(oElem,tOptions[0],msgLang_fieldFormatMaxChar); break;
		case "M":	sError=_checkFmtMail(oElem,tOptions[0],msgLang_fieldFormatMaxChar); break;
		case "B":	sError=_checkFmtBoolean(oElem,tOptions[0]); break;
		case "L":	sError=_checkFmtList(oElem,tOptions[0]); break;
		case "P":	sError=_checkFmtPass(oElem,tOptions[0],msgLang_fieldFormatMaxChar); break;
	}


	if(sError) return sError;
	for(var iCtr=1; iCtr<tOptions.length; iCtr++)
		if(sError=_checkFmtOption(oElem,tOptions[iCtr])) return sError;
/*	if(oElem.newsrc)
		oElem.src.insertAdjacentHTML("AfterEnd","<label id='l_"+oElem.src.id+"'></label");
	oElem.label=document.getElementById("l_"+oElem.src.id);
	*/

	if(oElem.sw.A)
	{
		oElem.label.innerText=(oElem.sw.BR ? "\n" : " ")+oElem.layout+
			(oElem.sw.I && oElem.limits ? " ["+oElem.limits+"]" : "");
	}

	if(oElem.sw.TI)
		oElem.src.title=oElem.layout+(oElem.sw.I && oElem.limits ? "\n["+oElem.limits+"]" : "");

	if(oElem.sw.ML)
	{
		oElem.src.maxLength=oElem.ml;
		if (oElem.typ == "D" || oElem.typ == "N")
			oElem.src.size=oElem.ml;
		if (oElem.typ == "T"|| oElem.typ == "P"|| oElem.typ == "ID")
		{	if (oElem.src.style.width=="")
			{
				if (oElem.ml<=10) {oElem.src.style.width=oElem.ml*9+"px";}
				if (oElem.ml<=20 && oElem.ml>10) {oElem.src.style.width=oElem.ml*7+"px";}
				if (oElem.ml<=50 && oElem.ml>20) {oElem.src.style.width=oElem.ml*5+"px";}
				if (oElem.ml>50 )
				{
					if(oElem.sw.A)
						oElem.src.style.width="70%";
					else
						oElem.src.style.width="90%";
				}
			}
		}
	}

	if(oElem.sw.CL)
		oElem.defaultClass=this.sty.txt;
	if (oElem.typ == "N")
		oElem.src.style.textAlign = "right";
	return "";
}

function _CreateFmtSelect(oElem)
{
	var tRes=oElem.fmt.match( /^#(L)(.*)$/ );
	if(!tRes) return "fieldFormatInvalid@"+oElem.fmt;
	var tOptions=tRes[2].split("#");
	var sError="";
	oElem.objtyp="S";
	oElem.typ=tRes[1];
	oElem.sw={CL:""};
	oElem.maj={};
	oElem.defaultClass=oElem.src.className;
	sError=_checkFmtSelect(oElem,tOptions[0]);
	if(sError) return sError;
	for(var iCtr=1; iCtr<tOptions.length; iCtr++)
		if(sError=_checkFmtOption(oElem,tOptions[iCtr])) return sError;
	if(oElem.sw.CL)
		oElem.defaultClass=this.sty.lst;
	return "";
}

// <--- Fonctions de vérification des paramètres de chaque `fmt` --->

function _checkFmtNumeric(oElem,sParam,sSgn,oLocale)
{
	var tRes;
	oElem.sgn=sSgn;
	oElem.len=3;
	oElem.dec=2;
	oElem.limits="";
	oElem.min="";
	oElem.max="";
	oElem.sw.I="";
	oElem.sw.ML="";
	if(sParam)
		if(tRes=sParam.match( /^(\d\d)(\d\d)((-?\d+\.?\d*)?\/(-?\d+\.?\d*)?)?$/ ))
		{
			oElem.len=tRes[1]-0;
			oElem.dec=tRes[2]-0;
			if(tRes[3])
				if(tRes[3]!="/")
				{
					if(tRes[4])
					{
						oElem.min=tRes[4];
						oElem.limits+=oLocale.NumberToScr(tRes[4]);
					}
					oElem.limits+=" <= ";
					if(tRes[5])
					{
						oElem.max=tRes[5];
						oElem.limits+=oLocale.NumberToScr(tRes[5]);
					}
				}
				else
					return "fieldNumFormatLimitInvalid@"+oElem.fmt+"@"+tRes[3];
		}
		else
			return "fieldNumFormatInvalid@"+oElem.fmt+"@"+sParam;
	for(iCtr=0; iCtr<oElem.len; iCtr++) oElem.layout+=(iCtr ? "" : sSgn)+"9";
	for(iCtr=0; iCtr<oElem.dec; iCtr++) oElem.layout+=(iCtr ? "" : oLocale.numSep)+"9";
	oElem.ml=oElem.layout.length;
	oElem.locale=oLocale;
	oElem.fctToScr=new Function("sSrc","return this.locale.NumberToScr(sSrc)");
	oElem.fctFromScr=new Function("sSrc","return this.locale.NumberFromScr(sSrc)");
	oElem.check=_checkChampNumeric;
	return "";
}

function _checkFmtDate(oElem,sParam,oLocale)
{
	var tRes;
	oElem.limits="";
	oElem.min="";
	oElem.max="";
	oElem.sw.I="";
	oElem.sw.ML="";
	if(sParam)
		if(tRes=sParam.match( /^((\d{1,2}\/\d{1,2}\/\d{4})?-(\d{1,2}\/\d{1,2}\/\d{4})?)?$/ ))
		{
			if(tRes[1])
			{
				if(tRes[2])
				{
					oElem.min=oLocale.DateCheck(tRes[2]);
					if(!oElem.min) return "msgLang_fieldDateFormatLimitInvalid@"+oElem.fmt+"@"+sParam;
					oElem.limits+=oLocale.DateToScr(tRes[2]);
				}
				oElem.limits+=" <= ";
				if(tRes[3])
				{
					oElem.max=oLocale.DateCheck(tRes[3]);
					if(!oElem.max) return "msgLang_fieldDateFormatLimitInvalid@"+oElem.fmt+"@"+sParam;
					oElem.limits+=oLocale.DateToScr(tRes[3]);
				}
			}
		}
		else
			return "fieldDateFormatInvalid@"+oElem.fmt+"@"+sParam;
	oElem.layout=oLocale.FmtDate;
	oElem.ml=(oLocale.datSep ? 14 : 12);
	oElem.fctToScr=new Function("sSrc","return this.locale.DateToScr(sSrc)");
	oElem.fctFromScr=new Function("sSrc","return this.locale.DateFromScr(sSrc)");
	oElem.locale=oLocale;
	oElem.check=_checkChampDate;
	return "";
}

function _checkFmtTime(oElem,sParam,oLocale)
{
	var tRes;
	oElem.limits="";
	oElem.min="";
	oElem.max="";
	oElem.sw.I="";
	oElem.sw.ML="";
	if(sParam)
		if(tRes=sParam.match( /^((\d{1,2}:\d{2})?-(\d{1,2}:\d{2})?)?$/ ))
		{
			if(tRes[1])
			{
				if(tRes[2])
				{
					oElem.min=oLocale.TimeCheck(tRes[2]);
					if(!oElem.min) return "fieldTimeFormatLimitInvalid@"+oElem.fmt+"@"+sParam;
					oElem.limits+=oLocale.TimeToScr(tRes[2]);
				}
				oElem.limits+=" <= ";
				if(tRes[3])
				{
					oElem.max=oLocale.TimeCheck(tRes[3]);
					if(!oElem.max) return "fieldTimeFormatLimitInvalid@"+oElem.fmt+"@"+sParam;
					oElem.limits+=oLocale.TimeToScr(tRes[3]);
				}
			}
		}
		else
			return "fieldTimeFormatInvalid@"+oElem.fmt+"@"+sParam;
	oElem.ml=(oLocale.timSep ? 5 : 4);
	oElem.layout=oLocale.FmtTime;
	oElem.fctToScr=new Function("sSrc","return this.locale.TimeToScr(sSrc)");
	oElem.fctFromScr=new Function("sSrc","return this.locale.TimeFromScr(sSrc)");
	oElem.locale=oLocale;
	oElem.check=_checkChampTime;
	return "";
}

function _checkFmtPass(oElem,sParam,sLib)
{
	var tRes;
	oElem.len=250;
	oElem.sw.UC="";
	oElem.sw.LC="";
	oElem.sw.TR="";
	oElem.sw.ML="";

	var tKey=sParam.split("§");

	if(tKey.length!=3){return "fieldFormatParamInvalid@"+oElem.fmt+"@"+sParam;}
	sParam = tKey[0];
	sKeyInfo = tKey[1];
	sNb = tKey[2];
	if(sParam)
		if(tRes=sParam.match( /^([1-9][0-9]{0,4})$/ ))
			{oElem.len=tRes[1]-0;
			iLen = (oElem.len-5);
			if(iLen<0){return "fieldFormatParamInvalid@"+oElem.fmt+"@"+sParam;}
			}
		else
			return "fieldFormatParamInvalid@"+oElem.fmt+"@"+sParam;
	if(sKeyInfo)
		if(tRes=sKeyInfo.match( /^([1-9][0-9]{0,10})$/ ))
			oElem.Info=tRes[1]-0;
		else
			return "fieldFormatParamInvalid@"+oElem.fmt+"@"+sKeyInfo;
	if(sNb)
		{if(tRes=sNb.match( /^([0-9][0-9]{0,1})$/ ))
			{oElem.limits=tRes[1]-0;}
		else
			return "fieldFormatParamInvalid@"+oElem.fmt+"@"+sNb;}
	else
			return "fieldFormatParamInvalid@"+oElem.fmt+"@"+sNb;
	oElem.layout=oElem.len+" "+sLib;
	oElem.ml=oElem.len;
	oElem.check=_checkChampPass;
	oElem.fctFromScr=new Function("sSrc","sInfo","return _PassFromScr(sSrc,sInfo)");
	oElem.fctToScr=new Function("sSrc","sInfo","return _PassToScr(sSrc,sInfo)");
	return "";
}

function hexfromdec(num) {
	if (num > 65535) { return ("overflow!") }
	first = Math.round(num/4096 - .5);
	temp1 = num - first * 4096;
	second = Math.round(temp1/256 -.5);
	temp2 = temp1 - second * 256;
	third = Math.round(temp2/16 - .5);
	fourth = temp2 - third * 16;
    	return (""+getletter(first)+getletter(second)+getletter(third)+getletter(fourth));
}

function getletter(num) {
	if (num < 10) {
		return num;
	}
	else
	{
		if (num == 10) { return "A" }
                if (num == 11) { return "B" }
                if (num == 12) { return "C" }
                if (num == 13) { return "D" }
                if (num == 14) { return "E" }
                if (num == 15) { return "F" }
        }
}

function he2i(sHex)
{
	ih2i = 0 ;
	iMultJS = 16;
	iResultJS = 0 ;
	for(var ih2i = 0; ih2i<=1; ih2i++)
	{
		sDigit = sHex.substr(ih2i,1)
		if (sDigit == "F") { iResultJS = iResultJS + 15 * iMultJS  }
		if (sDigit == "E") { iResultJS = iResultJS + 14 * iMultJS  }
		if (sDigit == "D") { iResultJS = iResultJS + 13 * iMultJS  }
		if (sDigit == "C") { iResultJS = iResultJS + 12 * iMultJS  }
		if (sDigit == "B") { iResultJS = iResultJS + 11 * iMultJS  }
		if (sDigit == "A") { iResultJS = iResultJS + 10 * iMultJS  }
		if (sDigit == "9") { iResultJS = iResultJS + 9 * iMultJS  }
		if (sDigit == "8") { iResultJS = iResultJS + 8 * iMultJS  }
		if (sDigit == "7") { iResultJS = iResultJS + 7 * iMultJS  }
		if (sDigit == "6") { iResultJS = iResultJS + 6 * iMultJS  }
		if (sDigit == "5") { iResultJS = iResultJS + 5 * iMultJS  }
		if (sDigit == "4") { iResultJS = iResultJS + 4 * iMultJS  }
		if (sDigit == "3") { iResultJS = iResultJS + 3 * iMultJS  }
		if (sDigit == "2") { iResultJS = iResultJS + 2 * iMultJS  }
		if (sDigit == "1") { iResultJS = iResultJS + 1 * iMultJS  }
		iMultJS = iMultJS - 15
	}
	return iResultJS
}

function _PassFromScr(sSrc,sInfo)
{
	sNewKey = "";
	sResultInf = "";
	sInfoVal = new String(sInfo);
	while (sSrc.length>sNewKey.length){sNewKey = sNewKey+sInfoVal;}
	sNewKey = sNewKey.substr(0,sSrc.length)
	for(var iBoucle = 0; iBoucle<sSrc.length; iBoucle++)
	{
		sXOR = hexfromdec(sSrc.substr(iBoucle,1).charCodeAt(0) ^ sInfoVal.substr(iBoucle,1).charCodeAt(0));
  		sResultInf = sResultInf+sXOR.substr(sXOR.length-2,sXOR.length);
	}
	return sResultInf;
}

function _PassToScr(sSrc,sInfo)
{
	sNewKey = "";
	sResultInf = "";
	sInfoVal = new String(sInfo);
	while (sSrc.length/2>sNewKey.length){sNewKey = sNewKey+sInfoVal;}
	sNewKey = sNewKey.substr(0,sSrc.length)
	for(var iBoucle = 1; iBoucle<sSrc.length/2+1; iBoucle++)
	{
		sResultInf = sResultInf+String.fromCharCode(he2i(sSrc.substr((iBoucle-1)*2, 2))^sInfoVal.substr(iBoucle-1,1).charCodeAt(0));
	}
	return sResultInf;
}

//MMM: ex tag
function _checkFmtText(oElem,sParam,sLib)
{
	var tRes;
	oElem.len=4096;
	oElem.sw.UC="";
	oElem.sw.LC="";
	oElem.sw.TR="";
	oElem.sw.ML="";
	oElem.sw.EX="";
	if(sParam)
	{
		if(tRes=sParam.match( /^([1-9][0-9]{0,4})$/ ))
			oElem.len=tRes[1]-0;
		else
			return "fieldFormatParamInvalid@"+oElem.fmt+"@"+sParam;
	}
	oElem.layout=oElem.len+" "+sLib;
	oElem.ml=oElem.len;
	oElem.check=_checkChampText;
	return "";
}

function _checkFmtScript(oElem,sParam,sLib)
{
	var tRes;
	oElem.len=4096;
	oElem.sw.UC="";
	oElem.sw.LC="";
	oElem.sw.TR="";
	oElem.sw.ML="";
	oElem.sw.EX="";
	if(sParam)
	{
		if(tRes=sParam.match( /^([1-9][0-9]{0,4})$/ ))
			oElem.len=tRes[1]-0;
		else
			return "fieldFormatParamInvalid@"+oElem.fmt+"@"+sParam;
	}
	oElem.layout=oElem.len+" "+sLib;
	oElem.ml=oElem.len;
	oElem.check=_checkChampScript;
	return "";
}

//MMM: ajout type
function _checkFmtFmt(oElem,sParam,sLib)
{
	var tRes;
	oElem.len=4096;
	oElem.sw.UC="";
	oElem.sw.LC="";
	oElem.sw.TR="";
	oElem.sw.ML="";
	oElem.sw.EX="";
	if(sParam)
	{
		if(tRes=sParam.match( /^([1-9][0-9]{0,4})$/ ))
			oElem.len=tRes[1]-0;
		else
			return "fieldFormatParamInvalid@"+oElem.fmt+"@"+sParam;
	}
	oElem.layout=oElem.len+" "+sLib;
	oElem.ml=oElem.len;
	oElem.check=_checkChampFmt;
	return "";
}

//MMM: ajout type
function _checkFmtID(oElem,sParam,sLib)
{
	var tRes;
	oElem.len=250;
	oElem.sw.UC="";
	oElem.sw.LC="";
	oElem.sw.TR="";
	oElem.sw.ML="";
	oElem.sw.EX="";
	if(sParam)
	{
		if(tRes=sParam.match( /^([1-9][0-9]{0,4})$/ ))
			oElem.len=tRes[1]-0;
		else
			return "fieldFormatParamInvalid@"+oElem.fmt+"@"+sParam;
	}
	oElem.layout=oElem.len+" "+sLib;
	oElem.ml=oElem.len;
	oElem.check=_checkChampID;
	return "";
}

//MMM: ajout type
function _checkFmtIN(oElem,sParam,sLib)
{
	var tRes;
	oElem.len=250;
	oElem.sw.UC="";
	oElem.sw.LC="";
	oElem.sw.TR="";
	oElem.sw.ML="";
	oElem.sw.EX="";
	if(sParam)
	{
		if(tRes=sParam.match( /^([1-9][0-9]{0,4})$/ ))
			oElem.len=tRes[1]-0;
		else
			return "fieldFormatParamInvalid@"+oElem.fmt+"@"+sParam;
	}
	oElem.layout=oElem.len+" "+sLib;
	oElem.ml=oElem.len;
	oElem.check=_checkChampIN;
	return "";
}

function _checkFmtIP(oElem,sParam)
{
	oElem.sw.ML="";
	if(sParam)
		return "fieldIPformatInvalid@"+oElem.fmt+"@"+sParam;
	else
		oElem.layout=msgLang_fieldIPsyntaxe;
	oElem.ml=15;
	oElem.check=_checkChampIP;
	return "";
}

function _checkFmtMail(oElem,sParam,sLib)
{
	var tRes;
	oElem.len=250;
	oElem.sw.UC="";
	oElem.sw.LC="";
	oElem.ML;
	if(sParam)
		if(tRes=sParam.match( /^([1-9][0-9]{0,2})$/ ))
			oElem.len=tRes[1]-0;
		else
			return "fieldMailFormatInvalid@"+oElem.fmt+"@"+sParam;
	oElem.layout=msgLang_fieldMailSyntaxe + " ("+oElem.len+" "+sLib+")";
	oElem.ml=oElem.len;
	oElem.check=_checkChampMail;
	return "";
}

function _checkFmtBoolean(oElem,sParam)
{
	var tRes;
	oElem.items="";
	oElem.sw.UC="";
	oElem.sw.LC="";
	oElem.sw.ML="";
	oElem.ml=0;
	if(tRes=sParam.match( /^[^.]+-[^,]+$/ ))
	{
		oElem.items=sParam.split("-");
		oElem.layout=sParam;
		for(iCtr=0; iCtr<oElem.items.length; iCtr++)
			if(oElem.items[iCtr].length>oElem.ml)
				oElem.ml=oElem.items[iCtr].length;
	}
	else
		return "fieldBoolFormatInvalid@"+oElem.fmt+"@"+sParam;
	oElem.check=_checkChampBoolean;
	return "";
}

function _checkFmtList(oElem,sParam)
{
	oElem.items="";
	oElem.sw.UC="";
	oElem.sw.LC="";
	oElem.sw.ML="";
	if(sParam)
	{
		oElem.items=sParam.split(",");
		oElem.layout=sParam;
		for(iCtr=0; iCtr<oElem.items.length; iCtr++)
			if(oElem.items[iCtr].length>oElem.ml)
				oElem.ml=oElem.items[iCtr].length;
	}
	else
		return "fieldListFormatInvalid@"+oElem.fmt+"@"+sParam;
	oElem.check=_checkChampList;
	return "";
}

function _checkFmtSelect(oElem,sParam)
{
	if(sParam=="") return "";
	var tOptions=sParam.split("§");
	var iCtr,tValeurs;
	while(oElem.src.options.length>0) oElem.src.remove(0);
	for(iCtr=0; iCtr<tOptions.length; iCtr++)
	{
		tValeurs=tOptions[iCtr].split("|");
		if(tValeurs.length<2)
			oElem.src.options.add(new Option(tValeurs[0],tValeurs[0]));
		else
			oElem.src.options.add(new Option(EprUnescape(tValeurs[1]),tValeurs[0]));
	}
	return "";
}

function _checkFmtOption(oElem,sOption)
{
	var tRes;
	if(tRes=sOption.match( /^F([A-Z]+)([0-9]+)$/) )
		oElem.maj[tRes[1]]=tRes[2]-0;
	else if(tRes=sOption.match( /^D(.+)$/ ))
		oElem.defaultValue=tRes[1];
	else if((tRes=sOption.match( /^([A-Z]+)(.+)$/))
		&& oElem.sw[tRes[1]]!=null)
	{
//MMM		alert(tRes[1] + " == " +tRes[2]);
		oElem.sw[tRes[1]] = tRes[2];
	}
	else if(oElem.sw[sOption]==null)
		return "fieldListOptInvalid@"+sOption;
	else if(oElem.sw[sOption])
		return "fieldListOptRepeated@"+sOption;
	else
		oElem.sw[sOption]=1;
	return "";
}

// <--- Functions de vérification des la valeur des champs proprement dit --->

function _CheckScr(sForm,sMaj)
{
	var oElem,oFocus,sMsg;
	var sError="";

	for(var sCtr in this.tUtils)
	{
		oElem=this.tUtils[sCtr];
		if (sForm != null && oElem.src.form != sForm) continue;
		if(sMaj && oElem.maj[sMaj]==null) continue;
		sMsg=this.CheckVal(oElem.src);
		if(sMsg && !sError)
		{
			sError=sMsg;
			oFocus=oElem.src;
		}
	}
	if(sError)
	{
		alert(this.ReplParamSep(sError));
		_FldFocus(oFocus);
		return 1;
	}
	return 0;
}

function _appliIdMake(appliIdList)
{
	var arr = appliIdList.split("|"), ret = new Array, cnt=0;
    for(var i = 0; i < arr.length; i++)
    {
		ret[cnt++] = "$f_"+arr[i]+"_";
	}
	return ret;
}

function _appliIdMatch(sCtrName, appliIdList)
{
    for(var i = 0; i < appliIdList.length; i++)
    {
		var sappid = appliIdList[i];
    	if (sCtrName.substr(0,sappid.length) == sappid)
			return true;
	}
	return false;
}

function _SendAllScr(sForm,appliId,inputCheck,sMaj)
{
	var oElem,oFocus,sMsg;
	var sError="";
	var params = new Array;
	var _appliPrefix;
	if (appliId)
		_appliPrefix=_appliIdMake(appliId);

	if (inputCheck)
	{
		for(var sCtr in this.tUtils)
		{
			oElem=this.tUtils[sCtr];
	//		if (sForm != null && oElem.src.form != sForm) continue;
	        if (_appliPrefix && !_appliIdMatch(sCtr,_appliPrefix))
				continue;
			if(sMaj && oElem.maj[sMaj]==null) continue;
			sMsg=this.CheckVal(oElem.src);
			if(sMsg && !sError)
			{
				sError=sMsg;
				oFocus=oElem.src;
			}
		}
	}
	if(sError)
	{
		alert(this.ReplParamSep(sError));
		_FldFocus(oFocus);
		return false;
	}
//	alert("posting form "+sForm.id);
	sForm.submit();

	return 'nochange';
}

function _RemoveFields(appliId)
{
	var _appliPrefix;
    if (appliId)
        _appliPrefix=_appliIdMake(appliId);
	var newArray = new Array;
	for(var sCtr in this.tUtils)
	{
        if (_appliPrefix && _appliIdMatch(sCtr,_appliPrefix))
            continue;
	    oElem=this.tUtils[sCtr];
		newArray[sCtr] = oElem;
	}

	this.tUtils = newArray;

	newArray = new Array;
	for(var sCtr in this.tHiddens)
	{
        if (_appliPrefix && _appliIdMatch(sCtr,_appliPrefix))
            continue;
	    oElem=this.tHiddens[sCtr];
		newArray[sCtr] = oElem;
	}

	this.tHiddens = newArray;
}

function _SendRemoteScr(sForm,appliId,remoteFrm,remoteUrl,inputCheck,sMaj)
{
    var oElem,oFocus,sMsg;
    var sError="",limReached=false;
	var params="";
	var _appliPrefix;
    if (appliId)
        _appliPrefix=_appliIdMake(appliId);

	for(var sCtr in this.tHiddens)
	{
		oElem=this.tHiddens[sCtr];
//      if (sForm != null && oElem.src.form != sForm) continue;
        if (_appliPrefix && !_appliIdMatch(sCtr,_appliPrefix))
            continue;
		if(sMaj && oElem.maj[sMaj]==null) continue;
		if (!oElem.src.name)
			continue;
		params += "&" + oElem.src.name + '=' + EprEscape(oElem.src.value);
	}

	for(var sCtr in this.tUtils)
	{
	    oElem=this.tUtils[sCtr];
//      if (sForm != null && oElem.src.form != sForm) continue;
        if (_appliPrefix && !_appliIdMatch(sCtr,_appliPrefix))
            continue;
	    if(sMaj && oElem.maj[sMaj]==null) continue;
		if (inputCheck)
		{
			sMsg=this.CheckVal(oElem.src);
			if(sMsg && !sError)
			{
				sError=sMsg;
				oFocus=oElem.src;
			}
		}
		if (!oElem.src.name)
			continue;
	    if (sError)
			continue;
		var arg = "&" + oElem.src.name + '=' + EprEscape(this.GetEleVal(oElem));
		if (arg.length + params.length > 1700)
		{
			limReached = true;
			continue;
		}
        params += arg;
	}

	remoteUrl += params;
//	alert(params);
    if (limReached)
    {
        alert("Warning: Data to post exceeds size limit !");
    }


    if(sError)
    {
        alert(this.ReplParamSep(sError));
        _FldFocus(oFocus);
        return false;
    }

	var frm = document.getElementById(remoteFrm);
	if (!frm)
	{
		alert("Remote frame '"+remoteFrm+"' not found !");
		return false;
	}
    //alert("Remote url="+remoteUrl);

	frm.src = remoteUrl;

    return 'nochange';
}

function _ExecuteResponse(retobj,url)
{
	var ret;
	if (typeof(retobj) == 'string')
		ret = retobj;
	else
		ret = retobj.return_value;
//	alert('rs: '+ret);
	if (ret == 'nochange')
		return;
	if (ret == 'done')
	{
		if (typeof(url) != 'undefined' && url !='')
		{
			if (url == 'self')
				document.location.reload(true);
			else
				document.location.href=url;
		}
		return;
	}
	var pos = ret.indexOf(':');
	if (pos < 0)
	{
		alert('Unknown remote script response: '+ret);
		return;
	}
	var opval=ret.substr(pos+1);
	var opname=ret.substr(0,pos);

	if (opname=='url')
	{
		document.location.href=opval;

		return;
	}

	alert('Unknown remote script response(2): '+ret);
}

function _CheckVal(Obj)
{
	var sObj=(typeof(Obj)=="object" ? Obj.id : Obj);
	var oElem=this.tUtils[sObj];
	var sMsg="";
	if(oElem==null) return "";
	if(oElem.check==null) return "";
	if(oElem.sw.TR || oElem.sw.TR==null)
		oElem.src.value=oElem.src.value.replace(/(^\s+|\s+$)/g,"");
	if(oElem.src.value)
		sMsg=oElem.check();
	else if(!oElem.sw.NULL)
		sMsg="fieldValueRequired";
	this.FldError(oElem,sMsg);
	return sMsg;
}
function _FldError(oElem,errmsg)
{
    oElem.src.className=(errmsg ? this.sty.err : oElem.defaultClass);

	if(oElem.sw && oElem.sw.TI)
		return;

	if (errmsg)
		oElem.src.title = this.ReplParamSep(errmsg);
	else
	{
		if (errmsg)
			oElem.src.title = errmsg;
		else
			oElem.src.title = "";
	}
    var divErrId = 'fldErr_'+oElem.src.id;
	var divErr = document.getElementById(divErrId);
	if (!divErr)
	{
		if (divErrId.substr(divErrId.length - 7) == '-handly')
		{
			divErrId = divErrId.substr(0, divErrId.length - 7);
			divErr = document.getElementById(divErrId);
		}
	}
	if (!divErr)
	{
//		if (errmsg)
//			alert(divErrId + " not found (PutError) !");
		return;
	}
	if (errmsg)
	{
		divErr.innerHTML="<img src='"+this.errorIco+"' border=0>";
		divErr.title = oElem.src.title;
	}
	else
	{
		divErr.innerHTML="";
		divErr.title = "";
	}
}

function _FldFocus(sObj)
{
	try
	{
		if (typeof(sObj)=="object")
		{
			if (!sObj.focus)
				return false;
			sObj.focus();
			return true;
		}
		var obj = document.getElementById(sObj+"-handly");
		if (obj)
			return _FldFocus(obj);
	    obj = document.getElementById(sObj);
	    if (!obj)
			return false;
		return _FldFocus(obj);
	}
	catch(e)
	{
		return false;
	}
}
function _PutError(Obj,errmsg)
{
	var sObj=(typeof(Obj)=="object" ? Obj.id : Obj);
	var oElem=this.tUtils[sObj];
	var sMsg="";
	if(oElem==null)
	{
		oElem = this.tUtils[sObj+"-handly"];
		if(oElem==null)
		{
		    var divErrId = 'fldErr_'+sObj;
		    var divErr = document.getElementById(divErrId);
            var divErrInp = document.getElementById(sObj);
			if (divErrInp)
			{
				divErrInp.className = "bos_fielderror";
				divErrInp.title = errmsg;
			}
		    if (!divErr)
		    {
//		        if (errmsg && !divErrInp)
//		            alert(divErrId + " not found (PutError) !");
		        return null;
		    }
		    if (errmsg)
		    {
		        divErr.innerHTML="<img src='"+this.errorIco+"' border=0>";
		        divErr.title = errmsg;
		    }
		    else
		    {
		        divErr.innerHTML="";
		        divErr.title = "";
		    }

			return null;
		}
	}
	this.FldError(oElem,errmsg);
	return oElem;
}

function _PutModified(Obj)
{
	var sObj=(typeof(Obj)=="object" ? Obj.id : Obj);
	var oElem=this.tUtils[sObj];
	if(oElem==null)
	{
		oElem = this.tUtils[sObj+"-handly"];
		if(oElem==null)
		{
		    var divErrId = 'fldErr_'+sObj;
		    var divErr = document.getElementById(divErrId);
		    if (!divErr)
		    {
		        return null;
		    }

			if (this.modifiedIco)
				divErr.innerHTML="<img src='"+this.modifiedIco+"' border=0>";
			else
				divErr.innerHTML="";
	        divErr.title = "Modified";
			return null;
		}
	}

    var divErrId = 'fldErr_'+oElem.src.id;
	var divErr = document.getElementById(divErrId);
	if (!divErr)
		return null;

	if (this.modifiedIco)
		divErr.innerHTML="<img src='"+this.modifiedIco+"' border=0>";
	else
		divErr.innerHTML="";
    divErr.title = "Modified";
	return oElem;
}

function _checkChampNumeric()
{
	var tRes=this.src.value.match(/^([+-]?)(\d+)([.,]?)(\d*)$/);
	var iTmp;
	if(!tRes) return "fieldNumStringInvalidNoArg";
	if(this.sgn && (tRes[1]=="-")!=(this.sgn=="-")) return "fieldNumSignInvalid";
	if(tRes[2].length>this.len) return "fieldNumStringInvalid@"+this.layout;
	if(tRes[3])
	{
		if(tRes[3].charAt(0)!=this.locale.numSep) return "fieldNumStringInvalid@"+this.layout;
		if(tRes[4].length>this.dec) return "fieldNumStringInvalid@"+this.layout;
	}
	iTmp=parseFloat(this.fctToScr(this.src.value));
	if( this.min && (iTmp<parseFloat(this.min)) ) return "fieldNumNotInRange@"+this.limits;
	if( this.max && (iTmp>parseFloat(this.max)) ) return "fieldNumNotInRange@"+this.limits;
	return "";
}

function _checkChampDate()
{
	var sValeur=this.locale.DateFromScr(this.src.value);
	if(!sValeur) return "fieldDateStringInvalid";
	if(!this.locale.DateCheck(sValeur))
		return "fieldDateInvalid";
	if(this.min && (this.locale.DateCmp(sValeur,this.min)==-1)) return "fieldDateNotInRange@"+this.limits;
	if(this.max && this.locale.DateCmp(sValeur,this.max)==1) return "fieldDateNotInRange@"+this.limits;
	return "";
}

function _checkChampTime()
{
	var sValeur=this.locale.TimeFromScr(this.src.value);
	if(!sValeur) return "fieldTimeStringInvalid@"+this.src.value;
	if(!this.locale.TimeCheck(sValeur))
		return "fieldTimeInvalid";
	if(this.min && this.locale.TimeCmp(sValeur,this.min)==-1) return "fieldTimeNoInRange@"+this.limits;
	if(this.max && this.locale.TimeCmp(sValeur,this.max)==1) return "fieldTimeNoInRange@"+this.limits;
	return "";
}

function _checkChampPass()
{
	if(this.len < this.src.value.length) return "fieldValueTooLong@"+this.len;
	//if((this.src.value.length-3)<0) return "fieldValueTooLittle@3";
	var tRes;
	if(this.src.value!=""&&this.limits>0)
	{

		tRes=this.src.value.match( /(\d{1})/g );

		if(!tRes) {return "fieldPasswordWithoutNum@"+this.limits;}
		else
			if(tRes.length<this.limits) {return "fieldPasswordWithoutNum@"+this.limits;}
	}
	if(this.sw.UC) this.src.value=this.src.value.toUpperCase();
	else if(this.sw.LC) this.src.value=this.src.value.toLowerCase();
	return "";
}

function _checkChampText()
{
/*	if(this.len < this.src.value.length) return "fieldValueTooLong@"+this.len;*/
	if(this.sw.UC) this.src.value=this.src.value.toUpperCase();
	else if(this.sw.LC) this.src.value=this.src.value.toLowerCase();
	var tRes=this.src.value.match( /(\|+|\§+|\#+|\~+)|\µ+/g );
	if(!tRes)
	{
		tRes = -1;
		var exclChs = this.sw.EX.split(",");
		for(var iex in exclChs)
		{
			if (exclChs[iex] && (tRes = this.src.value.indexOf(EprUnescape(exclChs[iex])))>=0)
				break;
		}
		if (tRes < 0)
			return "";
	}

	var ret = "fieldCharForbidden@|,§,#,~,µ";
	if (this.sw.EX && this.sw.EX != "")
	{
		ret += ","+EprUnescape(this.sw.EX);
	}
	return ret;
}


function _checkChampScript()
{
	if (this._editor != null)
	{
		this.src.value = this._editor.getHTML();
	}
	if(this.len < this.src.value.length) return "fieldValueTooLong@"+this.len;
	if(this.sw.UC) this.src.value=this.src.value.toUpperCase();
	else if(this.sw.LC) this.src.value=this.src.value.toLowerCase();
	return "";
}

function _checkChampFmt()
{
/*	if(this.len < this.src.value.length) return "fieldValueTooLong@"+this.len;*/
	if(this.sw.UC) this.src.value=this.src.value.toUpperCase();
	else if(this.sw.LC) this.src.value=this.src.value.toLowerCase();
	var tRes=this.src.value.match( /\µ+/g );
	if(!tRes)
	{
		tRes = -1;
		var exclChs = this.sw.EX.split(",");
		for(var iex in exclChs)
		{
			if (exclChs[iex] && (tRes = this.src.value.indexOf(EprUnescape(exclChs[iex])))>=0)
				break;
		}
		if (tRes < 0)
			return "";
	}
	var ret = "fieldCharForbidden@µ";
	if (this.sw.EX && this.sw.EX != "")
	{
		ret += ","+EprUnescape(this.sw.EX);
	}
	return ret;
}

//MMM
function _checkChampID()
{
	var tRes=this.src.value.match(/^[A-Za-z_]([0-9A-Za-z_]+)$/);
	if(!tRes) return "fieldCharForbidden@"+this.src.value;

/*	if(this.len < this.src.value.length) return "fieldValueTooLong@"+this.len;*/

	if(this.sw.UC) this.src.value=this.src.value.toUpperCase();
	else if(this.sw.LC) this.src.value=this.src.value.toLowerCase();

	tRes = -1;
	var exclChs = this.sw.EX.split(",");
	for(var iex in exclChs)
	{
		if (exclChs[iex] && (tRes = this.src.value.indexOf(EprUnescape(exclChs[iex])))>=0)
			break;
	}
	if (tRes < 0)
		return "";
	var ret = "fieldCharForbidden@"+this.src.value.charAt(tRes);
	return ret;
}

//MMM
function _checkChampIN()
{
	var tRes=this.src.value.match(/^([0-9A-Za-z =@._-]+)$/);
	if(!tRes) return "fieldCharForbidden@"+this.src.value;

/*	if(this.len < this.src.value.length) return "fieldValueTooLong@"+this.len;*/

	if(this.sw.UC) this.src.value=this.src.value.toUpperCase();
	else if(this.sw.LC) this.src.value=this.src.value.toLowerCase();

	tRes = -1;
	var exclChs = this.sw.EX.split(",");
	for(var iex in exclChs)
	{
		if (exclChs[iex] && (tRes = this.src.value.indexOf(EprUnescape(exclChs[iex])))>=0)
			break;
	}
	if (tRes < 0)
		return "";
	var ret = "fieldCharForbidden@"+this.src.value.charAt(tRes);
	return ret;
}

function _checkChampIP()
{
	var tRes=this.src.value.match(/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/);
	if(!tRes) return "fieldIPinvalid";
	for(iCtr=1; iCtr<=4; iCtr++)
		if(tRes[iCtr]>255) return "fieldIPinvalid";
	return "";
}

function _checkChampMail()
{
	var tRes=this.src.value.match(/^([0-9A-Za-z._-]+)@([0-9A-Za-z._-]+)$/);
	if(!tRes) return "fieldMailInvalid";
	if(this.sw.UC) this.src.value=this.src.value.toUpperCase();
	else if(this.sw.LC) this.src.value=this.src.value.toLowerCase();
	return "";
}

function _checkChampBoolean()
{
	if(this.sw.UC) this.src.value=this.src.value.toUpperCase();
	else if(this.sw.LC) this.src.value=this.src.value.toLowerCase();
	var bFound=false;
	for(var iCtr=0; !bFound && iCtr<this.items.length; iCtr++)
		if(this.items[iCtr]==this.src.value) bFound=true;
	if(!bFound) return "fieldBoolInvalid@"+this.layout;
	return "";
}

function _checkChampList()
{
	if(this.sw.UC) this.src.value=this.src.value.toUpperCase();
	else if(this.sw.LC) this.src.value=this.src.value.toLowerCase();
	var bFound=false;
	for(var iCtr=0; !bFound && iCtr<this.items.length; iCtr++)
		if(this.items[iCtr]==this.src.value) bFound=true;
	if(!bFound) return "fieldListValueInvalid@"+this.items;
	return "";
}

// <---  Functions de contrôle et affichage --->

function _ClearScr(sForm,sMaj)
{
	for(var sCtr in this.tUtils)
	{
		var oElem=this.tUtils[sCtr];
		if (sForm != null && oElem.src.form != sForm) continue;
		if(sMaj && oElem.maj[sMaj]==null) continue;
		this.ClearVal(oElem.src);
	}
}

function _ClearVal(Obj)
{
	var sObj=(typeof(Obj)=="object" ? Obj.id : Obj);
	var oElem=this.tUtils[sObj];
	if(oElem==null) return 1;
	oElem.src.value=(((oElem.fctToScr)&&(oElem.typ!="P")) ? oElem.fctToScr(oElem.defaultValue,oElem.Info) : oElem.defaultValue);
	this.FldError(oElem);
	return 0;
}

function _ResetScr(sForm,sMaj)
{
	for(var sCtr in this.tUtils)
	{
		var oElem=this.tUtils[sCtr];
		if (sForm != null && oElem.src.form != sForm) continue;
		if(sMaj && oElem.maj[sMaj]==null) continue;
		if (oElem.src.readOnly && oElem.src.readOnly==true) continue;
		this.ResetVal(oElem.src);
	}
}

function _ResetVal(Obj)
{
	var sObj=(typeof(Obj)=="object" ? Obj.id : Obj);
	var oElem=this.tUtils[sObj];
	if(oElem==null) return 1;
	oElem.src.value="";
	this.FldError(oElem);
	return 0;
}

function _PutScr(sForm,sMaj,sSrc)
{
	var sCtr,iIndice,oElem,sValeur;
	var tValeurs=sSrc.split("|");
	for(var sCtr in this.tUtils)
	{
		oElem=this.tUtils[sCtr];
		if (sForm != null && oElem.src.form != sForm) continue;
		if(sMaj && oElem.maj[sMaj]==null) continue;
		iIndice=oElem.maj[sMaj];
		sValeur=(iIndice<tValeurs.length ? tValeurs[iIndice] : "");
		this.PutVal(oElem.src,sValeur);
	}
}

function _PutVal(Obj,sValeur)
{
	var sObj=(typeof(Obj)=="object" ? Obj.id : Obj);
	var oElem=this.tUtils[sObj];
	if(oElem==null) return 1;
	sValeur+="";
	if(oElem.sw.TR==null || oElem.sw.TR)
		sValeur=sValeur.replace(/(^\s+|\s+$)/g,"");
	if(oElem.sw.UC)
		sValeur=sValeur.toUpperCase();
	else if(oElem.sw.LC)
		sValeur=sValeur.toLowerCase();
	oElem.src.value=(oElem.fctToScr ? oElem.fctToScr(sValeur,oElem.Info) : sValeur);
	this.FldError(oElem);
	return 0;
}

function _GetScr(sForm,sMaj,iLen)
{
	var oElem;
	var tValeurs=[];
	if(iLen!=null) tValeurs.length=iLen;
	for(var sCtr in this.tUtils)
	{
		oElem=this.tUtils[sCtr];
		if (sForm != null && oElem.src.form != sForm) continue;
		if(sMaj && oElem.maj[sMaj]==null) continue;
		iIndice=oElem.maj[sMaj];
		tValeurs[iIndice]=this.GetEleVal(oElem);
	}
	return tValeurs.join("|");
}

function _GetVal(Obj)
{
	var sObj=(typeof(Obj)=="object" ? Obj.id : Obj);
	var oElem=this.tUtils[sObj];
	if(oElem==null) return "";
	return _GetEleVal(oElem);
}

function _GetEleVal(oElem)
{
	if (oElem._editor != null)
	{
		oElem.src.value = oElem._editor.getHTML();
	}
	if(oElem.sw.TR || oElem.sw.TR==null)
		oElem.src.value=oElem.src.value.replace(/(^\s+|\s+$)/g,"");
	if(oElem.sw.UC)
		oElem.src.value=oElem.src.value.toUpperCase();
	else if(oElem.sw.LC)
		oElem.src.value=oElem.src.value.toLowerCase();

	if(oElem.fctFromScr){  r = oElem.fctFromScr(oElem.src.value,oElem.Info)}
	else{r = oElem.src.value}
	return r;
}

function _LockScr(sForm,sMaj,bVal)
{
	var oElem;
	for(var sCtr in this.tUtils)
	{
		oElem=this.tUtils[sCtr];
		if (sForm != null && oElem.src.form != sForm) continue;
		if(sMaj && oElem.maj[sMaj]==null) continue;

		this.LockVal(oElem.src,bVal);
		this.FldError(oElem);
	}
}

function _LockVal(oObj,bVal)
{
	if(bVal!=null)
	{
		if(oObj.readOnly=bVal)
		{
			oObj.className=this.sty.loc;
			oObj.blur();
		}
		else
		{
			oObj.className=this.sty.txt;
		}
	}
	return oObj.readOnly;
}

function _ActifScr(sForm,sMaj,bVal)
{
	var oElem;
	for(var sCtr in this.tUtils)
	{
		oElem=this.tUtils[sCtr];
		if (sForm != null && oElem.src.form != sForm) continue;
		if(sMaj && oElem.maj[sMaj]==null) continue;
		this.ActifVal(this.tUtils[sCtr].src,bVal);
	}
}

function _ActifVal(oObj,bVal)
{
	if(bVal!=null)
	{
		if(oObj.disabled=!bVal)
			oObj.className=this.sty.loc;
		else
			oObj.className=(oObj.type && oObj.type=="text" ? this.sty.txt : this.sty.lst);
	}
	return !oObj.disabled;
}

function _LstClear(oSel)
{
	while(oSel.options.length>0) oSel.remove(0);
}

function _LstAdd(oSel,sValue,sText)
{
	if(sText==null)
		oSel.options.add(new Option(sValue,sValue));
	else
		oSel.options.add(new Option(sText,sValue));
}

function _LstAddAll(oSel,sParam)
{
	var tOptions=sParam.split("§");
	var iCtr,tValeurs;
	for(iCtr=0; iCtr<tOptions.length; iCtr++)
	{
		tValeurs=tOptions[iCtr].split("|");
		this.LstAdd(oSel,tValeurs[0],tValeurs[1]);
	}
}

//	==========
//	<--- gestion des messages et libellés suivant les langues --->
//	==========

function _ReplParam(iIndexMsg)
{
	var sReturn;
	try
	{
		sReturn=eval("msgLang_"+iIndexMsg);
	}
	catch(e)
	{
		sReturn=iIndexMsg;
	}
	if(sReturn==null) return "["+iIndexMsg+"]";
	for(var iCtr=arguments.length-1; iCtr>=1; iCtr--)
		sReturn=sReturn.replace(new RegExp("&&"+iCtr),arguments[iCtr]);
	return sReturn;
}

function _ReplParamSep(sMsg)
{
	var tMsgs=sMsg.split("@");
	var sReturn;
    try
    {
        sReturn=eval("msgLang_"+tMsgs[0]);
    }
    catch(e)
    {
        sReturn=tMsgs[0];
    }
	if(sReturn==null) return "["+sMsg+"]";
	for(var iCtr=tMsgs.length-1; iCtr>=1; iCtr--)
		sReturn=sReturn.replace(new RegExp("&&"+iCtr),tMsgs[iCtr]);
	return sReturn;
}

function _SrvError(Obj,epr)
{
	var sObj=""+(typeof(Obj)=="object" ? Obj.return_value : Obj);
	//MMM 2003/4/4
	if (sObj == "" && Obj.message && Obj.message != "")
	{
		if (Obj.message.indexOf("$flderror|") == 0)
		{
			var fldname = Obj.message.substr(10);
			var pos = fldname.indexOf("|");
			if (pos >= 0)
			{
				var txt=fldname.substr(pos+1);
				fldname = fldname.substr(0,pos);
				if (txt.substr(0,1) == "@")
					txt = this.ReplParamSep(txt.substr(1));
				else if (epr)
					txt = txt.replace("&&0",epr.GetVal(fldname));

				var oElem;
				if (epr)
					oElem = epr.PutError(fldname,txt);

				alert(txt);
				if (oElem)
					epr.FldFocus(oElem.src);

				return 1;
			}
		}
		alert(Obj.message+"\n\n[Call to remote script has failed !]");
		return 1;
	}
	sObj=sObj.replace(/\n/g,"\\n");
	var tRes=sObj.match(/^@ERR@(ID@)?(.*)$/);
	if(!tRes) return 0;
	tRes[2]=tRes[2].replace(/\\n/g,"\n");
	var sReturn;
	if(tRes[1])
		sReturn=this.ReplParamSep(tRes[2]);
	else
		sReturn=tRes[2];
	alert(sReturn);
	return 1;
}

function _SrvMessage(iMsg)
{
	var sReturn;
	if(iMsg==1)
	{
		sReturn="E_Process - Load...";
	}
	else if(iMsg==2)
	{
		sReturn="E_Process - Ready...";
	}
	window.defaultStatus=sReturn;
	return sReturn;
}

//	=====
//	<--- Objet ´Locale´ : gère les conversions de date, heure, chiffres... --->
//	=====

function _loc(sFormats,sLibs)
{
	this.SetLocale=_SetLocale;

// Date functions
	this.DateCheck=_DateCheck;
	this.DateFromScr=_DateFromScr;
	this.DateToScr=_DateToScr;
	this.DateCmp=_DateCmp;
	this.DateDif=_DateDif;
	this.DateAdd=_DateAdd;
// Time functions
	this.TimeCheck=_TimeCheck;
	this.TimeFromScr=_TimeFromScr;
	this.TimeToScr=_TimeToScr;
	this.TimeCmp=_TimeCmp;
// Number functions
	this.NumberFromScr=_NumberFromScr;
	this.NumberToScr=_NumberToScr;
	this.NumberCmp=_NumberCmp;
	this.NumberCalc=_NumberCalc;

	this.SetLocale(sFormats,sLibs);
}

function _SetLocale(sFormats,sLibs)
{
	var tRes; //=sFormats.match( /^([DMY]{3})([./-]?)@([.:-]?)@([.,])$/ );
	if(!tRes)
		tRes=["","DMY","/",":","."];
	this.dat={};
	this.dat.D=tRes[1].indexOf("D");
	if(this.dat.D<0) return "2";
	this.dat[this.dat.D]=0;
	this.dat.M=tRes[1].indexOf("M");
	if(this.dat.M<0) return "3";
	this.dat[this.dat.M]=1;
	this.dat.Y=tRes[1].indexOf("Y");
	if(this.dat.Y<0) return "4";
	this.dat[this.dat.Y]=2;
	this.datSep=tRes[2];
	this.timSep=tRes[3];
	this.numSep=tRes[4];

	var tLibs=sLibs.split("@");
	if(tLibs.length<3)
		this.FmtDate="DD/MM/YYYY";
	else
		this.FmtDate=tLibs[this.dat[0]]+this.datSep+tLibs[this.dat[1]]+this.datSep+tLibs[this.dat[2]];
	if(tLibs.length<5)
		this.FmtTime="HH:MM";
	else
		this.FmtTime=tLibs[3]+this.timSep+tLibs[4];

	return "";
}

function _DateCheck(sSrc)
{
	var tDat=sSrc.match( /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/ );
	if(!tDat) return "";
	var dt=new Date(tDat[3],tDat[2]-1, tDat[1]);
	if(dt.getDate() != tDat[1]-0) return "";
	if(dt.getMonth() != tDat[2]-1) return "";
	if(dt.getFullYear() != tDat[3]) return "";
	return sSrc;
}

function _DateFromScr(sSrc)
{
	var tRes;
	if(this.datSep)
	{
		switch(this.dat.Y)
		{
			case 0:  tRes=sSrc.match(/^(\d{4})(\D)(\d{1,2})(\D)(\d{1,2})$/); break;
			case 1:  tRes=sSrc.match(/^(\d{1,2})(\D)(\d{4})(\D)(\d{1,2})$/); break;
			default: tRes=sSrc.match(/^(\d{1,2})(\D)(\d{1,2})(\D)(\d{4})$/); break;
		}
		if(!tRes || tRes[2]!=this.datSep || tRes[4]!=this.datSep) return "";
		return tRes[this.dat.D*2+1]+"/"+tRes[this.dat.M*2+1]+"/"+tRes[this.dat.Y*2+1];
	}

	switch(this.dat.Y)
	{
		case 0:  tRes=sSrc.match(/^(\d{4})(\d{2})(\d{2})$/); break;
		case 1:  tRes=sSrc.match(/^(\d{2})(\d{4})(\d{2})$/); break;
		default: tRes=sSrc.match(/^(\d{2})(\d{2})(\d{4})$/); break;
	}
	if(!tRes) return "";
	return tRes[this.dat.D+1]+"/"+tRes[this.dat.M+1]+"/"+tRes[this.dat.Y+1];
}

function _DateToScr(sSrc)
{
	var tRes=sSrc.match(/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/);
	if(!tRes) return "";
	if(tRes[1].length<2) tRes[1]="0"+tRes[1];
	if(tRes[2].length<2) tRes[2]="0"+tRes[2];
	return tRes[this.dat[0]+1]+this.datSep+tRes[this.dat[1]+1]+this.datSep+tRes[this.dat[2]+1];
}

function _DateCmp(sDat1,sDat2)
{
	var tDat1=sDat1.match( /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/ );
	if(!tDat1) return "";
	var tDat2=sDat2.match( /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/ );
	if(!tDat2) return "";
	var dt1=new Date(tDat1[3], tDat1[2]-1, tDat1[1]);
	var dt2=new Date(tDat2[3], tDat2[2]-1, tDat2[1]);
	if(dt1>dt2) return 1;
	if(dt1<dt2) return -1;
	return 0;
}

function _DateDif(sDat1,sDat2)
{
	var t3;

	var tDat1=sDat1.match( /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/ );
	if(!tDat1) return "";
	var tDat2=sDat2.match( /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/ );
	if(!tDat2) return "";
	var dt1=new Date(tDat1[3], tDat1[2]-1, tDat1[1]);
	var dt2=new Date(tDat2[3], tDat2[2]-1, tDat2[1]);

	var MinMilli = 1000 * 60
	var HrMilli = MinMilli * 60
	var DyMilli = HrMilli * 24
	t3 = dt2-dt1;
	r = Math.round(t3 / DyMilli);
	return r;
}

function _DateAdd(sDat1,sNum)
{
	var tDat1=sDat1.match( /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/ );
	if(!tDat1) return "";
	if(!sNum) return "";

	var dt1=new Date(tDat1[3], tDat1[2]-1, tDat1[1]);

	daysup = new Number(tDat1[1])
	sNum = new Number(sNum);
	r2 = (daysup+sNum);

	var dt2=new Date(tDat1[3], tDat1[2]-1, r2);
	r = dt2.getDate()+"/"+(dt2.getMonth()+1)+"/"+dt2.getUTCFullYear();
	return(r);
}

function _TimeCheck(sSrc)
{
	var tRes=sSrc.match(/^(\d{1,2}):(\d{2})$/);
	if(!tRes) return "";
	if(tRes[1]-0>23) return "";
	if(tRes[2]-0>59) return "";
	return sSrc;
}

function _TimeFromScr(sSrc)
{
	var tRes;
	if(this.timSep)
	{
		tRes=sSrc.match(/^(\d{1,2})(\D)(\d{2})$/);
		if(!tRes || tRes[2]!=this.timSep) return "";
		if(tRes[1].length<2) tRes[1]="0"+tRes[1];
		return tRes[1]+":"+tRes[3];
	}

	tRes=sSrc.match(/^(\d{2})(\d{2})$/);
	if(!tRes) return "";
	return tRes[1]+":"+tRes[2];
}

function _TimeToScr(sSrc)
{
	var tRes=sSrc.match(/^(\d{1,2})\D(\d{2})$/);
	if(!tRes) return "";
	if(tRes[1].length<2) tRes[1]="0"+tRes[1];
	return tRes[1]+this.timSep+tRes[2];
}

function _TimeCmp(sTim1,sTim2)
{
	var tTim1=sTim1.match( /^(\d{1,2}):(\d{2})$/ );
	if(!tTim1) return "";
	var tTim2=sTim2.match( /^(\d{1,2}):(\d{2})$/ );
	if(!tTim2) return "";
	if(tTim1[1]-0<tTim2[1]-0) return -1;
	if(tTim1[1]-0>tTim2[1]-0) return 1;
	if(tTim1[2]-0<tTim2[2]-0) return -1;
	if(tTim1[2]-0>tTim2[2]-0) return 1;
	return 0;
}

function _NumberFromScr(sSrc)
{
	var tRes=sSrc.match( /^([+-]?\d+)(\D?)(\d*)$/ );
	if(!tRes || (tRes[2] && tRes[2]!=this.numSep)) return "";
	return tRes[1]+(tRes[2]?"."+tRes[3]:"");
}

function _NumberCmp(sNum1,sNum2)
{
	if(sNum1-0==sNum2-0) return 0;
	else if(sNum1-0<sNum2-0) return -1;
	return 1;
}

function _NumberCalc(sFormul,iDeci)
{
var sReturn=sFormul;
 	var cCar;
	for(var iCtr=2; iCtr<arguments.length && iCtr<26; iCtr++)
	{
		cCar=String.fromCharCode(63+iCtr);
		var RegString = new RegExp(cCar,"g");
		sReturn=sReturn.replace(RegString,arguments[iCtr]);
	}
	if(sReturn.match(/[A-Z]/)) return "";
	iDeci = Math.pow(10,eval(iDeci));
	return (eval((Math.round(eval(sReturn) * iDeci))/iDeci));
}

function _NumberToScr(sSrc)
{
	sSrc = new String(sSrc);
	var tRes=sSrc.match( /^([+-]?\d+)(\D?)(\d*)$/ );
	if(!tRes) return "";
	return tRes[1]+(tRes[2]?this.numSep+tRes[3]:"");
}

//	=====
//	<--- Objet gen : Regroupant des fonctions utiles --->
//	=====

function _gen()
{
	this.ToSvr=_ToSvr;
	this.ToHTML=_ToHTML;
	this.FromHTML=_FromHTML;
	this.Chomp=_Chomp;
	this.IENum=_IENum;
}

function _ToSvr(sSrc)
{
	var sRet=""+sSrc;
	if(!sRet) return "";
	sRet=sRet.replace(/[\f\n\r]+/g," ");
	sRet=sRet.replace(/\\/g,"\\\\");
	sRet=sRet.replace(/"/g,'\\"');
	sRet=sRet.replace(/\+/g,"\\+");
	return sRet;
}

function _ToHTML(sSrc)
{
	var sRet=""+sSrc;
	if(!sRet) return "";
	sRet=sRet.replace(/&/g,"&amp;");
	sRet=sRet.replace(/'/g,"&rsquo");
	sRet=sRet.replace(/"/g,"&#34;");
	sRet=sRet.replace(/</g,"&lt;");
	sRet=sRet.replace(/>/g,"&gt;");
	return sRet;
}

function _FromHTML(sSrc)
{
	var sRet=""+sSrc;
	if(!sRet) return "";
	sRet=sRet.replace(/&amp;/g,"&");
	sRet=sRet.replace(/&rsquo/g,"'");
	sRet=sRet.replace(/&#34/g,'"');
	sRet=sRet.replace(/&lt;/g,"<");
	sRet=sRet.replace(/&gt;/g,">");
	return sRet;
}

function _Chomp(sSrc,sCar)
{
	sSrc+="";
	if(sCar==null || sSrc.charAt(sSrc.length-1)==sCar)
		return sSrc.slice(0,-1);
	return sSrc;
}

function _IENum()
{
	var tRes=window.navigator.appVersion.match(/;\s*msie\s*([0-9.]+)\s*;/i);
	if(!tRes) return 0;
	return parseFloat(tRes[1]);
}

// Procédure de gestion des popups -------------------------------------------------------------------->
domok = document.getElementById;
popupX = -1;
popupY = -1;
popupInfo = new Array;
popupInfoLock = false;

if (domok)
{
	if(navigator.appName.substring(0,3) == "Net")
		document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = get_mouse;
}
function get_mouse(e)
{
	try
	{
	    popupX = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
	    popupY = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
    }
	catch (em)
	{
        //if (debugMode) alert(em);
    }

}

function popupLevelNo(divlevel)
{
	if (typeof(divlevel) == 'undefined')
		return 0;
	return divlevel;
}

function popupLevel(divlevel)
{
	return popupInfo[popupLevelNo(divlevel)];
}

function popupLevelAccess(divlevel)
{
	var lvlno = popupLevelNo(divlevel);
	if (lvlno < popupInfo.length-1)
		popupLevelClose(lvlno-1);

	var lvl = popupInfo[lvlno];
    if (lvl)
        return lvl;

	if (popupInfo.length != lvlno)
    {
        alert("popupLevelAccess: pb stacklg("+popupInfo.length+") != level("+lvlno+")");
        toto();
    }

    lvl = {popupDiv: null, popupAppliId:null, popupLevel:lvlno, arrWindowedCtrl:null};
    popupInfo[lvlno] = lvl;
	return lvl;
}

function popupLevelCloseAll()
{
	popupLevelClose(0);
    popupInfoLock = false;
}

function popupLevelClose(divlevel)
{
    var lvlno = popupLevelNo(divlevel);
    if (lvlno < 0)
        lvlno = 0;

    if (lvlno >= popupInfo.length)
		return;

	for(var i = popupInfo.length-1; i >= lvlno; i--)
	{
		_popupLevelClose(popupInfo[i]);
	}

	var newInfo = new Array;
	for(var i = 0; i < lvlno; i++)
	{
		newInfo[i] = popupInfo[i];
	}

	popupInfo = newInfo;
	bosMCancel();
}

function _popupStyleHide(popupSt)
{
    popupSt.display = "none";
    popupSt.visibility = "hidden";
    popupSt.height = "0%";
}

function _popupStyleShow(popupSt)
{
    popupSt.display = "block";
    popupSt.visibility = "visible";
    popupSt.height = "";
}

function _popupLevelClose(lvl)
{
    if (lvl.popupDiv == null)
        return;
    if (lvl.popupAppliId)
    {
        Epr.RemoveFields(lvl.popupAppliId);
        lvl.popupAppliId = null;
    }
	var _popupDiv = lvl.popupDiv;
    lvl.popupDiv = null;
	_popupStyleHide(_popupDiv.style);
    _popupDiv.innerHTML = "**CLOSED**";

    _popupLevelShowWindowedCtrl(lvl);
	_popupLevelCtrlClose(lvl);
}

function popupLevel_click(divlevel)
{
    if (popupInfoLock)
    {
		if (divlevel == 0)
			popupInfoLock = false;
        return;
    }
	popupLevelClose(divlevel);
   	if (divlevel > 0)
       popupInfoLock = true;
}

function popupLevelVisible(divlevel,divName)
{
    var lvl = popupLevel(divlevel);
    if (!lvl)
        return false;

    var _div;
    if (typeof(divName) == "string")
        _div = document.getElementById(divName);
    else
        _div = divName;

    if (!_div)
    {
        alert("popupLevelVisible, div ("+divName+"): not found");
        return false;
    }

    return lvl.popupDiv == _div;
}

function popupLevelShow(divlevel,divName,appliId)
{
    if (!domok || popupX == -1 || popupY == -1)
        return;

    var lvl = popupLevelAccess(divlevel);

	var _div;
    if (typeof(divName) == "string")
        _div = document.getElementById(divName);
    else
        _div = divName;

    if (!_div)
	{
  		alert("popupLevelShow, div ("+divName+"): not found");
        return;
	}

	if (lvl.popupDiv != _div)
	{
	    if (lvl.popupDiv) _popupLevelClose(lvl);
		lvl.popupDiv = _div;
	}

	var _appliId;
    if (typeof(appliId) != "undefined")
        _appliId = appliId;
    else
        _appliId = null;
    if (_appliId != lvl.popupAppliId)
    {
        if (lvl.popupAppliId) Epr.RemoveFields(lvl.popupAppliId);
        lvl.popupAppliId = _appliId;
    }

    var popupSt = popupDiv.style;
    if (popupX - 10 < 0)
        popupSt.left = 0;
    else
        popupSt.left = popupX + 10;
    popupSt.top = popupY - 10;
	_popupStyleShow(popupSt);

    _popupLevelHideWindowedCtrl(_div,lvl,bosGetRect(popupDiv));
}

function popupLevelPlacedShow(divlevel,divName,ctrlName,popupMode,ctrlStyle,appliId)
{
	if (!domok)
	{
		alert("Popup not supported by your browser !");
		return;
	}

	var _div;
	if (typeof(divName) == "string")
		_div = document.getElementById(divName);
	else
		_div = divName;
	var _ctrl;
	if (typeof(ctrlName) == "string")
		_ctrl = document.getElementById(ctrlName);
	else
		_ctrl = ctrlName;
//	alert("div ("+divName+"): "+popupInplaceDiv);
	if (!_div || !_ctrl)
	{
		alert('unknown div :'+divName+', or ctrl:'+ctrlName+' !!');
		return;
	}

    var lvl = popupLevelAccess(divlevel),newpopup;

    if (lvl.popupDiv == _div)
		newpopup = false;
	else
    {
        if (lvl.popupDiv) _popupLevelClose(lvl);
        lvl.popupDiv = _div;
		newpopup = true;
    }

    var _appliId;
    if (typeof(appliId) != "undefined")
        _appliId = appliId;
    else
        _appliId = null;
    if (_appliId != lvl.popupAppliId)
    {
        if (lvl.popupAppliId) Epr.RemoveFields(lvl.popupAppliId);
        lvl.popupAppliId = _appliId;
    }
	_popupAlign(_div,_ctrl,popupMode);
	_popupLevelCtrl(lvl,_ctrl,ctrlStyle);
	if (newpopup)
	{
	    _popupStyleShow(_div.style);

        _popupLevelHideWindowedCtrl(_div,lvl,bosGetRect(_div));
	}
	else
	{
		popupLevelPlacedUpdate(divlevel,divName);
	}
}

function _popupAlign(_div,_ctrl,popupMode)
{
    var scX = 0, scY = 0, _popupMode = 0;
    if (typeof(popupMode) != "undefined")
        _popupMode = popupMode;

    var rect = bosGetRect(_ctrl);
/*  if (typeof(_div.getBoundingClientRect) != 'undefined')
    {
        rect = _ctrl.getBoundingClientRect();

        var node = _ctrl;
        while(node)
        {
            if (typeof(node.scrollLeft) != 'undefined')
            {
                scX += node.scrollLeft;
                scY += node.scrollTop;

                if (node.nodeName == "DIV")
                {
                    scX -= node.offsetLeft;
                    scY -= node.offsetTop;
                }
            }
            node = node.parentElement;
        }
    }
    else
        rect = document.getBoxObjectFor(_ctrl);
*/
    var rectPopup = bosGetRect(_div);
    var rectPopupWidth,rectPopupHeight;
    if (rectPopup)
    {
        rectPopupWidth = rectPopup.right - rectPopup.left;
        rectPopupHeight = rectPopup.bottom - rectPopup.top;
    }
/*  if (!rectPopupWidth)
        rectPopupWidth = 200;
    if (!rectPopupHeight)
        rectPopupHeight = 100;
*/
/*  if (_popupMode == 1)
    {
        popupSt.left = rect.left+scX+150;
        popupSt.top = rect.top+scY;
    }
    else*/
    {
        var px = rect.left+scX,py = rect.bottom+scY;
        var winSz = bosGetWindowSize();
        if (winSz && rectPopupWidth && rectPopupHeight)
        {
            //alert("Before sz: WinSz:"+winSz.width+"x"+winSz.height+", popup:"+rectPopupWidth+"x"+rectPopupHeight+", pos: x:"+px+", y:"+py);

            if (px+rectPopupWidth > winSz.width)
			{
                px = rect.right+scX - rectPopupWidth;
				if(px<5)
					px=5;
			}
            if (py+rectPopupHeight > winSz.height)
			{
                py = rect.top+scX - rectPopupHeight;
                if(py<5)
                    py=5;
			}

			// alert("After sz: WinSz:"+winSz.width+"x"+winSz.height+", popup:"+rectPopupWidth+"x"+rectPopupHeight+", pos: x:"+px+", y:"+py);
        }
		/*else
		{
			if (winSz)
				winSz = "{width:"+winSz.width+",height:"+winSz.height+"}";
            if (rectPopup)
                rectPopup = "{left:"+rectPopup.left+",top:"+rectPopup.top+" - right:"+rectPopup.right+",bottom:"+rectPopup.bottom+"}";
			alert("auto pos not supported : "+winSz+","+rectPopupWidth+","+rectPopupHeight+","+rectPopup);
		}*/

        bosSetXY(_div,{x:px,y:py});
    }
}

function _popupLevelCtrl(lvl,_ctrl,ctrlStyle)
{
	if (lvl.ctrl)
    {
		if (lvl.ctrl == _ctrl)
			return;
		_popupLevelCtrlClose(lvl);
	}
    if (!ctrlStyle)
		return;
//        ctrlStyle = 'background-color: green';

    lvl.ctrl = _ctrl;
    if (bos_mouseCtrl == _ctrl)
	{
        lvl.ctrlOldStyle = bos_mouseCtrlOldStyle;
        bos_mouseCtrlOldStyle = null;
	}
	else
    	lvl.ctrlOldStyle = _ctrl.style.cssText;

    _ctrl.style.cssText = ctrlStyle;
}

function _popupLevelCtrlClose(lvl)
{
    if (!lvl.ctrl)
		return;
    var _ctrl = lvl.ctrl;
	lvl.ctrl = null;
    _ctrl.style.cssText = lvl.ctrlOldStyle;
}

function popupLevelPlacedHideShow(divlevel,divName,ctrlName,divContent,popupMode,ctrlStyle,appliId)
{
	if (!domok)
		return false;

	var _div;
	if (typeof(divName) == "string")
		_div = document.getElementById(divName);
	else
		_div = divName;

	if (!_div)
    {
        alert("popupLevelPlacedHideShow, div ("+divName+"): not found");
        return false;
    }

    var lvl = popupLevelAccess(divlevel);

	if (lvl.popupDiv && lvl.popupDiv == _div)
	{
		popupLevelClose(divlevel);
		return false;
	}

    if (divContent && typeof(divContent) != 'undefined')
		_div.innerHTML = divContent;

	popupLevelPlacedShow(divlevel,_div,ctrlName,popupMode,ctrlStyle,appliId);

/*    if (divContent && typeof(divContent) != 'undefined')
    {
	    if (_div.all)
	    	_div.all[_div.all.length-1].scrollIntoView(false);
	}*/
//	alert('show: '+divName+':'+ctrlName);
	return true;
}

function popupLevelPlacedUpdate(divlevel,divName,appliId,ctrlName)
{
    if (!domok)
        return false;

    var _div;
    if (typeof(divName) == "string")
        _div = document.getElementById(divName);
    else
        _div = divName;

	if (_div.all)
	{
		var widthMax=0,cWidth;
		for(var iCtr=0; iCtr<_div.children.length; iCtr++)
		{
			oTag=_div.children[iCtr];

			cWidth = bosGetWidth(oTag);
			if (cWidth > widthMax)
				widthMax = cWidth;
		}
		if (widthMax > 200)
			_div.style.width=widthMax;
		else
			_div.style.width="400px";
	}
	else
		_div.style.width="";

	if (ctrlName)
	{
	    var _ctrl;
	    if (typeof(ctrlName) == "string")
	        _ctrl = document.getElementById(ctrlName);
	    else
	        _ctrl = ctrlName;

//		alert("popupLevelPlacedUpdate: ctrl align:"+ _ctrl);

		_popupAlign(_div,_ctrl);
	}

    var lvl = popupLevelAccess(divlevel);
    if (lvl.popupDiv != _div)
		return;

	if (typeof(appliId) != "undefined" && lvl.popupAppliId != appliId)
	{
        if (lvl.popupAppliId) Epr.RemoveFields(lvl.popupAppliId);
        lvl.popupAppliId = appliId;
	}

	var oldArrWindowedCtrl = lvl.arrWindowedCtrl;
	lvl.arrWindowedCtrl = null;
    _popupLevelHideWindowedCtrl(_div,lvl,bosGetRect(_div));

    var oTag,found;
    for(var iCtr=0; iCtr<oldArrWindowedCtrl.length; iCtr++)
    {
        oTag = oldArrWindowedCtrl[iCtr];
		found = false;
	    for(var iCtr2=0; iCtr2<lvl.arrWindowedCtrl.length; iCtr2++)
	    {
	        if (oTag == lvl.arrWindowedCtrl[iCtr2])
			{
				found = true;
				break;
			}
		}
		if (found)
			continue;

//		lvl.arrWindowedCtrl[lvl.arrWindowedCtrl.length] = oTag;
        oTag.style.visibility = 'visible';
    }
//	if (_div.all)
//		_div.all[_div.all.length-1].scrollIntoView(false);
    //alert('scroll into view - '+_div.getBoundingClientRect().top + ' - '+ _div.getBoundingClientRect().bottom);
}

function _popupLevelHideWindowedCtrl(div,lvl,rect)
{
	if (lvl.arrWindowedCtrl != null)
	{
		_popupLevelShowWindowedCtrl(lvl)
	}

	lvl.arrWindowedCtrl = new Array();

	var oTag,txt = '';
	if (document.all)
	{
		for(var iCtr=0, ix = 0; iCtr<document.all.length; iCtr++)
		{
			oTag=document.all[iCtr];
			if(typeof(oTag.type) == 'undefined' || oTag.type.indexOf('select') < 0)
			{
	//			txt += ',' + oTag.id + ':' +oTag.type;
				continue;
			}

			var crect = bosGetRect(oTag);

			if (rect.top >= crect.bottom ||  rect.bottom < crect.top
				|| rect.left >= crect.right ||  rect.right < crect.left)
				continue;
			if (oTag.style.visibility != 'visible' && oTag.style.visibility != '')
				continue;
			var par = oTag.parentElement;
			while(par)
			{
				if (par == div)
					break;
				par = par.parentElement;
			}
			if (par)
				continue;

			lvl.arrWindowedCtrl[ix] = oTag;
			oTag.style.visibility = 'hidden';
			ix++;
		}
	}
	else
	{
		var body = document.getElementById("bosbody");

		for(var iCtr=0; iCtr<body.length; iCtr++)
		{
			oTag=body.Item(iCtr);
			if(typeof(oTag.type) == 'undefined' || oTag.type.indexOf('select') < 0)
			{
	//			txt += ',' + oTag.id + ':' +oTag.type;
				continue;
			}

			var crect = bosGetRect(oTag);

			if (rect.top >= crect.bottom ||  rect.bottom < crect.top
				|| rect.left >= crect.right ||  rect.right < crect.left)
				continue;
			if (oTag.style.visibility != 'visible' && oTag.style.visibility != '')
				continue;
			var par = oTag.parentElement;
			while(par)
			{
				if (par == div)
					break;
				par = par.parentElement;
			}
			if (par)
				continue;

			lvl.arrWindowedCtrl[ix] = oTag;
			oTag.style.visibility = 'hidden';
			ix++;
		}
	}

//	alert(txt + ':' + arrWindowedCtrl.length);
}

function _popupLevelShowWindowedCtrl(lvl)
{
	if (lvl.arrWindowedCtrl == null)
		return;
	var oTag;
	for(var iCtr=0; iCtr<lvl.arrWindowedCtrl.length; iCtr++)
	{
		oTag = lvl.arrWindowedCtrl[iCtr];
		oTag.style.visibility = 'visible';
	}
	lvl.arrWindowedCtrl = null;
}

function bospopup_click(naviid,divid,url,divlevel,popupMode,ctrlStyle)
{
    popupInfoLock = true;

    if (!popupLevelPlacedHideShow(divlevel,divid, naviid,'<font color=gray><b><I>Please wait...</i></b></font>',popupMode,ctrlStyle))
        return false;

    bosMCancel();
    eval(url);

    return true;
}

function boslistbox_view(naviId,url,divlevel,mode)
{
    if (mode == 'edit')
    {
        var curPathVal = document.getElementById(naviId).value;
		if (!curPathVal)
		{
			//alert("No link to edit");
			return;
		}
    }

    popupInfoLock = true;

    if (!popupLevelPlacedHideShow(divlevel,'divpopup_'+naviId, naviId+'-ctrl',
		'<font color=gray><b><I>Please wait...</i></b></font>'))
		return false;

    var prevFnd = document.getElementById(naviId+'-find');
    if (prevFnd)
		prevFnd.value = '??';

    boslistbox_search(naviId,url,divlevel,true,mode);

    return true;
}
function boslistbox_editstart(naviId,noeditreset)
{
    var curFnd = document.getElementById(naviId);
    var curFnd3 = document.getElementById(naviId+'-handly');
    EprFldChanged(curFnd);
    EprFldChanged(curFnd3);
    if (curFnd.value == '')
        return;
    if (noeditreset)
    {
		var oldFnd = document.getElementById(naviId+'-oldval');
		if (oldFnd)
			oldFnd.value = curFnd3.value;
	}
    var curFnd2 = document.getElementById(naviId+'-key');
    if (curFnd3.value != curFnd2.value)
		curFnd3.value = curFnd2.value;
	if (!noeditreset)
		curFnd.value = '';
}
function boslistbox_editcancel(naviId)
{
    var curFnd = document.getElementById(naviId);
    if (curFnd.value == '')
        return;
    var oldFnd = document.getElementById(naviId+'-oldval');
    if (!oldFnd || oldFnd.value == '')
		return;
    var curFnd3 = document.getElementById(naviId+'-handly');
    if (curFnd3.value != oldFnd.value)
		curFnd3.value = oldFnd.value;
	oldFnd.value = '';
//    EprFldChangeCancel(curFnd);
//    EprFldChangeCancel(curFnd3);
}
function boslistbox_search(naviId,url,divlevel,noeditstart,mode)
{
    if (!popupLevelVisible(divlevel,'divpopup_'+naviId))
    {
	    if (!noeditstart)
	        boslistbox_editstart(naviId);

		boslistbox_view(naviId,url,divlevel,mode);
        return;
    }

    bosMCancel();

    if (!noeditstart)
		boslistbox_editstart(naviId);

	if (mode == 'edit')
	{
    	var curPathVal = document.getElementById(naviId).value;
    	eval(url);
		return;
	}

    var curFndVal = document.getElementById(naviId).value;
	if (!curFndVal)
    	curFndVal = document.getElementById(naviId+'-handly').value;
    var prevFnd = document.getElementById(naviId+'-find');
    if (prevFnd)
    {
		if (prevFnd.value == curFndVal)
			return;
		prevFnd.value = curFndVal;
	}
	eval(url);
}
function boslistbox_select(naviId,divlevel,mainPath,linkLabel,linkKey,iconUrl,onchg)
{
    var curFnd = document.getElementById(naviId);
    curFnd.value = mainPath;
    EprFldChanged(curFnd);

    curFnd = document.getElementById(naviId+'-handly');
    curFnd.value = linkLabel;
    EprFldChanged(curFnd);

    document.getElementById(naviId+'-key').value = linkKey;
    var prevFnd = document.getElementById(naviId+'-find');
    if (prevFnd)
		prevFnd.value = '??';
    var img = document.getElementById('icon_'+naviId);
	if (img)
		img.src = iconUrl;
	var oldFnd = document.getElementById(naviId+'-oldval');
	if (oldFnd)
		oldFnd.value = '';

    /* alert("changed !"); */
	if (onchg) eval(onchg);
	popupLevelClose(divlevel);
}


var bos_mouseCtrl = null,bos_mouseCtrlCancelled = null,bos_clickLocked=false,bos_clickSysLocked=false;
var bos_mouseCtrlOldStyle = null;
//var bos_mouseCtrlOldClass = null;
function bosMOver(ctrl,style)
{
    if (bos_mouseCtrl == ctrl)
        return;

    if (bos_mouseCtrl != null)
        return;
    /*bosMOut();*/

	bos_mouseCtrlCancelled = null;
    bos_mouseCtrl = ctrl;
    if (!ctrl)
        return;

/*          bos_mouseCtrlOldClass = ctrl.className;
    ctrl.className = "linksover";*/

    if (style == null)
    {
        bos_mouseCtrlOldStyle = null;
        return;
    }
    bos_mouseCtrlOldStyle = ctrl.style.cssText;

    ctrl.style.cssText = style+"; cursor: pointer";
}
function bosMOut(ctrl)
{
    if (typeof(ctrl) == 'undefined')
        ctrl = bos_mouseCtrl;
    if (bos_mouseCtrl == null)
        return;
    if (bos_mouseCtrl != ctrl)
        return;
    bos_mouseCtrl = null;
    if (bos_mouseCtrlOldStyle != null)
        ctrl.style.cssText = bos_mouseCtrlOldStyle;
//          if (bos_mouseCtrlOldClass != null)
//              ctrl.className = bos_mouseCtrlOldClass;
}
function bosMCancel()
{
	if (!bos_mouseCtrl)
		return;
	bos_mouseCtrlCancelled = bos_mouseCtrl;
	bosMOut();
}
function bosIsMOver(ctrl)
{
    if (typeof(ctrl) == 'undefined')
        ctrl = window.event.srcElement;//pour ie
    if (ctrl != bos_mouseCtrl && ctrl != bos_mouseCtrlCancelled)
		return false;
	if (!bos_clickLocked)
	{
		bosForceFocus(ctrl);
		return true;
	}
	if (bos_clickSysLocked)
	{
		bos_clickSysLocked = false;
		return false;
	}
    if (!confirm("Page is loading, you should wait. Do you want to proceed your new action anyway ?"))
		return false;

	bos_clickLocked = false;
    bosForceFocus(ctrl);
    return true;
}
function bosForceFocus(ctrl)
{
	if (!ctrl)
		return;

	try
	{
		ctrl.focus();
//		alert("bosForceFocus: Ok");
	}
	catch(e)
	{
//        alert("bosForceFocus: Err");
	}
}

function bosClickLocked()
{
	return bos_clickLocked;
}
function bosClickLock()
{
	bos_clickLocked = true;
}
function bosClickSysLock()
{
	bos_clickLocked = true;
	bos_clickSysLocked = true;
}
function bosClickUnlock()
{
	bos_clickLocked = false;
	bos_clickSysLocked = false;
}
function bosClickDone()
{
	bos_clickLocked = false;
	bos_clickSysLocked = false;
	bosMCancel();
}
function EprRemoveFields(AppId)
{
    Epr.RemoveFields(AppId);
}
function EprAddField(fldName,fldFmt,fldArg)
{
    Epr.AddField(fldName,fldFmt,fldArg);
}
function EprAddFieldHidden(fldName)
{
    Epr.AddFieldHidden(fldName);
}
function EprFldFocus(sObj)
{
    Epr.FldFocus(sObj);
}
function EprPutError(Obj,errmsg)
{
    Epr.PutError(Obj,errmsg);
}
function EprEventTarget(ev)
{
	return ev.srcElement? ev.srcElement : ev.target;
}
function EprEnterKey(event)
{
    // Compatibilité IE / Firefox
    if(!event && window.event)
        event = window.event;

    // IE
	if (event.keyCode == 13)
	{
		event.returnValue=false;
        event.cancelBubble = true;
		return true;
	}
    // DOM
    if(event.which == 13)
	{
        event.preventDefault();
        event.stopPropagation();
        return true;
    }
	return false;
}

function EprFldChanged(ctrl)
{
    if (typeof(ctrl) == 'undefined')
        ctrl = window.event.srcElement;//pour ie

//	alert('EprFldChanged: '+ctrl);

	if (ctrl.name != '')
		return;

    ctrl.name = ctrl.id;
    Epr.PutModified(ctrl);
}
function EprFldHdnChanged(ctrl)
{
    if (typeof(ctrl) == 'undefined')
        ctrl = window.event.srcElement;//pour ie

	if (ctrl.name != '')
		return;

	var ctname = ctrl.id.substr(4);
    ctrl.name = ctname;
    Epr.PutModified(ctname);
}
function EprFldChangeVal(ctrl,val)
{
    ctrl.value = val;
	if (ctrl.name != '')
		return;
    ctrl.name = ctrl.id;
    Epr.PutModified(ctrl);
}
function EprEscape(val)
{
//	if (!encodeURIComponent)
//		return escape(val);
	return encodeURIComponent(val);
}
function EprUnescape(val)
{
//	if (!encodeURIComponent)
//		return unescape(val);
	return decodeURIComponent(val);
}

function bosGetStyle(el, property)
{
	var value = null;
	var dv = document.defaultView;

    if (typeof(el) == "string")
        el = document.getElementById(el);

	if (property == 'opacity' && el.filters)
	{// IE opacity
         value = 1;
		try
		{
			value = el.filters.item('DXImageTransform.Microsoft.Alpha').opacity / 100;
		}
		catch(e)
		{
			try {
				value = el.filters.item('alpha').opacity / 100;
			}
			catch(e)
			{}
         }
	}
	else if (el.style[property])
		value = el.style[property];
	else if (el.currentStyle && el.currentStyle[property])
		value = el.currentStyle[property];
	else if ( dv && dv.getComputedStyle )
	{  // convert camelCase to hyphen-case
		var converted = '';
		for(i = 0, len = property.length;i < len; ++i)
		{
			if (property.charAt(i) == property.charAt(i).toUpperCase())
				converted = converted + '-' + property.charAt(i).toLowerCase();
			else
				converted = converted + property.charAt(i);
		}

		if (dv.getComputedStyle(el, '').getPropertyValue(converted))
			value = dv.getComputedStyle(el, '').getPropertyValue(converted);
	}

	return value;
};

function bosSetStyle(el, property, val)
{
    if (typeof(el) == "string")
        el = document.getElementById(el);
	switch(property)
	{
	case 'opacity' :
		if (el.filters)
		{
			el.style.filter = 'alpha(opacity=' + val * 100 + ')';

			if (!el.currentStyle.hasLayout)
				el.style.zoom = 1;
            else
			{
               el.style.opacity = val;
               el.style['-moz-opacity'] = val;
               el.style['-khtml-opacity'] = val;
			}
		}
        break;
	default :
		el.style[property] = val;
	}
};

function bosGetXY(el)
{
    if (typeof(el) == "string")
        el = document.getElementById(el);

	if (el.parentNode === null || bosGetStyle(el, 'display') == 'none')
		return false;

	if (el.getBoundingClientRect)
	{ // IE
		box = el.getBoundingClientRect();

		var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
		var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;

		return {x:box.left + scrollLeft, y:box.top + scrollTop};
	}

    var parent = null;
    var pos = [];
    var box;

	if (document.getBoxObjectFor)
	{ // gecko
		box = document.getBoxObjectFor(el);
		pos = {x:box.x, y:box.y};
	}
	else
	{ // safari/opera
		pos = {x:el.offsetLeft, y:el.offsetTop};
		parent = el.offsetParent;
		if (parent != el)
		{
			while (parent)
			{
			   pos.x += parent.offsetLeft;
			   pos.y += parent.offsetTop;
			   parent = parent.offsetParent;
			}
		}

         // opera & (safari absolute) incorrectly account for body offsetTop
         var ua = navigator.userAgent.toLowerCase();
         if (ua.indexOf('opera') != -1
            || ( ua.indexOf('safari') != -1 && bosGetStyle(el, 'position') == 'absolute' ))
            pos.y -= document.body.offsetTop;
      }

      if (el.parentNode)
		parent = el.parentNode;
      else
	  	parent = null;

	while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML')
	{
		pos.x -= parent.scrollLeft;
		pos.y -= parent.scrollTop;

		if (parent.parentNode) parent = parent.parentNode;
		else parent = null;
	}

	return pos;
};

function bosGetRect(el)
{
    if (typeof(el) == "string")
        el = document.getElementById(el);

    if (el.parentNode === null || bosGetStyle(el, 'display') == 'none')
        return false;

    if (el.getBoundingClientRect)
    { // IE
        box = el.getBoundingClientRect();

        var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
        var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;

        return {left:box.left + scrollLeft, top:box.top + scrollTop, right:box.right + scrollLeft, bottom: box.bottom + scrollTop};
    }

    var parent = null;
    var box;

/*    if (document.getBoxObjectFor)
    { // gecko
        box = document.getBoxObjectFor(el);
    }
    else*/
    { // safari/opera
        box = {left:el.offsetLeft, top:el.offsetTop, right: el.offsetLeft+el.offsetWidth, bottom: el.offsetTop+el.offsetHeight};
        parent = el.offsetParent;
        if (parent != el)
        {
            while (parent)
            {
               box.left += parent.offsetLeft;
               box.right += parent.offsetLeft;
               box.top += parent.offsetTop;
               box.bottom += parent.offsetTop;
               parent = parent.offsetParent;
            }
        }

         // opera & (safari absolute) incorrectly account for body offsetTop
         var ua = navigator.userAgent.toLowerCase();
         if (ua.indexOf('opera') != -1
            || ( ua.indexOf('safari') != -1 && bosGetStyle(el, 'position') == 'absolute' ))
		{
            box.top -= document.body.offsetTop;
            box.bottom -= document.body.offsetTop;
		}
	}

	if (el.parentNode)
		parent = el.parentNode;
	else
		parent = null;

    while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML')
    {
        box.left -= parent.scrollLeft;
        box.right -= parent.scrollLeft;
        box.top -= parent.scrollTop;
        box.bottom -= parent.scrollTop;

        if (parent.parentNode)
			parent = parent.parentNode;
        else
			parent = null;
    }

    return box;
};

function bosGetX(el)
{
	return bosGetXY(el).x;
}

function bosGetY(el)
{
    return bosGetXY(el).y;
}

function bosSetXY(el, pos, noRetry)
{
	if (typeof(el) == "string")
	    el = document.getElementById(el);

	var pageXY = bosGetXY(el);
	if (pageXY === false) return false; // has to be part of doc to have pageXY

	if (bosGetStyle(el, 'position') == 'static')
	{ // default to relative
		 bosSetStyle(el, 'position', 'relative');
	}

	var delta = {
	 x: parseInt( bosGetStyle(el, 'left'), 10 ),
	 y: parseInt( bosGetStyle(el, 'top'), 10 )
	};

	if ( isNaN(delta.x) ) { delta.x = 0; } // defaults to 'auto'
	if ( isNaN(delta.y) ) { delta.y = 0; }

	if (pos.x !== null) { el.style.left = pos.x - pageXY.x + delta.x + 'px'; }
	if (pos.y !== null) { el.style.top = pos.y - pageXY.y + delta.y + 'px'; }

	var newXY = bosGetXY(el);

	// if retry is true, try one more time if we miss
	if (!noRetry && ((pos.x !== null && newXY.x != pos.x) || (pos.y !== null && newXY.y != pos.y)) )
	 	return bosSetXY(el, pos, true);

	return true;
};

function bosSetX(el, x)
{
	return bosSetXY(el, {x:x, y:null});
}

function bosSetY(el, y)
{
    return bosSetXY(el, {x:null, y:y});
}

function bosGetSize(el)
{
    // return  value: html element position [x,y]
    if (typeof(el) == "string")
        el = document.getElementById(el);

	return {width: el.offsetWidth, height: el.offsetHeight};
}
function bosGetWidth(el)
{
	return bosGetSize(el).width;
}
function bosGetHeight(el)
{
    return bosGetSize(el).height;
}

function bosGetWindowSize()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		return {width:window.innerWidth,height:window.innerHeight};
	}

	if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		return {width:document.documentElement.clientWidth,height:document.documentElement.clientHeight};
	}

	if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		return {width:document.body.clientWidth, height:document.body.clientHeight};
	}

	return false;
}

function bosGetWindowScrollXY()
{
	if( typeof( window.pageYOffset ) == 'number' )
	{
		//Netscape compliant
		return {x:window.pageXOffset,y:window.pageYOffset};
	}

    if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
    {
        //IE6 standards compliant mode
        return {x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop};
    }

	if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
	{
		//DOM compliant
		return {x:document.body.scrollLeft,y:document.body.scrollTop};
	}

	return false;
}


/*001*/ var msgLang_fieldFormatInvalid="Invalid format '&&1'";
/*002*/ var msgLang_fieldNumFormatInvalid="Numeric field '&&1' invalid:\nParameter '&&2' incorrect";
/*003*/ var msgLang_fieldNumFormatLimitInvalid="Numeric field '&&1' invalid:\nParameter limit '&&2' incorrect";
/*008*/ var msgLang_fieldDateFormatInvalid="Date field '&&1' invalid :\nParameter '&&2' incorrect";
/*009*/ var msgLang_fieldDateFormatLimitInvalid="Date field '&&1' invalid :\nParameter limit '&&2' incorrect";
/*013*/ var msgLang_fieldTimeFormatInvalid="Time field '&&1' invalid :\nParameter '&&2' incorrect";
/*014*/ var msgLang_fieldTimeFormatLimitInvalid="Time field '&&1' invalid :\nParameter limit '&&2' incorrect";
/*018*/ var msgLang_fieldFormatParamInvalid="Field format '&&1' invalid :\nParameter '&&2' incorrect";
/*023*/ var msgLang_fieldMailFormatInvalid="Mail field '&&1' invalid :\nParameter '&&2' incorrect";
/*026*/ var msgLang_fieldBoolFormatInvalid="Booleen field '&&1' invalid :\nParameter '&&2' incorrect";
/*028*/ var msgLang_fieldListFormatInvalid="List field invalid :\nParameter '&&2' incorrect";
/*027*/ var msgLang_fieldBoolInvalid="Booleen field '&&1' invalid :\nMust show in :\n&&1";
/*030*/ var msgLang_fieldListOptInvalid="Option '&&1' invalid (in this type of field)";
/*031*/ var msgLang_fieldListOptRepeated="Option '&&1' repeated";

/*004*/ var msgLang_fieldNumSignInvalid="Numeric value incorrect :\nErroneous sign";
/*005*/ var msgLang_fieldNumStringInvalid="Numeric value incorrect :\nMust follow format (&&1)";
/*006*/ var msgLang_fieldNumNotInRange="Numeric value incorrect :\nMust be in the interval (&&1)";
/*007*/ var msgLang_fieldNumStringInvalidNoArg="Numeric value incorrect :\nBad format";

/*010*/ var msgLang_fieldDateStringInvalid="Date value incorrect :\nBad format";
/*011*/ var msgLang_fieldDateInvalid="Date value incorrect :\nDate invalid";
/*012*/ var msgLang_fieldDateNotInRange="Date value incorrect :\nMust be in interval &&1";

/*015*/ var msgLang_fieldTimeStringInvalid="Time value incorrect :\nBad format";
/*016*/ var msgLang_fieldTimeInvalid="Time value incorrect :\nTime incorrect";
/*017*/ var msgLang_fieldTimeNoInRange="Time value incorrect :\nMust be in interval &&1";

/*019*/ var msgLang_fieldFormatMaxChar="Max .Char.";

/*020*/ var msgLang_fieldValueTooLong="Field value incorrect :\nMaximum &&1 character(s) authorized";
/*021*/ var msgLang_fieldIPformatInvalid="IP field '&&1' invalid :\nToo many parameters '&&2'";
/*022*/ var msgLang_fieldIPinvalid="IP address invalid";
        var msgLang_fieldIPsyntaxe="<=255.255.255.255";
/*024*/ var msgLang_fieldMailSyntaxe="name@server";
/*025*/ var msgLang_fieldMailInvalid="Mail address invalid";
/*029*/ var msgLang_fieldListValueInvalid="List value incorrect :\nMust show in :\n&&1";
/*032*/ var msgLang_fieldValueRequired="A value is required for this field";
/*033*/ var msgLang_fieldDateSyntaxe="JJ@MM@AAAA@HH@MM";
/*035*/ var msgLang_fieldValueTooLittle="Text value incorrect: \nMinimum &&1 characters authorized";
/*036*/ var msgLang_fieldPasswordWithoutNum="Your password must contain at least one number";
/*037*/ var msgLang_fieldCharForbidden="Characters '&&1' are forbidden";
