function imgShow(imgList,imgShow,number,width,direction){ var objUl = imgList.find("ol"); var objLi = imgList.find("li"); // var objCImg = objLi.children("img"); // var objImg = imgShow.find("img"); var objUp = imgList.find('.last_year'); var objDown = imgList.find('.next-year'); if(direction == "left"){ objUl.width(objLi.length*width*2); }else{ objUl.height(objLi.length*width*2); } objLi.click(function(){ proSlideRun(objLi.index(this)); }) objUp.click(function(){ proSlideRun(objLi.index(objUl.children("li.cur"))-1); }) objDown.click(function(){ proSlideRun(objLi.index(objUl.children("li.cur"))+1); }) function proSlideRun(n){ if(n>=objLi.length){n=objLi.length-1;return false;} if(n<0){n=0;return false;} if(n<=1){ if(direction == "left"){ objUl.animate({"left":0},300); }else{ objUl.animate({"margin-top":0},300); }; }else if(n>=objLi.length-(number-1) && objLi.length-(number-1)>0){ if(direction == "left"){ objUl.animate({"left":-(objLi.length-number)*width+"px"},300); }else{ objUl.animate({"margin-top":-(objLi.length-number)*width+"px"},300); }; }else if(objLi.length-(number-1)>0){ if(direction == "left"){ objUl.animate({"left":-(n-1)*width+"px"},300); }else{ objUl.animate({"margin-top":-(n-1)*width+"px"},300); }; } objLi.removeClass("cur").eq(n).addClass("cur"); imgShow.css('display','none').eq(n).css('display','block'); }; proSlideRun(0); }