/*
*
* enpExpand - 100% width tab navigation
*
*/
 
(function($){
	$.fn.enpExpand = function() {
        return this.each(function() {
        
            ul = $(this);
            li = ul.children('li');
            anchor = li.children('a');
            
            navWidth = ul.parent().width();
            liWidth = 0;
            anchorWidth = 0;
            numTabs = li.size();
            
    		li.each(function(i) {
    		
    			if(i == 0) {
    				$(this).addClass("first");
    			}
    			
    			if(i === (numTabs-1)) {
    				$(this).addClass("last");
    			}

    			anchorWidth += $(this).outerWidth({ margin: true });
    		});
            
            totalExpand = (navWidth - anchorWidth) / numTabs;
            roundedExpand =  parseInt(totalExpand);
            
            remainder = Math.floor((totalExpand - roundedExpand) * numTabs);
            
            anchor.each(function(i) {
    			
                width = roundedExpand + $(this).width();
              
                if(i === (numTabs-1)) {
                    width += remainder;
                }
                
                $(this).css({ width:width + "px" });
    		});
	
        });
	};

})(jQuery);