var box={};box.version="0.5.0";(function(h){var e=this,o=this.document,s=o.documentElement;if(!s||!o.getElementById||!o.getElementsByTagName||!o.createElement||!o.createTextNode){box.disabled=true;return}box.disabled=false;var m=h(s).attr("id","js");box.domIsReady=false;h(o).ready(function(){box.domIsReady=true});box.loadIsDone=false;h(e).load(function(){box.loadIsDone=true});var r={},d={},l={};box.dom=function(B,A){return h(B,A)};box.util=function(A){return l[A]};box.ui=function(A){return d[A]};box.addPluginUI=function(B,A){B="plugin."+B;if(!d[B]){d[B]=A}return A};box.removePluginUI=function(A){A="plugin."+A;delete d[A]};var v=(function(){var A=function(){};return function(B,C){A.prototype=C.prototype;B.prototype=new A();B.prototype.constructor=B}})();box.inherit=v;var x=function(C,B){for(var A in B){if(B.hasOwnProperty(A)){C.prototype[A]=B[A]}}};box.extend=x;var y=function(B){var C={};for(var A in B){if(B.hasOwnProperty(A)){C[A]=B[A]}}return C};box.clone=y;box.loadScript=function(C,B,A){h.ajax({type:"GET",url:B,dataType:"script",cache:A!==false,error:function(){box.fire({type:"requesterror",component:"loadscript",id:C})},success:function(){box.fire({type:"requestsuccess",component:"loadscript",id:C})}})};var q={};var g=function(H,C,D){var B=q[H];var G=true;if(B&&B.length){var F=B.length,A=F-1,E;while(F--){if(B[A-F].apply(C.source||null,D)===false){G=false}}}return G};box.fire=function(A){if(typeof A=="object"&&typeof A.type=="string"){var B=Array.prototype.slice.call(arguments,1);B=[A].concat(B);if(typeof A.source=="undefined"){A.source=null}var E=A.type;if(typeof A.component=="string"){E+="."+A.component}if(typeof A.id=="string"){E+="."+A.id}if(typeof A.namespace=="string"){E+="."+A.namespace}var D=E.split("."),C=D.length;while(C){if(g(D.slice(0,C).join("."),A,B)===false){break}--C}}return this};box.bind=function(B){for(var A in B){if(B.hasOwnProperty(A)){if(!q[A]){q[A]=[]}q[A][q[A].length]=B[A]}}return this};box.unbind=function(){var A=arguments.length,C,B;while(A--){C=arguments[A];if(q[C]){delete q[C]}else{if(C.indexOf("*")>-1){C=C.replace(/\*/i,"");for(B in q){if(q.hasOwnProperty(B)){if(B.indexOf(C)>-1){delete q[B]}}}}}}return this};var u=0;h.fn.getAnId=function(){var A;if(this.length==1){A=this.getBoxDatas("id")||this.attr("id");if(!A){A="__n__"+(++u)}}return A};h.fn.getBoxDatas=function(G){var E=null;if(this.length){var I=this[0].className,B;if(I&&I.indexOf("box[")>-1){if(typeof G=="string"){var H=new RegExp(G+"=([^;\\]]+)");B=I.match(H);E=B&&B[1]}else{E={};var D=I.replace(/.*box\[([^)]+)\].*/,"$1");var F=D.split(";");var C=F.length,A=C-1;while(C--){B=F[C].split("=");E[B[0]]=B[1]}}}}return E};h.fn.setBoxDatas=function(A){if(typeof A=="object"&&this.length){this.each(function(D,F){var B=F.className,C,E=false;if(!B||B.indexOf("box[")==-1){h(F).addClass("box[]");E=true}B=F.className;for(var D in A){C=D+"="+A[D];if(A.hasOwnProperty(D)&&B.indexOf(C)==-1){B=B.replace("]",(E?"":";")+C+"]")}}F.className=B})}return this};h.fn.clearBoxDatas=function(A){if(typeof A=="object"&&this.length){var B=this[0].className,D;for(var C in A){D=C+"="+A[C];if(A.hasOwnProperty(C)&&B.indexOf(D)>-1){B=B.replace(D,"")}}this[0].className=B}};var t=/(text|password)/i;var f=/^\s*$/;var j=function(){if(this.value==this.defaultValue){this.value=""}};var p=function(){if(f.test(this.value)){this.value=this.defaultValue}};h.fn.clearTextFields=function(){this.each(function(A,B){if(B.nodeName.toLowerCase()=="input"&&t.test(B.type)){h(B).focus(j).blur(p)}else{h("input[type=text], input[type=password]",B).focus(j).blur(p)}})};var i=h("<div></div>");h.fn.outerHTML=function(){i.html("");return i.append(this.eq(0).clone()).html()};h.fn.replaceIn=function(B){var A="";this.each(function(C,D){A+=h(D).outerHTML()});h(B).html(A);return this};h.fn.getScroll=function(){return{top:this.scrollTop(),left:this.scrollLeft()}};var c={"viewport-width":function(){return h(e).width()},"viewport-height":function(){return h(e).height()},"document-width":function(){return h(o).width()},"document-height":function(){return h(o).height()},"content-box-width":function(A){return A.width()},"content-box-height":function(A){return A.height()},"padding-box-width":function(A){return A.innerWidth()},"padding-box-height":function(A){return A.innerHeight()},"border-box-width":function(A){return A.outerWidth()},"border-box-height":function(A){return A.outerHeight()},"margin-box-width":function(A){return A.outerWidth(true)},"margin-box-height":function(A){return A.outerHeight(true)}};var a=function(D,B,A){if(D[0]===e){return c["viewport-"+B.toLowerCase()]()}else{if(D[0]===o){return c["document-"+B.toLowerCase()]()}else{var C=typeof A=="string"?A.toLowerCase()+"-"+B:"content-box-"+B;if(c[C]){return c[C](D)}else{return c["content-box-"+B.toLowerCase()](D)}}}};h.fn.getSize=function(A){return{width:a(this,"width",A),height:a(this,"height",A)}};h.fn.getWidth=function(A){return a(this,"width",A)};h.fn.getHeight=function(A){return a(this,"height",A)};h.fn.setSize=function(A){if(typeof A=="number"||A=="auto"){this.width(A).height(A)}else{if(typeof A=="object"){if(typeof A.width=="number"||A.width=="auto"){this.width(A.width)}if(typeof A.height=="number"||A.height=="auto"){this.height(A.height)}}}return this};h.fn.setWidth=function(A){if(typeof A=="number"||A=="auto"){this.width(A)}return this};h.fn.setHeight=function(A){if(typeof A=="number"||A=="auto"){this.height(A)}return this};var w=function(B,A){if(B[0]===o){return{top:0,left:0}}else{if(B[0]===e){return B.getScroll()}else{if(A=="positioned-ancestor"){return B.position()}else{return B.offset()}}}};h.fn.getXY=function(A){return w(this,A)};h.fn.getX=function(A){return w(this,A).left};h.fn.getY=function(A){return w(this,A).top};h.fn.setXY=function(A){if(typeof A=="number"){this.css({top:A+"px",left:A+"px"})}else{if(typeof A=="object"){var B={};if(typeof A.top=="number"){B.top=A.top+"px"}else{if(A.top=="auto"){B.top="auto"}}if(typeof A.left=="number"){B.left=A.left+"px"}else{if(A.left=="auto"){B.left="auto"}}this.css(B)}}};var k={root:function(B,C,A){return C.offset()[A]},"positioned-ancestor":function(B,C,A){return C.position()[A]},before:function(D,F,C,B){var A=D["get"+B]("border-box");var E=F.getXY()[C];return E-A},start:function(C,D,B,A){return D.getXY()[B]},middle:function(E,G,D,B){var A=E["get"+B]("border-box");var C=a(G,B);var F=G.getXY()[D];return F+(C-A)/2},end:function(E,G,D,B){var A=E["get"+B]("border-box");var C=a(G,B);var F=G.getXY()[D];return F+C-A},"in-before":function(C,D,B,A){return -C["get"+A]("border-box")},"in-start":function(){return 0},"in-middle":function(E,F,D,B){var A=E["get"+B]("border-box");var C=a(F,B);return(C-A)/2},"in-end":function(E,F,D,B){var A=E["get"+B]("border-box");var C=a(F,B);return C-A}};var z=function(A){var B={viewport:e,document:o};return B[A]||A};var n=function(B,C){var A;if(typeof B.width=="string"){A=B.width.split(":");if(A.length==2){B.width=c[A[1]+"-width"](h(z(A[0])),"width")}if(!isNaN(B["min-width"])&&!isNaN(B.width)){B.width=B.width<B["min-width"]?B["min-width"]:B.width;delete B["min-width"]}if(!isNaN(B["max-width"])&&!isNaN(B.width)){B.width=B.width>B["max-width"]?B["max-width"]:B.width;delete B["max-width"]}}if(typeof B.height=="string"){A=B.height.split(":");if(A.length==2){B.height=c[A[1]+"-height"](h(z(A[0])),"height")}if(!isNaN(B["min-height"])&&!isNaN(B.height)){B.height=B.height<B["min-height"]?B["min-height"]:B.height;delete B["min-height"]}if(!isNaN(B["max-height"])&&!isNaN(B.height)){B.height=B.height>B["max-height"]?B["max-height"]:B.height;delete B["max-height"]}}return B};var b=function(B,C){var A;if(typeof B.top=="string"){A=B.top.split(":");if(A.length==2){B.top=k[A[1]](C,h(z(A[0])),"top","Height")}if(!isNaN(B["min-top"])&&!isNaN(B.top)){B.top=B.top<B["min-top"]?B["min-top"]:B.top;delete B["min-top"]}if(!isNaN(B["max-top"])&&!isNaN(B.top)){B.top=B.top>B["max-top"]?B["max-top"]:B.top;delete B["max-top"]}}if(typeof B.left=="string"){A=B.left.split(":");if(A.length==2){B.left=k[A[1]](C,h(z(A[0])),"left","Width")}if(!isNaN(B["min-left"])&&!isNaN(B.left)){B.left=B.left<B["min-left"]?B["min-left"]:B.left;delete B["min-left"]}if(!isNaN(B["max-left"])&&!isNaN(B.left)){B.left=B.left>B["max-left"]?B["max-left"]:B.left;delete B["max-left"]}}return B};h.fn.applyStyles=function(A){if(this.length&&typeof A=="object"){var C=this.eq(0),B=y(A);B=n(B,C);if(!isNaN(B.width)){C.width(B.width);delete B.width}if(!isNaN(B.height)){C.height(B.height);delete B.height}B=b(B,C);C.css(B)}return this};h.fn.getStyles=function(A){if(this.length&&typeof A=="object"){var C=this.eq(0),B=y(A);B=n(B,C);B=b(B,C);return B}return null};(function(){var B={btnPrev:'<a href="#" class="{$btnPrevCls} {$btnDisabledCls}">'+l10n.prev+"</a>",btnPrevCls:"prev",btnNext:'<a href="#" class="{$btnNextCls} {$btnDisabledCls}">'+l10n.next+"</a>",btnNextCls:"next",btnDisabledCls:"off",pagesWrap:'<div class="{$pagesWrapCls}"><ul>{$content}</ul></div>',pagesWrapCls:"pagination",pagesItem:'<li{$pagesItemActiveCls}><a href="#">{$content}</a></li>',pagesItemActiveCls:"on"};d.carousel={create:function(Q){Q.id=Q.id||h(Q.element).getAnId();var R="carousel."+Q.id;return d[R]||(d[R]=new K(Q))},destroy:function(){var Q=arguments.length,R;while(Q--){R="carousel."+arguments[Q];if(d[R]){delete d[R]}}},configure:function(Q){for(var R in Q){if(Q.hasOwnProperty(R)&&B[R]!==undefined){B[R]=Q[R]}}}};var M=function(Q){Q=Q=="next"?"btnNext":"btnPrev";return B[Q].replace("{$"+Q+"Cls}",B[Q+"Cls"]).replace("{$btnDisabledCls}",B.btnDisabledCls)};var O=function(Q){return parseInt(Q.moveable.css(Q.property),10)||0};var A=function(R,Q){if(isNaN(Q)){return 0}else{if(Q<0){return Q+R.length}else{if(Q<R.length){return Q}else{return Q-R.length}}}};var D=function(S,Q){S.current=A(S,Q);if(S.currentPage!==undefined){var R=Math.ceil((S.current+S.display)/S.display);h("li",S.pagination).eq(S.currentPage-1).removeClass(B.pagesItemActiveCls).end().eq(R-1).addClass(B.pagesItemActiveCls);S.currentPage=R}};var F=function(Y,U){if(Y.autoplay){Y.pauseAutoplay()}Y.moving=true;var Q=O(Y);var T=Q+Y.moveBy*(Y.current-U);var Z=parseInt(Y.items.eq(Y.current).css(Y.property),10);var R=U-(Y.hasOffset&&Q%Y.moveBy?1:0);var X=Y.current;var V,W;for(var S=R;S<X;S++){V=A(Y,S);W=Z-(Y.current-S)*Y.moveBy;Y.items.eq(V).css(Y.property,W+"px")}D(Y,U);I(Y,T)};var H=function(Y,U){if(Y.autoplaying){Y.pauseAutoplay()}Y.moving=true;var Q=O(Y);var T=Q+(-Y.moveBy*(U-Y.current));var Z=parseInt(Y.items.eq(Y.current).css(Y.property),10)+Y.display*Y.moveBy;var R=Y.current+Y.display-(Y.hasOffset&&Q%Y.moveBy?1:0);var X=U+Y.display-(Y.hasOffset&&Q%Y.moveBy?1:0);var V,W;for(var S=R;S<X;S++){V=A(Y,S);W=Z+(S-Y.display-Y.current)*Y.moveBy;Y.items.eq(V).css(Y.property,W+"px")}D(Y,U);I(Y,T)};var G=function(R,Q){if(R.autoplaying){R.pauseAutoplay()}R.moving=true;Q=Math.min(Q,R.length-R.display);if(R.buttons){if(!Q){R.buttonPrev.addClass(B.btnDisabledCls);R.buttonNext.removeClass(B.btnDisabledCls)}else{if(Q==R.length-R.display){R.buttonPrev.removeClass(B.btnDisabledCls);R.buttonNext.addClass(B.btnDisabledCls)}else{R.buttonPrev.removeClass(B.btnDisabledCls);R.buttonNext.removeClass(B.btnDisabledCls)}}}D(R,Q);I(R,-R.moveBy*Q)};var P=function(U,T){var S=(U.hasOffset&&U.offset)?U.startAt-1:U.startAt;var Q=S+U.length;var W,V;for(var R=S;R<Q;R++){W=A(U,R);U.items.eq(W).css(U.property,R*U.moveBy+"px")}};var L=function(Q,R){if(Q.circular&&R==(-(Q.length*Q.moveBy)+Q.offset)){Q.moveable.css(Q.property,Q.offset+"px");P(Q,true)}};var I=function(R,S){if(R.duration){var Q={};Q[R.property]=S;R.moveable.animate(Q,R.duration,function(){L(R,S);if(R.autoplaying){R.startAutoplay(R.autoplay)}R.moving=false})}else{R.moveable.css(R.property,S+"px");L(R,S);if(R.autoplaying){R.startAutoplay(R.autoplay)}R.moving=false}};var E=function(Q){return Math.ceil(Q.length/Q.display)};var J=function(R){var Q=R.currentPage-1;if(Q<1){Q=R.circular?E(R):1}return Q*R.display-R.display};var C=function(R){var Q=R.currentPage+1;if(Q>E(R)){Q=R.circular?1:E(R)}return Q*R.display-R.display};var N=function(R,Q){if(R.target.nodeName.toLowerCase()=="a"){R.preventDefault();if(!Q.moving){Q.moveToItem((Number(h(R.target).text())-1)*Q.display+1)}}};var K=function(Q){this.initialize(Q)};K.prototype={initialize:function(Q){var R=this;R.id=Q.id;R.property=Q.horizontal?"left":"top";R.buttons=Q.buttons===false?false:true;R.circular=!!Q.circular||false;R.duration=!isNaN(Q.duration)?Q.duration:null;R.autoplay=!isNaN(Q.autoplay)&&Q.autoplay>10&&R.circular?Q.autoplay:null;R.hasOffset=!!Q.hasOffset;R.element=h(Q.element);R.mask=Q.mask?R.element.find(Q.mask):R.element.children();R.moveable=Q.moveable?R.mask.find(Q.moveable):R.mask.children();R.items=Q.items?R.moveable.find(Q.items):R.moveable.children();R.length=R.items.length;R.display=Q.display;R.startAt=!isNaN(Q.startAt)?Q.startAt-1:0;if(R.startAt<0||R.startAt>=R.length){R.startAt=0}R.offset=parseInt(R.moveable.css(R.property),10)||0;if(R.hasOffset&&R.offset>0&&R.length>R.display+1){++R.display}R.moveBy=R.items.eq(0)[R.property=="top"?"outerHeight":"outerWidth"](true);D(R,R.startAt);if(R.property=="left"){R.moveable.width(R.moveBy*R.length)}if(R.circular){P(R)}if(R.length>R.display){R.disabled=false;if(!R.circular&&R.current>R.length-R.display){R.current=R.length-R.display}if(R.current){R.moveable.css(R.property,-R.moveBy*R.current+R.offset);R.offset=-R.moveBy*R.current+R.offset}if(R.buttons){R.buttonNext=h(M("next")).appendTo(R.element).click(function(S){R.moveNext(S);S.preventDefault()});R.buttonPrev=h(M("prev")).prependTo(R.element).click(function(S){R.movePrev(S);S.preventDefault()});if(R.circular||R.current){R.buttonPrev.removeClass(B.btnDisabledCls)}if(R.circular||R.current+R.display<R.length){R.buttonNext.removeClass(B.btnDisabledCls)}}if(Q.paginate){R.addPagination()}if(R.autoplay){R.startAutoplay(R.autoplay)}}else{R.disabled=true}},movePrev:function(){if(!this.moving){var Q=!isNaN(this.currentPage)?J(this):this.current-1;if(this.circular){F(this,Q)}else{if(Q>-1){G(this,Q)}}}},moveNext:function(){if(!this.moving){var Q=!isNaN(this.currentPage)?C(this):this.current+1;if(this.circular){H(this,Q)}else{if(Q<this.length){G(this,Q)}}}},moveToItem:function(Q){if(!this.moving&&typeof Q=="number"){--Q;if(this.items[Q]){if(this.currentPage){var R=Math.floor(Q/this.display)+1;Q=(R-1)*this.display}if(this.circular){if(Q>this.current&&Q-this.current>this.length-Q){Q=Q-this.length}else{if(Q<this.current&&this.current-Q>Q+this.length-this.current){Q=this.length+Q}}if(Q<this.current){F(this,Q)}else{if(Q>this.current){H(this,Q)}}}else{G(this,Q)}}}},startAutoplay:function(Q){var R=this;if(R.circular&&(!isNaN(Q)||R.autoplay)){if(isNaN(Q)){Q=R.autoplay}else{R.autoplay=Q}R.autoplaying=true;R.timer=e.setInterval(function(){R.moveNext()},Q)}},pauseAutoplay:function(){e.clearInterval(this.timer);this.timer=null},endAutoplay:function(){this.pauseAutoplay();this.autoplaying=false},addPagination:function(){var W=this;var V=B.pagesWrap.replace("{$pagesWrapCls}",B.pagesWrapCls);var R=E(W);var T,Q,S="";for(var U=1;U<=R;U++){T=(U-1)*W.display;Q=T+W.display-1;if(W.startAt>=T&&W.startAt<=Q){W.currentPage=U;S+=B.pagesItem.replace("{$pagesItemActiveCls}",' class="'+B.pagesItemActiveCls+'"')}else{S+=B.pagesItem.replace("{$pagesItemActiveCls}","")}S=S.replace(/{\$content}/g,U)}V=V.replace("{$content}",S);this.pagination=h(V).appendTo(W.element).click(function(X){N(X,W)})},removePagination:function(){this.pagination.unbind("click").remove()}}})()})(jQuery);
