updated the search and query functions. Still working on passing query through js using JSON and not rely on php Session variables.