/**
* @author: Vincent Coulon 2007 add an event to an HTML event (listener = method, type = "change", "click", etc ...)
*/
function addEvent(element, type, listener, useCapture){
	// DOM standard
	if(element.addEventListener){element.addEventListener(type, listener, useCapture);}
	// IE web browser
	else{element.attachEvent("on"+type, listener);}
}

// ***********
// Appels AJAX
// ***********

function handleForward() {
	//alert("DEBUT: handleForward");
	try {
		document.getElementById("messageErreur").innerHTML = "&nbsp;";
		//alert(document.getElementById("messageErreur").innerHTML);
	} catch(e) {
		//alert("erreur 1!");
	}
//	try {
//		//document.getElementsByTagName("messageErreur2").value = getElementText(xml.getElementsByTagName("result")[0].getElementsByTagName("message2")[0]);
//		document.getElementById("messageErreur2").innerHTML = "&nbsp;";
//	} catch(e) {
//		//alert("erreur 2!");
//	}
	$(':submit').addClass('disabled');
	
	$(':submit').removeClass('enabled');
	document.getElementById("submit").disabled=true;
	//alert("DEBUT handleForward2");
	
	// Recuperation du XMLHttpRquest
	var req = getXMLHttpRequest();
	if(req!=null) {
		// Listener sur le send
		req.onreadystatechange = function () {
			if (req.readyState == 4 && req.status == 200) {
				//Reponse renvoyee
				var xmlResponse = req.responseXML;
				var xml = clean(xmlResponse);
				
				if(getElementText(xml.getElementsByTagName("result")[0].getElementsByTagName("forward")[0]) == "success") {
					//alert("success");
					try {
						document.getElementsByTagName("messageErreur").value = "";
					} catch(e) {
						//alert("error 1");
					}
//					try {
//						document.getElementsByTagName("messageErreur2").value = "";
//					} catch(e) {
//						//alert("error 2");
//					}
					try {
						window.location = getElementText(xml.getElementsByTagName("result")[0].getElementsByTagName("path")[0]);
						//form.submit()
						//document.getElementsByTagName("form")[0].action = getElementText(xml.getElementsByTagName("result")[0].getElementsByTagName("path")[0]);
						//alert(document.getElementsByTagName("form")[0].action);
						//try{
						//document.getElementsByTagName("form")[0].submit();
						//alert("OK2");
						//}catch(e){
						//alert(e);
						//alert("KO2");
						//}
						//alert("FIN");
					} catch(e) {
						//alert("no path");
					}
				} else {
					//alert("no success");
					//var messageErreur = getElementText(xml.getElementsByTagName("result")[0].getElementsByTagName("message")[0]);
					//var messageErreur2 = getElementText(xml.getElementsByTagName("result")[0].getElementsByTagName("message2")[0]);
					//alert(messageErreur);
					//window.location="exclusionSouscriptionB2CAA.do";
					try {
						document.getElementById("messageErreur").innerHTML = getElementText(xml.getElementsByTagName("result")[0].getElementsByTagName("message")[0]);
						//alert(document.getElementById("messageErreur").innerHTML);
					} catch(e) {
						//alert("error 1!");
					}
					
//					try {
//						//document.getElementsByTagName("messageErreur2").value = getElementText(xml.getElementsByTagName("result")[0].getElementsByTagName("message2")[0]);
//						document.getElementById("messageErreur2").innerHTML = getElementText(xml.getElementsByTagName("result")[0].getElementsByTagName("message2")[0]);
//					} catch(e) {
//						//alert("error 2!");
//					}
					$(':submit').addClass('enabled');
					$(':submit').removeClass('disabled');
					document.getElementById("submit").disabled=false;
				}
			}
		};
		
		// Construction des parametres de la requete
		var vars = getFormAsString(document.getElementsByTagName("form")[0]);
		
		// Construction de l'URL
		var url = document.getElementsByTagName("form")[0].action + "?" + vars;
		
		sendAjaxUrl(req,url,"POST");
	}
	//alert("FIN handleForward");
}

// Romain Maton
// Recuperation du XmlHttpRequest
function getXMLHttpRequest() {
	//alert("DEBUT: getXMLHttpRequest");
    if (window.XMLHttpRequest) {
      	var req = new XMLHttpRequest();
      	//alert("FIN: getXMLHttpRequest");
      	return req;
    }
	else if (window.ActiveXObject) { 
	    try {
	    	var req = new ActiveXObject("Msxml2.XMLHTTP");
	    } 
	    catch (e) {
	    	var req = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    //alert("FIN: getXMLHttpRequest");
	    return req;
	}
	else {
		//alert("FIN: getXMLHttpRequest");
		return null;
	}	
}

// Romain Maton
// Envoi de la requete
function sendAjaxUrl(req,url,method) {
	//alert("DEBUT: sendAjaxUrl");
	if(method=="undefined" || method==null) {
		method="GET";
	}
	
	if(url != null) url = url.replace(/\+/g, "%2B");
	
	var myUrl = url;
	var data = null;
	if(method=="POST") {
		myUrl = url.split("?")[0];
		data = unescape(url.split("?")[1]);
	}
	
	req.open(method, myUrl, true);
	//if(navigator.appName=="Microsoft Internet Explorer") {
		//alert("IE");
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	//}
	//else {
		//alert("FF/autre");
		//req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=CP1252");
	//}
	req.setRequestHeader("Content-Length", myUrl.length);
    if (window.XMLHttpRequest || window.ActiveXObject) {
    	req.send(data);
	} else{
		//alert("FIN: sendAjaxUrl");
		return;
	}
	//alert("FIN: sendAjaxUrl");
}


// Christophe Schreiber
// M�thode d'envoi Ajax SYNCHRONE
function sendAjaxUrlSynchrone(req,url,method) {
	if(method=="undefined" || method==null) {
		method="GET";
	}
	var myUrl = url;
	var data = null;
	if(method=="POST") {
		myUrl = url.split("?")[0];
		data = unescape(url.split("?")[1]);
	}
	//3e parametre : pour la synchronisation
	req.open(method, myUrl, false);	
	req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	req.setRequestHeader("Content-Length", myUrl.length);
	if (window.XMLHttpRequest || window.ActiveXObject) {
    	req.send(data);
	} else{
		return;
	}
}
//CSC-

// Romain Maton
// Recuperation de la reponse XML bien formatte
function clean(d){
	//alert("DEBUT clean");
	var bal=d.getElementsByTagName('*');
	for(i=0;i<bal.length;i++){
		a = bal[i].previousSibling;
		if(a && a.nodeType==3)
			go(a);
		b = bal[i].nextSibling;
		if(b && b.nodeType==3)
			go(b);
	}
	//alert ('sortie clean :'+ d.text);
	//alert("FIN clean");
	return d;
}
function go(c){
	if(!c.data.replace(/\s/g,''))
		c.parentNode.removeChild(c);
}

//recupere le texte a l'interieur d'une balise de flux XML
//compatibilite Firefox/IE
function getElementText(element) {
	if(element.text != "" && !element.text) {
		return element.textContent;
	} else {
		return element.text;
	}
}

// Romain Maton
// Recuperation du formulaire en string (format URL)
function getFormAsString(frmObj) {
    var query = "";
	for (var i = 0; i < frmObj.length; i++) {
        var element = frmObj.elements[i];
        if(!element.type) {
        	query += element.name + "=" + escape(element.value);
        }
        else if (element.type.indexOf("checkbox") == 0 || 
            element.type.indexOf("radio") == 0) { 
            if (element.checked) {
                query += element.name + "=" + escape(element.value);
            }
		}
		else if (element.type.indexOf("select") == 0) {
			for (var j = 0; j < element.length ; j++) {
				if (element.options[j].selected) {
                    query += element.name + "=" + escape(element.value);
                    if(j<element.length -1) query += "&";
                }
			}
        }
        else {
            query += element.name + "=" + escape(element.value); 
        }
        if(i<frmObj.length -1) query += "&";
    }
    return query;
}

function encodeUTF8(s){
  for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
    s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
  );
  return s.join("");
}

