/*Tested with http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.jsin FF Mac, Safari Mac, Chrome Mac, Opera Mac, FF PC, IE 7 and 8, IE 6 works with css hack on LIs _width:3px;Requirements: Menu structure has to be <ul><li><a...<ul> must have a class or id*/  /* PAD LIs EVENLY */	(function($){    $.fn.limenupadding = function(options) {	var lisTotalWidth = 0;	var liCount = $((this).children()).size()	for (var i=0; i < liCount; i++) {		lisTotalWidth += $(this).children().children(':eq(' + i + ')').width();	}		var paddingLR = Math.floor(((970-lisTotalWidth)/(liCount-1))/2);	for (var i=1; i < liCount-1; i++) {		$(this).children().children(':eq(' + i + ')').css({'padding-left': paddingLR, 'padding-right': paddingLR});	}	$(this).children().children(':eq(0)').css({'padding-left': 0, 'padding-right': paddingLR});	$(this).children().children(':eq(' + (liCount-1) + ')').css({'padding-left': paddingLR, 'padding-right': 0});		  };  	})(jQuery);			function test () {    $.fn.limenupadding = function(options) {	  var opts = $.extend({		shiftR: 0 // exclude from calculation for end caps: positive interger		},options);		  var shiftR = opts.shiftR;	  	  var lisTotalWidth = 0;		  var liCount = $((this).children()).size()	  var exclude = 0;	 exclude += $(this).children().children(':eq(0)').width();	 exclude += $(this).children().children(':eq('+(liCount-1)+')').width();		for (var i=1; i < liCount-1; i++) {			lisTotalWidth += $(this).children().children(':eq(' + i + ')').width();		}	  var ulWidth = ((this).width() - exclude); /* exclude is adjustment amount. Used here to subtract end caps */	  var difference = ulWidth - lisTotalWidth;  var paddingLRraw = (difference/(liCount-2))/2-shiftR;  var paddingLRfloor = Math.floor(paddingLRraw); /* round down to be safe, if too much pad li may wrap */  /* distribute computed padding across all LIs */	for (var i=1; i < liCount-1; i++) {  		$(this).children().children(':eq(' + i + ')').css({'padding-left': paddingLRfloor, 'padding-right': paddingLRfloor});	}  /* if lis don't space perfectly, how much filler do we need to even them out? */  var paddingRemainder = paddingLRfloor * (liCount * 2);  var filler = difference - paddingRemainder;   /* distribute 1px of filler across several LIs, Mozilla has a bug that can cause a wrap in some cases. 1px breathing room seems to correct it. */  if ($.browser.mozilla) {	 filler = filler -1;  }  var filler1 = filler/2;  var filler2 = filler1;  filler1 = Math.floor(filler1);  filler2 = Math.ceil(filler2);  for ( var i=0; i < filler1; i++) {	 $(this).children().children(':eq(' + i + ')').css({'padding-left': (paddingLRfloor + 1)});  }  for ( var i=0; i < filler2; i++) {	  $(this).children().children(':eq(' + i + ')').css({'padding-right': (paddingLRfloor + 1)});  }	$(this).children().children(':eq(0)').css({'padding-left': (0)});	$(this).children().children(':eq('+(liCount-1)+')').css({'padding-right': (0)});	//alert ("Menu id: " + $(this).attr('id') + "\nMenu class: " + $(this).attr('class') + "\nMenu width: " + (this).width() + "px\nPixels to exclude: " + exclude + "px\nSum of <li> widths: " + lisTotalWidth + "px\nDifference: " + difference  + "px\n<li> count: " + liCount  + "\nComputed pad amount raw: " + paddingLRraw  + "\nComputed pad amount rounded down: " + paddingLRfloor  + "\nSum of <li>s with computed padding: " + paddingRemainder  + "px\nFiller needed: " + filler  + " (" + difference + "px - " + paddingRemainder + "px)\n(1px applied as LEFT pad on " + filler1 + " <li>)\n(1px applied as RIGHT pad on " + filler2 + " <li>)");/*alert ("Menu id: " + $(this).attr('id') + "\nMenu class: " + $(this).attr('class') + "\nMenu width: " + (this).width() + "px\nPixels to exclude: " + exclude + "px\nSum of <li> widths: " + lisTotalWidth + "px\nDifference: " + difference  + "px\n<li> count: " + liCount  + "\nComputed pad amount raw: " + paddingLRraw  + "\nComputed pad amount rounded down: " + paddingLRfloor  + "\nSum of <li>s with computed padding: " + paddingRemainder  + "px\nFiller needed: " + filler  + " (" + difference + "px - " + paddingRemainder + "px)\n(1px applied as LEFT pad on " + filler1 + " <li>)\n(1px applied as RIGHT pad on " + filler2 + " <li>)");*/  };  }
