(function(a){a.fn.at_intervals=function(d,b){var c=a.extend({},a.fn.at_intervals.defaults,b);return this.each(function(){var i=a(this);var g=c.name;var f=c.delay;var h={should_stop:function(){return !this.element_in_dom()||this.user_wants_to_stop()},should_work:function(){return this.element_visible()&&!this.user_wants_to_pause()},user_wants_to_stop:function(){return i.data(g).should_stop==true},user_wants_to_pause:function(){return i.data(g).should_pause==true},element_in_dom:function(){return i.parents("html").length>0},element_visible:function(){return i.parents("*").andSelf().not(":visible").length==0},stop:function(e){clearInterval(e);i.removeData(g)}};if(i.data(g)){h.stop(i.data(g).interval_id)}i.data(g,{delay:f});if(h.should_work()){d()}var j=setInterval(function(){if(h.should_stop()){h.stop(j)}else{if(h.should_work()){d()}}},f);i.data(g).interval_id=j})};a.fn.at_intervals.defaults={name:"at_intervals",delay:1000}})(jQuery);
