function tabImg(dir) {
var num = $(".logoImg img").length-1;//有多少张图片
var hot = $(".count").children("."+dir);//被点击的按钮
var logoImg = $(".logoImg");
var imgWidth = $(".logoImg img:first").outerWidth() + 6;//得到每张图片的宽度
var marginLeft = logoImg.css("margin-left");//得到距离左边的位置
if(dir == "left"){
if(Math.abs(parseInt(marginLeft,10)) < parseInt(imgWidth,10)*num){
logoImg.animate({"margin-left":parseInt(marginLeft,10) - parseInt(imgWidth,10)},1000);
var countHover = $(".countHover");
$(".count span").removeClass("countHover");
countHover.next("span").not(".left").addClass("countHover");
}
}else if(dir == "right") {
if(Math.abs(parseInt(marginLeft,10)) >= parseInt(imgWidth,10) &&
Math.abs(parseInt(marginLeft,10)) <= parseInt(imgWidth,10)*num ){
logoImg.animate({"margin-left":parseInt(marginLeft,10) + parseInt(imgWidth,10)},1000);
var countHover = $(".countHover");
$(".count span").removeClass("countHover");
countHover.prev("span").not(".right").addClass("countHover");
}
}
}
var num = $(".logoImg img").length-1;//有多少张图片
var hot = $(".count").children("."+dir);//被点击的按钮
var logoImg = $(".logoImg");
var imgWidth = $(".logoImg img:first").outerWidth() + 6;//得到每张图片的宽度
var marginLeft = logoImg.css("margin-left");//得到距离左边的位置
if(dir == "left"){
if(Math.abs(parseInt(marginLeft,10)) < parseInt(imgWidth,10)*num){
logoImg.animate({"margin-left":parseInt(marginLeft,10) - parseInt(imgWidth,10)},1000);
var countHover = $(".countHover");
$(".count span").removeClass("countHover");
countHover.next("span").not(".left").addClass("countHover");
}
}else if(dir == "right") {
if(Math.abs(parseInt(marginLeft,10)) >= parseInt(imgWidth,10) &&
Math.abs(parseInt(marginLeft,10)) <= parseInt(imgWidth,10)*num ){
logoImg.animate({"margin-left":parseInt(marginLeft,10) + parseInt(imgWidth,10)},1000);
var countHover = $(".countHover");
$(".count span").removeClass("countHover");
countHover.prev("span").not(".right").addClass("countHover");
}
}
}