// Copyright 2010 Sleepless Software Inc.  All Rights Reserved

/*
$.each(document.getElementsByTagName("*"), function(i, e) {
	if(e.id && e.id.substr(0,1) != "_")
		window["$"+e.id] = $(e);
});
*/

Array.prototype.each = function(f) {
		var l = this.length;
		for(var i = 0; i < l; i++)
			f(this[i], i);
	}

String.prototype.lower = function() { return this.toLowerCase(); }
String.prototype.upper = function() { return this.toUpperCase(); }
String.prototype.asInt = function() { return parseInt(this); };
String.prototype.asFlt = function() { return parseFloat(this); };

if(String.prototype.trim === undefined) {
	String.prototype.trim = function() {
		return this.replace(/^\s+/gi, "").replace(/\s+$/gi, "" );
	}
}

//Object.prototype.store = function(k) {localStorage.k = JSON.stringify(this));return this;}
//Object.prototype.fetch = function(k) {return JSON.parse(localStorage.k);}


// convert 1050 to 10.50 
cents2Bucks = function(n) {
	return (((""+n).asInt())/100).toFixed(2);
}

Date.prototype.toUS = function(ts) {
	var d = this;
	if(ts !== undefined)
		d = new Date(ts);
	var lz = function(s) { return ("0"+s).substr(-2); }
	return lz(d.getMonth()) + "/" + lz(d.getDate()) + "/" + lz(d.getYear());
}



