improve javascript for advanced search