function moreButton($nav) { var lisInRow = 0; var langNavChildren = $("nav.mainMenu ul.languageNav>li", $nav); var hasLangNav = $(langNavChildren).length; var menuItemsNav = $('nav.mainMenu>ul.menuItemsNav', $nav); var menuItemsNavChildren = $('nav.mainMenu>ul.menuItemsNav>li:not(".moreButton, .moreButtonMeasure")', $nav); var menuItemsNavChildrenWidth = 0; var langNavWidth = 0; var moreButtonMeasureContainerWidth = 0; var navMenuWidth = parseInt($('nav.mainMenu', $nav).outerWidth(), 10); var navMenuWidthAfterCalc; var topRowWidth = 0; var lisInRowArr = []; var moreVerbiage='More'; menuItemsNavChildren.each(function(index) { menuItemsNavChildrenWidth += parseInt($(this).outerWidth(true), 10) + 1; // + 1 pixel to counteract some browsers' subpixel calculation }); if ( hasLangNav > 0 ) { langNavChildren.each(function(index) { langNavWidth += parseInt($(this).outerWidth(true), 10); }); } if ((menuItemsNavChildrenWidth + langNavWidth) > $('nav.mainMenu', $nav).outerWidth()) { menuItemsNavChildren.each(function() { lisInRow++; }); menuItemsNav .append($('