var ListLogic = {};
/**
 * Stolen shamelessly from Ben Nolan's Behaviour, but using Prototype's $$ to do the selector-magic
 */
ListLogic.Behaviour = {
	/**
	 * Contains the rules that will be applied when go is called
	 * @type {Array}
	 */
	rulesets: [],
	/**
	 * Adds a ruleset to the rules array
	 * @param {Object} rules An object-literal (hash) of css-selector=>function(element) pairs
	 */
	add: function(rules) {
		ListLogic.Behaviour.rulesets.push(rules);
	},
	/**
	 * Applies all currently registered roles against the supplied context
	 * @param {Object} [d] A context for the getElementsBySelector call, defaults to document
	 */
	go: function(d) {
		d = d || document;
		ListLogic.Behaviour.rulesets.each(function(ruleset) {
			$H(ruleset).each(function(pair) {
				Element.getElementsBySelector(d,pair.key).each(function(node) {
					pair.value($(node));
				});
			});
		});
	}	
};
Event.observe(window,"load",function(e) {
	ListLogic.Behaviour.go();
});