/* Copyright (C) 2007 - 2011 YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

(function(b){var d=function(){};d.prototype=b.extend(d.prototype,{name:"slideshow",options:{index:0,width:"auto",height:"auto",autoplay:!0,interval:3E3,tpl:'<div class="slideshow"><div class="element" /><div class="next"></div><div class="prev"></div>'},nav:null,initialize:function(a,d){var c=this,e=0,i=0;this.options=b.extend({},b.widgetkit.effects.defaults,this.options,d);this.element=a;this.wrapper=b.tmpl(this.options.tpl,b.extend({element:a},this.options)).insertAfter(a);b(".element",this.wrapper).replaceWith(a);
a.children().each(function(){e=Math.max(e,b(this).height());i=Math.max(i,b(this).width())});if(this.options.height=="auto")this.options.height=e;if(this.options.width=="auto")this.options.width=i;this.wrapper.css({position:"relative",width:this.options.width});this.slides=b("ul.slides:first",this.wrapper).css({position:"relative",overflow:"hidden",height:this.options.height}).children().css({top:"0px",left:"0px",position:"absolute",width:this.wrapper.width(),height:this.options.height}).hide();this.button=
{};this.index=this.slides[this.options.index]?this.options.index:0;this.button.next=b("div.next:first",this.wrapper).bind("click",function(){c.stop();c.nextSlide()});this.button.prev=b("div.prev:first",this.wrapper).bind("click",function(){c.stop();c.prevSlide()});if(this.wrapper.find(".nav:first").length)this.nav=this.wrapper.find(".nav:first"),this.nav.children().each(function(a){b(this).bind("click",function(){c.stop();c.slides[a]&&c.show(a)})}),b(this.nav.children().get(this.index)).addClass("active");
b(this.slides.get(this.index)).show();this.timer=null;this.hover=!1;this.wrapper.hover(function(){c.hover=!0},function(){c.hover=!1});this.options.autoplay&&this.start();"ontouchend"in document&&(a.bind("touchstart",function(c){function d(a){if(f){var b=a.originalEvent.touches?a.originalEvent.touches[0]:a;g={time:(new Date).getTime(),coords:[b.pageX,b.pageY]};Math.abs(f.coords[0]-g.coords[0])>10&&a.preventDefault()}}var e=c.originalEvent.touches?c.originalEvent.touches[0]:c,f={time:(new Date).getTime(),
coords:[e.pageX,e.pageY],origin:b(c.target)},g;a.bind("touchmove",d).one("touchend",function(){a.unbind("touchmove",d);f&&g&&g.time-f.time<1E3&&Math.abs(f.coords[0]-g.coords[0])>30&&Math.abs(f.coords[1]-g.coords[1])<75&&f.origin.trigger("swipe").trigger(f.coords[0]>g.coords[0]?"swipeleft":"swiperight");f=g=void 0})}),this.wrapper.bind("swipeleft",function(){c.stop();c.nextSlide()}).bind("swiperight",function(){c.stop();c.prevSlide()}))},nextSlide:function(){this.show(this.slides[this.index+1]?this.index+
1:0)},prevSlide:function(){this.show(this.index-1>-1?this.index-1:this.slides.length-1)},show:function(a){if(!(this.index==a||this.fx))this.current=b(this.slides.get(this.index)),this.next=b(this.slides.get(a)),this.animated=this.options.animated,this.duration=this.options.duration,this.easing=this.options.easing,this.dir=a>this.index?"right":"left",this.nav&&b(this.nav.children().removeClass("active").get(a)).addClass("active"),this.index=a,b.widgetkit.effects.show.apply(this)},start:function(){if(!this.timer){var a=
this;this.timer=setInterval(function(){a.hover||a.nextSlide()},this.options.interval)}},stop:function(){this.timer&&clearInterval(this.timer)}});b.fn[d.prototype.name]=function(){var a=arguments,h=a[0]?a[0]:null;return this.each(function(){var c=b(this);if(d.prototype[h]&&c.data(d.prototype.name)&&h!="initialize")c.data(d.prototype.name)[h].apply(c.data(d.prototype.name),Array.prototype.slice.call(a,1));else if(!h||b.isPlainObject(h)){var e=new d;d.prototype.initialize&&e.initialize.apply(e,b.merge([c],
a));c.data(d.prototype.name,e)}else b.error("Method "+h+" does not exist on jQuery."+d.name)})}})(jQuery);

