(function(a){a.circulate=function(c,b){var e=this,i,g,d,f,h;e.$el=a(c);e.$el.data("circulate",e);e.stopAnimation=function(){e.options.keepGoing=false};e.runAnimation=function(){if(e.options.keepGoing){i=e.$el.width();g=e.$el.height();f=e.$el.position().left;h=e.$el.position().top;if(e.options.sizeAdjustment==100){d=i;newHeight=g;halfWayWidth=i;halfWayHeight=g}else{d=parseInt(i)*(e.options.sizeAdjustment/100);newHeight=parseInt(g)*(e.options.sizeAdjustment/100);halfWayWidth=(parseInt(i)+d)/2;halfWayHeight=(parseInt(g)+newHeight)/2}if(e.$el.css("position")!="absolute"){e.$el.css("position","relative")}e.$el.css("z-index",e.options.zIndexValues[0]);e.$el.animate({top:["+="+(e.options.height/2)+"px","easeInQuad"],marginLeft:["+="+(e.options.width/2)+"px","easeOutQuad"],width:[halfWayWidth,"linear"],height:[halfWayHeight,"linear"],opacity:1},e.options.speed,function(){e.$el.css("z-index",e.options.zIndexValues[1])}).animate({top:["+="+(e.options.height/2)+"px","easeOutQuad"],marginLeft:["-="+(e.options.width/2)+"px","easeInQuad"],width:[d,"linear"],height:[newHeight,"linear"]},e.options.speed,function(){e.$el.css("z-index",e.options.zIndexValues[2])}).animate({top:["-="+(e.options.height/2)+"px","easeInQuad"],marginLeft:["-="+(e.options.width/2)+"px","easeOutQuad"],width:[halfWayWidth,"linear"],height:[halfWayHeight,"linear"]},e.options.speed,function(){e.$el.css("z-index",e.options.zIndexValues[3])}).animate({top:["-="+(e.options.height/2)+"px","easeOutQuad"],marginLeft:["+="+(e.options.width/2)+"px","easeInQuad"],width:[i,"linear"],height:[g,"linear"]},e.options.speed,function(){e.$el.css("z-index",e.options.zIndexValues[0]);if(e.options.loop===true){e.runAnimation()}})}};e.init=function(){e.options=a.extend({},a.circulate.defaultOptions,b);e.runAnimation()};e.init()};a.circulate.defaultOptions={speed:400,height:200,width:200,sizeAdjustment:100,loop:false,zIndexValues:[1,1,1,1],keepGoing:true};a.fn.circulate=function(b){if(typeof(b)==="string"){return this.each(function(){var c=a(this).data("circulate");if(c){c.stopAnimation()}})}else{return this.each(function(){(new a.circulate(this,b))})}}})(jQuery);
