search box and refactoring of search code

- added a search box in base and search templates;
- moved search related code in an include file.