$(function(){
	$('#tab-holder').jqueryTabs({
		event: 'mouseenter',
		duration: 350
	});
})

//* jquery tabs *********************************************************************************
jQuery.fn.jqueryTabs = function(_options){
	// defaults options
/*
		event: 'click','mouseenter','mouseleave'
*/
	var _options = jQuery.extend({
		event: 'click',
		holder: '.tabs-content',
		duration: 200,
		tabset: 'ul.tabset'
	},_options);

	return this.each(function(){
		var _this = jQuery(this);
		var _tabset = jQuery(_options.tabset,_this);
		var _holder = jQuery(_options.holder,_this);
		var _d = $.browser.msie ? 0 : _options.duration;
		var _t = null;
		_tabset.each(function(){
			var _list = $(this);
			var _links = _list.find('a.tab', _list);
			if(_links.filter('.active').length == 0) _links.eq(0).addClass('active');
			_links.each(function() {
				var _link = $(this);
				var _href = _link.attr('href');
				var _tab = $(_href, _this);

				if(_link.hasClass('active')) {
					_tab.show();
					_holder.css({
						height: _tab.outerHeight(true)+'px'
					})
				}else {
					_tab.css({
						position: 'absolute',
						top: 0,
						left: 0,
						zIndex: 1
					}).hide();
				}

				_link.bind(_options.event, function(){
					if($(this).hasClass('active')) return false;
					_links.filter('.active').each(function(){
						var _prev = $($(this).removeClass('active').attr('href'));
						if(_prev.is(':animated')) _prev.stop(true,true);
						_prev.fadeOut(_d);
					});
					_holder.animate({height:_tab.outerHeight(true)},_d);
					if(_tab.is(':animated')) _tab.stop(true,true);
					_tab.css({
						position: 'absolute',
						top: 0,
						left: 0,
						zIndex: 2
					}).fadeIn(_d,function(){
						$(this).css({
							position: 'relative',
							top: 0,
							left: 0,
							zIndex: 3
						})
					});
					_link.addClass('active');
					return false;
				});
			});
		});
	})
}

