function acai_carto_utils() {

		if (acai_carto_utils.singleton) {
				return acai_carto_utils.singleton;
		}

		acai_carto_utils.adaptRectangleToMap = function(_mapWidth, _mapHeight, _xmin, _xmax, _ymin, _ymax) {
				var manque;
				var rapportZoom = (_xmax-_xmin)/(_ymax-_ymin);
				var rapportImage = (_mapWidth)/(_mapHeight);
				if (rapportZoom < rapportImage) {
						// etirer en largeur
						manque = rapportImage*(_ymax-_ymin) - (_xmax-_xmin);
						_xmin = parseInt(_xmin - manque/2);
						_xmax = parseInt(_xmax + manque/2);
				} else {
						// etirer en hauteur
						manque = (_xmax-_xmin)/rapportImage - (_ymax-_ymin);
						_ymin = parseInt(_ymin - manque/2);
						_ymax = parseInt(_ymax + manque/2);
				}
				return [_xmin, _xmax, _ymin, _ymax];
		};
		
		acai_carto_utils.decimalRound = function (myNumber,decimals) {
			var sNumber = myNumber.toString();
			var pos = sNumber.indexOf(".");
			if (pos != -1) {
				if ( (pos+decimals+1) < sNumber.length ) {
					sNumber = sNumber.substr(0,pos+decimals+1);
				}
			}
			return sNumber;
		};

		acai_carto_utils.waitingMessage = function(_message) {
				return "<div align=\'center\'>" +
					"<table border=\'0\' height='\100%\'>" +
					"<tr height=\'33%\'><td>&nbsp;</td></tr>" +
					"<tr height=\'34%\'><td>" +
					"<table cellpadding=\'5\'><tr>" +
					"<td style=\'font-family:Arial;font-size:16pt;font-weight:bold;text-align:center;color:blue;background:white;border-width:1;border-color:blue;border-style:solid;\'>" +
					_message +
					"</td></tr></table>" +
					"</td></tr>" +
					"<tr height=\'33%\'><td>&nbsp;</td></tr>" +
					"</table>" +
					"</div>";

		};
		
		acai_carto_utils.findProjectionText = function(_projCode) {
			var _projText = "?";
			for (var i=0 ; i<aProj.length ; i++) {
				if (aProj[i][PROJ_CODE] === _projCode) {
					_projText = aProj[i][PROJ_TEXT];
					break;
				}
			}
			return _projText;
		};
		
		acai_carto_utils.ajax_TextLoader = function(distantFile,lSync) {
			var comHTTP;
			var comHTTPOK = false;
			var flux;

			try {
				comHTTP = new ActiveXObject("Msxml2.XMLHTTP");
				comHTTPOK = true;
			} catch (e) {
				try {
					comHTTP = new ActiveXObject("Microsoft.XMLHTTP");
					comHTTPOK = true;
				} catch (E) {
					comHTTPOK = false;
				}
			}

			if (!comHTTPOK && typeof XMLHttpRequest != 'undefined') {
				try {
					comHTTP = new XMLHttpRequest();
					comHTTPOK = true;
				} catch (e) {
					comHTTPOK = false;
				}
			}
			if (comHTTPOK) {
				try {
					comHTTP.open("GET", distantFile,lSync);
					comHTTP.send(null);
					eval(comHTTP.responseText);
				} catch (e) {
//					alert("readyState : " + comHTTP.readyState);
//					alert("status : " + comHTTP.status);
//					alert("response : " + comHTTP.responseText);
					throw new acai_carto_exception("pas de retour");
				}
			} else {
				throw new acai_carto_exception("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
			}

		};
		
}
acai_carto_utils.singleton = new acai_carto_utils();

function acai_carto_exception(message) {
	this.message = message;
	this.name = "acai_carto_exception";
	this.showMessage = function () {
		alert(this.message);
	};
	
	
}


