function acai_commons_genericCouche() {
	var fNom = '';
	var fVisible = true;
	var fBackgroundColor = '#ffffff';
	var fForeColor = '#000000';
	var fTop = 0;
	var fLeft = 0;
	var fHeight = 0;
	var fWidth = 0;
	var fContenu = '';
	var fTextAlign = 'left';
	var fBorderWidth = 0;
	var fBorderStyle = 'none';
	var fBorderColor = '#000000';
	var fZIndex = 1;
	var fScrolling = false;

	this.setNom = function(pNom) {
		var couche = document.getElementById(pNom);
		if (couche == null) {
			fBackgroundColor = document.body.bgColor;
			fForeColor = document.body.text;
			fBorderColor = document.body.text;
			couche = document.createElement('div');
			var attribut = document.createAttribute('id');
			attribut.value = pNom;
			couche.setAttributeNode(attribut);
			couche.style.position = "absolute";
			couche.style.overflow = 'hidden';
			var racine =  document.getElementsByTagName('body').item(0);
			racine.appendChild(couche);
		} else {
	   		fVisible = (couche.style.display==='' ? true : false);
			fLeft = couche.style.left;
			fTop = couche.style.top;
			fWidth = couche.style.width;
			fHeight = couche.style.height;
			fBackgroundColor = couche.style.backgroundColor;
			fForeColor = couche.style.color;
			fTextAlign = couche.style.textAlign;
			fBorderColor = couche.style.borderColor;
			fBorderStyle = couche.style.borderStyle;
			fBorderWidth = couche.style.borderWidth;
			fScrolling = (couche.style.overflow==='auto' ? true : false);
			fContenu = couche.innerHTML;
		}
		fNom = pNom;
	};

	this.getNom = function() {
		return fNom;
	};

	this.setVisible = function(pVisible) {
		if (fVisible != pVisible) {
			fVisible = pVisible;
			this.redraw();
		}
	};

	this.isVisible = function() {
		return fVisible;
	};

	this.setScrolling = function(pScrolling) {
		if (fScrolling != pScrolling) {
			fScrolling = pScrolling;
			this.redraw();
		}
	};

	this.isScrolling = function() {
		return fScrolling;
	};

	this.setBgColor = function(pColor) {
		if (fBackgroundColor != pColor) {
			fBackgroundColor = pColor;
			this.redraw();
		}
	};

	this.getBgColor = function() {
		return fBackgroundColor;
	};

	this.setColor = function(pColor) {
		if (fForeColor != pColor) {
			fForeColor = pColor;
			this.redraw();
		}
	};

	this.getColor = function() {
		return fForeColor;
	};

	this.setBorderColor = function(pColor) {
		if (fBorderColor != pColor) {
			fBorderColor = pColor;
			this.redraw();
		}
	};

	this.getBorderColor = function() {
		return fBorderColor;
	};

	this.setBorderStyle = function(pStyle) {
		if (fBorderStyle != pStyle) {
			fBorderStyle = pStyle;
			this.redraw();
		}
	};

	this.getBorderStyle = function() {
		return fBorderStyle;
	};

	this.setBorderWidth = function(pWidth) {
		if (fBorderWidth != pWidth) {
			fBorderWidth = pWidth;
			this.redraw();
		}
	};

	this.getBorderWidth = function() {
		return fBorderWidth;
	};

	this.setPosition = function(pLeft,pTop,pWidth,pHeight) {
		fLeft = pLeft;
		fTop = pTop;
		fWidth = pWidth;
		fHeight = pHeight;
		this.redraw();
	};

	this.setWidth = function(pWidth) {
		if (fWidth != pWidth) {
			fWidth = pWidth;
			this.redraw();
		}
	};

	this.setHeight = function(pHeight) {
		if (fHeight != pHeight) {
			fHeight = pHeight;
			this.redraw();
		}
	};

	this.getLeft = function() {
		return fLeft;
	};

	this.setLeft = function(pLeft) {
		if (fLeft != pLeft) {
			fLeft = pLeft;
			this.redraw();
		}
	};

	this.getTop = function() {
		return fTop;
	};

	this.getWidth = function() {
		return fWidth;
	};

	this.getHeight = function() {
		return fHeight;
	};

	this.setContenu = function(pContenu) {
		if (fContenu != pContenu) {
			fContenu = pContenu;
			this.redraw();
		}
	};

	this.getContenu = function() {
		return fContenu;
	};

	this.setAlignementTexte = function(pTextAlign) {
		if (fTextAlign != pTextAlign) {
			fTextAlign = pTextAlign;
			this.redraw();
		}
	};

	this.getAlignementTexte = function() {
		return fTextAlign;
	};

	this.setZIndex = function(pZIndex) {
		if (fZIndex != pZIndex) {
			fZIndex = pZIndex;
			this.redraw();
		}
	};

	this.getZIndex = function() {
		return fZIndex;
	};

	this.redraw = function() {
		var couche = document.getElementById(this.getNom());
   		couche.style.display = (this.isVisible() ? '' : 'none');
	   	couche.style.overflow = (this.isScrolling() ? 'auto' : 'hidden');
		couche.style.left = this.getLeft().toString() + "px";
		couche.style.top = this.getTop().toString() + "px";
/*
		if (navigator.userAgent.indexOf("MSIE") != -1 && fBorderWidth !=0 && fBorderWidth!="") {
				// pour IE
				realWidth = this.getWidth()+ 2*parseInt(this.getBorderWidth());
				realHeight = this.getHeight()+ 2*parseInt(this.getBorderWidth());
				realWidth = this.getWidth();
				realHeight = this.getHeight();
		} else {
				// pour Mozilla
				realWidth = this.getWidth();
				realHeight = this.getHeight();
		}
		couche.style.width = realWidth.toString() + "px";
		couche.style.height = realHeight.toString() + "px";
*/
		couche.style.width = this.getWidth().toString() + "px";
		couche.style.height = this.getHeight().toString() + "px";
		couche.style.backgroundColor = this.getBgColor();
		couche.style.color = this.getColor();
		couche.style.textAlign = this.getAlignementTexte();
		if (this.getBorderWidth() !=0) {
			couche.style.borderColor = this.getBorderColor();
			couche.style.borderStyle = this.getBorderStyle();
			couche.style.borderWidth = this.getBorderWidth().toString() + "px";
		}
		couche.style.paddingLeft = '0px';
		couche.style.paddingRight = '0px';
		couche.style.paddingTop = '0px';
		couche.style.paddingBottom = '0px';
		couche.style.marginLeft = '0px';
		couche.style.marginRight = '0px';
		couche.style.marginTop = '0px';
		couche.style.marginBottom = '0px';
		couche.style.zIndex = this.getZIndex();
		if (this.getContenu() != '') {
			couche.innerHTML = this.getContenu();
		}
	};
}