function decodeUTF8(s){
  for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
    ((a = s[i][c](0)) & 0x80) &&
    (s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
    o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
  );
  return s.join("");
}


/******************************************************************************/
/************ VERSION ICARE PERSONALISEE DE LA BIBLIOTHEQUE RIALTO ************/
/******************************************************************************/

var AJAX_REQUEST_ERROR = "Une erreur est survenue.";

rialto.widget.FormIcare = function (formName, url, loadingText, cancelText, parent, objPar) {
    var objParam = objPar ? objPar : {};
    objParam.type = "form";
    objParam.height = 0;
    objParam.width = 0;
    objParam.name = formName;
    this.base = rialto.widget.AbstractContainer;
    this.base(objParam);
    this.action = url;
    this.url = url;
    this.autoSubmit = true;
    this.imgBtonSubmit = null;
    this.idCont = null;
    this.boolWithFenWait = true;
    this.boolAsynch = true;
    this.method = "get";
    this.boolIframe = false;
    this.canBeCancel = true;
    this.parameters = {};
    this.loadingText = loadingText;
    this.cancelText = cancelText;
    if (objPar) {
        if (objPar.imgBtonSubmit) {
            this.imgBtonSubmit = objPar.imgBtonSubmit;
        }
        if (rialto.lang.isBoolean(objPar.autoSubmit)) {
            this.autoSubmit = objPar.autoSubmit;
        }
        if (rialto.lang.isStringIn(objPar.method, ["post", "get"])) {
            this.method = objPar.method;
        }
        if (rialto.lang.isBoolean(objPar.boolWithFenWait)) {
            this.boolWithFenWait = objPar.boolWithFenWait;
        }
        if (rialto.lang.isBoolean(objPar.boolAsynch)) {
            this.boolAsynch = objPar.boolAsynch;
        }
        if (objPar.idCont) {
            this.idCont = objPar.idCont;
            var primCar = this.url.indexOf("?") != -1 ? "&" : "?";
            this.url += primCar + "FENID=" + objPar.idCont;
        }
        if (rialto.lang.isBoolean(objPar.canBeCancel)) {
            this.canBeCancel = objPar.canBeCancel;
        }
        if (rialto.lang.isBoolean(objPar.boolIframe)) {
            this.boolIframe = objPar.boolIframe;
        }
        if (objPar.onSuccess) {
            this.onSuccess = objPar.onSuccess;
        }
        if (objPar.callBackObjectOnSuccess) {
            this.callBackObjectOnSuccess = objPar.callBackObjectOnSuccess;
        }
        if (objPar.parameters) {
            this.parameters = objPar.parameters;
        }
    }
    var oThis = this;
    //this.autoSubmit = false;
    this.divExt.style.top = this.top;
    this.divExt.style.left = this.left;
    this.divExt.style.height = this.height;
    this.divExt.style.width = this.width;
    this.divExt.style.position = this.position;
    this.formulaire = document.createElement("FORM");
    this.formulaire.style.position = "relative";
    this.formulaire.method = this.method;
    this.divExt.appendChild(this.formulaire);
    if (this.boolAsynch && !this.boolIframe) {
        this.remote = new rialto.io.AjaxRequestIcare({url:this.url, method:this.method, callBackObjectOnSuccess:this.callBackObjectOnSuccess, withWaitWindow:this.boolWithFenWait, canBeCancel:this.canBeCancel, onSuccess:this.onSuccess, loadingText:this.loadingText, cancelText:this.cancelText});
    }
    if (this.autoSubmit) {
        this.formulaire.onkeypress = function (evt) {
            if (!evt) {
                evt = window.event;
            }
            var key = evt.keyCode ? evt.keyCode : evt.charCode ? evt.charCode : evt.which ? evt.which : void 0;
            if (key == 13) {
                document.onselectstart = new Function("return false");
                oThis.submitForm();
                return false;
            }
        };
    }
    if (this.imgBtonSubmit) {
        this.imgBtonSubmit.oCiu = this;
        this.affComportBtonSubmit();
    }
    if (parent) {
        this.placeIn(parent);
    }
    objPar = null;
    objParam = null;
};

rialto.widget.FormIcare.prototype = new rialto.widget.AbstractContainer;
rialto.widget.FormIcare.prototype.tabIndex = 1;
rialto.widget.FormIcare.prototype.nbReq = 0;
rialto.widget.FormIcare.prototype.release = function (imgBtonSubmit) {
    this.formulaire.onkeypress = null;
    if (this.imgBtonSubmit) {
        if (this.imgBtonSubmit.remove) {
            this.imgBtonSubmit.remove();
        }
        this.imgBtonSubmit.oCiu = null;
        this.imgBtonSubmit.onclick = null;
    }
};
rialto.widget.FormIcare.prototype.addBtonSubmit = function (imgBtonSubmit) {
    this.imgBtonSubmit = imgBtonSubmit;
    this.imgBtonSubmit.oCiu = this;
    this.affComportBtonSubmit();
};
rialto.widget.FormIcare.prototype.affComportBtonSubmit = function () {
    this.imgBtonSubmit.onclick = function () {
        this.oCiu.submitForm();
    };
};
rialto.widget.FormIcare.prototype.getHtmlCont = function () {
    return this.formulaire;
};
rialto.widget.FormIcare.prototype.buildQueryString = function () {
    var qs = "";
    for (param in this.parameters) {
        qs += "&" + param + "=" + escape(this.parameters[param]);
    }
    for (var e = 0; e < this.formulaire.elements.length; e++) {
        var elmt = this.formulaire.elements[e];
        if (elmt.name != "") {
            if (elmt.type == "radio" && elmt.checked == true) {
                qs += "&" + elmt.name + "=" + escape(elmt.value);
            } else {
                if (elmt.type != "radio") {
                    qs += "&" + elmt.name + "=" + escape(elmt.value);
                }
            }
        }
    }
    if (qs != "") {
        qs = qs.substring(1);
    }
    return qs;
};
rialto.widget.FormIcare.prototype.resetForm = function () {
    this.formulaire.reset();
    for (var e = 0; e < this.formulaire.elements.length; e++) {
        var elmt = this.formulaire.elements[e];
        if (elmt.type == "hidden" && elmt.parentNode.parentNode.oCiu.type == "combo") {
            elmt.value = "";
        }
    }
};
rialto.widget.FormIcare.prototype.submitForm = function () {
    if (this.onSubmitForm()) {
        if (this.boolAsynch) {
            if (!this.boolIframe) {
                this.remote.load(this.buildQueryString());
            } else {
                var idExtReq = ++rialto.widget.FormIcare.prototype.nbReq;
                if (!this.iframe) {
                    this.iframe = new objFrame("ifr", 0, 0, 0, 0);
                    this.iframe.create(document.body);
                }
                var primCar = this.url.indexOf("?") != -1 ? "&" : "?";
                this.lastURL = this.url + primCar + this.buildQueryString();
                this.iframe.load(this.lastURL);
                if (this.boolWithFenWait) {
                    this.fen = new rialto.widget.WaitWindowIcare({text:"", canBeCancel:true});
                }
            }
        } else {
            this.formulaire.action = this.action;
            this.formulaire.submit();
        }
        this.afterSubmitForm();
    }
};

