(function($) { if($('.page-node-36').length > 0){ if ( $("#block-views-birell-block").length > 0 ) { if($(".view-id-birell .view-content").length > 0){ $('.views-row-1').attr('id','views-row-1'); }; if($(".view-id-birell .view-content").length > 0){ $('.views-row-2').attr('id','views-row-2'); }; if($(".view-id-birell .view-content").length > 0){ $('.views-row-3').attr('id','views-row-3'); }; if($(".view-id-birell .view-content").length > 0){ $('.views-row-4').attr('id','views-row-4'); }; if($(".view-id-birell .view-content").length > 0){ $('.views-row-5').attr('id','views-row-5'); }; if($(".view-id-birell .view-content").length > 0){ $('.views-row-6').attr('id','views-row-6'); }; } $('a[href^="#"]').click(function(e){ e.preventDefault(); var target = this.hash; var $target = $(target); $('html, body').stop().animate({ 'scrollTop': $target.offset().top }, 900, 'swing', function () { //window.location.hash = target; }); }); $('.about_nav li').eq(0).addClass("active"); $('.about_nav a').click(function() { $('.about_nav li').removeClass(); $(this).parent().addClass("active"); }); var lastId, rightMenu = $(".about_nav"), rightMenuHeight= rightMenu.outerHeight(), menuItems = rightMenu.find("a"), scrollItems = menuItems.map(function(){ var item = $($(this).attr("href")); if (item.length) { return item; } }); $(window).scroll(function(){ var fromTop = $(this).scrollTop()+rightMenuHeight; var current = scrollItems.map(function(){ if ($(this).offset().top < fromTop) return this; }); current = current[current.length-1]; var id = current && current.length ? current[0].id : ""; if (lastId !== id) { lastId = id; menuItems .parent().removeClass("active") .end().filter("[href='#"+id+"']").parent().addClass("active"); } }); } })(jQuery);