(function ($) {
  $.fn.mettabs = function (args) {
	    var options = $.extend({}, {active: 1}, args);
		var $this = $(this);
		
		var clearSelected = function() {
			$this.find('li').each(function() {
				$(this).find(':first-child').removeClass('selected');
			});
		};
	  	
		return this.each(function() {
			var i = 1;
			$this.find('li').each(function() {
				
										   
				var lnk = $(this).find(':first-child');
				lnk.attr('contentPane',i);
				$('div#tab-content-'+i).addClass('tab-content');
				if (i == options['active']) {
					lnk.addClass('selected');
				} else {
					$('div#tab-content-'+i).hide();
				}
				
				lnk.click(function(e) {
					clearSelected();
					lnk.addClass('selected');
					$('.tab-content').hide();
					$('div#tab-content-'+lnk.attr('contentPane')).show();
					e.preventDefault();
				});	 
				
				
				i++;
			});
		});
  };
})(jQuery);