Number.prototype.format=function(decimalPoints,thousandsSep,decimalSep){
	var val=this+'',re=/^(-?)(\d+)/,x,y;
	if (decimalPoints!=null) val = this.toFixed(decimalPoints);
	if (thousandsSep && (x=re.exec(val))) {
		for (var a=x[2].split(''),i=a.length-3;i>0;i-=3) a.splice(i,0,thousandsSep);
		val=val.replace(re,x[1]+a.join(''));
	}
	if (decimalSep) val=val.replace(/\./,decimalSep);
	return val;
}
if (typeof Number.prototype.toFixed!='function' || (.9).toFixed()=='0' || (.007).toFixed(2)=='0.00') Number.prototype.toFixed=function(f){
 if (isNaN(f*=1) || f<0 || f>20) f=0;
 var s='',x=this.valueOf(),m='';
 if (this<0){ s='-'; x*=-1; }
 if (x>=Math.pow(10,21)) m=x.toString();
 else{
  m=Math.round(Math.pow(10,f)*x).toString();
  if (f!=0){
   var k=m.length;
   if (k<=f){
    var z='00000000000000000000'.substring(0,f+1-k);
    m=z+m;
    k=f+1;
   }
   var a = m.substring(0,k-f);
   var b = m.substring(k-f);
   m = a+'.'+b;
  }
 }
 if (m=='0') s='';
 return s+m;
}
function dateToString( date ) {
	var str = "";
	if (date) {
		if (date.getDate() < 10) { str += "0"+date.getDate(); } else { str += date.getDate(); }
		if (date.getMonth() < 9) { str += ".0"+(date.getMonth()+1); } else { str += "."+(date.getMonth()+1); }
		str += "."+date.getFullYear();
	}
	return str;
}
function stringToDate( string ) {
	var matches;
	if (matches = string.match(/^(\d{4,4})-(\d{2,2})-(\d{2,2})$/)) {
		return new Date(matches[1], matches[2] - 1, matches[3]);
	} else {
		return null;
	};
}
function localeStringToDate( string ) {
	var matches;
	if (matches = string.match(/^(\d{2,2})\.(\d{2,2})\.(\d{4,4})$/)) {
		return new Date(matches[3], matches[2] - 1, matches[1]);
	} else {
		return null;
	};
}

