﻿var he=0;
var int,wang,hw,num,out;
function $(item){
	return document.getElementById(item);
}
function potpic(v){

	$("img_list").style.top=-v*303+300+"px";    
	 for(i=1;i<num+1;i++){
	    $("spic"+i).style.border="1px solid #CCC";	
	     
	   }	
	   $("spic"+v).style.border="1px solid #f60";	 
	   clearInterval(int);	
	   clearInterval(wang);
	   clearInterval(out);	
	  
//alert(v);
}
function  potout(v){
	   he=v*3-1;	   
	  out=setInterval("auto();",6000);	  
}
function auto(){
 clearInterval(out);	 
 int=setInterval("roll()",50);
	 for(i=1;i<num+1;i++){$("spic"+i).style.border="1px solid #CCC";}	 
	     
}
function roll(){
       clearInterval(wang);	   
var wei=he%3;
	if(wei==0){ 
		 $("img_list").style.top=-he*101+"px";
		  if(he==0){
			   $("spic1").style.border="1px solid #F60";
			 
		  }	  
		  else{
			   hw=he/3+1;
			   $("spic"+hw).style.border="1px solid #F60";				  
		  }	  
		clearInterval(int);		 	
		wang=setInterval("auto();",6000);
	}
	else{
		clearInterval(wang);
		$("img_list").style.top=-he*100+"px";	
	}
    if(he<num*3){he=he+1;}
    if(he>=num*3){he=0;}
}
