box = function(divMask, divContainer){
	
	this.closeSiClickSurMarsk = true;
	var maskSelect = null;
	var me_box = this;
	this.open = function () {
		this.positionneDiv();
		if (this.closeSiClickSurMarsk)
		{
			this.addListener(divMask, "click", this.close);
		}
		this.addListener(window, "resize", adapteOnResize);
		divMask.style.display = 'block';
		divContainer.style.display = 'block';
		this.maskSelect();
	},
	
	this.close = function () {
		divMask.style.display = 'none';
		divContainer.style.display = 'none';
		me_box.afficheSelect();
		//delete this;
	},
	
	this.maskSelect = function(){
		this.maskSelect = document.getElementsByTagName("select");
		if (this.maskSelect)
		{
			for(i=0; i < this.maskSelect.length ; i++)
			{
				document.getElementsByTagName("select")[i].style.display='none';
			}
		}
	},
	
	this.afficheSelect = function(){
		if (this.maskSelect != null)
		{
			for(i=0; i < this.maskSelect.length ; i++)
			{
				document.getElementsByTagName("select")[i].style.display='inline';
			}
		}
	},
	
	
	this.positionneDiv = function() {
		
		var arrayPageSize = this.getPageSize();
	    var width = arrayPageSize[0] + 'px';
		var height = arrayPageSize[1] + 'px';
		
//		alert("width="+width+" | height="+height);
		if (divMask){
			//alert(width);
			divMask.style.width = width;
			divMask.style.height = height;//IL faut utilisser l'evt onResize sur le body....
		}
		else{
			alert("le Div mask est manquant");
			return false;
		}

		// calculate top and left offset for the box 
        var arrayPageScroll = new Array(window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop);
		
		var hauteurContenu = this.getDimensions(divContainer).height;
		var largeurContenu = this.getDimensions(divContainer).width;
        var boxTop = arrayPageScroll[1] + (document.documentElement.clientHeight / 10) - (hauteurContenu/2) + 200;
        var boxLeft = document.documentElement.clientWidth / 2 - (largeurContenu/2);//arrayPageScroll[0];
        var top = boxTop + 'px';
		var left = boxLeft + 'px';
		//alert("top="+top+" | left="+left);
		if (divContainer){
			divContainer.style.top = top;
			divContainer.style.left = left;//IL faut utilisser l'evt onResize sur le body....
		}
		else{
			alert("le Div container est manquant");
			return false;
		}
    },
	
	this.getDimensions = function(element) {
		// All *Width and *Height properties give 0 on elements with display none,
		// so enable the element temporarily
		var els = element.style;
		var originalVisibility = els.visibility;
		var originalPosition = els.position;
		var originalDisplay = els.display;
		els.visibility = 'hidden';
		els.position = 'absolute';
		els.display = 'block';
		var originalWidth = element.clientWidth;
		var originalHeight = element.clientHeight;
		els.display = originalDisplay;
		els.position = originalPosition;
		els.visibility = originalVisibility;
		return {width: originalWidth, height: originalHeight};
	},
	
	this.addListener = function(element, evt, functionName) {
		if (element.addEventListener) {
			element.addEventListener(evt, functionName, false);
		} else {
			element.attachEvent("on"+evt, functionName);
		}
	},


	this.getPageSize=function() {     
		
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		/*
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else */
		
		if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight];
	}
}


