dex;
          break;
        }
        nodeIndex++;
      }



      if (index &gt;= 0) {
        // open PhotoSwipe if valid index found
        openPhotoSwipe(index, clickedGallery);
      }
      return false;
    };

    // parse picture index and gallery index from URL (#&amp;pid=1&amp;gid=2)
    var photoswipeParseHash = function() {
      var hash = window.location.hash.substring(1),
        params = {};

      if (hash.length &lt; 5) {
        return params;
      }

      var vars = hash.split('&a