(function($){$.extend({tabs:{remotecount:0}});$.fn.tabs=function(initial,settings){if(typeof initial=='object')settings=initial;settings=$.extend({initial:(initial&&typeof initial=='number'&&initial>0)?--initial:0,disabled:null,bookmarkable:$.ajaxhistory?true:false,remote:false,spinner:'������...',hashprefix:'remote-tab-',fxfade:null,fxslide:null,fxshow:null,fxhide:null,fxspeed:'normal',fxshowspeed:null,fxhidespeed:null,fxautoheight:false,onclick:null,onhide:null,onshow:null,navclass:'tabs-nav',selectedclass:'tabs-selected',disabledclass:'tabs-disabled',containerclass:'tabs-container',hideclass:'tabs-hide',loadingclass:'tabs-loading',tabstruct:'div'},settings||{});$.browser.msie6=$.browser.msie&&($.browser.version&&$.browser.version<7||/msie 6.0/.test(navigator.useragent));function unfocus(){scrollto(0,0)}return this.each(function(){var container=this;var nav=$('ul.'+settings.navclass,container);nav=nav.size()&&nav||$('>ul:eq(0)',container);var tabs=$('a',nav);if(settings.remote){tabs.each(function(){var id=settings.hashprefix+(++$.tabs.remotecount),hash='#'+id,url=this.href;this.href=hash;$('
').appendto(container);$(this).bind('loadremotetab',function(e,callback){var $$=$(this).addclass(settings.loadingclass),span=$('span',this)[0],tabtitle=span.innerhtml;if(settings.spinner){span.innerhtml=''+settings.spinner+''}settimeout(function(){$.getjson(url,function(data){$(hash).empty();if(data.error){$(hash).append(data.error)}else{$(hash).append('
');switch($(hash).parent().attr('id')){case'task':$(hash+' table:first-child').append('����ʱ������');$.each(data.data,function(i,item){$(hash+' table:first-child').append(''+item.title+''+item.createtime+''+item.trans+'')});$(hash).append('');break;case'news':$(hash+' table:first-child').append('');$.each(data.data,function(i,item){$(hash+' table:first-child').append(''+item.title+''+item.createtime+'')});$(hash).append('');break;case'notice':$(hash+' table:first-child').append('');$.each(data.data,function(i,item){$(hash+' table:first-child').append(''+item.title+''+item.createtime+'')});$(hash).append('');break;case'dtask':$(hash+' table:first-child').append('');$.each(data.data,function(i,item){$(hash+' table:first-child').append(''+item.title+''+item.createtime+'')});$(hash).append('');break;case'dnotice':$(hash+' table:first-child').append('');$.each(data.data,function(i,item){$(hash+' table:first-child').append(''+item.title+''+item.createtime+'')});$(hash).append('');break;case'pmsgbox':$(hash+' table:first-child').append('');$.each(data.data,function(i,item){$(hash+' table:first-child').append(''+item.title+''+item.createtime+'')});$(hash).append('');break;case'pmailbox':$(hash+' table:first-child').append('');$.each(data.data,function(i,item){$(hash+' table:first-child').append(''+item.title+''+item.createtime+'')});$(hash).append('');break;case'leader':$(hash+' table:first-child').append('����ʱ����ա');$.each(data.data,function(i,item){$(hash+' table:first-child').append(''+item.title+''+item.createtime+''+item.trans+'')});$(hash).append('');break;default:break}}callback&&callback()});if(settings.spinner){span.innerhtml=tabtitle}$$.removeclass(settings.loadingclass)},500)})})}var containers=$('div.'+settings.containerclass,container);containers=containers.size()&&containers||$('>'+settings.tabstruct,container);nav.is('.'+settings.navclass)||nav.addclass(settings.navclass);containers.each(function(){var $$=$(this);$$.is('.'+settings.containerclass)||$$.addclass(settings.containerclass)});var hasselectedclass=$('li',nav).index($('li.'+settings.selectedclass,nav)[0]);if(hasselectedclass>=0){settings.initial=hasselectedclass}if(location.hash){tabs.each(function(i){if(this.hash==location.hash){settings.initial=i;if(($.browser.msie||$.browser.opera)&&!settings.remote){var toshow=$(location.hash);var toshowid=toshow.attr('id');toshow.attr('id','');settimeout(function(){toshow.attr('id',toshowid)},500)}unfocus();return false}})}if($.browser.msie){unfocus()}containers.filter(':eq('+settings.initial+')').show().end().not(':eq('+settings.initial+')').addclass(settings.hideclass);$('li',nav).removeclass(settings.selectedclass).eq(settings.initial).addclass(settings.selectedclass);tabs.eq(settings.initial).trigger('loadremotetab').end();if(settings.fxautoheight){var _setautoheight=function(reset){var heights=$.map(containers.get(),function(el){var h,jq=$(el);if(reset){if($.browser.msie6){el.style.removeexpression('behaviour');el.style.height='';el.minheight=null}h=jq.css({'min-height':''}).height()}else{h=jq.height()}return h}).sort(function(a,b){return b-a});if($.browser.msie6){containers.each(function(){this.minheight=heights[0]+'px';this.style.setexpression('behaviour','this.style.height = this.minheight ? this.minheight : "1px"')})}else{containers.css({'min-height':heights[0]+'px'})}};_setautoheight();var cachedwidth=container.offsetwidth;var cachedheight=container.offsetheight;var watchfontsize=$('#tabs-watch-font-size').get(0)||$('m').css({display:'block',position:'absolute',visibility:'hidden'}).appendto(document.body).get(0);var cachedfontsize=watchfontsize.offsetheight;setinterval(function(){var currentwidth=container.offsetwidth;var currentheight=container.offsetheight;var currentfontsize=watchfontsize.offsetheight;if(currentheight>cachedheight||currentwidth!=cachedwidth||currentfontsize!=cachedfontsize){_setautoheight((currentwidth>cachedwidth||currentfontsize
').get(0);tempform.submit();$(this).trigger('click');if(settings.bookmarkable){$.ajaxhistory.update(hash)}}else{if(settings.bookmarkable){location.hash=hash.replace('#','')}else{$(this).trigger('click')}}});tabs.bind('disabletab',function(){var li=$(this).parents('li:eq(0)');if($.browser.safari){li.animate({opacity:0},1,function(){li.css({opacity:''})})}li.addclass(settings.disabledclass)});if(settings.disabled&&settings.disabled.length){for(var i=0,k=settings.disabled.length;iul:eq(0)',this);var a;if(!tab||typeof tab=='number'){a=$('li a',nav).eq((tab&&tab>0&&tab-1||0))}else if(typeof tab=='string'){a=$('li a[@href$="#'+tab+'"]',nav)}a.trigger(tabevent)})}})(tabevents[i])}$.fn.activetab=function(){var selectedtabs=[];this.each(function(){var nav=$('ul.tabs-nav',this);nav=nav.size()&&nav||$('>ul:eq(0)',this);var lis=$('li',nav);selectedtabs.push(lis.index(lis.filter('.tabs-selected')[0])+1)});return selectedtabs[0]}})(jquery);