rialto.widget.FormIcare.prototype.onSubmitForm = function () {
    return true;
};

rialto.widget.FormIcare.prototype.afterSubmitForm = function () {
    return true;
};

rialto.widget.FormIcare.prototype.addParameter = function (tab) {
    this.parameters[tab[0]] = tab[1];
};

rialto.widget.FormIcare.prototype.setURL = function (url) {
    this.url = url;
    if (this.idCont) {
        var primCar = this.url.indexOf("?") != -1 ? "&" : "?";
        this.url += primCar + "FENID=" + this.idCont;
    }
};

rialto.io.AjaxRequestIcare = function (objPar) {
    this.withWaitWindow = true;
    this.callBackObjectOnSuccess = null;
    this.callBackObjectOnFailure = null;
    this.canBeCancel = true;
    this.config = {asynchronous:true, method:"get", onSuccess:this.reportSuccess, onFailure:this.reportError};
    this.setUp(objPar);
    this.xhttpr = null;
    if (window.ActiveXObject) {
        try {
            this.xhttpr = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            this.xhttpr = new ActiveXObject("Microsoft.XMLHTTP");
        }
    } else {
        if (window.XMLHttpRequest) {
            this.xhttpr = new XMLHttpRequest();
        } else {
            this.xhttpr = false;
        }
    }
    this.status = ["Uninitialized", "Loading", "Loaded", "Interactive", "Complete"];
};

rialto.io.AjaxRequestIcare.prototype = {setUp:function (objPar) {
    if (objPar != null) {
        if (objPar.url) {
            this.url = objPar.url;
        }
        if (objPar.callBackObjectOnSuccess) {
            this.callBackObjectOnSuccess = objPar.callBackObjectOnSuccess;
        }
        if (objPar.callBackObjectOnFailure) {
            this.callBackObjectOnFailure = objPar.callBackObjectOnFailure;
        }
        if (rialto.lang.isBoolean(objPar.canBeCancel)) {
            this.canBeCancel = objPar.canBeCancel;
        }
        if (rialto.lang.isBoolean(objPar.withWaitWindow)) {
            this.withWaitWindow = objPar.withWaitWindow;
        }
        if (rialto.lang.isStringIn(objPar.method, ["post", "get"])) {
            this.config.method = objPar.method;
        }
        if (objPar.onSuccess) {
            if (this.callBackObjectOnSuccess) {
                this.config.onSuccess = rialto.lang.link(this.callBackObjectOnSuccess, objPar.onSuccess);
            } else {
                this.config.onSuccess = objPar.onSuccess;
            }
        }
        if (objPar.onFailure) {
            if (this.callBackObjectOnFailure) {
                this.config.onFailure = rialto.lang.link(this.callBackObjectOnFailure, objPar.onFailure);
            } else {
                this.config.onFailure = objPar.onFailure;
            }
        }
        if (objPar.loadingText) {
            this.loadingText = objPar.loadingText;
        }
        if (objPar.cancelText) {
            this.cancelText = objPar.cancelText;
        }
    }
    if (this.withWaitWindow) {
        this.config.onLoading = rialto.lang.link(this, this.displayWaitWindow);
    }
}, load:function (parameters) {
    var url = this.url;
    this.config.parameters = parameters;
    try {
        if (this.config.method == "get" && this.config.parameters.length > 0) {
            url += (url.match(/\?/) ? "&" : "?") + parameters;
        }
        this.xhttpr.open(this.config.method, url, this.config.asynchronous);
        this.xhttpr.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
        if (this.config.method == "post") {
            this.xhttpr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        }
        if (this.config.asynchronous) {
            this.xhttpr.onreadystatechange = rialto.lang.link(this, this.respondToReadyState);
        }
        this.xhttpr.send(this.config.method == "post" ? this.config.parameters : null);
    }
    catch (e) {
        //alert(e + "\n (url :" + url + ")");
    }
}, responseIsSuccess:function () {
    return (this.xhttpr.status == undefined || this.xhttpr.status == 0 || (this.xhttpr.status >= 200 && this.xhttpr.status < 300));
}, responseIsFailure:function () {
    return !this.responseIsSuccess();
}, respondToReadyState:function () {
    var readyState = this.xhttpr.readyState;
    var status = this.status[readyState];
    switch (status) {
      case "Complete":
        if (this.withWaitWindow && this.fen) {
            this.fen.setVisible(false);
        }
        try {
            this.config["on" + (this.responseIsSuccess() ? "Success" : "Failure")](this.xhttpr);
        }
        catch (e) {
        }
        break;
      default:
        try {
            this.config["on" + status](this.xhttpr);
        }
        catch (e) {
        }
        break;
    }
}, abort:function () {
    if (this.canBeCancel) {
        this.xhttpr.abort();
    }
}, displayWaitWindow:function () {
    if (this.fen) {
        this.fen.setVisible(true);
    } else {
        var oThis = this;
        this.fen = new rialto.widget.WaitWindowIcare({text:this.loadingText, canBeCancel:this.canBeCancel, cancelText:this.cancelText});
        if (this.canBeCancel) {
            this.fen.onclick = function () {
                oThis.abort();
                this.setVisible(false);
            };
        }
    }
}, reportSuccess:function (request) {
    var div = document.createElement("DIV");
    div.innerHTML = request.responseText;
    var fen = new rialto.widget.objFenData(600, 400, div, "Response");
}, reportError:function (request) {
    var div = document.createElement("DIV");
    div.innerHTML = request.responseText;
    var fen = new rialto.widget.objFenData(600, 400, div, AJAX_REQUEST_ERROR);
}};


rialto.widget.WaitWindowIcare = function (objPar) {
    this.canBeCancel = true;
    this.text = rialto.I18N.getLabel("lanWaitWindowDefaultText");
    this.cancelText = rialto.I18N.getLabel("lanCancelButton");
    if (objPar) {
        if (rialto.lang.isBoolean(objPar.canBeCancel)) {
            this.canBeCancel = objPar.canBeCancel;
        }
        if (rialto.lang.isString(objPar.text)) {
            this.text = objPar.text;
        }
        if (objPar.cancelText) {
            this.cancelText = objPar.cancelText;
        }
    }
    var widthGlobal = document.body.clientWidth;
    var heightGlobal = document.body.clientHeight;
    var top = (heightGlobal / 2) - 30;
    var left = (widthGlobal / 2) - 70;
    this.fen = new rialto.widget.PopUp("fen", top, left, 140, 70, "", " ", "Transparent", {withCloseButon:false});
    var divLib = document.createElement("DIV");
    divLib.className = "libelle1";
    divLib.style.position = "absolute";
    divLib.style.top = "5px";
    divLib.style.left = "28px";
    //divLib.style.width = "100%";
    divLib.innerHTML = this.text;
    this.fen.add(divLib);
    var img = document.createElement("IMG");
    img.src = rialtoConfig.buildImageURL("images/sablier.gif");
    img.style.position = "absolute";
    img.style.height = "35px";
    img.style.width = "27px";
    img.style.left = "48px";
    img.style.top = "22px";
    this.fen.add(img);
    if (this.canBeCancel) {
        var oThis = this;
        this.BANN = new rialto.widget.Button(60, 50, this.cancelText);
        this.BANN.onclick = function () {
            oThis.closeWindow();
            oThis.onclick();
        };
        this.fen.add(this.BANN);
    }
};
rialto.widget.WaitWindowIcare.prototype.closeFen = function () {
    rialto.deprecated("rialto.widget.WaitWindowIcare", "closeFen", "closeWindow");
};
rialto.widget.WaitWindowIcare.prototype.closeWindow = function () {
    this.fen.closeWindow();
};
rialto.widget.WaitWindowIcare.prototype.setVisible = function (visible) {
    this.fen.setVisible(visible);
};
rialto.widget.WaitWindowIcare.prototype.onclick = function () {
    return true;
};






