/*! jQuery Ticker Plugin v1.2.0 | https://github.com/BenjaminRH/jquery-ticker | Copyright 2014 Benjamin Harris | Released under the MIT license */
(function(l){function B(c){for(var a=c.length-1;0<a;a--){var v=Math.floor(Math.random()*(a+1)),b=c[a];c[a]=c[v];c[v]=b}return c}function w(c,a){a=a||[];return c.replace(/\x3c!--.*?--\x3e/img,"").replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/img,function(c,b){return-1!==a.indexOf(b.toLowerCase())?c:""})}l.fn.ticker=function(c){var a=l.extend({},l.fn.ticker.defaults,c);return this.each(function(){function c(){t=!0;x?(x=!1,b()):y=setTimeout(function(){a.pauseOnHover&&d.hasClass("hover")?(clearTimeout(h),c()):b()},a.itemSpeed)}function b(){t?(t=!1,z()):a.finishOnHover&&a.pauseOnHover&&d.hasClass("hover")&&e<=k[f].length?(p.html(u()),e+=1,b()):h=setTimeout(function(){a.pauseOnHover&&d.hasClass("hover")?(clearTimeout(h),b()):(z(),e>k[f].length&&(f+=1,e=0,f==k.length&&(f=0),clearTimeout(h),clearTimeout(y),c()))},a.cursorSpeed)}function z(){0===e&&a.fade?(clearTimeout(h),p.fadeOut(a.fadeOutSpeed,function(){p.html(u());p.fadeIn(a.fadeInSpeed,function(){e+=1;b()})})):(p.html(u()),e+=1,clearTimeout(h),b())}function u(){var c,b,q,m;switch(e%2){case 1:c=a.cursorOne;break;case 0:c=a.cursorTwo}e>=k[f].length&&(c="");var n="",d=[];for(b=0;b<e;b++){m=null;for(q=0;q<r[f].length;q++)if(r[f][q]&&r[f][q].start===b){m=r[f][q];break}m&&(n+=m.tag,m.selfClosing||("/"===m.tag.charAt(1)?d.pop():d.push(m.name)));n+=k[f][b]}for(b=0;b<d.length;b++)n+="</"+d[b]+">";return n+c}var d=l(this),p,C=d.find("li"),k=[],r={},y,h,f=0,e=0,x=!0,t=!0,D="a b strong span i em u".split(" ");if(a.finishOnHover||a.pauseOnHover)d.removeClass("hover"),d.hover(function(){l(this).toggleClass("hover")});var s,A;C.each(function(a,c){var b=s=w(l(this).html(),D),d;d=[];for(var e=/<\/?([a-z][a-z0-9]*)\b[^>]*>/im,f=/\/\s{0,}>$/m,h=[],g;null!==(g=e.exec(b));)if(0===d.length||-1!==d.indexOf(g[1]))g={tag:g[0],name:g[1],selfClosing:f.test(g[0]),start:g.index,end:g.index+g[0].length-1},h.push(g),b=b.slice(0,g.start)+b.slice(g.end+1),e.lastIndex=0;A=h;s=w(s);k.push(s);r[k.length-1]=A});a.random&&B(k);d.find("ul").after("<div></div>").remove();p=d.find("div");c()})};l.fn.ticker.defaults={random:!1,itemSpeed:3E3,cursorSpeed:50,pauseOnHover:!0,finishOnHover:!0,cursorOne:"_",cursorTwo:"",fade:!0,fadeInSpeed:600,fadeOutSpeed:300}})(jQuery);