function acai_commons_genericCadre(pNom, pVisible, pBorderColor, pBorderWidth) {
	var fLeftBorder = new acai_commons_genericCouche();
	var fRightBorder = new acai_commons_genericCouche();
	var fTopBorder = new acai_commons_genericCouche();
	var fBottomBorder = new acai_commons_genericCouche();
	var fTop = 0;
	var fLeft = 0;
	var fHeight = 0;
	var fWidth = 0;
	var fBorderWidth = 2;
	var fBorderColor = document.body.text;
	var fVisible = true;

	this.setNom = function(pNom) {
		fLeftBorder.setNom(pNom + '_LB');
		fRightBorder.setNom(pNom + '_RB');
		fTopBorder.setNom(pNom + '_TB');
		fBottomBorder.setNom(pNom + '_BB');
	};

	this.setBorderColor = function(pColor) {
		if (fBorderColor != pColor) {
			fBorderColor = pColor;
			this.redraw();
		}
	};

	this.getBorderColor = function() {
		return fBorderColor;
	};

	this.setBorderWidth = function(pWidth) {
		if (fBorderWidth != pWidth) {
			fBorderWidth = pWidth;
			this.redraw();
		}
	};

	this.getBorderWidth = function() {
		return fBorderWidth;
	};

	this.setVisible = function(pVisible) {
		if (fVisible != pVisible) {
			fVisible = pVisible;
			this.redraw();
		}
	};

	this.isVisible = function() {
		return fVisible;
	};

	this.setPosition = function(pLeft,pTop,pWidth,pHeight) {
		fLeft = pLeft;
		fTop = pTop;
		fWidth = pWidth;
		fHeight = pHeight;
		this.redraw();
	};

	this.getLeft = function() {
		return fLeft;
	};

	this.getTop = function() {
		return fTop;
	};

	this.getWidth = function() {
		return fWidth;
	};

	this.getHeight = function() {
		return fHeight;
	};

	this.redraw = function() {
		fLeftBorder.setVisible(this.isVisible());
		fRightBorder.setVisible(this.isVisible());
		fTopBorder.setVisible(this.isVisible());
		fBottomBorder.setVisible(this.isVisible());

		fLeftBorder.setPosition(this.getLeft(), this.getTop(), this.getBorderWidth(), this.getHeight());
		fRightBorder.setPosition(this.getLeft() + this.getWidth() - this.getBorderWidth(), this.getTop(), this.getBorderWidth(), this.getHeight());
		fTopBorder.setPosition(this.getLeft(), this.getTop(), this.getWidth(), this.getBorderWidth());
		fBottomBorder.setPosition(this.getLeft(), this.getTop() + this.getHeight()- this.getBorderWidth(), this.getWidth(), this.getBorderWidth());

		fLeftBorder.setBgColor(this.getBorderColor());
		fRightBorder.setBgColor(this.getBorderColor());
		fTopBorder.setBgColor(this.getBorderColor());
		fBottomBorder.setBgColor(this.getBorderColor());

		fLeftBorder.setZIndex(1100);
		fRightBorder.setZIndex(1100);
		fTopBorder.setZIndex(1100);
		fBottomBorder.setZIndex(1100);
	};

	this.setNom(pNom);
	if (pBorderColor != null) this.setBorderColor(pBorderColor);
	if (pBorderWidth != null) this.setBorderWidth(pBorderWidth);
	if (pVisible != null) this.setVisible((pVisible ? true : false));

}

