/*
 * CenterUl 1.0
 *
 * Auto Centers ul or ol based on total width of li and setting
 * right & left margins to auto
 * Adds class  "last" to last li  & class "first" to first li
 *
 * Usage: $('#content ul').centerul();
 *
 * @class centerul
 *
 * Copyright (c) 2008 Adam Randlett (adam@monkdevelopment.com)
 * Thanks to Luke Simpson for idea and basics of functionality which drive plugin.
 * Released under a GNU General Public License v3 (http://creativecommons.org/licenses/by/3.0/)
 */

jQuery.fn.centerul = function() { 
         var el = $(this);
         var el_width=0;
	     el.find("li").not(":children").each(function(){
                el_width+= $(this).width() + parseInt($(this).css('marginRight')) + parseInt($(this).css('marginLeft'))+ parseInt($(this).css('paddingRight')) + parseInt($(this).css('paddingLeft'))+10;
         });
         
         el.find("li:first").addClass("first");
         el.find("li:last").addClass("last");
     
         el.css({
              "width": el_width,
              "margin-left": "auto",
              "margin-right": "auto"
              }); 

   };  

