text: 'use strict';
  
  var $          = require('./main')
    , onDocReady = require('./on-document-ready')
  
    , nextNode, resolved = {}, count = 0, onReady;
  
  nextNode = function (node) {
  	while (node) {
  		if (node.nextSibling) return node.nextSibling;
  		node = node.parentNode;
  	}
  	return null;
  };
  
  onReady = function (id, cb, partial, repeated) {
  	var el, fn;
  	el = $(id, true);
  	if (!el) {
  		if ($.isDocumentReady) throw new Error(id + " not found");
  	} else {
  		if (!el.$manoOnReadyId) el.$manoOnReadyId = ++count;
  		else if (resolved.hasOwnProperty(el.$manoOnReadyId)) return;
  		if (partial || $.isDocumentReady || nextNode(el)) {
  			resolved[el.$manoOnReadyId] = true;
  			cb(el);
  			return;
  		}
  	}
  	if (!repeated) {
  		onDocReady(fn = function () { onReady(el || id, cb, partial, true); });
  	}
  	setTimeout(fn, 200);
  };
  
  module.exports = $.onReady = function (ids, cb, partial) {
  	var count, i, doId, result, l;
  	if ((typeof ids !== 'object') || (ids.nodeName)) {
  		onReady(ids, cb, partial);
  		return;
  	}
  	count = ids.length;
  	result = {};
  	doId = function (id) {
  		onReady(id, function (el) {
  			result[id] = el;
  			if (!--count) cb(result);
  		}, partial);
  	};
  	l = count;
  	for (i = 0; i < l; ++i) {
  		if (ids.hasOwnProperty(i)) doId(ids[i]);
  		else if (!--count) cb(result);
  	}
  };
  