(function($){$.fn.simpleslider=function(settings){var defaults={auto:true,interval:3500,speed:1000,easing:'swing',direction:'vertical',continuous:'true',buttons:false,autobuttonsize:false,previoustext:'Previous',nexttext:'Next'};settings=$.extend({},defaults,settings);$(this).each(function(){var $this,$frame,$wrapper,wrapperHeight,containerHeight,frameHeight,wrapperWidth,containerWidth,frameWidth,frameCount,frameNumber;$this=$(this);$frame=$this.children().addClass('frame');$wrapper=$this.wrap('<div id="'+$this.attr('id')+'-wrapper" />').parent('#'+$this.attr('id')+'-wrapper')
frameCount=$frame.size();wrapperHeight=0;frameHeight=0;$frame.each(function(){if($(this).height()>frameHeight)frameHeight=$(this).height();if($(this).outerHeight(true)>wrapperHeight)wrapperHeight=$(this).outerHeight(true);});wrapperWidth=$this.width();frameWidth=$frame.width();frameNumber=1;$wrapper.css({width:wrapperWidth,height:wrapperHeight,overflow:'hidden'});if(settings.direction=='horizontal'){containerWidth=wrapperWidth*frameCount;containerHeight=wrapperHeight;}else if(settings.direction=='vertical'){containerWidth=wrapperWidth;containerHeight=wrapperHeight*frameCount;}
$this.css({width:containerWidth,height:containerHeight});$frame.css({display:'block',float:'left',height:frameHeight,width:frameWidth});if(settings.buttons){$wrapper.before('<input type="button" id="'+$this.attr('id')+'-previous_button" class="button" value="'+settings.previoustext+'" />').after('<input type="button" id="'+$this.attr('id')+'-next_button" class="button" value="'+settings.nexttext+'" />');}
if(settings.autobuttonsize&&settings.direction=='horizontal'){$wrapper.parent().find('.button').css({height:containerHeight});}else if(settings.autobuttonsize&&(settings.direction=='vertical')){$wrapper.parent().find('.button').css({width:containerWidth});}
$('#'+$this.attr('id')+'-previous_button').click(function(e){e.preventDefault();prevFrame();stopTimer();});$('#'+$this.attr('id')+'-next_button').click(function(e){e.preventDefault();nextFrame();stopTimer();});checkButtons();if(settings.auto==true){startTimer(settings.interval);checkHover();}
function move(toFrame){if(toFrame!==undefined){if(settings.direction=='horizontal'){$this.animate({marginLeft:(-1)*(toFrame-1)*wrapperWidth+'px'},settings.speed,settings.easing);}else if(settings.direction=='vertical'){$this.animate({marginTop:(-1)*(toFrame-1)*wrapperHeight+'px'},settings.speed,settings.easing);}}else{if(settings.direction=='horizontal'){$this.animate({marginLeft:(-1)*(frameNumber-1)*wrapperWidth+'px'},settings.speed,settings.easing);}else if(settings.direction=='vertical'){$this.animate({marginTop:(-1)*(frameNumber-1)*wrapperHeight+'px'},settings.speed,settings.easing);}}}
function prevFrame(){frameNumber--;if(frameNumber>0){move();}else{move(frameCount);frameNumber=frameCount;}
checkButtons();}
function nextFrame(){frameNumber++;if(frameNumber<=frameCount){move();}else{move(1);frameNumber=1;}
checkButtons();}
function checkButtons(){if(frameNumber==1){$('#'+$this.attr('id')+'-previous_button').attr('disabled','disabled').addClass('disabled');}else{$('#'+$this.attr('id')+'-previous_button').removeAttr('disabled').removeClass('disabled');}
if(frameNumber==frameCount){$('#'+$this.attr('id')+'-next_button').attr('disabled','disabled').addClass('disabled');}else{$('#'+$this.attr('id')+'-next_button').removeAttr('disabled').removeClass('disabled');;}}
function startTimer(interval){auto=setInterval(nextFrame,interval);}
function stopTimer(){if(settings.auto!==false){clearInterval(auto);}}
function checkHover(){$wrapper.hover(function(){stopTimer();},function(){startTimer(settings.interval);});}});}})(jQuery);
