﻿(function(a){a.marquee={version:"1.0.01"};a.fn.marquee=function(e){var b=typeof arguments[0]=="string"&&arguments[0],f=b&&Array.prototype.slice.call(arguments,1)||arguments,d=this.length==0?null:a.data(this[0],"marquee");if(d&&b&&this.length)if(b.toLowerCase()=="object")return d;else if(d[b]){var c;this.each(function(g){var e=a.data(this,"marquee")[b].apply(d,f);if(g==0&&e)if(!!e.jquery)c=a([]).add(e);else{c=e;return false}else if(!!e&&!!e.jquery)c=c.add(e)});return c||this}else return this;else return this.each(function(){new a.Marquee(this,e)})};a.Marquee=function(p,b){b=a.extend({},a.Marquee.defaults,b);var f=this,c=a(p),d=c.find("> li"),h=-1,g=false,e=false,n=0;a.data(c[0],"marquee",f);this.pause=function(){g=true;m()};this.resume=function(){g=false;i()};this.update=function(){var a=d.length;d=c.find("> li");if(a<=1)i()};function q(h){if(d.filter("."+b.cssShowing).length>0)return false;var e=d.eq(h);if(a.isFunction(b.beforeshow))b.beforeshow.apply(f,[c,e]);var g={top:(b.yScroll=="top"?"-":"+")+e.outerHeight()+"px",left:0};c.data("marquee.showing",true);e.addClass(b.cssShowing);e.css(g).animate({top:"0px"},b.showSpeed,b.fxEasingShow,function(){if(a.isFunction(b.show))b.show.apply(f,[c,e]);c.data("marquee.showing",false);l(e)})}function l(a,f){if(e==true)return false;f=f||b.pauseSpeed;if(o(a))setTimeout(function(){if(e==true)return false;var c=a.outerWidth(),f=c*-1,d=parseInt(a.css("left"),10);a.animate({left:f+"px"},(c+d)*b.scrollSpeed,b.fxEasingScroll,function(){k(a)})},f);else if(d.length>1)setTimeout(function(){if(e==true)return false;a.animate({top:(b.yScroll=="top"?"+":"-")+c.innerHeight()+"px"},b.showSpeed,b.fxEasingScroll);k(a)},f)}function k(d){if(a.isFunction(b.aftershow))b.aftershow.apply(f,[c,d]);d.removeClass(b.cssShowing);j()}function m(){e=true;if(c.data("marquee.showing")!=true)d.filter("."+b.cssShowing).dequeue().stop()}function i(){e=false;if(c.data("marquee.showing")!=true)l(d.filter("."+b.cssShowing),1)}if(b.pauseOnHover)c.hover(function(){if(g)return false;m()},function(){if(g)return false;i()});function o(a){return a.outerWidth()>c.innerWidth()}function j(){h++;if(h>=d.length){if(!isNaN(b.loop)&&b.loop>0&&++n>=b.loop)return false;h=0}q(h)}if(a.isFunction(b.init))b.init.apply(f,[c,b]);j()};a.Marquee.defaults={yScroll:"top",showSpeed:850,scrollSpeed:12,pauseSpeed:5e3,pauseOnHover:true,loop:-1,fxEasingShow:"swing",fxEasingScroll:"linear",cssShowing:"marquee-showing",init:null,beforeshow:null,show:null,aftershow:null}})(jQuery)