// JavaScript Document by tmato QQ11407215

function showImg(index){
var adwidth = $(".ximgdiv").width();
$("#tomatoximg").stop(true,false).animate({marginLeft: -adwidth*index},300);
var tomatoadf=$("#tomatoximg").eq(index*5+1).attr("src")
$("#tomatodimg").attr("src",tomatoadf); 	
}
//内容垂直居中居中
function tomatovMiddle(){
    var middleDiv=document.getElementById("webcon");
    var divHeight=middleDiv.offsetHeight;
    var bodyHeight=document.body.offsetHeight ;
    if(bodyHeight>divHeight)
      middleDiv.style.marginTop=-divHeight/2+"px";
   else{
      middleDiv.style.marginTop=0;
      middleDiv.style.top=0;
    }
}
//导航条
$(function(){
$("#divnavbg").css("opacity","0.6");
var tablen = $(".xiala").length;
$(".xiala").mouseover(function(){
var toindex = $(".xiala").index(this);
$(".fenlei").css("display","none")
$(".fenlei").eq(toindex).css("display","block")
});
$("#webcon").hover(function(){},function(){$(".fenlei").css("display","none")});


//产品滚动 
$(".ximgdiv table").attr("id","tomatoximg"); 
$("#tomatoximg img").css("cursor","pointer");

var len =Math.ceil($("#tomatoximg td").length / 5);
var index = 0;
var adTimer;
var tomatimg;
function marquee(){
index++;
if(index==len){index=0;}
showImg(index);
}
adTimer = setInterval(marquee,3000)
$("#leftbar").click(function(){
index--;
if(index<0){index=len-1;}
showImg(index);
});
$("#rightbar").click(function(){
index++;
if(index==len){index=0;}
showImg(index);
});
$("#picadffs").hover(function(){
clearInterval(adTimer);
},function(){
adTimer = setInterval(function(){
index++;
if(index==len){index=0;}
showImg(index);
},3000);
});
$("#tomatoximg img").click(function(e){
e.preventDefault();
tomatimg=$(this).attr("src");
$("#tomatodimg").attr("src",tomatimg);
})


 


})

