// My most gracious thanks to the Safari team for leaving out such
// worthless functions as Number.toFixed and Number.toExponential.  I'll
// do your job for you, thank me later:
//
// Copyright 2005 Michael Chaney Consulting Corporation, All Rights Reserved

if (!Number.prototype.toFixed) {
	Number.prototype.toFixed=function(digits) {
		// First, round it appropriately
		var num=this.valueOf();
		if (!digits) digits=0;
		if (digits<0 || digits>20) throw new RangeError('"digits" is 0 to 20 (inclusive) for Number.toFixed');
		var rounder=Math.pow(10,digits);
		num=Math.round(num*rounder)/rounder;
		num=num.toString();
		var p=num.match(/(\+|-)?(\d+)?(?:\.(\d+)?)?/);
		var sign=p[1]||'', intpart=p[2], fracpart=p[3];
		if (digits==0) return sign+intpart;
		while (digits>fracpart.length) fracpart += '0';
		return sign+intpart+'.'+fracpart;
	}
}

if (!Number.prototype.toExponential) {
	Number.prototype.toExponential=function(digits) {
		// First, round it appropriately
		var num=this.valueOf();
		if (digits!==undefined && digits<0 || digits>20) throw new RangeError('"digits" is 0 to 20 (inclusive) for Number.toExponential');
		if (num>=1) {
			// The new power of ten is the number of digits in "intpart" minus one
			var p=num.toString().match(/(\+|-)?(\d+)?(?:\.(\d+)?)?/);
			var sign=p[1]||'', intpart=p[2], fracpart=p[3];
			var pot=intpart.length-1;
			var wholenum=''+intpart+fracpart;
			var msign='+';
		} else {
			// purely fractional number, negative power of ten
			var p=num.toString().match(/(\+|-)?0?(?:\.(0*)(\d+)?)?/);
			var sign=p[1]||'', leadingzeros=p[2], fracpart=p[3];
			var pot=leadingzeros.length+1;
			var wholenum=fracpart;
			var msign='-';
		}
		if (digits===undefined)
			return sign+wholenum.slice(0,1)+'.'+wholenum.slice(1)+'e'+msign+pot;
		if (wholenum.length>digits+1) {
			var rounder=Math.pow(10,wholenum.length-digits-1);	// this is digits after the .
			wholenum=(Math.round(wholenum/rounder)).toString();
		}
		while (digits+1>wholenum.length) wholenum += '0';
		if (digits==0) {
			return sign+wholenum.slice(0,1)+'e'+msign+pot;
		} else {
			return sign+wholenum.slice(0,1)+'.'+wholenum.slice(1)+'e'+msign+pot;
		}
	}
}

try {
	var sdlkjsdflkfweoiwejiosd=undefined;
} catch (e) {
	undefined=void 0;
}
