  // JavaScript Document
$(function(){
	/*---导航---*/
  /* $("#nav>li").mouseover(function(){
	         $(this).children("a").addClass("current");
			 $(this).siblings().find("a").removeClass("current");
			 $(this).find(".subNav").show();
	   }).mouseout(function(){
	         $(this).find(".subNav").hide();
	   });*/

	
	/*---banner---*/
	imgLength=$(".prolists img").length;
	//图片宽度
	imgWidth=$(".prolists img").width();
    //向左移动的距离就是：个数*宽度
	$(".prolists").width(imgLength*imgWidth);
    $(".banner .ctrl span").eq(0).addClass("red").fadeIn(1000);
   //鼠标经过页码
	$(".banner .ctrl span").mouseover(function(){	
	    $(this).addClass("red").fadeIn(1000).siblings().removeClass("red");	
		index1=$(this).index();  //获取当前索引值
		$(".banner .prolists").stop().animate({left:"-"+imgWidth*index1},{duration:1000,queue:false});	
	})	
//--------------------自动切换知识点--------------------
    //使用trigger模拟用户的鼠标经过操作
    //隔n秒钟执行一次触发  setInterval(function(){}，1000）
    //触发当前页的下一页
	int=setInterval(function(){
	//获得当前页的索引值，自动触发下一页的mouseover事件
    index=$(".banner .red").index(".ctrl span");
	//判断一下当前页是否是最后一页
	if(index+1==imgLength){
		nextindex=0;		
	}
	else{
		nextindex=index+1;
	}
	$(".ctrl span").eq(nextindex).trigger("mouseover");		
	},4000);
	//当鼠标经过图片时，大图显示	
	$(".prolists img").mouseover(function(){
		clearInterval(int);
	}).mouseout(function(){
	int=setInterval(function(){
	//获得当前页的索引值，自动触发下一页的mouseover事件
    index=$(".banner .red").index(".ctrl span");
	//判断一下当前页是否是最后一页
	if(index+1==imgLength){
		nextindex=0;		
	}
	else{
		nextindex=index+1;
	}
	$(".ctrl span").eq(nextindex).trigger("mouseover");		
	},4000);})
	
	
	/*----图片滚动#left .two----*/
  var page=1;//定义默认当前页为第一页
  var num=1;//一页显示5页
  var imgNum=$("#por img").length;//图片的总长度
  //一共多少页（Math.ceil(小数点向上取整)）
  var pageMax=Math.ceil(imgNum/num);
  $(".right").click(function()
  {
	  //当点击.right的时候判断是否处于动画状态
	 if(!$("#pors").is(":animated"))
	 {
		 //如果是，判断是否是最后一页
		if(page==pageMax)
		{
			//如果是让它回到第一页
			$("#pors").animate({left:"0"},1000);
			page=1;
		}
		else
	    { 
		   //如果不是继续往下走
		   $("#pors").animate({left:"-=696px"},1000);
		   page++;	
	    }
	 }  
  })
  $(".left").click(function()
  {
	  //当点击.left的时候判断是否处于动画状态
	 if(!$("#pors").is(":animated"))
	 {
		 //如果是，判断是否是第一页
		if(page==1)
		{
			//如果是让它回到最后一页
			$("#pors").animate({left:"-"+696*(pageMax-1)+"px"},1000);
			page=pageMax;
		}
		else
	    { 
		   //如果不是继续往下走
		   $("#pors").animate({left:"+=696px"},1000);
		   page--;	
	    }
	 }  
  })
});