	$.tabs=function(container,def,onswitch,eventname){
		var panels=[],t=null,p=null,prev=null;
		function hideAll(){$(panels.join(',')).hide()}
		$("a",container).each(function(i,n){
			var _T=this,id=_T.hash;
			if(!id || id.length<=1)id=false;
			if(id){
				panels.push(id);
				if(!def)def=$(id);
			}
			var cur={tab:$(this),panel:(id?$(id):def)};
			if(t==null){
				t=cur.tab;
				//_T.html=def.html();
			}
			_T.doswitch=function(){
				hideAll();
				if(!id){
					if(!_T.html)$.ajax({type:'GET',url:_T.href,data:{r:Math.random()},async:false,success:function(data){_T.html=data;},error:function(xhr,st,e){_T.html='error:'+st+','+e}});
					def.html(_T.html);
				}
				try{if(onswitch)onswitch(prev,cur);}catch(err){}
				cur.panel.show();
				prev=cur;
				return false;
			}
			if(eventname){cur.tab.bind(eventname,_T.doswitch);if('click'!=eventname)cur.tab.click(_T.doswitch);}
			else cur.tab.click(_T.doswitch);
		});
		if(eventname) t.trigger(eventname);
		else t.doswitch();
	};
	//$(function(){
		$.tabs($("#category-button"),$("#category-def-panel"),function(p,c){if(p)p.tab.removeClass('sel');c.tab.addClass('sel');},"mouseover");
	//});
