/* bxslider v2.0 plugin developed by: steven wanderski http://bxslider.com http://stevenwanderski.com released under the gpl license: http://www.gnu.org/licenses/gpl.html */ (function($) { $.fn.bxslider = function(options) { var defaults = { alignment: 'horizontal', controls: true, speed: 500, pager: true, margin: 0, next_text: 'next', next_image: '', prev_text: 'prev', prev_image: '', auto: false, pause: 3500, auto_direction: 'next', auto_hover: true, auto_controls: false, ticker: false, ticker_controls: false, ticker_direction: 'next', ticker_hover: true, stop_text: 'stop', start_text: 'start', wrapper_class: 'bxslider_wrap' }; var o = $.extend(defaults, options); return this.each(function() { var $this = $(this); var $kids = $this.children(); var l = $this.children().length; var first = $this.children(':first').clone(); var last = $this.children(':last').clone(); var w = 0, h = 0, current_temp = 0, pos = 0, d = 0; var is_working = false, playing = true, tick_play = true; var current = 1; var ease = 'swing', side = '', t = ''; var ani = {}; $this.append(first).prepend(last); $this.wrap('
'); $this.parent().wrap('
'); if (o.alignment == 'horizontal') { $this.children().css({ 'float': 'left', 'liststyle': 'none', 'marginright': o.margin }); w = first.outerwidth(true); $this.css({ 'width': '99999px', 'position': 'relative', 'left': -w }); $this.parent().css({ 'position': 'relative', 'overflow': 'hidden', 'width': w - o.margin }); } else if (o.alignment == 'vertical') { $kids.each(function() { if ($(this).height() > h) { h = $(this).height(); } }); w = first.outerwidth(); $this.children().css({ 'height': h, 'liststyle': 'none', 'marginbottom': o.margin }); $this.css({ 'height': '99999px', 'width': w, 'position': 'relative', 'top': -(h + o.margin) }); $this.parent().css({ 'position': 'relative', 'overflow': 'hidden', 'height': h }) } if (o.pager && !o.ticker) { $this.parent().after('
'); var $a; $kids.each(function(index) { $a = $('' + (index + 1) + ''); $this.parent().siblings('.bx_pager').append($a); $a.click(function() { is_working = false; tick_play = false; $this.stop(); move_slide(index + 1); current = index + 1; if (o.auto) { clearinterval(t); $this.parent().siblings('.auto_controls').find('a').html(o.start_text); playing = false; } else if (o.ticker) { $this.parent().siblings('.ticker_controls').find('a').html(o.start_text); playing = false; } return false; }); }); set_active(1); } if (o.controls && !o.ticker) { if (o.next_image != '' || o.prev_image != '') { $this.parent().after(''); } else { $this.parent().after(''); } $this.parent().siblings('.next').click(function() { if (!is_working) { move_slide(++current); } if (o.auto) { clearinterval(t); $this.parent().siblings('.auto_controls').find('a').html(o.start_text); playing = false; } return false; }); $this.parent().siblings('.prev').click(function() { if (!is_working) { move_slide(--current); } if (o.auto) { clearinterval(t); $this.parent().siblings('.auto_controls').find('a').html(o.start_text); playing = false; } return false; }); } if (o.auto && !o.ticker) { t = setinterval(function() { if (o.auto_direction == 'next') { move_slide(++current); } else { move_slide(--current); } }, o.pause); if (o.auto_hover) { $this.hover(function() { clearinterval(t); }, function() { if (playing) { t = setinterval(function() { if (o.auto_direction == 'next') { move_slide(++current); } else { move_slide(--current); } }, o.pause); } }); } if (o.auto_controls) { $this.parent().after('
' + o.stop_text + '
'); $this.parent().siblings('.auto_controls').find('a').click(function() { if (playing) { clearinterval(t); $(this).html(o.start_text); playing = false; } else { t = setinterval(function() { if (o.auto_direction == 'next') { move_slide(++current); } else { move_slide(--current); } }, o.pause); $(this).html(o.stop_text); playing = true; } return false; }); } } if (o.ticker) { var tick_play = true; tick_slide(); $this.hover(function() { $this.stop(); }, function() { if (tick_play) { tick_slide(); } }); if (o.ticker_controls) { $this.parent().after('
' + o.stop_text + '
'); $this.parent().siblings('.ticker_controls').find('a').click(function() { if (tick_play) { $this.stop(); $(this).html(o.start_text); tick_play = false; } else { is_working = false; $(this).html(o.stop_text) tick_slide(); tick_play = true; } return false; }); } } function tick_slide() { if (o.ticker_direction == 'next' && o.alignment == 'horizontal') { $this.animate({ left: '-=5px' }, o.speed / 5, 'linear', function() { if (parseint($this.css('left')) <= -((l + 1) * w)) { $this.css('left', -w); } tick_slide(); }); } else if (o.ticker_direction == 'prev' && o.alignment == 'horizontal') { $this.animate({ left: '+=5px' }, o.speed / 5, 'linear', function() { if (parseint($this.css('left')) >= -(w)) { $this.css('left', -((l + 1) * w)); } tick_slide(); }); } else if (o.ticker_direction == 'next' && o.alignment == 'vertical') { $this.animate({ top: '-=5px' }, o.speed / 5, 'linear', function() { if (parseint($this.css('top')) <= -((l + 1) * (h + o.margin))) { $this.css('top', -(h + o.margin)); } tick_slide(); }); } else if (o.ticker_direction == 'prev' && o.alignment == 'vertical') { $this.animate({ top: '+=4px' }, o.speed / 5, 'linear', function() { if (parseint($this.css('top')) > -(h + o.margin)) { $this.css('top', -((l + 1) * (h + o.margin - 1))); } tick_slide(); }); } } function move_slide(num) { if (o.ticker) { ease = 'linear'; } if (!is_working) { if (o.alignment == 'horizontal') { d = w; side = 'left'; } else if (o.alignment == 'vertical') { d = h + o.margin; side = 'top'; } pos = num * d; ani[side] = -pos; is_working = true; $this.animate(ani, o.speed, ease, function() { is_working = false; if (current > l) { $this.css(side, -d); current = 1; } else if (current < 1) { $this.css(side, -(d * l)); current = l; } set_active(current); }); } } function set_active(num) { if (o.pager) { $('.bx_pager a').removeclass('active').eq(num - 1).addclass('active'); } } }); }; })(jquery);