');
          
         
    $('fieldset.collapsible').once('collapse', function () {
      var $fieldset = $(this);
      // Expand fieldset if there are errors inside, or if it contains an
      // element that is targeted by the uri fragment identifier. 
      var anchor = location.hash && location.hash != '#' ? ', ' + location.hash : '';
      if ($('.error' + anchor, $fieldset).length) {
        $fieldset.removeClass('collapsed');
      }
      var summary = $('');
      $fieldset.
        bind('summaryUpdated', function () {
          var text = $.trim($fieldset.drupalGetSummary());
          summary.html(text ? ' (' + text + ')' : '');
        })
        .trigger('summaryUpdated');
      // Turn the legend into a clickable link, but retain span.fieldset-legend
      // for CSS positioning.
      var $legend = $('> legend .fieldset-legend', this);
      $('')
        .append($fieldset.hasClass('collapsed') ? Drupal.t('Show') : Drupal.t('Hide'))
        .prependTo($legend)
        .after(' ');
      // .wrapInner() does not retain bound events.
      var $link = $('')
        .prepend($legend.contents())
        .appendTo($legend)
        .click(function () {
          var fieldset = $fieldset.get(0);
          // Don't animate multiple times.
          if (!fieldset.animating) {
            fieldset.animating = true;
            Drupal.toggleFieldset(fieldset);
          }
          return false;
        });
      $legend.append(summary);
    });
  
        });
      
                 
        $("body").addClass('no_scroll'); //body no scrolling
        history.pushState(null,null,window.location.protocol + '//' + window.location.hostname + atr_link);
        oldurlpin=window.location.pathname;
      	setTimeout("checkHash()",500);
      	/*
      	$('body').click(function(event) {
      	if (!$(event.target).closest('.p_zoom_in').length) {
        	history.back();
      	};
    		});
    		*/
      }
      return false;                  
    }
    var $container = $('.pin_page #content .content:has(.pin_box)');
    $container.imagesLoaded(function(){
      $container.masonry({
        itemSelector: '.pin_box',
        columnWidth: 0
        
      });
    });   
    $container.infinitescroll({
      navSelector  : 'ul.pager',    // selector for the paged navigation 
      nextSelector : 'ul.pager .pager-next a',  // selector for the NEXT link (to page 2)
      itemSelector : '.pin_box',     // selector for all items you'll retrieve
      loading: {
          finishedMsg: 'Nema više aktualnih ponuda.',
          img: 'http://i.imgur.com/6RMhx.gif'
        }
      }
      ,
      // trigger Masonry as a callback
      
      function( newElements ) {
        // hide new items while they are loading
        var $newElems = $( newElements ).css({ opacity: 0 });
        // ensure that images load before adding to masonry layout
        $newElems.imagesLoaded(function(){
          // show elems now they're ready
          window.a_second++;
          $newElems.addClass('second_'+a_second);
          $newElems.animate({ opacity: 1 });
          $container.masonry( 'appended', $newElems, true );
          if (checkBrowser()) $('.second_'+a_second+' .pin_image a').click(pin_image_click);
          
          $('.like-widget:not(.like-processed)').addClass('like-processed').each(function () {
            var widget = $(this);
            var ids = widget.attr('id').match(/^like\-([a-z]+)\-([0-9]+)\-([0-9]+)\-([0-9])$/);
            var data = {
              content_type: ids[1],
              content_id: ids[2],
              widget_id: ids[3],
              widget_mode: ids[4]
            };
            $('a.like-button', widget).click(function() {
              var token = this.getAttribute('href').match(/like\=([a-zA-Z0-9\-_]{32,64})/)[1];
              return Drupal.likeVote(widget, data, token);
            });
          });
      
        });
      }
    );
 
  });
 
})(jQuery);
//-->