/**
 * showbox
 *
 * @License URI:http://www.gnu.org/licenses/gpl-2.0.html
 */

 /* It would be great if you’d leave the link back to my site in the footer */
$(function(){
var $cur=1;
var $i=1;
var $len=$('.showbox>ul>li').length;
var $pages=Math.ceil($len/$i);
var $w=$('.ibox').width();
var $showbox=$('.showbox');
var $num=$('span.num li');
var $pre=$('span.pre');
var $next=$('span.next');
var $autoFun;autoSlide();$pre.click(function()
{if(!$showbox.is(':animated'))
{if($cur==1){$showbox.animate({left:'-='+$w*($pages-1)},500);$cur=$pages}else{$showbox.animate({left:'+='+$w},500);$cur--}$num.eq($cur-1).addClass('numcur').siblings().removeClass('numcur')}});$next.click(function()
{if(!$showbox.is(':animated')){if($cur==$pages){$showbox.animate({left:0},500);$cur=1}else{$showbox.animate({left:'-='+$w},500);$cur++}$num.eq($cur-1).addClass('numcur').siblings().removeClass('numcur')}});$num.click(function()
{if(!$showbox.is(':animated')){var $index=$num.index(this);$showbox.animate({left:'-'+($w*$index)},500);$cur=$index+1;$(this).addClass('numcur').siblings().removeClass('numcur')}});clearFun($showbox);clearFun($pre);clearFun($next);clearFun($num);function clearFun(elem){elem.hover(function(){clearAuto()},function(){autoSlide()})}function autoSlide(){$next.trigger('click');$autoFun=setTimeout(autoSlide,3000)}function clearAuto(){clearTimeout($autoFun)}});
