Function.prototype.defer = function(condition, poll_interval)
{
	var interval;
	
	if(!poll_interval)
		poll_interval=100;
	
	if(typeof(condition) != 'function') // Just wait until the DOM is loaded
	{
		setTimeout(this, 0); // This will make it fire after DOM load. Who knew?
		return;
	}
	
	if(condition())
		this();
	else
	{
		interval=setInterval(function()
		{
			if(condition())
			{
				clearInterval(interval);
				this();
			}
		}.bind(this), poll_interval);
	}
	
	return this;
}

