bar.js: cookies replaced with localStorage
bar.js: closing of windows is detected in beforeunload instead of unload, to make it work in IE