function acai_commons_genericCroix(pNom, pVisible, pBorderColor, pBorderWidth) {
	var fHorizontalBar = new acai_commons_genericCouche();
	var fVerticalBar = new acai_commons_genericCouche();
	var fTop = 0;
	var fLeft = 0;
	var fSize = 0;
	var fBorderWidth = 2;
	var fBorderColor = document.body.text;
	var fVisible = true;

	this.setNom = function(pNom) {
		fHorizontalBar.setNom(pNom + '_HB');
		fVerticalBar.setNom(pNom + '_VB');
	};

	this.setBorderColor = function(pColor) {
		if (fBorderColor != pColor) {
			fBorderColor = pColor;
			this.redraw();
		}
	};

	this.getBorderColor = function() {
		return fBorderColor;
	};

	this.setBorderWidth = function(pWidth) {
		if (fBorderWidth != pWidth) {
			fBorderWidth = pWidth;
			this.redraw();
		}
	};

	this.getBorderWidth = function() {
		return fBorderWidth;
	};

	this.setVisible = function(pVisible) {
		if (fVisible != pVisible) {
			fVisible = pVisible;
			this.redraw();
		}
	};

	this.isVisible = function() {
		return fVisible;
	};

	this.setPosition = function(pLeft,pTop,pSize) {
		fLeft = pLeft;
		fTop = pTop;
		fSize = pSize;
		this.redraw();
	};

	this.getLeft = function() {
		return fLeft;
	};

	this.getTop = function() {
		return fTop;
	};

	this.getSize = function() {
		return fSize;
	};

	this.redraw = function() {
		fHorizontalBar.setVisible(this.isVisible());
		fVerticalBar.setVisible(this.isVisible());

		fHorizontalBar.setPosition(this.getLeft() - (this.getSize()/2), this.getTop(), this.getSize(), this.getBorderWidth());
		fVerticalBar.setPosition(this.getLeft(), this.getTop() - (this.getSize()/2), this.getBorderWidth(), this.getSize());

		fHorizontalBar.setBgColor(this.getBorderColor());
		fVerticalBar.setBgColor(this.getBorderColor());

		fHorizontalBar.setZIndex(1100);
		fVerticalBar.setZIndex(1100);
	};

	this.setNom(pNom);
	if (pBorderColor != null) this.setBorderColor(pBorderColor);
	if (pBorderWidth != null) this.setBorderWidth(pBorderWidth);
	if (pVisible != null) this.setVisible((pVisible ? true : false));

}

function acai_commons_image(pSrc, pAlt, pWidth, pHeight, pId) {
	var fSrc = pSrc || '';
	var fAlt = pAlt || '';
	var fWidth = pWidth || '';
	var fHeight = pHeight || '';
	var fId = pId || '';
	var fOpacity = -1;

/*
	this.setId = function(pId) {
		fId=pId;
	};
*/

	this.setOpacity = function(pOpacity) {
		fOpacity = pOpacity;
	};
	
	this.toHTML = function() {
		if (fSrc === '') {
			return '';
		} else {
			var imageHTML = '<img src=\'' + fSrc + '\'';
			if (fId != '')	imageHTML += ' id=\'' + fId + '\'';
			if (fAlt != '')	imageHTML += ' alt=\'' + fAlt + '\' title=\'' + fAlt + '\'';
			if (fWidth != '')	imageHTML += ' width=\'' + fWidth + '\'';
			if (fHeight != '')	imageHTML += ' height=\'' + fHeight + '\'';
			if (fOpacity != -1) {
				if (navigator.userAgent.indexOf("MSIE") != -1) {
					imageHTML += ' style=\'opacity:' + fOpacity/100 + ';filter:alpha(opacity=' + fOpacity + ');\'';
				} else {
					imageHTML += ' style=\'opacity:' + fOpacity/100 + ';\'';
				}
			}
			imageHTML += '>'
		}
		return imageHTML;
	};
}

