/**
* @author Paulo Paixão
*/
(function ($) {
$.fn.tabview = function (options) {
			
	options = $.extend({
		activeIndex : 0,
        toggleEnable: false,
        onClick: null
    }, options || {});
		
	var $tab = $(this);	
	
	$(this).find(".nav a").click(function(e) {		
		var $content =  $tab.find('#' + $(this).attr('href'));		
		if($content.is(':visible') == false){			
			
			$tab.find(".box:visible").hide();
			$tab.find(".nav li").removeClass('active');
			$(this).parent().addClass('active');
			$content.show();
			
			if(options.onClick){
				options.onClick.call(this, $content);
			} 	
			
		}else{
			
			if(options.toggleEnable){
				$(this).parent().removeClass('active');
				$content.hide();
			}
						
		}		
		e.preventDefault();		
	});	 
	$(this).find(".nav li:eq("+options.activeIndex+") a").trigger('click');		
};
})(jQuery);
