/**
 * zudolab TabContents
 *
 * @version    1
 * @copyright    (c)2008 Takeshi Takatsudo (http://zudolab.net/)
 * @license    MIT (http://www.opensource.org/licenses/mit-license.php)
 */
(function(a){TabContents=function(b){this.selector=b;this.elemSets=[];var c=this;a(function(){c.setup()})};TabContents.prototype.setup=function(){this.prepareSets();if(!this.elemSets){return}this.preploadTabImgs();this.enable1stSelectedSet();this.setEvents()};TabContents.prototype.prepareSets=function(){var b=this;var c=a(b.selector);if(!c){return}c.each(function(){var g=this;var l=a(g);var d=a(this).find("img").eq(0);var h=(d.length==1)?d.get(0):null;if(h){var k=d.attr("src");var j=k;var i=k.replace("_off.","_ov.")}var f=l.hasClass("sd_showThis")?true:false;l.removeClass("sd_showThis");var e=a(l.attr("href"));b.elemSets.push({anchor:g,$content:e,selected:f,img:h,srcOff:j?j:null,srcOn:i?i:null})})};TabContents.prototype.setEvents=function(){var b=this;for(var c=0,d;d=this.elemSets[c];c++){a(d.anchor).click(function(){b.changeTabTo(this);return false})}};TabContents.prototype.changeTabTo=function(b){var c=this.getElemSetFromAnchor(b);var d=this.getLastSelectedElemSet();if(c==d){return}this.disableSet(d);this.enableSet(c)};TabContents.prototype.disableSet=function(b){a(b.anchor).css("cursor","pointer");if(b.img){b.img.src=b.srcOff}a(b.anchor).removeClass("on");b.$content.hide();b.selected=false};TabContents.prototype.enableSet=function(b){a(b.anchor).css("cursor","default");if(b.img){b.img.src=b.srcOn}a(b.anchor).addClass("on");b.$content.show();b.selected=true};TabContents.prototype.enable1stSelectedSet=function(){for(var b=0,c;c=this.elemSets[b];b++){if(c.selected){this.enableSet(c);return}}};TabContents.prototype.preploadTabImgs=function(){for(var b=0,c;c=this.elemSets[b];b++){if(!c.img){continue}if(c.selected){(new Image).src=c.srcOff}else{(new Image).src=c.srcOn}}};TabContents.prototype.getElemSetFromAnchor=function(b){for(var c=0,d;d=this.elemSets[c];c++){if(d.anchor==b){return d}}};TabContents.prototype.getLastSelectedElemSet=function(){for(var b=0,c;c=this.elemSets[b];b++){if(c.selected){return c}}return false}})(jQuery);
