/* ==========================================================
 * MobilySelect
 * date: 18.1.2010
 * author: Marcin Dziewulski
 * last update: 18.1.2010
 * web: http://www.mobily.pl or http://playground.mobily.pl
 * email: hello@mobily.pl
 * Free to use under the MIT license.
 * ========================================================== */
(function($){$.fn.mobilyselect=function(options){var defaults={animation:"absolute",animationTime:500,listClass:"selecterContent",btnsClass:"selecterBtns",btnActiveClass:"active",selector:"li",onChange:function(){},onFinishAnimation:function(){}};var sets=$.extend({},defaults,options);return this.each(function(){var $t=$(this),list=$t.find("."+sets.listClass),btns=$t.find("."+sets.btnsClass),btn=btns.find("a"),li=list.find(sets.selector),w=li.width(),h=li.height(),l=li.length,finishTime;if(sets.animation=="absolute"){li.css({position:"relative"}).children().css({position:"absolute",top:0,left:0})}var select={init:function(){select.trigger()},trigger:function(){btn.bind("click",function(){var $t=$(this),rel=$t.attr("rel"),sel=li.filter("."+rel),s=li.filter(function(){return $(this).css("display")=="block"});if(rel=="all"){if(l!=s.length){select.animation(li,li)}}else{select.animation(li,sel)}btn.removeClass(sets.btnActiveClass);$t.addClass(sets.btnActiveClass);sets.onChange.call(this);return false})},animation:function(not,sel){switch(sets.animation){case"plain":$(not).hide();$(sel).show();break;case"fade":$(not).fadeOut(sets.animationTime);setTimeout(function(){$(sel).fadeIn(sets.animationTime)},sets.animationTime+400);break;case"absolute":setTimeout(function(){$(sel).show().children().animate({top:0,left:0},sets.animationTime)},sets.animationTime+400);$(not).children().animate({top:-h+"px",left:-w+"px"},sets.animationTime,function(){$(not).hide()});break}if(sets.animation=="absolute"||sets.animation=="fade"){finishTime=sets.animationTime*2+400}else{finishTime=100}setTimeout(function(){sets.onFinishAnimation.call(this)},finishTime)}};select.init()})}}(jQuery));
