function waitFor(test, callback) {
        var intervalId = window.setInterval(function() {
            if (test()) {
                window.clearInterval(intervalId);
                callback();
            }
        }, 100);
    }
Wait for a condition to occur, then execute the callback
@name _pjs.waitFor
@param {Function} test       Test function; should return true when ready
@param {Function} callback   Callback function to execute