/*
	hoverTabs plugin for jQuery
	Copyright (c) 2007-2010 Mat Brennan (http://www.twitter.com/loadx)
	Licensed under the MIT license 
	Version: 1.0.0
*/

(function($){
	$.fn.hoverTabs = function(options){
		var defaults = {
				//select the first tab by default
				selectedTab: $(this).find('li a:first').attr('class').replace('mn_', ''),
				allowClick: true
		}
		
		var opts = $.extend({}, defaults, options);
		
		return this.each(function(){
			var parent = this;
			
			//set the active tab if there is one
			if(opts.selectedTab !== null)
				$(this).toggleClass(opts.selectedTab+'_hover');
			
			//begin the hovering
			$(this).find('li a').hover(function(){
				var currClass = $(this).attr('class').replace('mn_', '');

				//remove any hover classes first
				$(parent).removeClass(opts.selectedTab+'_hover');
				$(parent).toggleClass(currClass+'_hover');
			}, function(){
				if(opts.selectedTab !== null){
					var currClass = $(this).attr('class').replace('mn_', '');
					
					//remove any other hovered tabs
					$(parent).toggleClass(currClass+'_hover');
					$(parent).toggleClass(opts.selectedTab+'_hover');	
				}
			});
			
			if(opts.allowClick === true)
				$(this).find('li a').click(function(){
					opts.selectedTab = $(this).attr('class').replace('mn_', '');
				})
		});
	};
})(jQuery);