/*!
* jcarousel - riding carousels with jquery
* http://sorgalla.com/jcarousel/
*
* copyright (c) 2006 jan sorgalla (http://sorgalla.com)
* dual licensed under the mit (http://www.opensource.org/licenses/mit-license.php)
* and gpl (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* built on top of the jquery library
* http://jquery.com
*
* inspired by the "carousel component" by bill scott
* http://billwscott.com/carousel/
*/
(function(g){var q={vertical:!1,rtl:!1,start:1,offset:1,size:null,scroll:3,visible:null,animation:"normal",easing:"swing",auto:0,wrap:null,initcallback:null,setupcallback:null,reloadcallback:null,itemloadcallback:null,itemfirstincallback:null,itemfirstoutcallback:null,itemlastincallback:null,itemlastoutcallback:null,itemvisibleincallback:null,itemvisibleoutcallback:null,animationstepcallback:null,buttonnexthtml:"
",buttonprevhtml:"",buttonnextevent:"click",buttonprevevent:"click", buttonnextcallback:null,buttonprevcallback:null,itemfallbackdimension:null},m=!1;g(window).bind("load.jcarousel",function(){m=!0});g.jcarousel=function(a,c){this.options=g.extend({},q,c||{});this.autostopped=this.locked=!1;this.buttonprevstate=this.buttonnextstate=this.buttonprev=this.buttonnext=this.list=this.clip=this.container=null;if(!c||c.rtl===void 0)this.options.rtl=(g(a).attr("dir")||g("html").attr("dir")||"").tolowercase()=="rtl";this.wh=!this.options.vertical?"width":"height";this.lt=!this.options.vertical? this.options.rtl?"right":"left":"top";for(var b="",d=a.classname.split(" "),f=0;f").parent();if(this.container.size()===0)this.container=this.clip.wrap("").parent();b!==""&&this.container.parent()[0].classname.indexof("jcarousel-skin")==-1&&this.container.wrap('');this.buttonprev=g(".jcarousel-prev",this.container);if(this.buttonprev.size()===0&&this.options.buttonprevhtml!==null)this.buttonprev=g(this.options.buttonprevhtml).appendto(this.container);this.buttonprev.addclass(this.classname("jcarousel-prev"));this.buttonnext= g(".jcarousel-next",this.container);if(this.buttonnext.size()===0&&this.options.buttonnexthtml!==null)this.buttonnext=g(this.options.buttonnexthtml).appendto(this.container);this.buttonnext.addclass(this.classname("jcarousel-next"));this.clip.addclass(this.classname("jcarousel-clip")).css({position:"relative"});this.list.addclass(this.classname("jcarousel-list")).css({overflow:"hidden",position:"relative",top:0,margin:0,padding:0}).css(this.options.rtl?"right":"left",0);this.container.addclass(this.classname("jcarousel-container")).css({position:"relative"}); !this.options.vertical&&this.options.rtl&&this.container.addclass("jcarousel-direction-rtl").attr("dir","rtl");var j=this.options.visible!==null?math.ceil(this.clipping()/this.options.visible):null,b=this.list.children("li"),e=this;if(b.size()>0){var h=0,i=this.options.offset;b.each(function(){e.format(this,i++);h+=e.dimension(this,j)});this.list.css(this.wh,h+100+"px");if(!c||c.size===void 0)this.options.size=b.size()}this.container.css("display","block");this.buttonnext.css("display","block");this.buttonprev.css("display", "block");this.funcnext=function(){e.next()};this.funcprev=function(){e.prev()};this.funcresize=function(){e.resizetimer&&cleartimeout(e.resizetimer);e.resizetimer=settimeout(function(){e.reload()},100)};this.options.initcallback!==null&&this.options.initcallback(this,"init");!m&&g.browser.safari?(this.buttons(!1,!1),g(window).bind("load.jcarousel",function(){e.setup()})):this.setup()};var f=g.jcarousel;f.fn=f.prototype={jcarousel:"0.2.8"};f.fn.extend=f.extend=g.extend;f.fn.extend({setup:function(){this.prevlast= this.prevfirst=this.last=this.first=null;this.animating=!1;this.tail=this.resizetimer=this.timer=null;this.intail=!1;if(!this.locked){this.list.css(this.lt,this.pos(this.options.offset)+"px");var a=this.pos(this.options.start,!0);this.prevfirst=this.prevlast=null;this.animate(a,!1);g(window).unbind("resize.jcarousel",this.funcresize).bind("resize.jcarousel",this.funcresize);this.options.setupcallback!==null&&this.options.setupcallback(this)}},reset:function(){this.list.empty();this.list.css(this.lt, "0px");this.list.css(this.wh,"10px");this.options.initcallback!==null&&this.options.initcallback(this,"reset");this.setup()},reload:function(){this.tail!==null&&this.intail&&this.list.css(this.lt,f.intval(this.list.css(this.lt))+this.tail);this.tail=null;this.intail=!1;this.options.reloadcallback!==null&&this.options.reloadcallback(this);if(this.options.visible!==null){var a=this,c=math.ceil(this.clipping()/this.options.visible),b=0,d=0;this.list.children("li").each(function(f){b+=a.dimension(this, c);f+1this.options.size)c=this.options.size;for(var b=a;b<=c;b++){var d=this.get(b);if(!d.length||d.hasclass("jcarousel-item-placeholder"))return!1}return!0}, get:function(a){return g(">.jcarousel-item-"+a,this.list)},add:function(a,c){var b=this.get(a),d=0,p=g(c);if(b.length===0)for(var j,e=f.intval(a),b=this.create(a);;){if(j=this.get(--e),e<=0||j.length){e<=0?this.list.prepend(b):j.after(b);break}}else d=this.dimension(b);p.get(0).nodename.touppercase()=="li"?(b.replacewith(p),b=p):b.empty().append(c);this.format(b.removeclass(this.classname("jcarousel-item-placeholder")),a);p=this.options.visible!==null?math.ceil(this.clipping()/this.options.visible): null;d=this.dimension(b,p)-d;a>0&&a=this.first&&a<=this.last)){var b=this.dimension(c);athis.options.size?this.options.size:a);for(var d=this.first>a,g=this.options.wrap!="circular"&&this.first<=1?1:this.first,j=d?this.get(g): this.get(this.last),e=d?g:g-1,h=null,i=0,k=!1,l=0;d?--e>=a:++ethis.options.size)))j=this.get(this.index(e)),j.length&&(h=this.add(e,j.clone(!0)));j=h;l=this.dimension(h);k&&(i+=l);if(this.first!==null&&(this.options.wrap=="circular"||e>=1&&(this.options.size===null||e<= this.options.size)))b=d?b+l:b-l}for(var g=this.clipping(),m=[],o=0,n=0,j=this.get(a-1),e=a;++o;){h=this.get(e);k=!h.length;if(h.length===0){h=this.create(e).addclass(this.classname("jcarousel-item-placeholder"));if(j.length===0)this.list.prepend(h);else j[d?"before":"after"](h);if(this.first!==null&&this.options.wrap=="circular"&&this.options.size!==null&&(e<=0||e>this.options.size))j=this.get(this.index(e)),j.length&&(h=this.add(e,j.clone(!0)))}j=h;l=this.dimension(h);if(l===0)throw error("jcarousel: no width/height set for items. this will cause an infinite loop. aborting..."); this.options.wrap!="circular"&&this.options.size!==null&&e>this.options.size?m.push(h):k&&(i+=l);n+=l;if(n>=g)break;e++}for(h=0;h0&&(this.list.css(this.wh,this.dimension(this.list)+i+"px"),d&&(b-=i,this.list.css(this.lt,f.intval(this.list.css(this.lt))-i+"px")));i=a+o-1;if(this.options.wrap!="circular"&&this.options.size&&i>this.options.size)i=this.options.size;if(e>i){o=0;e=i;for(n=0;++o;){h=this.get(e--);if(!h.length)break;n+=this.dimension(h);if(n>=g)break}}e=i-o+ 1;this.options.wrap!="circular"&&e<1&&(e=1);if(this.intail&&d)b+=this.tail,this.intail=!1;this.tail=null;if(this.options.wrap!="circular"&&i==this.options.size&&i-o+1>=1&&(d=f.intval(this.get(i).css(!this.options.vertical?"marginright":"marginbottom")),n-d>g))this.tail=n-g-d;if(c&&a===this.options.size&&this.tail)b-=this.tail,this.intail=!0;for(;a-- >e;)b+=this.dimension(this.get(a));this.prevfirst=this.first;this.prevlast=this.last;this.first=e;this.last=i;return b},animate:function(a,c){if(!this.locked&& !this.animating){this.animating=!0;var b=this,d=function(){b.animating=!1;a===0&&b.list.css(b.lt,0);!b.autostopped&&(b.options.wrap=="circular"||b.options.wrap=="both"||b.options.wrap=="last"||b.options.size===null||b.last=b.first&&c<=b.last)&&(c<1||c>b.options.size)&&b.remove(c)}; this.notify("onbeforeanimation");if(!this.options.animation||c===!1)this.list.css(this.lt,a+"px"),d();else{var f=!this.options.vertical?this.options.rtl?{right:a}:{left:a}:{top:a},d={duration:this.options.animation,easing:this.options.easing,complete:d};if(g.isfunction(this.options.animationstepcallback))d.step=this.options.animationstepcallback;this.list.animate(f,d)}}},startauto:function(a){if(a!==void 0)this.options.auto=a;if(this.options.auto===0)return this.stopauto();if(this.timer===null){this.autostopped= !1;var c=this;this.timer=window.settimeout(function(){c.next()},this.options.auto*1e3)}},stopauto:function(){this.pauseauto();this.autostopped=!0},pauseauto:function(){if(this.timer!==null)window.cleartimeout(this.timer),this.timer=null},buttons:function(a,c){if(a==null&&(a=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="first"||this.options.size===null||this.last=this.options.size))a=this.tail!==null&&!this.intail;if(c==null&&(c=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="last"||this.first>1),!this.locked&&(!this.options.wrap||this.options.wrap=="last")&&this.options.size!==null&&this.first==1))c=this.tail!==null&&this.intail;var b=this;this.buttonnext.size()>0?(this.buttonnext.unbind(this.options.buttonnextevent+".jcarousel",this.funcnext),a&&this.buttonnext.bind(this.options.buttonnextevent+".jcarousel",this.funcnext), this.buttonnext[a?"removeclass":"addclass"](this.classname("jcarousel-next-disabled")).attr("disabled",a?!1:!0),this.options.buttonnextcallback!==null&&this.buttonnext.data("jcarouselstate")!=a&&this.buttonnext.each(function(){b.options.buttonnextcallback(b,this,a)}).data("jcarouselstate",a)):this.options.buttonnextcallback!==null&&this.buttonnextstate!=a&&this.options.buttonnextcallback(b,null,a);this.buttonprev.size()>0?(this.buttonprev.unbind(this.options.buttonprevevent+".jcarousel",this.funcprev), c&&this.buttonprev.bind(this.options.buttonprevevent+".jcarousel",this.funcprev),this.buttonprev[c?"removeclass":"addclass"](this.classname("jcarousel-prev-disabled")).attr("disabled",c?!1:!0),this.options.buttonprevcallback!==null&&this.buttonprev.data("jcarouselstate")!=c&&this.buttonprev.each(function(){b.options.buttonprevcallback(b,this,c)}).data("jcarouselstate",c)):this.options.buttonprevcallback!==null&&this.buttonprevstate!=c&&this.options.buttonprevcallback(b,null,c);this.buttonnextstate= a;this.buttonprevstate=c},notify:function(a){var c=this.prevfirst===null?"init":this.prevfirst=j&&k<=e)&&a(k)}}},create:function(a){return this.format("",a)},format:function(a,c){for(var a=g(a),b=a.get(0).classname.split(" "),d=0;d