var mBoxObj = function(mbxVarName) {
	this.ie = (document.all ? true : false);

	// chaine de caractère contenant le nom de la variable crée avec new
	// ex : var mBox = new mBoxObj("mBox")
	this.VarName = mbxVarName;

	// type de mBoxBox
	this.mbxOk	  = 0;
	this.mbxClose = 1;
	this.mbxFile  = 2;

	// les objets du DOM : fond, ombre, box et template
	this.mbxBGD = document.createElement("div");
	this.mbxBOX = document.createElement("div");
	this.mbxTMP = document.createElement("div");

	// l'id définit pour le style -> voir mBox.css
	this.mbxBGD.id = "mBoxBackground";
	this.mbxBOX.id = "mBoxBox";
	this.mbxTMP.id = "mBoxTemplate";

	// fonction pour utilisation externe : pour charger un fichier template html
	this.mbxTMP.loadTemplate = function(htmlfile) {
		load_htmldoc(htmlfile, data = "", dest_id = this.id, after_onload = null);
	};
	// chargement fichier template par défaut
	document.body.appendChild(this.mbxTMP);
	this.mbxTMP.loadTemplate("res/mBox/mBoxDefault.html");

	// objet parent de l'élément DOM pour setTimeout() 
	// dans this.mbxBGD.fadein() et this.mbxBGD.fadeout()
	this.mbxBGD.parentObj = this;
	
	// opacité maxi du background (valeur pour ff, pour ie = valeur * 100 -> voir fadein et fadeout)
	this.mbxBGD.maxOpacity = 0.70;

	// gestion de l'affichage du Background
	this.mbxBGD.fadeout = function() {
		with(this) {
			if (opacity > 0) {
				opacity -= (maxOpacity / 3);
				setTimeout(parentObj.VarName + ".mbxBGD.fadeout()", 10);
			}
			else {
				opacity = 0;
				style.display = "none";
			}
			style.opacity = (parentObj.ie ? opacity * 100 : opacity);
			style.filter  = "alpha(opacity = " + (parentObj.ie ? opacity * 100 : opacity) + ")";
		}
	};
	this.mbxBGD.fadein = function() {
		with(this) {
			if (opacity < maxOpacity) {
				opacity += (maxOpacity / 3);
				setTimeout(parentObj.VarName + ".mbxBGD.fadein()", 10);
			}
			else {
				opacity = maxOpacity;
			}
			style.opacity = (parentObj.ie ? opacity * 100 : opacity);
			style.filter  = "alpha(opacity = " + (parentObj.ie ? opacity * 100 : opacity) + ")";
		}
	};

	// déclaration de la fonction/événement à surcharger : 
	// se déclenche quand on clique sur Ok -> voir Template
	this.onok = function(){};

	// déclaration de la fonction/événement à surcharger : 
	// se déclenche avant qu'on cache le mBox -> voir hide()
	// fonction de récupération du contenu
	this.onhide = function(){};

	// déclaration de la fonction/événement à surcharger : 
	// se déclenche avant qu'on affiche le mBox -> voir show()
	// fonction d'initialisation du contenu
	// permet de finaliser les dimensions
	this.onshow = function(){};

	// gestion des dimensions et du positionnement du mBoxBox une fois chargé -> voir show()
	this.onloaded = function() {
		with(this) {
			// mBoxBox caché pendant le positionnement
			mbxBOX.style.visibility = "hidden";

			// display pour modification des dimensions du mBoxBox
			mbxBOX.style.display = "block";

			// appel à l'événement d'initialisation du contenu
			// permet de finaliser les dimensions
			onshow();
			onshow = function(){};

			// modification des dimensions du mBoxBox
			mbxBOX.style.height = px(mbxBOX.firstChild.clientHeight);
			mbxBOX.style.width  = px(mbxBOX.firstChild.clientWidth);

			// positionnement du mBoxBox
			var offset = 3;
			var l = (mbxBGD.clientWidth - mbxBOX.clientWidth) / 2;
			var t = "40%"; //(document.body.client(mbxBGD.clientHeight - mbxBOX.clientHeight) / 2;
			mbxBOX.style.left = px(l);
			mbxBOX.style.top  = t; //px(t);

			// affichage du mBoxBox
			mbxBOX.style.visibility = "visible";
		}
	}

	// fonction lancée par défaut quand on clique sur Ok ou Cancel -> voir template
	// - appel l'événement onhide()
	// - raz des événements onok(), onshow() et onhide()
	// - cache le mBox
	this.hide = function() {
		with(this) {
			onhide();

			onok = function(){};
			onshow = function(){};
			onhide = function(){};

			mbxBOX.innerHTML = "";
			mbxBOX.style.display = "none";
			mbxBGD.opacity = mbxBGD.maxOpacity;
			mbxBGD.fadeout();
		}
	};
	
	// affichage du mBox
	this.show = function(mBoxTitle, mBoxBody, mBoxType) {
		with(this) {
			// affichage du Background
			mbxBGD.opacity = 0;
			mbxBGD.fadein();
			mbxBGD.style.display = "block";
			
			// dimensions du Background
			var fullHeight = document.body.scrollHeight; 
			var fullWidth  = document.body.scrollWidth; 
			mbxBGD.style.height = px(fullHeight);
			mbxBGD.style.width  = px(fullWidth);

			// réinitialise les dimensions par défaut du Box -> voir mBox.css
			mbxBOX.innerHTML = "";
			mbxBOX.style.width = px(300);
			mbxBOX.style.height = px(150);

			// recharge le template vide
			mbxBOX.innerHTML = mbxTMP.innerHTML;

			// conteneur des éléments -> voir template
			var table = mbxBOX.getElementsByTagName("table");
			var td = Array();
			td[0] = table[0].getElementsByTagName("td");

			// modifie le titre
			td[0][1].innerHTML = mBoxTitle;
			
			// gestion des boutons
			if (mBoxType == mbxOk) {
				// pas de bouton Close
				td[0][2].style.visibility = "hidden";
			}

			if (mBoxType == mbxFile) {

alert("à faire ICI");
return;
				// charge le fichier mBoxBody dans le corps de mbxBOX puis appelle onloaded
				loadHttpRequest(mBoxBody, td[0][2], function(){onloaded()});
			}
			else {
				// charge le texte dans corps de mbxBOX
				td[0][4].innerHTML = mBoxBody;

				// puis appelle onloaded
				onloaded();
			}
		}
	};

	// insertion des éléments du DOM : en dernier pour le zIndex -> voir body.onload()
	this.appendDOMElement = function() {
		with(this) {
			document.body.appendChild(mbxBGD);
			document.body.appendChild(mbxBOX);
			mbxBGD.onclick = function(){this.parentObj.hide()};
			hide();
		}
	};
};
