// added by Jesse
jQuery.wait_for = function(wait_for, fn) {
	if (typeof(wait_for) === 'string')
		wait_for = [ wait_for ];

	function all_there() {
		var found = true;

		jQuery.each(wait_for, function(i, selector) {
			if (jQuery(selector).length == 0) {
				found = false;
				return false;
			}
		});

		return found;
	}

	function check_all_there() {
		if (all_there()) {
			fn();
		} else {
			setTimeout(check_all_there, 100);
		}
	}
	check_all_there();
};

function xhr_enabled() {
	if (window.ActiveXObject) {
		try {
		  new ActiveXObject("Microsoft.XMLHttp");
		} catch (e) {
		  return false;
		}
		return true;
	}
	return !!window.XMLHttpRequest;
}
function require_xhr() {
	if (!xhr_enabled()) throw "XMLHttpRequest not supported";
}
