// *********************************************************************************************************************************
//
// Formatages
//
// *********************************************************************************************************************************
var _A = {
	formatstring : function(str) {
		while (str.indexOf("é") != -1) {
			str = str.replace(/é/, "[eacute]");
		}
		while (str.indexOf("è") != -1) {
			str = str.replace(/è/, "[egrave]");
		}
		while (str.indexOf("ê") != -1) {
			str = str.replace(/ê/, "[ecirc]");
		}
		while (str.indexOf("ë") != -1) {
			str = str.replace(/ë/, "[euml]");
		}
		while (str.indexOf("à") != -1) {
			str = str.replace(/à/, "[egrave]");
		}
		while (str.indexOf("â") != -1) {
			str = str.replace(/â/, "[acirc]");
		}
		while (str.indexOf("ä") != -1) {
			str = str.replace(/ä/, "[auml]");
		}
		while (str.indexOf("ô") != -1) {
			str = str.replace(/ô/, "[ocirc]");
		}
		while (str.indexOf("ö") != -1) {
			str = str.replace(/ö/, "[ouml]");
		}
		while (str.indexOf("ù") != -1) {
			str = str.replace(/ù/, "[ugrave]");
		}
		while (str.indexOf("û") != -1) {
			str = str.replace(/û/, "[ucirc]");
		}
		while (str.indexOf("ü") != -1) {
			str = str.replace(/ü/, "[uuml]");
		}
		while (str.indexOf("î") != -1) {
			str = str.replace(/î/, "[icirc]");
		}
		while (str.indexOf("ï") != -1) {
			str = str.replace(/ï/, "[iuml]");
		}
		while (str.indexOf("ç") != -1) {
			str = str.replace(/ç/, "[ccedil]");
		}
		while (str.indexOf("&") != -1) {
			str = str.replace(/&/, "[amp]");
		}
		while (str.indexOf("°") != -1) {
			str = str.replace(/°/, "[deg]");
		}
		while (str.indexOf(">") != -1) {
			str = str.replace(/°/, "[gt]");
		}
		while (str.indexOf("<") != -1) {
			str = str.replace(/°/, "[lt]");
		}
		while (str.indexOf("%") != -1) {
			str = str.replace(/%/, "[37]");
		}
		while (str.indexOf("+") != -1) {
			str = str.replace(/%/, "[43]");
		}
		while (str.indexOf("=") != -1) {
			str = str.replace(/%/, "[61]");
		}
		while (str.indexOf("Ê") != -1) {
			str = str.replace(/Ê/, "[Ecirc]");
		}
		while (str.indexOf("Ë") != -1) {
			str = str.replace(/Ë/, "[Euml]");
		}
		while (str.indexOf("Â") != -1) {
			str = str.replace(/Â/, "[Acirc]");
		}
		while (str.indexOf("Ä") != -1) {
			str = str.replace(/Ä/, "[Auml]");
		}
		while (str.indexOf("Ô") != -1) {
			str = str.replace(/Ô/, "[Ocirc]");
		}
		while (str.indexOf("Ö") != -1) {
			str = str.replace(/Ö/, "[Ouml]");
		}
		while (str.indexOf("Û") != -1) {
			str = str.replace(/Û/, "[Ucirc]");
		}
		while (str.indexOf("Ü") != -1) {
			str = str.replace(/Ü/, "[Uuml]");
		}
		while (str.indexOf("Î") != -1) {
			str = str.replace(/Î/, "[Icirc]");
		}
		while (str.indexOf("Ï") != -1) {
			str = str.replace(/Ï/, "[Iuml]");
		}
					
		return str;
	},
	
	affCharSpe : function(str) {
		while (str.indexOf("[37]") != -1) {
			str = str.replace("[37]", "[#37]");
		}
		while (str.indexOf("[43]") != -1) {
			str = str.replace("[43]", "[#43]");
		}
		while (str.indexOf("[61]") != -1) {
			str = str.replace("[61]", "[#61]");
		}		
		while (str.indexOf("[") != -1) {
			str = str.replace("[", "&");
		}
		while (str.indexOf("]") != -1) {
			str = str.replace("]", ";");
		}
		return str;		
	},
	
	htmlSpecialChar : function(str) {
		while (str.indexOf("[eacute]") != -1) {
			str = str.replace("[eacute]", "é");
		}
		while (str.indexOf("[egrave]") != -1) {
			str = str.replace("[egrave]", "è");
		}
		while (str.indexOf("[ecirc]") != -1) {
			str = str.replace("[ecirc]", "ê");
		}
		while (str.indexOf("[euml]") != -1) {
			str = str.replace("[euml]", "ë");
		}
		while (str.indexOf("[egrave]") != -1) {
			str = str.replace("[egrave]", "à");
		}
		while (str.indexOf("[acirc]") != -1) {
			str = str.replace("[acirc]", "â");
		}
		while (str.indexOf("[auml]") != -1) {
			str = str.replace("[auml]", "ä");
		}
		while (str.indexOf("[ocirc]") != -1) {
			str = str.replace("[ocirc]", "ô");
		}
		while (str.indexOf("[ouml]") != -1) {
			str = str.replace("[ouml]", "ö");
		}
		while (str.indexOf("[ugrave]") != -1) {
			str = str.replace("[ugrave]", "ù");
		}
		while (str.indexOf("[ucirc]") != -1) {
			str = str.replace("[ucirc]", "û");
		}
		while (str.indexOf("[uuml]") != -1) {
			str = str.replace("[uuml]", "ü");
		}
		while (str.indexOf("[icirc]") != -1) {
			str = str.replace("[icirc]", "î");
		}
		while (str.indexOf("[iuml]") != -1) {
			str = str.replace("[iuml]", "ï");
		}
		while (str.indexOf("[ccedil]") != -1) {
			str = str.replace("[ccedil]", "ç");
		}
		while (str.indexOf("[amp]") != -1) {
			str = str.replace("[amp]", "&");
		}
		while (str.indexOf("[deg]") != -1) {
			str = str.replace("[deg]", "°");
		}
		while (str.indexOf("[37]") != -1) {
			str = str.replace("[37]", "%");
		}
		while (str.indexOf("[Ecirc]") != -1) {
			str = str.replace("[Ecirc]", "Ê");
		}
		while (str.indexOf("[Euml]") != -1) {
			str = str.replace("[Euml]", "Ë");
		}
		while (str.indexOf("[Acirc]") != -1) {
			str = str.replace("[Acirc]", "Â");
		}
		while (str.indexOf("[Auml]") != -1) {
			str = str.replace("[Auml]", "Ä");
		}
		while (str.indexOf("[Ocirc]") != -1) {
			str = str.replace("[Ocirc]", "Ô");
		}
		while (str.indexOf("[Ouml]") != -1) {
			str = str.replace("[Ouml]", "Ö");
		}
		while (str.indexOf("[Ucirc]") != -1) {
			str = str.replace("[Ucirc]", "Û");
		}
		while (str.indexOf("[Uuml]") != -1) {
			str = str.replace("[Uuml]", "Ü");
		}
		while (str.indexOf("[Icirc]") != -1) {
			str = str.replace("[Icirc]", "Î");
		}
		while (str.indexOf("[Iuml]") != -1) {
			str = str.replace("[Iuml]", "Ï");
		}					
		return str;
	},
	
	stripslashes : function(str) {
		while (str.indexOf("\\") != -1) {
			str = str.replace("\\", "");
		}
		return str;
	},
	// *********************************************************************************************************************************
	// Formats d'affichage
	// *********************************************************************************************************************************
	formatDate : function(str) {
		var result;
		if ((str != "") && (str != "&nbsp;") && (str != "[nbsp]")) {
			if (str.length == 8) {
				result = str.substr(6,2)+"/"+str.substr(4,2)+"/"+str.substr(0,4);
			} else {
				if (str.length == 6) {
					result = str.substr(4,2)+"/"+str.substr(2,2)+"/"+str.substr(0,2);
				} else {
					result = str;
				}
			}
		} else {
			result = str;
		}
		
		return result; 
	},
	
	formatHeure : function(str) {
		var result;
		if ((str != "") && (str != "&nbsp;") && (str != "[nbsp]")) {
			result = str.substr(0,2)+":"+str.substr(2,2);
		} else {
			result = str;
		}
		
		return result; 
	},
	
	formatMon : function(str) {
		var result;
		if ((str != "") && (str != "&nbsp;") && (str != "[nbsp]")) {
			result = "<nobr><span>"+_A.formatReel(str)+"</span> €</nobr>";
		} else {
			result = str;
		}
		
		return result; 
	},
	
	formatReel : function(str) {
		var result;
		if ((str != "") && (str != "&nbsp;") && (str != "[nbsp]")) {
			var signe = "";
			if (str.substr(0,1) == "-") {
				signe = "-";
				str = str.substr(1);
			}
			if (str.indexOf(",") != -1) str = str.replace(",", ".");
			var num = parseFloat(str).toFixed(2);
			str = num.toString();
			var part = str.split(".");
			var nb000 = Math.floor((part[0].length)/3);
			var entier = "";
			for (var i=1;i<=nb000;i++) {
				entier = part[0].substr((part[0].length)-3,3)+entier;
				part[0] = part[0].substr(0,(part[0].length)-3);
				if (part[0].length != 0) entier = " "+entier;
			}
			result = signe+part[0]+entier+","+part[1];
		} else {
			result = str;
		}
		
		return result; 
	},
	
	formatInt : function(str) {
		var result;
		if ((str != "") && (str != "&nbsp;") && (str != "[nbsp]")) {
			var signe = "";
			if (str.substr(0,1) == "-") {
				signe = "-";
				str = str.substr(1);
			}
			var part = str;
			var nb000 = Math.floor((part.length)/3);
			var entier = "";
			for (var i=1;i<=nb000;i++) {
				entier = part.substr((part.length)-3,3)+entier;
				part = part.substr(0,(part.length)-3);
				if (part.length != 0) entier = " "+entier;
			}
			result = signe+part+entier;
		} else {
			result = str;
		}
		
		return result; 
	},
	
	valNum : function(str) {
		var result;
		if ((str != "") && (str != "&nbsp;") && (str != "[nbsp]")) {
			while (str.indexOf(" ") != -1) {
				str = str.replace(" ","");
			}
			if (str.indexOf(",") != -1) str = str.replace(",",".");
			if (str.indexOf("€") != -1) str = str.replace(" €","");
		} else {
			str = "0";
		}
		return parseInt(str);
	},
	
	formatData : function(val,tp) {
		switch (tp.substr(0,1)) {
			case "T":
				if (tp == "T17") {
					if (val.indexOf(".") != -1) val = val.replace(".",",");
				} else if (tp == "T14") {
					// traiter date
					var dateX = val.split("/");
					var jour = dateX[0];
					var mois = dateX[1];
					var an = dateX[2];
					val = an+mois+jour;
				} else if (tp == "T11") {
					// traiter heure
					var heureX = val.split(":");
					var heure = heureX[0];
					var minute = heureX[1];
					val = heure+minute;				
				}
				break;
				
			case "N":
				if (val.indexOf(".") != -1) val = val.replace(".",",");
				val = "n"+val;		
				break;
		}
		return val;
	}
}
// *********************************************************************************************************************************
//
// Info browser + ecran
//
// *********************************************************************************************************************************
var _B = {
	n_Width : 800,
	n_Height : 600,
	n_type : "ff",
	n_vers : 2,
	n_centreH : 500,
	n_centreV : 374,
	
	init : function() {
		_B.infoNavigateur();
		_B.n_centreH = _B.NavigateurCentreHoriz();
		if (_B.NavigateurCentreVertical() > 200) _B.n_centreV = _B.NavigateurCentreVertical();
		//_C.init();
	},
	
	browserSize : function() {
  		if( typeof( window.innerWidth ) == 'number' ) {
    		//Non-IE
    		_B.n_Width = window.innerWidth;
    		_B.n_Height = window.innerHeight;
 		 } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    		//IE 6+ in 'standards compliant mode'
    		_B.n_Width = document.documentElement.clientWidth;
    		_B.n_Height = document.documentElement.clientHeight;
  		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    		//IE 4 compatible
    		_B.n_Width = document.body.clientWidth;
    		_B.n_Height = document.body.clientHeight;
  		}
	},

	NavigateurCentreHoriz : function() {
		var milieuLargeur = _B.n_Width/2;
		return milieuLargeur;
	},

	NavigateurCentreVertical : function() {
		var milieuhauteur = _B.n_Height/2;
		return milieuhauteur;
	},
	
	infoNavigateur : function() {
		if (navigator.userAgent.indexOf("Firefox") != -1) {
			_B.n_type = "ff";
			if (window.Iterator) {
				_B.n_vers = 2;
			} else if (Array.every) {
				_B.n_vers = 1.5;
			} else {
				_B.n_vers = 1;
			}
		} else if (navigator.appVersion.indexOf("MSIE") != -1) {
			_B.n_type = "ie";
			if (document.documentElement && typeof document.documentElement.style.maxHeight != "undefined") {
				_B.n_vers = 7;
			} else if (document.compatMode && document.all) {
				_B.n_vers = 6;
			} else if (window.createPopup) {
				_B.n_vers = 5.5;
			} else if (window.attachEvent) {
				_B.n_vers = 5;
			}
		} else {
			if (window.opera) {
				_B.n_type = "o";
				if (window.getComputedStyle) {
					_B.n_vers = 8;
				} else {
					_B.n_vers = 7;
				}
			} else {
				_B.n_type = "s";
				_B.n_vers = 1;
			}
		}
	}
}

