Try this:
if (window.location.hash === '#open')
The hash member of window.location will return the # sign, plus whatever string follows it.
You can detect this behavior by typing console.log(window.location.hash) into your console.
Additionally, since you are already using jQuery, you could potentially stick with:
$(function() {
instead of
window.onload