var getParameterByName = function (name, url) {
    if (!url) url = window.parent.location.href;
    name = name.replace(/[\[\]]/g, '\\$&');
    var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, ' '));
  }

  var handleHashChange = function () {
    window.parent.location.hash = window.location.hash
  }

  window.onload = function () {
    var nav = getParameterByName('nav')
    if (nav === window.navId) {
        window.location.hash = window.parent.location.hash
    }

    window.onhashchange = handleHashChange
  }