(function() {
	// private constructor
	function _$(els) {
		this.elements = [];
		for (var i=0; i<els.length; i++) {
			var element = els[i];
			if (typeof element == 'string') {
				element = document.getElementById(element);
			}
			this.elements.push(element);
		}
		return this;
	}
	_$.prototype = {
		each: function(fn) {
			for ( var i = 0, len = this.elements.length; i<len; ++i ) {
				fn.call(this, this.elements[i]);
			}
			return this;
		},
		setStyle: function(prop, val) {
			this.each(function(el) {
				el.style[prop] = val;
			});
			return this;
		},
		addClass: function(className) {
			this.each(function(el) {
				el.className += ' '+className;
			});
			return this;
		},
		on: function(type, fn) {
			var listen = function(el) {
				if (window.addEventListener) {
					el.addEventListener(type, fn, false);
				} else if (window.attachEvent) {
					el.attachEvent('on'+type, function() {
						fn.call(el, window.event);
					});
				}
			};
			this.each(function(el) {
				listen(el);
			});
			return this;
		},
		css: function(o) {
			var that = this;
			this.each(function(el) {
				for (var prop in o) {
					console.log(prop);
					that.setStyle(prop, o[prop]);
				}
			});
			return this;
		}
	};
	window.$ = function() {
		return new _$(arguments);
	}
})();