Major bug fixes, consolidated DB queries

Fixed a bug where the jQuery interface would cause fatal errors if
bot_id was not set by checking for an empty value and setting it to the
default bot ID if empty.
Fixed a bug where the Search/Edit AIML admin page was displaying AIML
for only the first (default) chatbot, rather than the currently selected
chatbot.
Consolidated all DB select queries into two function calls (db_fetch()
and db_fetchAll()  ), which eliminated hundreds of lines of code. Also
added error handling to the DB query functions, to help reduce the
number of fatal errors encountered.