(function($) {
	$.Lin = {
		tabs : function(hd, bd, delay, onTime, e) {
			if (delay=='' || delay==null){delay=0;}
			if (onTime=='' || onTime==null){onTime=0;}
			if (e=='' || e==null){e='mouseover';}
			
			var _this = this;
			var current = 0;
			var count = $(hd).size()-1;
			var onTimeID = null;
			var delayID = null;
	
			tabsAction();
			
			if (e=="click") {
				$(hd).bind("click", tabSelect);
			}else{
				$(hd).bind("mouseover", tabSelect).bind("mouseout",tabGo);
			}
			$(bd).parent().bind("mouseover", function(){
				clearTimeout(delayID);
			}).bind("mouseout",tabGo);
			
			function tabSelect(){
				clearTimeout(onTimeID);
				var index = $(hd).index($(this));
				if (current == index){return;}
				current = index;
				onTimeID = setTimeout(tabsAction, onTime);
				clearTimeout(delayID);
			}

			function tabGo(){
				clearTimeout(delayID);
				onTimeID = null;
				if (delay>0 && onTimeID==null){delayID = setTimeout(play, delay);}
			}
			
			function tabsAction(){
				clearTimeout(delayID);
				$(hd).removeClass("current").eq(current).addClass("current");
				$(bd).hide().eq(current).fadeIn(0);
				if (delay>0 && onTimeID==null){delayID = setTimeout(play, delay);}
			}
			
			function play(){
				current = (current < count) ? current+1 : 0;
				tabsAction();
			}
		}
	}
})(jQuery);
