//功能：首页5图片轮换显示效果 修正了bug modified 2010-12-30
 $(document).ready(function (){
     //初始化div
      var num = $('#thebox ul li').length; //alert(num)
	  var numMax =num-1;
	  var img_w=720;//图片的宽度
	  var currtNum = 0;
	  var imgTime =null;
	  
      $('#thebox ul').width(parseInt(img_w*num));
	  
	  timeAuto();
	  
	 //next播放
	 $('#label_r').click(
	   function()
	    {
		  if(imgTime){clearInterval(imgTime);}
		  
		  if(currtNum<numMax)
	      {
            currtNum++;
			//$('#text').text(currtNum);
            $('#thebox ul').animate({"marginLeft":-(img_w*currtNum)},250);
			$('#label_l img').eq(0).show();
			$(this).attr('title','查看下一张');
			$('#label_l').attr('title','查看上一张');
	      }
		  if(currtNum==numMax)
		  {
		    $(this).attr('title','已经到尽头了');
			$('#label_l').attr('title','查看上一张');
		    $('#label_r img').eq(0).hide();
			$('#label_r img').eq(1).show();
		  };

		}
	 );
	 
	 $('#label_l').click(
	   function()
	    {
		  if(currtNum>0)
	      {
            currtNum--;
            $('#thebox ul').animate({"marginLeft":-(img_w*currtNum)},250);
			$('#label_r img').eq(0).show();
			$(this).attr('title','查看上一张');
			$('#label_r').attr('title','查看下一张');
	      }
		  if(currtNum==0)
		  {
		    $(this).attr('title','已经到尽头了');
			$('#label_r').attr('title','查看下一张');
		    $('#label_l img').eq(0).hide();
			$('#label_l img').eq(1).show();
		  };

		}
	 );
	
function timeAuto()
{
   	 //自动播放
    imgTime = setInterval(function(){
	
	    if(currtNum<numMax)
		{ currtNum++;
		  //$('#textauto').text(currtNum)
		  showTheImg(currtNum);
		}else
		{
		  currtNum=0;
		  showTheImg(currtNum); 
		  $('#label_r img').eq(0).show();
		  $('#label_r img').eq(1).hide(); 
		}

	} ,10000); 
}	
	
function showTheImg(i)
{
   $('#thebox ul').animate({"marginLeft":-(img_w*i)},250);
}

 });


function showtopceng(i)
{
  if(i==1)
  {
    $("#ceng1").animate({opacity: 0.95},300).show();$("#ceng2").hide();$("#ceng3").hide();
	$("#closebtn1").click(function(){$("#ceng1").hide()});
  }
    if(i==2)
  {
    $("#ceng1").hide();$("#ceng2").animate({opacity: 0.95},300).show();$("#ceng3").hide();
	$("#closebtn2").click(function(){$("#ceng2").hide()});
  }
    if(i==3)
  {
  
    $("#ceng1").hide();$("#ceng2").animate({opacity: 0.95},300).hide();$("#ceng3").show();
	$("#closebtn3").click(function(){$("#ceng3").hide()});
	
  }
}

