$j(document).ready(function() {
    //this script will adjust tab width with a margin of error, in pixels, equal to twice the number
    //of tabs within the navigation.  So if you have 4 tabs, it might be off by 8 pixels, since
    //we are rounding down with all of the calculations.  We are also assuming there is no padding
    //on the individual list items, only on the anchors (on the <a>'s not the <li>'s)
    var numberOfTabs = $j("#SiteMenu > ul > li").size();
    //this should be 924, the width specified in the css
    var cWidth = 927; //$j("#SiteMenu").width();
    var totalWidths = 0;
    //add up all of the tab widths + any defined padding/margin to get the total width
    $j("#SiteMenu > ul > li > a").each(function(i) {
        var pads = parseInt($j(this).css('padding-left')) + parseInt($j(this).css('padding-right'));
        var margs = parseInt($j(this).css('margin-left')) + parseInt($j(this).css('margin-right'));
        var stupidBoxModel = pads + margs + $j(this).width();
        totalWidths = totalWidths + stupidBoxModel;

    });
	
	

    var widthdifference = (cWidth - totalWidths);

    widthdifference = (widthdifference + 15);

    while (widthdifference > 0) {

        $j("#SiteMenu > ul > li > a").each(function(i) {
            if (widthdifference > 0) {

                var tempwidth = parseInt($j(this).width());
                var padleft = parseInt($j(this).css('padding-left'))
                var padright = parseInt($j(this).css('padding-left'))
                $j(this).css('padding-left', 0);
                $j(this).css('padding-left', (padleft + 1));
                widthdifference--;
                $j(this).css('padding-right', (padright + 1));
                widthdifference--;
                
            }
        });

    }

});

