code: function waitFor (testCondition, onReady, onTimeout, timeout, attemptFrequency) {
  	// Default Max Timout is 3s
  	// {int} How frequently to check back in. 
  	var start = Date.now();
  	var success = false;
  	var isTimedOut = false;
  	attemptFrequency = attemptFrequency || 250;
  	timeout = timeout || 3000;
  	var interval = setInterval(function() {
  		var now = Date.now();
  		var sinceStart = now - start;
  		// If we've achieved success, then fantastic - stop the loop
  		if (success) {
  			clearInterval(interval);
  		}
  		// Check if we've timed out, in which case, bail
  		else if ( sinceStart >= timeout ) {
  			clearInterval(interval);
  			isTimedOut = true;
  			onTimeout();
  		}
  		// If not fulfilled, but we've got time on the clock, then retest
  		else {
  			testCondition(readyCallback);
  		}
  	}, attemptFrequency);
  
  	function readyCallback () {
  		if (!isTimedOut) {
  			success = true;
  			clearInterval(interval);
  			onReady();
  		}
  	}
  }
docs: From https://github.com/ariya/phantomjs/blob/master/examples/waitfor.js
  
  Wait until the test condition is true or a timeout occurs. Useful for waiting
  on a server response or for a ui change (fadeIn, etc.) to occur.
  
  @param {function} testCondition
  Evaluates to a boolean, true if we are ready
  @param {function} onReady
  Called when testCondition condition is fulfilled
  @param {function} onTimeout
  Called when testCondition has not been fullfilled, and time exceeds timeout
  @param {int} (optional) timeout
  Max amout of time, in milliseconds to wait, default 3000ms
  @param {int} (optional) attemptFrequency
  Time, in milliseconds, to wait before attempting again, default 250ms