function acai_commons_dropList(pLabel, pOnChangeAction) {
	var fLabel = pLabel || '';
	var fOnChangeAction = pOnChangeAction || '';
	var fItems = new Array(1);
	var fNbItems = 0;
	ITEM_VALUE = 0;
	ITEM_LABEL = 1;
	ITEM_SELECTED = 2;

	this.addItem = function(pValue, pLabel, pSelected) {
		fNbItems ++;
		fItems[fNbItems] = new acai_commons_dropListItem(pValue, pLabel, pSelected);
	};

	this.getItem = function(pIndex) {
		return fItems[pIndex];
	};

	this.toHTML = function() {
		var dropListHTML = '<span>' + fLabel + '</span>'
			+ '<select onChange=\'' + fOnChangeAction + '\'>';
		for (var itemIterator=1 ; itemIterator<=fNbItems ; itemIterator++) {
			dropListHTML += fItems[itemIterator].toHTML();
		}
		dropListHTML += '</select>';
		return dropListHTML;
	};
}

function acai_commons_dropListItem(pValue, pLabel, pSelected) {
	var fValue = pValue || '';
	var fLabel = pLabel || '';
	var fSelected = pSelected || false;

	this.getValue = function() {
		return fValue;
	};

	this.getLabel = function() {
		return fLabel;
	};

	this.toHTML = function() {
		droptListItemHTML = '<option ' + ( (fSelected) ? 'selected ' : '') + 'value=\'' + fValue +'\'>' + fLabel +'</option>';
		return droptListItemHTML;
	};
}

function acai_commons_selectorBar(pNom,pLeft,pTop,pWidth,pHeight) {
	var fDropLists = new Array(1);
	var fNbDropList = 0;

	this.addDropList = function(acaiDropList) {
		fNbDropList ++;
		fDropLists[fNbDropList] = acaiDropList;
	};

	this.toHTML = function() {
		var selectorBarHTML = '';
		for (var dropListIterator=1 ; dropListIterator<=fNbDropList ; dropListIterator++) {
			selectorBarHTML += fDropLists[dropListIterator].toHTML();
		}
		return selectorBarHTML;
	};

	this.show = function() {
		if (fNbDropList > 0) {
			this.setContenu(this.toHTML());
			this.redraw();
		}
	};

	this.setNom(pNom);
	this.setPosition(pLeft,pTop,pWidth,pHeight);
}

acai_commons_selectorBar.prototype = new acai_commons_genericCouche;

function acai_commons_picto(pSrc, pAlt, pAction) {
	var fSrc = pSrc || '';
	var fAlt = pAlt || '';
	var fAction = pAction || '';
	var fToolBar = '';
	var fActive = false;
	var fNumPicto = 0;

	this.setToolBar = function(pToolBar) {
		fToolBar = pToolBar;
	};

	this.setActive = function(pActive) {
		fActive = pActive;
	};

	this.setNumPicto = function(pNumPicto) {
		fNumPicto = pNumPicto;
	};

	this.toHTML = function(pColor) {
		var pictoHTML = '<img src=\'' + fSrc + '\''
			+ ' alt=\'' + fAlt + '\' title=\'' + fAlt + '\''
			+ ((fActive) ? ' style=\'background:' + pColor + ';\'' : '')
			+ ' onclick=\'' + fToolBar + '.activePicto(' + fNumPicto + ');' + fAction + '\''
			+ '>';
		return pictoHTML;
	};
}