rialto.widget.TextIcare = function (name, top, left, width, datatype, parent, objPar) {
    var objParam = new Object;
    objParam.name = name;
    objParam.type = "text";
    objParam.left = left;
    objParam.top = top;
    objParam.width = width;
    if (objPar != null) {
        objParam.position = objPar.position;
    }
    this.base = rialto.widget.AbstractComponent;
    this.base(objParam);
    if (rialto.lang.isStringIn(datatype, ["T", "P", "A", "N", "I", "D", "H", "Hi"])) {
        this.datatype = datatype;
    } else {
        this.datatype = "A";
    }
    if (this.datatype == "P") {
        this.inputType = "password";
    } else {
        if (this.datatype == "Hi") {
            this.inputType = "hidden";
        } else {
            this.inputType = "text";
        }
    }
    this.autoUp = false;
    this.isRequired = false;
    this.disable = false;
    this.nbchar = 50;
    this.rows = 5;
    this.initValue = null;
    this.wvalue = "";
    this.accessKey = "";
    this.tabIndex = rialto.widget.Form.prototype.tabIndex++;
    if (objPar) {
        if (rialto.lang.isNumber(objPar.nbchar)) {
            this.nbchar = objPar.nbchar;
        }
        if (rialto.lang.isBoolean(objPar.autoUp)) {
            this.autoUp = objPar.autoUp;
        }
        if (rialto.lang.isBoolean(objPar.disable)) {
            this.disable = objPar.disable;
        }
        if (rialto.lang.isBoolean(objPar.isRequired)) {
            this.isRequired = objPar.isRequired;
        }
        if (rialto.lang.isNumber(objPar.rows)) {
            this.rows = objPar.rows;
        }
        if (rialto.lang.isString(objPar.initValue)) {
            this.initValue = objPar.initValue;
        }
        if (rialto.lang.isString(objPar.accessKey, true)) {
            this.accessKey = objPar.accessKey;
        }
        if (rialto.lang.isNumber(objPar.tabIndex)) {
            this.tabIndex = objPar.tabIndex;
        }
        if(this.datatype == "D") {
        	this.monthsList = objPar.monthsList;
        	this.weekDaysList = objPar.weekDaysList;
        }
    }
    objPar = null;
    objParam = null;
    var oThis = this;
    this.divExt.id = this.id + "_DivGen";
    this.divExt.style.position = this.position;
    this.divExt.style.left = this.left + "px";
    this.divExt.style.top = this.top + "px";
    this.divExt.style.width = this.width;
    this.divExt.style.height = 20;
    this.divExt.className = "field_global";
    var strInner = "";
    if (this.datatype == "T") {
        strInner = "<TEXTAREA  name='" + this.name + "'/>";
    } else {
        strInner = "<input type='" + this.inputType + "' name='" + this.name + "'/>";
    }
    this.divExt.innerHTML = strInner;
    if (parent) {
        this.placeIn(parent);
    }
};
rialto.widget.TextIcare.prototype = new rialto.widget.AbstractComponent;
rialto.widget.TextIcare.prototype.adaptToContext = function () {
    var oThis = this;
    this.champs = this.divExt.childNodes[0];
    if (this.datatype == "T") {
        this.champs.className = "field_textarea";
        this.divExt.style.height = "auto";
        this.champs.rows = this.rows;
    }
    this.champs.tabIndex = this.tabIndex;
    this.champs.maxlength = this.nbchar;
    this.champs.accessKey = this.accessKey;
    this.champs.className = "field_" + this.datatype;
    this.champs.onselectstart = function () {
        return true;
    };
    this.champs.style.width = "100%";
    if (this.initValue) {
        this.setValue(this.initValue);
    }
    this.champs.setAttribute("autocomplete", "off");
    if (this.datatype == "I") {
        this.autoUp = false;
        this.divExt.style.width = 80;
        this.champs.style.width = 80;
        this.champs.size = 10;
        this.champs.maxlength = 10;
    } else {
        if (this.datatype == "D") {
            this.autoUp = false;
            this.divExt.style.width = 115;
            this.champs.style.width = 80;
            this.champs.size = 10;
            this.champs.maxlength = 10;
            this.hlpimg = new rialto.widget.Image("text_date_helpbuton", 80, -2, this.divExt, rialto.I18N.getLabel("lanCalenderButton"), "text_date_helpbutonover", {position:"absolute"});
            this.hlpimg.onclick = function (e) {
                if (!e) {
                    e = window.event;
                }
                oThis.openCalendar(e);
            };
        } else {
            if (this.datatype == "H") {
                this.autoUp = false;
                this.divExt.style.width = 40;
                this.champs.style.width = 40;
                this.champs.size = 5;
                this.champs.maxlength = 5;
            }
        }
    }
    if (this.disable) {
        this.setEnable(false);
    }
    if (this.isRequired) {
        champsAs = document.createElement("DIV");
        champsAs.innerHTML = "*";
        champsAs.style.position = "absolute";
        champsAs.style.top = 0;
        champsAs.style.left = -7;
        champsAs.style.color = "red";
        this.divExt.appendChild(champsAs);
    }
    if (this.datatype != "Hi") {
        this.champs.onkeypress = function (e) {
            if (!e) {
                var e = window.event;
            }
            return oThis.checkKeyPress(e);
        };
        this.champs.onmousedown = function (e) {
            if (!e) {
                var e = window.event;
            }
            stopEvent(e);
        };
        this.champs.onfocus = function (e) {
            if (!e) {
                var e = window.event;
            }
            oThis.afterOnFocus();
        };
        this.champs.onblur = function (e) {
            if (!e) {
                var e = window.event;
            }
            oThis.afterOnBlur();
        };
        this.champs.onclick = function () {
            this.focus();
            return true;
        };
        this.champs.ondbleclick = function () {
            this.select();
            return true;
        };
    }
};
rialto.widget.TextIcare.prototype.adaptAfterSizeChange = function () {
    if (this.datatype == "D") {
        var width = this.width - 27;
        this.champs.style.width = width;
        this.hlpimg.setLeft(width);
    }
};
rialto.widget.TextIcare.prototype.release = function () {
    this.divExt.onselectstar = null;
    this.champs.onmousedown = null;
    this.champs.onkeypress = null;
    this.champs.onfocus = null;
    this.champs.onblur = null;
    this.champs.onclick = null;
    this.champs.ondbleclic = null;
    if (this.datatype == "D") {
        this.hlpimg.onclick = null;
        this.hlpimg.remove();
        if (this.calendar) {
            this.calendar.onclick = null;
            this.calendar.remove();
        }
    }
};
rialto.widget.TextIcare.prototype.setStyle = function (obStyle) {
    for (prop in obStyle) {
        try {
            this.champs.style[prop] = obStyle[prop];
        }
        catch (erreur) {
        }
    }
};
rialto.widget.TextIcare.prototype.openCalendar = function (e) {
    var othis = this;
    if (!this.calendar) {
        this.calendar = new rialto.widget.CalendarIcare({popUpMode:true,monthsList:this.monthsList,weekDaysList:this.weekDaysList});
        this.calendar.onclick = function (date) {
            othis.setValue(date);
            othis.setFocus();
        };
    }
    var top = compOffsetTop(this.divExt) + 27;
    var left = compOffsetLeft(this.divExt) - 90;
    if (left < 0) {
        left = 0;
    }
    this.calendar.displayCalendar(top, left);
};
rialto.widget.TextIcare.prototype.checkKeyPress = function (evt) {
    var boolCancel = false;
    boolReplaceKey = false;
    var keyCode = evt.keyCode ? evt.keyCode : evt.charCode ? evt.charCode : evt.which ? evt.which : void 0;
    var key;
    if (keyCode) {
        key = String.fromCharCode(keyCode);
    }
    if (evt.altKey) {
        return true;
    }
    if (evt.ctrlKey) {
        return true;
    }
    if (keyCode == 9 || (keyCode == 37) || (keyCode == 39) || (keyCode == 46) || keyCode == 8) {
        return true;
    }
    if ((this.champs.value.length + 1) > this.champs.maxlength) {
        if (window.event) {
            return false;
        } else {
            var oldSelectionStart = this.champs.selectionStart;
            var oldSelectionEnd = this.champs.selectionEnd;
            if (oldSelectionEnd - oldSelectionStart == 0) {
                return false;
            }
        }
    }
    if (keyCode == 13 && this.datatype != "T") {
        this.champs.blur();
        return this.blurOK;
    }
    if (this.datatype == "I") {
        boolCancel = "0123456789-".indexOf(key) == -1;
    }
    if (this.autoUp == true) {
        var newKey = key.toUpperCase();
        if (newKey != key) {
            boolReplaceKey = true;
            key = newKey;
        }
    }
    if (this.datatype == "N") {
        boolCancel = "0123456789".indexOf(key) == -1;
    }
    if (this.datatype == "D") {
        boolCancel = "0123456789/".indexOf(key) == -1;
    }
    if (this.datatype == "H") {
        if ("0123456789:".indexOf(key) == -1) {
            boolCancel = true;
        } else {
            if (key == ":" && this.champs.value.length != 2) {
                boolCancel = true;
            }
        }
    }
    if (keyCode && window.event && !window.opera) {
        if (boolCancel) {
            return false;
        } else {
            if (boolReplaceKey) {
                window.event.keyCode = key.charCodeAt();
                if (window.event.preventDefault) {
                    window.event.preventDefault();
                }
                return true;
            } else {
                return true;
            }
        }
    } else {
        if (typeof this.champs.setSelectionRange != "undefined") {
            if (boolCancel) {
                if (evt.preventDefault) {
                    evt.preventDefault();
                }
                return false;
            } else {
                if (boolReplaceKey) {
                    if (evt.preventDefault) {
                        evt.preventDefault();
                    }
                    var oldSelectionStart = this.champs.selectionStart;
                    var oldSelectionEnd = this.champs.selectionEnd;
                    this.champs.value = this.champs.value.substring(0, oldSelectionStart) + key + this.champs.value.substring(oldSelectionEnd);
                    this.champs.setSelectionRange(oldSelectionStart + key.length, oldSelectionStart + key.length);
                    return false;
                } else {
                    return true;
                }
            }
        } else {
            if (boolCancel) {
                if (evt.preventDefault) {
                    evt.preventDefault();
                }
                return false;
            } else {
                return true;
            }
        }
    }
};
rialto.widget.TextIcare.prototype.focus = function () {
    this.champs.focus();
};
rialto.widget.TextIcare.prototype.afterOnFocus = function () {
    document.onselectstart = function () {
        return true;
    };
    this.champs.select();
    this.blurOK = true;
    this.wchanged = false;
    this.onfocus();
};
rialto.widget.TextIcare.prototype.displayMessage = function (str, boolSetFoc) {
    var oThis = this;
    info = new rialto.widget.Alert(str);
    if (boolSetFoc) {
        info.onclose = function () {
            oThis.setValue("");
            oThis.champs.focus();
        };
        info = null;
    }
};
rialto.widget.TextIcare.prototype.afterOnBlur = function () {
    if (this.champs.value != "") {
        this.champs.value = rialto.string.trim(this.champs.value);
        if (this.datatype == "N" && this.champs.value != "") {
            if (!rialto.lang.isNumber(this.champs.value)) {
                this.displayMessage("MUST BE A NUMBER", true);
                this.blurOK = false;
            }
        }
        if (this.datatype == "D" && this.champs.value != "") {
            if (!this.checkDate()) {
                this.displayMessage("Date is not correct, format must be: DD/MM/YYYY", true);
                this.blurOK = false;
            }
        }
        if (this.datatype == "H" && this.champs.value != "") {
            if (!this.checkHour()) {
                this.displayMessage("Hour is not correct, format must be: HH:MM", true);
                this.blurOK = false;
            }
        }
        if (this.datatype == "I" && this.champs.value != "") {
            var wDoss = this.champs.value;
            var wPos = wDoss.indexOf("-");
            var wPre = "";
            var wSuf = "";
            if (wPos == -1) {
                if (wDoss.length <= 5) {
                    wPre = new Date().getYear().toString();
                    wSuf = wDoss;
                } else {
                    wPre = wDoss.substring(0, 4);
                    wSuf = wDoss.substring(4, wDoss.length);
                }
            } else {
                wPre = wDoss.substring(0, wPos);
                wSuf = wDoss.substring(wPos + 1, wDoss.length);
            }
            if (wPre == "") {
                wPre = new Date().getYear().toString();
            }
            if (wPre.length == 1) {
                wPre = ("200" + wPre);
            }
            if (wPre.length == 2 && wPre < "30") {
                wPre = ("20" + wPre);
            }
            if (wPre.length == 2 && wPre >= "30") {
                wPre = ("19" + wPre);
            }
            if (wPre.length == 3 && wPre < "030") {
                wPre = ("2" + wPre);
            }
            if (wPre.length == 3 && wPre >= "030") {
                wPre = ("1" + wPre);
            }
            if (wSuf.length < 5) {
                var wPad = "";
                for (var wI = wSuf.length; wI <= 4; wI++) {
                    wPad = (wPad + "0");
                }
                wSuf = (wPad + wSuf);
            }
            if (wPre.length != 4 || wSuf.length != 5) {
                this.displayMessage("Num?ro de dossier invalide, format utilisable: AA-NNNNN", true);
                this.blurOK = false;
            } else {
                this.champs.value = (wPre + "-" + wSuf);
            }
        }
        document.onselectstart = new Function("return false");
        if (this.datatype != "P") {
            this.champs.title = this.champs.value;
        }
        this.wchanged = (this.wvalue != this.champs.value);
        this.wvalue = this.champs.value;
        if (this.wchanged && this.blurOK) {
            this.blurOK = this.onblur();
        }
        this.removeAsRequired();
    } else {
        this.blurOK = this.onblur();
        if (this.isRequired) {
            this.showAsRequired();
            this.blurOK = false;
        }
    }
};
rialto.widget.TextIcare.prototype.onblur = function () {
    return true;
};
rialto.widget.TextIcare.prototype.hasChanged = function () {
    return this.wchanged;
};
rialto.widget.TextIcare.prototype.checkHour = function () {
    strHour = this.champs.value;
    strHour = rialto.string.replace(strHour, ":", "");
    switch (strHour.length) {
      case 1:
        h = parseInt(strHour);
        m = 0;
        break;
      case 2:
        if (parseInt(strHour.substring(0, 1)) == 0) {
            h = parseInt(strHour.substring(1, 2));
        } else {
            h = parseInt(strHour);
        }
        m = 0;
        break;
      case 4:
        if (parseInt(strHour.substring(0, 1)) == 0) {
            h = parseInt(strHour.substring(1, 2));
        } else {
            h = parseInt(strHour.substring(0, 2));
        }
        m = parseInt(strHour.substring(2, 4));
        break;
      default:
        return false;
        break;
    }
    strHour = h < 10 ? "0" + h : h;
    strHour += ":" + (m < 10 ? "0" + m : m);
    if (h <= 24 && m <= 60) {
        this.champs.value = strHour;
        return true;
    } else {
        return false;
    }
};
rialto.widget.TextIcare.prototype.checkDate = function () {
    var oDate = new Date();
    strDate = this.champs.value;
    var curMonth = oDate.getMonth() + 1;
    curMonth = (curMonth < 10) ? "0" + curMonth : curMonth;
    var curYear = oDate.getFullYear();
    strDate = rialto.string.replace(strDate, "/", "");
    switch (strDate.length) {
      case 1:
        strDate = "0" + strDate + "/" + curMonth + "/" + curYear;
        break;
      case 2:
        strDate = strDate + "/" + curMonth + "/" + curYear;
        break;
      case 3:
        strDate = strDate.slice(0, 2) + "/0" + strDate.charAt(2) + "/" + curYear;
        break;
      case 4:
        strDate = strDate.slice(0, 2) + "/" + strDate.slice(2, 4) + "/" + curYear;
        break;
      case 6:
        strDate = strDate.slice(0, 2) + "/" + strDate.slice(2, 4) + "/20" + strDate.slice(4, 6);
        break;
      case 8:
        strDate = strDate.slice(0, 2) + "/" + strDate.slice(2, 4) + "/" + strDate.slice(4, 8);
        break;
      default:
        return false;
        break;
    }
    if (rialto.date.isDate(strDate)) {
        this.setValue(strDate);
        return true;
    } else {
        return false;
    }
};
rialto.widget.TextIcare.prototype.setFocus = function () {
    this.champs.focus();
};
rialto.widget.TextIcare.prototype.getValue = function () {
    return this.champs.value;
};
rialto.widget.TextIcare.prototype.setValue = function (text) {
    this.champs.value = text;
    this.wvalue = text;
    if (this.datatype != "P") {
        this.champs.title = text;
    }
};
rialto.widget.TextIcare.prototype.active = function () {
    rialto.deprecated("Text", "active", "setEnable(true)");
    this.setEnable(true);
};
rialto.widget.TextIcare.prototype.inactive = function () {
    rialto.deprecated("Text", "inactive", "setEnable(false)");
    this.setEnable(false);
};
rialto.widget.TextIcare.prototype.setEnable = function (enable) {
    if (enable) {
        this.champs.disabled = false;
        this.champs.className = "field_" + this.datatype;
        if (this.datatype == "D") {
            this.hlpimg.setEnable(true);
        }
    } else {
        this.champs.disabled = true;
        this.champs.className += " field_desable";
        if (this.datatype == "D") {
            this.hlpimg.setEnable(false);
        }
    }
    this.enable = enable;
};
rialto.widget.TextIcare.prototype.showAsRequired = function () {
    this.champs.className += " field_required";
};
rialto.widget.TextIcare.prototype.removeAsRequired = function () {
    this.champs.className = "field_" + this.datatype;
};









