To answer your first question, yes waitForCondition(javascript,timeout) will run javascript until it returns the true value OR when a timeout occurs. You should take a look at the api documentation for this, since you need to use browserbot to run the script in your application window. API documentation link here
In Selenium 1, one of the ways you can deal with Ajax conditions is to create custom functions that will wait until the condition is met or a timeout occurs. While the normal Selenium.isElementPresent will immediately work if the item is missing, your user-defined function will wait some more time (Ajax load time) before it fails. As an example, you can refer to the following custom method for isElementPresent. It is written in JAVA, you should be able to use the same logic in the programming language that you use.
public boolean AjaxIsElementPresent(String elementToLookFor, int timeOutValueInSeconds){ int timer=1; while(timer<=timeOutValue){ if(selenium.isElementPresent(locator)) return true; else Thread.sleep(1000); } return false;
}
This method returns a boolean false if the element is missing even after the specified timeoutValue. If it finds an item within a timeoutvalue, it returns true.
I saw some built-in functions for handling AjaxCondition in Selenium 2. But I did not use it. You can refer to the code base of Selenium 2
Aj source share