(function(A){A.fn.kxbdMarquee=function(C){var B=A.extend({},A.fn.kxbdMarquee.defaults,C);return this.each(function(){var N=A(this);var M=N.get(0);var D=N.width();var J=N.height();var E=N.children();var H=E.children();var G=0;var P=(B.direction=="left"||B.direction=="right")?1:0;E.css(P?"width":"height",10000);if(B.isEqual){G=H[P?"outerWidth":"outerHeight"]()*H.length}else{H.each(function(){G+=A(this)[P?"outerWidth":"outerHeight"]()})}if(G<(P?D:J)){return}E.append(H.clone()).css(P?"width":"height",G*2+1);var F=G==10000;if(F){var K=0;if(P){A("li",N).each(function(Q,S){var R=parseInt(A("a",A(S)).css("paddingLeft"))+parseInt(A("a",A(S)).css("paddingRight"));K+=A(S).width()+R})}else{A("li",N).each(function(Q,S){var R=parseInt(A("a",A(S)).css("paddingTop"))+parseInt(A("a",A(S)).css("paddingBottom"));K+=A(S).height()+R})}}var O=0;function I(){var Q=(B.direction=="left"||B.direction=="right")?"scrollLeft":"scrollTop";if(B.loop>0){O+=B.scrollAmount;if(O>G*B.loop){M[Q]=0;return clearInterval(L)}}if(B.direction=="left"||B.direction=="up"){var R=M[Q]+B.scrollAmount;if(!F&&R>=G){R-=G}if(F&&R>=K){R-=K}M[Q]=R}else{var R=M[Q]-B.scrollAmount;if(R<=0){if(!F){R+=G}else{R+=K}}M[Q]=R}}var L=setInterval(I,B.scrollDelay);N.hover(function(){clearInterval(L)},function(){clearInterval(L);L=setInterval(I,B.scrollDelay)});if(B.controlBtn){A.each(B.controlBtn,function(Q,R){A(R).bind(B.eventA,function(){B.direction=Q;B.oldAmount=B.scrollAmount;B.scrollAmount=B.newAmount}).bind(B.eventB,function(){B.scrollAmount=B.oldAmount})})}})};A.fn.kxbdMarquee.defaults={isEqual:true,loop:0,direction:"left",scrollAmount:1,scrollDelay:20,newAmount:3,eventA:"mousedown",eventB:"mouseup"};A.fn.kxbdMarquee.setDefaults=function(B){A.extend(A.fn.kxbdMarquee.defaults,B)}})(jQuery);