
/*function include(fileName){
	eval("<script type='text/javascript' src='"+fileName+"'></script>" );
}*/

function _heriter(destination, source) {  
    for (var element in source) {  
        destination[element] = source[element];  
    }  
}  

function Remplacer(str, search, replace)
{
	var tmp = "";
	for(var i = 0; i < str.length; i++) {
		tmp = tmp + str.charAt(i);
		if (str.charAt(i) == search) {
			tmp = tmp.replace(search, replace);
		}
	}
	return tmp;
}

var CSerializer = (function(){
	/*var window,top,self,parent,location,reload,back,forward,
		alert,confirm,prompt,stop,frames,document;
	*/
	function addslashes(t){
		return t.replace("/(*)'/gim","$1$1'");
	}
	function strval(v) {
		//switch((v.constructor.name+"").toLowerCase()) {
		switch( typeof(v) ) {
			case "number":
				return v+0;
			break;
			case "string":
				return "'" + addslashes(v).replace(/r?n/gim,'n') + "'";
			break;
			case "date":
				return "date("+v.getTime()+")";
			break;
			case "boolean":
				return v===true?"true":"false";
			break;
			case "array":
				var t = "[";
				for(var i=0; i<v.length; i++) {
					t += strval(v[i]) + ",";
				}
				return t.replace("/,$/",'')+"]";
			break;
			case "object":
				return branch(v);
			break;
			default:
				return "null";
			break;
		}
	}
	function branch(obj) {
		var t = "{";
		for(var n in obj) {
			t += '"' + n + '":' + strval(obj[n]) + ',';
		}
		return t.replace("/,$/",'')+"}";
	}
	
	var self = {
		serialize : function(obj) {
			return branch(obj);
		},
		unserialize : function(str) {
			function date(s) {
				var d = new Date();
				d.setTime(s+0);
				return d;
			}
			return eval('(' + str + ')');
		}
	};
	
	return self;
})();

function formatNumber(value, nbDecimal, separator) {
	//value = Math.round((value*100)/100);
	value = parseFloat(value);
	if (!nbDecimal) {
		nbDecimal = 2;
	}
	value=value.toFixed(nbDecimal);
	
	if ( !separator ) {
		separator = ",";
	}
	return value.replace(".", separator);
}
