/* fucus*/ $(function() { var swidth = $("#focus").width(); //��ȡ����ͼ�ŀ�ȣ���ʾ����� var len = $("#focus ul li").length; //��ȡ����ͼ���� var index = 0; var pictimer; //���´���������ְ�ť�ͱ�ť��i�͸������������һҳ����һҳ������ť var btn = "
"; for(var i=0; i < len; i++) { btn += ""; } btn += "
"; $("#focus").append(btn); $("#focus .btnbg").css("opacity",0.3); //ϊс��ť�����껬���¼�������ʾ��ӧ������ $("#focus .btn span").css("opacity",0.3).mouseenter(function() { index = $("#focus .btn span").index(this); showpics(index); }).eq(0).trigger("mouseenter"); //��һҳ����һҳ��ť͸���ȴ��� $("#focus .prenext").css("opacity",0.1).hover(function() { $(this).stop(true,false).animate({"opacity":"0.3"},300); },function() { $(this).stop(true,false).animate({"opacity":"0.1"},300); }); //��һҳ��ť $("#focus .pre").click(function() { index -= 1; if(index == -1) {index = len - 1;} showpics(index); }); //��һҳ��ť $("#focus .next").click(function() { index += 1; if(index == len) {index = 0;} showpics(index); }); //����ϊ���ҹ�����������liԪ�ض�����ͬһ�����󸡶�������������ҫ�������χulԪ�صŀ�� $("#focus ul").css("width",swidth * (len)); //��껬�ͻ���ͼʱֹͣ�զ����ţ�����ʱ��ʼ�զ����� $("#focus").hover(function() { clearinterval(pictimer); },function() { pictimer = setinterval(function() { showpics(index); index++; if(index == len) {index = 0;} },4000); //��4000�����զ����ŵļ�����λ������ }).trigger("mouseleave"); //��ʾͼƭ���������ݽ��յ�indexֵ��ʾ��ӧ������ function showpics(index) { //��ͨ�л� var nowleft = -index*swidth; //����indexֵ����ulԪ�ص�leftֵ $("#focus ul").stop(true,false).animate({"left":nowleft},300); //ͨ��animate()����ulԪ�ع������������position //$("#focus .btn span").removeclass("on").eq(index).addclass("on"); //ϊ��ǰ�i�ť�л���ѡ�е�ч�� $("#focus .btn span").stop(true,false).animate({"opacity":"0.4"},300).eq(index).stop(true,false).animate({"opacity":"1"},300); //ϊ��ǰ�i�ť�л���ѡ�е�ч�� } });