function acai_commons_toolBar(pVarName,pNom,pLeft,pTop,pWidth,pHeight) {
	var fVarName = pVarName;
	var fTools = new Array(1);
	var fNbTools = 0;
	var fActiveTool = 0;
	var fSeparator = 0;

	this.addSeparator = function() {
//		fSeparator += fNbTools.toString() + "+";
		fSeparator = fNbTools;
	};

	this.addPicto = function(pSrc, pAlt, pAction) {
		fNbTools ++;
		fTools[fNbTools] = new acai_commons_picto(pSrc, pAlt, pAction);
		fTools[fNbTools].setToolBar(fVarName);
		fTools[fNbTools].setNumPicto(fNbTools);
	};

	this.activePicto = function(pActiveTool) {
		for (var toolIterator=1 ; toolIterator<=fNbTools ; toolIterator++) {
			fTools[toolIterator].setActive(false);
		}
		fTools[pActiveTool].setActive(true);
		fActiveTool = pActiveTool;
		this.show();
	};

	this.toHTML = function() {
//alert(fSeparator);
		var toolBarHTML = '';
		for (var toolIterator=1 ; toolIterator<=fNbTools ; toolIterator++) {
			toolBarHTML += fTools[toolIterator].toHTML(this.getColor());
//			if (fSeparator.indexOf(toolIterator.toString() + "+") != -1) {
			if (fSeparator == toolIterator) {
				toolBarHTML += "<br/>";
			}
		}
		return toolBarHTML;
	};

	this.show = function() {
		if (fNbTools > 0) {
			this.setContenu(this.toHTML());
			this.redraw();
		}
	};

	this.setNom(pNom);
	this.setPosition(pLeft,pTop,pWidth,pHeight);
	this.setColor(document.body.text);
}

acai_commons_toolBar.prototype = new acai_commons_genericCouche;


function acai_commons_tab(pText, pAlt, pAction) {
	var fText = pText || '';
	var fAlt = pAlt || '';
	var fAction = pAction || '';
	var fTabPanel = '';
	var fActive = false;
	var fNumTab = 0;

	this.setTabPanel = function(pTabPanel) {
		fTabPanel = pTabPanel;
	};

	this.setActive = function(pActive) {
		fActive = pActive;
		if (pActive) {
			eval(fAction);
		}
	};

	this.setNumTab = function(pNumTab) {
		fNumTab = pNumTab;
	};

	this.toHTML = function(pCellColor, pTextColor) {
		var textColor = fActive ? pCellColor : pTextColor;
		var cellColor = fActive ? pTextColor : pCellColor;
		var tabHTML = '<td align=\'center\''
			+ ' style=\'border:0px solid ' + document.body.text + ';background:' + cellColor + ';color:' + textColor + ';\''
			+ ' onclick=\'' + fTabPanel + '.activeTab(' + fNumTab + ');\''
			+ '><span style=\'font-family:Arial;font-size:10pt;\' title=\'' + fAlt + '\'>' + fText + '</span></td>';
		return tabHTML;
	};
}

function acai_commons_tabPanel(pVarName,pNom,pLeft,pTop,pWidth,pHeight) {
	var fVarName = pVarName;
	var fTabs = new Array(1);
	var fNbTabs = 0;
	var fActiveTab = 0;

	this.addTab = function(pText, pAlt, pAction) {
		fNbTabs ++;
		fTabs[fNbTabs] = new acai_commons_tab(pText, pAlt, pAction);
		fTabs[fNbTabs].setTabPanel(fVarName);
		fTabs[fNbTabs].setNumTab(fNbTabs);
	};

	this.activeTab = function(pActiveTab) {
		for (var tabIterator=1 ; tabIterator<=fNbTabs ; tabIterator++) {
			fTabs[tabIterator].setActive(false);
		}
		fTabs[pActiveTab].setActive(true);
		fActiveTab = pActiveTab;
		this.show();
	};

	this.getNbTabs = function() {
		return fNbTabs;
	};
	
	this.toHTML = function() {
		var tabPanelHTML = '<table ' + 'height=\'' + this.getHeight() + '\'' + ' width=\'100%\' cellspacing=\'0px\' cellpadding=\'1px\' ><tr>';
		for (var tabIterator=1 ; tabIterator<=fNbTabs ; tabIterator++) {
			tabPanelHTML += fTabs[tabIterator].toHTML(this.getBgColor(), this.getColor());
		}
		tabPanelHTML += '</tr></table>';
		return tabPanelHTML;
	};

	this.show = function() {
		if (fNbTabs > 0) {
			this.setContenu(this.toHTML());
		}
	};
	
	this.setNom(pNom);
	this.setPosition(pLeft,pTop,pWidth,pHeight);
	this.setColor(document.body.text);
	this.setBgColor(document.body.bgColor);
}

acai_commons_tabPanel.prototype = new acai_commons_genericCouche;



