/*!
 * jQuery Cooltabs 1.0
 *    - http://cooltabs.codeserenity.com/
 *
 * Copyright 2010, Gilles Cochez
 * Dual licensed under the MIT and GPL licenses.
 *    - http://www.opensource.org/licenses/mit-license.php
 *    - http://www.gnu.org/copyleft/gpl.html
 */
;(function($){var list='content-wrap,wrap,left,middle,tab,tab-left,tab-middle,tab-right,right,arrow,clear'.split(",");x=$.fn.cooltabs=function(o){o=$.extend({},$.fn.cooltabs.defaults,o);return $(this).each(function(){var
n=0,e={},span=[],cwidth=0,height=0,$ul=$('<ul>'),$content=$(this).children('div.'+o.prefix+'content');$.each(list,function(i){e[list[i].replace("-","_")]=$('<div>').addClass(o.prefix+list[i]);});e.tab2=e.tab.append(e.tab_left,e.tab_middle.append(e.arrow),e.tab_right,e.clear).clone().css('opacity',0.2);e.wrap.append(e.left,e.middle.append($ul,e.tab,e.tab2),e.right,e.clear).prependTo(this);$content.each(function(i){$('<li>').attr('pos',i).html(function(){var
arr=$content.children(o.header).eq(0).text().split(""),str='';$.each(arr,function(i){str+="<span>"+arr[i]+"</span>";});return str;}).addClass(i>0?o.prefix+'inactive':o.prefix+'active').click(function(){anim($(this));this.className=o.prefix+'active';}).hover(function(){anim($(this),o.hover_fx);},function(){anim($ul.children('li.'+o.prefix+'active').eq(0),o.hover_fx);}).appendTo($ul).children('span').each(function(){span[n]={left:$(this).position().left,width:$(this).innerWidth()};n++;});if(!height||$(this).innerHeight()>height)height=$(this).innerHeight();cwidth=$(this).outerWidth();$(this).css({position:'absolute',width:(cwidth-20)+"px",left:i*cwidth,top:$ul.height()}).appendTo(e.content_wrap);});$(this).css("height",height+"px").children('.'+o.prefix+'content').remove().end().append(e.content_wrap);e.tab_middle.css('width',$ul.children(0).innerWidth()+'px');function anim(li,hover){var el=hover?e.tab2:e.tab,mdl=hover?e.tab2.children().eq(1):e.tab_middle,$span=$ul.children().find('span');if(!hover)$ul.children('li').each(function(){this.className=o.prefix+'inactive';});el.stop(!hover).animate({left:li.position().left+10},{duration:o.speed,easing:o.tab_easing?o.tab_easing:'swing',step:function(){if(!hover){var data={width:e.tab.innerWidth(),left:e.tab.position().left-20};$span.each(function(i){if(span[i].left>=data.left-span[i].width&&span[i].left<=data.left+data.width)$span.get(i).className=o.prefix+'on';else $span.get(i).className=o.prefix+'off';});};},complete:function(){if(!hover)li.get().className=o.prefix+'active';}});mdl.stop().animate({width:li.innerWidth()+"px"},{easing:o.tab_easing?o.tab_easing:'swing',duration:o.speed});if(!hover)e.content_wrap.animate({left:"-"+li.attr('pos')*cwidth+"px"},{easing:o.content_easing?o.content_easing:'swing',duration:o.speed});};});};$.fn.cooltabs.defaults={content_easing:'',tab_easing:'',prefix:'cooltabs-',hover_fx:true,header:'h3',speed:500};})(jQuery);
