// documentオブジェクトの拡張
Object.extend(document, {
	// id、classNameを付加した要素を作成
	createElementWithId: function(tagName, id, className) {
		var element = document.createElement(tagName);
		if (id) element.id = id;
		if (className) element.className = className;
		return element;
	}
});

// Numberオブジェクトの拡張
Object.extend(Number.prototype, {
	toFormat: function() {
		var n = this.toString();
		var m = '';

		while (n) {
			m = n.slice(-3) + ',' + m;
			n = n.slice(0, -3);
		}

		return m.slice(0, -1);
	}
});

// Eventオブジェクトの拡張
Object.extend(Event, {
	onLoadEvents: [],

	// onLoad時に実行する関数を格納
	addOnLoad: function(func) {
		Event.onLoadEvents.push(func);
	},

	// 格納した順に関数を実行
	execOnLoad: function() {
		Event.onLoadEvents.each(function(func) { func(); });
	}
});
// execOnLoadをonLoadイベントに追加
Event.observe(window, 'load', Event.execOnLoad);

