$(function(){
  var px=860,i=1,turnpic,turnsmallpic,turnI=1;
  $(".products4_butl").click(function()
  {
	i++
	if(i>2){i=2;}
	$(".products4_img ul").animate({marginLeft:"-"+px*i+"px"},500);
  });
  $(".products4_butr").click(function()
  {
	i--;
	if(i<0){i=0;}
	$(".products4_img ul").animate({marginLeft:"-"+px*i+"px"},500);
  });
  $.fn.turnimg=function(turnI,time){
	var j=0;
	this.each(function()
	{
	  j++
	  if(turnI==j)
	  {
		$(".banner div img").hide();
		$(this).fadeIn(time);
	  }
	});
	j=0
	$(".banner_text ul li a").each(function()
	{
	  j++
	  if(turnI==j)
	  {
		$(".banner_text ul li a").attr("class","");
		$(this).attr("class","current");
	  }
	});
  }
  $.fn.fnturnpic=function()
  {
	if(turnI<4){turnI++;}else{turnI=1;}
	$(this).turnimg(turnI,500)
  }
  turnpic=setInterval("$('.banner div img').fnturnpic()",3000)
  $(".banner_text ul li a").mouseover(function()
  {
	clearTimeout(turnpic);
	clearTimeout(turnsmallpic);
	turnI=$(this).attr("rel");
	turnsmallpic=setTimeout("$('.banner div img').turnimg("+turnI+",300)",100)
  });
  $(".banner_text ul li a").mouseout(function()
  {
	clearTimeout(turnpic);
	turnpic=setInterval("$('.banner div img').fnturnpic()",3000);
  });
});