Micro-optimizations, bug fix

- Declare all vars at the beginning of the current scope, it allows to
minify the script better (~-100bytes);
- Cache some offset values;
- Chain some functions;
- On click on opened dropdown we close it, on click on another dropdown,
we close current dropdown and open another - similiar with original
<select> behaviour