//gestion de window.onload
//Fonction de stockage des scripts à charger 
FuncOL = new Array(); 
function windowOnLoad(Obj) { 
    FuncOL[FuncOL.length] = Obj; 
} 
     
//Execution des scripts au chargement de la page 
window.onload = function() {
	for(var i=0; i<FuncOL.length; i++) 
        {FuncOL[i]();} 
}

/* Dialog Box */
function DialogBox(divId){
	this.dialog = document.getElementById(divId);
	this.b = false;
	
	if(typeof DialogBox.initialized == "undefined"){
		DialogBox.prototype.show = function(){
			this.dialog.style.display = 'block';
			this.b = true;
		};
		DialogBox.prototype.hide = function(){
			this.dialog.style.display = 'none';
			this.b = false;
		};
		DialogBox.prototype.isOpen = function(){
			return this.b;
		};
		DialogBox.initialized = true;
	}
}

/* InfoBulle Box ListingProd */
function InfoBulle(divId){
	this.bulle = document.getElementById(divId);
	this.b = false;
	
	if(typeof InfoBulle.initialized == "undefined"){
		InfoBulle.prototype.move = function(e){
			if(this.b){
    			if(navigator.appName!="Microsoft Internet Explorer"){
					this.bulle.style.left = -220+e.pageX+"px";
					this.bulle.style.top = -185+e.pageY+"px";
    			}else{
    				this.bulle.style.left = -220+event.x+document.documentElement.scrollLeft+"px";
    				this.bulle.style.top = -185+event.y+document.documentElement.scrollTop+"px";
    			}
			}
		};
		InfoBulle.prototype.show = function(content){
			this.bulle.style.visibility = "visible";
			this.bulle.innerHTML = content;
			
			this.b = true;
		};
		InfoBulle.prototype.hide = function(){
			this.bulle.style.visibility = "hidden"; 
			this.b = false;
		};
		InfoBulle.prototype.isOpen = function(){
			return this.b;
		};
		InfoBulle.initialized = true;
	}
}

/* +-------------------------------------+
 * Number.prototype.nombreFormate
 * +-------------------------------------+
 * Params (facultatifs):
 *	- Int decimales: nombre de decimales (exemple: 2)
 *	- String signe: le signe precedent les decimales (exemple: "," ou ".")
 *	- String separateurMilliers: comme son nom l'indique
 * Returns:
 *	- String chaine formatee
 */

Number.prototype.nombreFormate = function (decimales, signe, separateurMilliers) {
	var _sNombre = String(this), i, _sRetour = "", _sDecimales = "";
	if (decimales == undefined) decimales = 2;
	if (signe == undefined) signe = '.';
	if (separateurMilliers == undefined) separateurMilliers = ' ';
	
	function separeMilliers (sNombre) {
		var sRetour = "";
		while (sNombre.length % 3 != 0) {
			sNombre = "0"+sNombre;
		}
		for (i = 0; i < sNombre.length; i += 3) {
			if (i ==  sNombre.length-1) separateurMilliers = '';
			sRetour += sNombre.substr(i, 3)+separateurMilliers;
		}
		while (sRetour.substr(0, 1) == "0") {
			sRetour = sRetour.substr(1);
		}
		return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers));
	}
	if (_sNombre.indexOf('.') == -1) {
		for (i = 0; i < decimales; i++) {
			_sDecimales += "0";
		}
		_sRetour = separeMilliers(_sNombre)+signe+_sDecimales;
	} else {
		var sDecimalesTmp = (_sNombre.substr(_sNombre.indexOf('.')+1));
		if (sDecimalesTmp.length > decimales) {
			var nDecimalesManquantes = sDecimalesTmp.length - decimales;
			var nDiv = 1;
			for (i = 0; i < nDecimalesManquantes; i++) {
				nDiv *= 10;
			}
			_sDecimales = Math.round(Number(sDecimalesTmp) / nDiv);
		}
		_sRetour = separeMilliers(_sNombre.substr(0, _sNombre.indexOf('.')))+String(signe)+_sDecimales; 
	}
	return _sRetour;
}