rialto.widget.CalendarIcare = function (objPar) {
    if (!objPar) {
        var objPar = {};
    }
    objPar.type = "calendar";
    this.base = rialto.widget.AbstractComponent;
    this.base(objPar);
    this.dateMin = null;
    this.dateMax = null;
    this.bOpenOnLastDate = true;
    this.bUkFormat = false;
    this.popUpMode = false;
    this.arrDay = new Array(31);
    this.currentDate = rialto.date.toDay();
    if (objPar != null) {
        if (rialto.lang.isDate(objPar.dateMin)) {
            this.dateMin = objPar.dateMin;
        }
        if (rialto.lang.isDate(objPar.dateMax)) {
            this.dateMax = objPar.dateMax;
            if (this.dateMin && this.dateMax < this.dateMin) {
                var d = this.dateMin;
                this.dateMin = this.dateMax;
                this.dateMax = d;
            }
        }
        if (rialto.lang.isDate(objPar.currentDate)) {
            this.currentDate = objPar.currentDate;
        }
        if (rialto.lang.isBoolean(objPar.bOpenOnLastDate)) {
            this.bOpenOnLastDate = objPar.bOpenOnLastDate;
        }
        if (rialto.lang.isBoolean(objPar.popUpMode)) {
            this.popUpMode = objPar.popUpMode;
        }
        if (rialto.lang.isBoolean(objPar.bUkFormat)) {
            this.bUkFormat = objPar.bUkFormat;
        }
        if (objPar.monthsList) {
        	this._Month = objPar.monthsList;
        }
        if (objPar.weekDaysList) {
        	this._Day = objPar.weekDaysList;
        }
    }
    this._SpecialDate = new Array, this.setCurrent();
    this.createCalendar(objPar.parent);
    objPar = null;
    this.base = null;
};
rialto.widget.CalendarIcare.prototype = new rialto.widget.AbstractComponent;
rialto.widget.CalendarIcare.prototype._Holidays = new Array("01/01", "01/05", "08/05", "14/07", "15/08", "01/11", "11/11", "25/12");
rialto.widget.CalendarIcare.prototype._LastDayInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
rialto.widget.CalendarIcare.prototype.DimanchePaques = false;
rialto.widget.CalendarIcare.prototype.isDate = function (wDate) {
    return (wDate instanceof Date);
};
rialto.widget.CalendarIcare.prototype.isHolidays = function (jf, mf) {
    var i = 0;
    mf += 1;
    for (var i in this._Holidays) {
        if (test = (((jf < 10) ? "0" + jf : jf) + "/" + ((mf < 10) ? "0" + mf : mf)) == this._Holidays[i++]) {
            return true;
        }
    }
    return false;
};
rialto.widget.CalendarIcare.prototype.isWeekEnd = function (jwe) {
    return (((jwe == 5) || (jwe == 6)) ? true : false);
};
rialto.widget.CalendarIcare.prototype.isToday = function (day) {
    var date1 = new Date(this.currentYear, this.currentMonth, day);
    return rialto.date.equals(date1, rialto.date.toDay());
};
rialto.widget.CalendarIcare.prototype.isDisable = function (day) {
    var dTest = new Date(this.currentYear, this.currentMonth, day);
    var check = false;
    if (rialto.lang.isDate(this.dateMin) && dTest < this.dateMin) {
        check = true;
    }
    if (rialto.lang.isDate(this.dateMax) && dTest > this.dateMax) {
        check = true;
    }
    return check;
};
rialto.widget.CalendarIcare.prototype.setDateMin = function (nDateMin) {
    if (rialto.lang.isDate(nDateMin)) {
        this.dateMin = nDateMin;
    } else {
        this.dateMin = null;
    }
};
rialto.widget.CalendarIcare.prototype.setDateMax = function (nDateMax) {
    if (rialto.lang.isDate(nDateMax)) {
        this.dateMax = nDateMax;
        if (this.dateMin && this.dateMax < this.dateMin) {
            var d = this.dateMin;
            this.dateMin = this.dateMax;
            this.dateMax = d;
        }
    } else {
        this.dateMax = null;
    }
};
rialto.widget.CalendarIcare.prototype.isPaques = function (pan) {
    this.DimanchePaques = true;
    var b = pan - 1900;
    var c = pan % 19;
    var d = Math.floor((7 * c + 1) / 19);
    var e = (11 * c + 4 - d) % 29;
    var f = Math.floor(b / 4);
    var g = (b + f + 31 - e) % 7;
    var date = 25 - e - g;
    if (date > 0) {
        mois = 4;
    } else {
        date = 31 + date;
        mois = 3;
    }
    date = ((date < 10) ? "0" + date : date);
    this._Holidays.push(((date < 10) ? "0" + date : date) + "/" + ((mois < 10) ? "0" + mois : mois));
    date += 1;
    if ((date > 31) && (mois = 3)) {
        date = 1;
        mois += 1;
    }
    this._Holidays.push(((date < 10) ? "0" + date : date) + "/" + ((mois < 10) ? "0" + mois : mois));
    date += 38;
    while (date > 31) {
        var tt = 0;
        date -= this._LastDayInMonth[mois - 1 + tt];
        tt++;
        mois += 1;
    }
    this._Holidays.push(((date < 10) ? "0" + date : date) + "/" + ((mois < 10) ? "0" + mois : mois));
    date += 10;
    while (date > 31) {
        var tt = 0;
        date -= this._LastDayInMonth[mois - 1 + tt];
        mois += 1;
    }
    this._Holidays.push(((date < 10) ? "0" + date : date) + "/" + ((mois < 10) ? "0" + mois : mois));
};
rialto.widget.CalendarIcare.prototype.setCurrent = function () {
    this.currentDay = this.currentDate.getDate();
    this.currentMonth = this.currentDate.getMonth();
    this.currentYear = this.currentDate.getFullYear();
};
rialto.widget.CalendarIcare.prototype.setSpecialDate = function (date, color, text) {
    this._SpecialDate.push([date, color, text]);
};
rialto.widget.CalendarIcare.prototype.removeSpecialDate = function () {
    this._SpecialDate = new Array;
};
rialto.widget.CalendarIcare.prototype.isInSpecialDate = function (date) {
    for (var i = 0; i < this._SpecialDate.length; i++) {
        if (rialto.lang.isDate(this._SpecialDate[i][0])) {
            if (rialto.date.equals(this._SpecialDate[i][0], date)) {
                return i;
            }
        } else {
            var inter = this._SpecialDate[i][0];
            if (date >= inter[0] && date <= inter[1]) {
                return i;
            }
        }
    }
    return -1;
};
rialto.widget.CalendarIcare.prototype.setMonthYear = function (m, a) {
    if (m > 11) {
        m = 0;
        a++;
    }
    if (m < 0) {
        m = 11;
        a--;
    }
    this.currentMonth = m;
    this.currentYear = a;
    this.fillCalendar();
};
rialto.widget.CalendarIcare.prototype.displayCalendar = function (top, left) {
    if (!this.bOpenOnLastDate) {
        this.setCurrent();
    }
    this.fillCalendar();
    if (this.popUpMode) {
        this.liste.setPosTop(top);
        this.liste.setPosLeft(left);
        this.liste.affichezoneMenu();
    }
};
rialto.widget.CalendarIcare.prototype.createCalendar = function (parent) {
    var oThis = this;
    this.divExt.id = "divExt";
    this.divExt.style.position = "absolute";
    this.divExt.style.zIndex = 1000;
    this.divExt.style.width = 200;
    this.divExt.onclick = function (e) {
        if (!e) {
            e = window.event;
        }
        stopEvent(e);
    };
    var oParent = this.divExt;
    var divDeco = new rialto.widget.decoration("popup", oParent);
    this.header = document.createElement("DIV");
    this.header.style.width = "100%";
    this.header.style.height = "30px";
    this.header.style.position = "absolute";
    this.header.style.top = 0;
    this.header.style.left = 0;
    this.divExt.appendChild(this.header);
    oParent = this.header;
    this.btnPreviousYear = new rialto.widget.Image("btonFirstDoctOff", 5, 5, oParent, rialto.I18N.getLabel("lanPreviousYear"), "btonFirstDoctOn", {position:"absolute"});
    this.btnPreviousYear.onclick = function () {
        oThis.setMonthYear(oThis.currentMonth, oThis.currentYear - 1);
    };
    this.btnPreviousMonth = new rialto.widget.Image("leftArrowOff", 25, 5, oParent, rialto.I18N.getLabel("lanPreviousMonth"), "leftArrowOn", {position:"absolute"});
    this.btnPreviousMonth.onclick = function () {
        oThis.setMonthYear(oThis.currentMonth - 1, oThis.currentYear);
    };
    this.currentMonthYear = document.createElement("DIV");
    this.currentMonthYear.className = "cal_current_month";
    this.header.appendChild(this.currentMonthYear);
    this.btnNextMonth = new rialto.widget.Image("rightArrowOff", 143, 5, oParent, rialto.I18N.getLabel("lanNextMonth"), "rightArrowOn", {position:"absolute"});
    this.btnNextMonth.onclick = function () {
        oThis.setMonthYear(oThis.currentMonth + 1, oThis.currentYear);
    };
    this.btnNextYear = new rialto.widget.Image("btonLastDoctOff", 160, 5, oParent, rialto.I18N.getLabel("lanNextYear"), "btonLastDoctOn", {position:"absolute"});
    this.btnNextYear.onclick = function () {
        oThis.setMonthYear(oThis.currentMonth, oThis.currentYear + 1);
    };
    if (this.popUpMode) {
        this.btnClose = new rialto.widget.Image("btonFenFermOff", 175, 5, oParent, rialto.I18N.getLabel("lanCloseButtonText"), "btonFenFermOn");
        this.btnClose.onclick = function () {
            oThis.closeCalendar();
        };
    }
    for (var j = 0; j < 7; j++) {
        var LibelleCelluleCalendar = document.createElement("DIV");
        LibelleCelluleCalendar.id = "cal_day_of_week";
        LibelleCelluleCalendar.className = "cal_day_of_week";
        LibelleCelluleCalendar.style.left = (5 + (j * 25)) + "px";
        if (j != 6) {
            LibelleCelluleCalendar.style.borderRight = "1px solid #4AA5C9";
        }
        this.header.appendChild(LibelleCelluleCalendar);
        LibelleCelluleCalendar.innerHTML = this._Day[j];
    }
    this.zoneCalendar = document.createElement("DIV");
    this.zoneCalendar.style.width = "100%";
    this.zoneCalendar.style.position = "absolute";
    this.zoneCalendar.style.top = 50;
    this.zoneCalendar.style.left = 0;
    this.divExt.appendChild(this.zoneCalendar);
    if (this.popUpMode) {
        var obj = {name:"MENU-CALENDAR", posFixe:true};
        this.liste = new rialto.widget.simpleMenu(obj);
        this.liste.add(this.divExt);
    } else {
        if (parent) {
            this.divExt.style.top = this.top;
            this.divExt.style.left = this.left;
            this.placeIn(parent);
            this.fillCalendar();
        }
    }
};
rialto.widget.CalendarIcare.prototype.afterOnClick = function (day, oHtml) {
    this.currentDate = new Date(this.currentYear, this.currentMonth, day);
    var clickDay = day < 10 ? "0" + day : day;
    var clickMonth = this.currentMonth + 1 < 10 ? "0" + (this.currentMonth + 1) : this.currentMonth + 1;
    var clickYear = this.currentYear;
    if (this.clickDiv) {
        this.setSytleOfOneDay(this.clickDiv);
    }
    if (oHtml) {
        this.setSytleOfOneDay(oHtml);
    }
    var strDate = "/" + clickYear;
    if (this.bUkFormat) {
        strDate = clickMonth + "/" + clickDay + strDate;
    } else {
        strDate = clickDay + "/" + clickMonth + strDate;
    }
    this.onclick(strDate);
    if (this.popUpMode) {
        this.closeCalendar();
    }
};
rialto.widget.CalendarIcare.prototype.onclick = function (dateSel) {
};
rialto.widget.CalendarIcare.prototype.closeCalendar = function () {
    if (this.popUpMode) {
        this.liste.fermezoneMenu();
    }
};
rialto.widget.CalendarIcare.prototype.fillCalendar = function () {
    var oThis = this;
    this.zoneCalendar.innerHTML = "";
    text = this._Month[this.currentMonth] + " " + this.currentYear;
    this.currentMonthYear.innerHTML = text;
    this.firstDay = new Date(this.currentYear, this.currentMonth).getDay() - 1;
    if (this.firstDay < 0) {
        this.firstDay = 6;
    }
    if (rialto.date.isBissextile(this.currentYear)) {
        this._LastDayInMonth[1] = 29;
    } else {
        this._LastDayInMonth[1] = 28;
    }
    if (!this.DimanchePaques) {
        this.isPaques(this.currentYear);
    }
    var nbCol = Math.ceil((this.firstDay + this._LastDayInMonth[this.currentMonth]) / 7);
    if (nbCol > 5) {
        this.divExt.style.height = 150;
    } else {
        this.divExt.style.height = 135;
    }
    var oThis = this;
    for (s = 0; s < nbCol; s++) {
        for (j = 0; j < 7; j++) {
            var day = 7 * s + j - this.firstDay + 1;
            var oneDay = document.createElement("DIV");
            oneDay.style.left = (5 + (j * 25)) + "px";
            oneDay.style.top = (s * 15) + "px";
            oneDay.borderStyle = {};
            oneDay.jw = j;
            oneDay.jM = day;
            if (s < nbCol) {
                oneDay.borderStyle.borderBottomWidth = "1px";
            }
            if (j != 6) {
                oneDay.borderStyle.borderRightWidth = "1px";
            }
            this.zoneCalendar.appendChild(oneDay);
            this.setSytleOfOneDay(oneDay);
            if (day > 0 && day <= this._LastDayInMonth[this.currentMonth]) {
                oneDay.innerHTML = day;
                this.arrDay[day] = oneDay;
                oneDay.onclick = function () {
                    oThis.afterOnClick(this.jM, this);
                };
                if (day == this._LastDayInMonth[this.currentMonth]) {
                    break;
                }
            }
        }
    }
    oneDay = null;
};
rialto.widget.CalendarIcare.prototype.setSytleOfOneDay = function (oneDay) {
    var day = oneDay.jM;
    var s = oneDay.style;
    oneDay.className = "cal_default_day";
    for (prop in oneDay.borderStyle) {
        s[prop] = oneDay.borderStyle[prop];
    }
    if (day > 0) {
        if (this.isDisable(day)) {
            oneDay.className += " cal_disable_day";
        } else {
            var date1 = new Date(this.currentYear, this.currentMonth, day);
            if (this.isWeekEnd(oneDay.jw)) {
                oneDay.className += " cal_weekend_day";
            }
            if (this.isHolidays(day, this.currentMonth)) {
                oneDay.className += " cal_holidays_day";
            }
            if (this.isToday(day)) {
                oneDay.className += " cal_today_day";
            }
            if (rialto.date.equals(date1, this.currentDate)) {
                this.clickDiv = oneDay;
                oneDay.className += " cal_select_day";
            }
            ind = this.isInSpecialDate(date1);
            if (ind != -1) {
                s.backgroundColor = this._SpecialDate[ind][1];
                oneDay.title = this._SpecialDate[ind][2];
            }
        }
    }
};
rialto.widget.CalendarIcare.prototype.release = function () {
    this.divExt.onclick = null;
    for (i = 0; i < 32; i++) {
        if (this.arrDay[i]) {
            this.arrDay[i].borderStyle = null;
            this.arrDay[i].onclick = null;
            this.arrDay[i] = null;
        }
    }
    this.btnPreviousYear.remove();
    this.btnPreviousMonth.remove();
    this.btnNextMonth.remove();
    this.btnNextYear.remove();
    if (this.popUpMode) {
        this.liste.remove();
        this.btnClose.remove();
    }
};
rialto.widget.CalendarIcare.prototype.getHtmlExt = function () {
    return this.divExt;
};





