;(function($){"use strict";$.fn.bjqs=function(o){var defaults={width:700,height:300,animtype:'fade',animduration:450,animspeed:4000,automatic:true,showcontrols:true,centercontrols:true,nexttext:'Next',prevtext:'Prev',showmarkers:true,centermarkers:false,keyboardnav:true,hoverpause:true,usecaptions:true,randomstart:false,responsive:true};var settings=$.extend({},defaults,o);var $wrapper=this,$slider=$wrapper.find('ul.bjqs'),$slides=$slider.children('li'),$c_wrapper=null,$c_fwd=null,$c_prev=null,$m_wrapper=null,$m_markers=null,$canvas=null,$clone_first=null,$clone_last=null;var state={slidecount:$slides.length,animating:false,paused:false,currentslide:1,nextslide:0,currentindex:0,nextindex:0,interval:null};var responsive={width:null,height:null,ratio:null};var vars={fwd:'forward',prev:'previous'};var init=function(){$slides.addClass('bjqs-slide');if(settings.responsive){conf_responsive();} else{conf_static();} if(state.slidecount>1){if(settings.randomstart){conf_random();} if(settings.showcontrols){conf_controls();} if(settings.showmarkers){conf_markers();} if(settings.keyboardnav){conf_keynav();} if(settings.hoverpause&&settings.automatic){conf_hoverpause();} if(settings.animtype==='slide'){conf_slide();}}else{settings.automatic=false;} if(settings.usecaptions){conf_captions();} if(settings.animtype==='slide'&&!settings.randomstart){state.currentindex=1;state.currentslide=2;} $slider.show();$slides.eq(state.currentindex).show();if(settings.automatic){state.interval=setInterval(function(){go(vars.fwd,false);},settings.animspeed);}};var conf_responsive=function(){responsive.width=$wrapper.outerWidth();responsive.ratio=responsive.width/settings.width,responsive.height=settings.height*responsive.ratio;if(settings.animtype==='fade'){$slides.css({'height':settings.height,'width':'100%'});$slides.children('img').css({'height':settings.height,'width':'100%'});$slider.css({'height':settings.height,'width':'100%'});$wrapper.css({'height':settings.height,'max-width':settings.width,'position':'relative'});if(responsive.width');if(settings.responsive&&(responsive.width');$c_fwd=$('
  • '+settings.nexttext+'
  • ');$c_prev=$('
  • '+settings.prevtext+'
  • ');$c_wrapper.on('click','a',function(e){e.preventDefault();var direction=$(this).attr('data-direction');if(!state.animating){if(direction===vars.fwd){go(vars.fwd,false);} if(direction===vars.prev){go(vars.prev,false);}}});$c_prev.appendTo($c_wrapper);$c_fwd.appendTo($c_wrapper);$c_wrapper.appendTo($wrapper);if(settings.centercontrols){$c_wrapper.addClass('v-centered');var offset_px=($wrapper.height()-$c_fwd.children('a').outerHeight())/2,ratio=(offset_px/settings.height)*100,offset=ratio+'%';$c_fwd.find('a').css('top',offset);$c_prev.find('a').css('top',offset);}};var conf_markers=function(){$m_wrapper=$('
      ');$.each($slides,function(key,slide){var slidenum=key+1,gotoslide=key+1;if(settings.animtype==='slide'){gotoslide=key+2;} var marker=$('
    1. '+slidenum+'
    2. ');if(slidenum===state.currentslide){marker.addClass('active-marker');} marker.on('click','a',function(e){e.preventDefault();if(!state.animating&&state.currentslide!==gotoslide){go(false,gotoslide);}});marker.appendTo($m_wrapper);});$m_wrapper.appendTo($wrapper);$m_markers=$m_wrapper.find('li');if(settings.centermarkers){$m_wrapper.addClass('h-centered');var offset=(settings.width-$m_wrapper.width())/2;$m_wrapper.css('left',offset);}};var conf_keynav=function(){$(document).keyup(function(event){if(!state.paused){clearInterval(state.interval);state.paused=true;} if(!state.animating){if(event.keyCode===39){event.preventDefault();go(vars.fwd,false);}else if(event.keyCode===37){event.preventDefault();go(vars.prev,false);}} if(state.paused&&settings.automatic){state.interval=setInterval(function(){go(vars.fwd);},settings.animspeed);state.paused=false;}});};var conf_hoverpause=function(){$wrapper.hover(function(){if(!state.paused){clearInterval(state.interval);state.paused=true;}},function(){if(state.paused){state.interval=setInterval(function(){go(vars.fwd,false);},settings.animspeed);state.paused=false;}});};var conf_captions=function(){$.each($slides,function(key,slide){var caption=$(slide).children('img:first-child').attr('title');if(!caption){caption=$(slide).children('a').find('img:first-child').attr('title');} if(caption){caption=$('

      '+caption+'

      ');caption.appendTo($(slide));}});};var conf_random=function(){var rand=Math.floor(Math.random()*state.slidecount)+1;state.currentslide=rand;state.currentindex=rand-1;};var set_next=function(direction){if(direction===vars.fwd){if($slides.eq(state.currentindex).next().length){state.nextindex=state.currentindex+1;state.nextslide=state.currentslide+1;} else{state.nextindex=0;state.nextslide=1;}} else{if($slides.eq(state.currentindex).prev().length){state.nextindex=state.currentindex-1;state.nextslide=state.currentslide-1;} else{state.nextindex=state.slidecount-1;state.nextslide=state.slidecount;}}};var go=function(direction,position){if(!state.animating){state.animating=true;if(position){state.nextslide=position;state.nextindex=position-1;} else{set_next(direction);} if(settings.animtype==='fade'){if(settings.showmarkers){$m_markers.removeClass('active-marker');$m_markers.eq(state.nextindex).addClass('active-marker');} $slides.eq(state.currentindex).fadeOut(settings.animduration);$slides.eq(state.nextindex).fadeIn(settings.animduration,function(){state.animating=false;state.currentslide=state.nextslide;state.currentindex=state.nextindex;});} if(settings.animtype==='slide'){if(settings.showmarkers){var markerindex=state.nextindex-1;if(markerindex===state.slidecount-2){markerindex=0;} else if(markerindex===-1){markerindex=state.slidecount-3;} $m_markers.removeClass('active-marker');$m_markers.eq(markerindex).addClass('active-marker');} if(settings.responsive&&(responsive.width