/**
 * @author luke.cuthbertson <luke.cuthbertson@heathwallace.com>
 * @projectDescription
 * @version 0.1
 * @date
 */
(function($){
	$.fn.simpleTabs = function(opts){
		
		var opts = $.extend({
			tabs: '.jvsTabs',
			content: '.jvsTabContent',
			selected: 'current'
		}, opts);
		
		return this.each(function(){ 
			var tabSet = $(this);
			var content = tabSet.find(opts.content);
			var links = tabSet.find(opts.tabs+' a');
			
			tabSet.addClass('jvsInitialised');
			
			var curLink = links.parent().filter('.'+opts.selected).find('a');
			if (!curLink.size()) {
				curLink = links.eq(0).closest('li').addClass(opts.selected);
			}
			
			current = content.hide().eq(links.index(curLink)).show();
			
			links.each(function(i){
				$(this).click(function(e){ 
					e.preventDefault();
					var link = $(this);
					if (!link.closest('li').hasClass(opts.selected)) {
						links.closest('li').removeClass(opts.selected);
						link.closest('li').addClass(opts.selected);
						content.hide().eq(i).show()
					}
				})
			});
			
		});
		
	}
	
})(jQuery);