chargeDossier = function(tree, node, param) {
	if(node.arrChildNode.length == 0) {
		var req = getXMLHttpRequest();
		if(req != null) {
			// Listener sur le send
			req.onreadystatechange = function () {
				if (req.readyState == 4 && req.status == 200) {
					//Reponse renvoyee
					var xmlResponse = req.responseXML;
					var xml = clean(xmlResponse);
					var files = xml.getElementsByTagName("results")[0].getElementsByTagName("file");
					for(var i = 0;i < files.length;i++) {
						var fileName = getElementText(files[i].getElementsByTagName("name")[0]);
						var newParam = getElementText(files[i].getElementsByTagName("param")[0]);
						if(getElementText(files[i].getElementsByTagName("folder")[0]) == "false") {
							var newNodeName = node.name + "File" + i;
							var newNode = tree.createAndAddNode(node.id, {name: newNodeName, text: fileName});
							newNode.img2.style.backgroundImage = "";
							newNode.img2.className = "imgFileNode";
							newNode.changeIcone = function () {};
							eval("newNode._onclick = function() {window.open(\"accessFichierDossiers.do?file=" + newParam + "\", \"\", \"\");}");
						}
						
						else {
							var newNodeName = node.name + "Folder" + i;
							eval("var " + newNodeName + " = tree.createAndAddNode(node.id, {name: newNodeName , text: fileName})");
							eval(newNodeName + "._onclick = function() {chargeDossier(dossiersTree, this, \"" + newParam + "\")}");
							var newNodeHasChild = getElementText(files[i].getElementsByTagName("has_child")[0]);
							eval(newNodeName + ".hasChild = function() {return " + newNodeHasChild + ";}");
							eval(newNodeName).toggle();
							if(eval(newNodeName).open) eval(newNodeName).toggle();
							eval(newNodeName + ".img1.onclick = function() {" + newNodeName + "._onclick();}");
						}
						if(!node.open) node.toggle();
					}
				}
			};
			
			var url = "chargeDossier.do?texte=" + param;
			sendAjaxUrl(req, url, "POST");
		}
	} else {
		node.toggle();
	}
};
