(function($){
$.fn.extend({
tabs:function(opt){
	var ret=this
	this.each(function(){
		var th=$(this),
			data=th.data('_tabs'),
			root={
			  	"undefined":function(){
					var _={
						enable:true,
						duration:800,
						items:'>ul>li',
						preFu:function(){
							_.itms.hide()
						},
						showFu:function(){
							_.next.fadeIn(_.duration)
						},
						hideFu:function(){
							_.itms.hide()
						},
						nextFu:function(){
							var _=this,
							n=_.n
						_.changeFu(++n<_.itms.length?n:0)
						},
						prevFu:function(){
							var _=this,
								n=_.n
							_.changeFu(--n>=0?n:_.itms.length-1)
						},
						navFu:function(str){
							var _=this
							_.n=-1
							_.next=$(str,_.me)
							_.hideFu()
							_.showFu()
						},
						changeFu:function(n){
							if(n==_.n)
								return false
							_.n=n
							_.next=_.itms.eq(n)
							_.hideFu()
							_.showFu()
						},
						init:function(){
							_.me=this
							_.itms=$(_.items,_.me)
							_.preFu()
						}
					}
					if(opt)
						$.extend(_,opt)
						
					if(!data)
						_.init.call(th),
						th.data({_tabs:data=_})
					else
						_=data
					ret=_
				},
				"object":function(){
					$.extend(data,opt)
					ret=th
				},
				"function":function(){
					data.onChangeMas.push(opt)
					ret=th
				},
				"number":function(){
					data.changeFu(opt)
					ret=th
				},
				"string":function(){
					if(opt=='next'||opt=='prev')
						({
						next:function(){
							data.nextFu()
						},
						prev:function(){
							data.prevFu()
						}
						})[opt]()
					else
						data.navFu(opt)
					ret=th
				},
				"boolean":function(){
					data.enable=_
					ret=th
				}
			},
			fu=root[typeof opt]
			
			if(!data&&opt!=undefined)
				root['undefined'](opt)
			if(data.enable||opt===true)
				fu()
		})
		return ret
	}
})
})(jQuery)
