var currentF=1;
document.getElementById("upbtn").style.visibility="hidden";
var mainobj = document.getElementById("gacon");
var frameheight = 160;
var scrolling=0;
var speed = 20;
var checkloaded=new Array();
for(i=1;i<=3;i++){
checkloaded[i]=1;
}
function checkdamie(n){
	checkloaded[n]=1;
	//alert(checkloaded[n])

}
function alertloading(sdirection){
scrolling=0;
if(sdirection == "down"){
currentF--;
}
else{
currentF++;
}
//alert("正在下载数据,请稍等");
}

function scrolldown(f){

	switch (f){
	case 2:
	if (mainobj.scrollTop>=frameheight){
		clearInterval(inter);
		mainobj.scrollTop=frameheight;
		scrolling=0;
		}
	else{mainobj.scrollTop+=speed;}
	break;
	case 3:
	if (mainobj.scrollTop>=frameheight*2){
		mainobj.scrollTop=frameheight*2;
		clearInterval(inter);
		scrolling=0;
		}
	else{mainobj.scrollTop+=speed;}
	break;
	}
}


function scrollup(f){

	switch (f){
	case 1:
	if (mainobj.scrollTop<=0){
		clearInterval(inter1);
		mainobj.scrollTop=0;
		scrolling=0;
		}
	else{
	mainobj.scrollTop-=speed;
	}
	break; 
	case 2:
	if (mainobj.scrollTop<=frameheight){
		mainobj.scrollTop=frameheight;
		clearInterval(inter1);
		scrolling=0;
		}
	else{
	mainobj.scrollTop-=speed;
	}
	break; 
	}

}

function slidedown(){
	//slide
if (scrolling==0){
	scrolling=1;
	currentF++;
	obj=eval("document.getElementById('f"+currentF+"')");
	obj.style.display="block";
	if (checkloaded[currentF]==1){
		inter=eval("setInterval('scrolldown("+currentF+")',5)");
		//led
		document.getElementById("upbtn").style.visibility="";
		if (currentF==3){
		document.getElementById("downbtn").style.visibility="hidden";
		}
		for (i=1;i<=3;i++){
		eval("document.getElementById('led"+i+"').className='pag'");
		}
		eval("document.getElementById('led"+currentF+"').className='foucpag'");
	}
	else{
	//alert(checkloaded[currentF]);
	alertloading("down");
	
	}
	}
}


function slideup(){
	//slide
if (scrolling==0){
	scrolling=1;
	currentF--;
	obj=eval("document.getElementById('f"+currentF+"')");
	obj.style.display="block";
		if (checkloaded[currentF]==1){
		inter1=eval("setInterval('scrollup("+currentF+")',5)");
		//led
		document.getElementById("downbtn").style.visibility="";
		if (currentF==1){
		document.getElementById("upbtn").style.visibility="hidden";
		}
		for (i=1;i<=3;i++){
		eval("document.getElementById('led"+i+"').className='pag'");
		}
		eval("document.getElementById('led"+currentF+"').className='foucpag'");
		}
		else{
		alertloading("up");
		}
	}
}
//auto slide
var direction = "down";
var interval01;
var autotime = 3000;
function autoslide(){
	if(direction == "down"){
		if (currentF == 2){
		 direction = "up";
		}
	slidedown();
	//alert(direction);
	}
	if(direction == "up"){
		if (currentF == 2){
		 direction = "down";
		}
	slideup();
	//alert(direction);
	}
}
function iniautoslide(){
interval01 = setInterval("autoslide()",autotime);
}
