var Roller=function(){
	this.images=document.getElementById("scroll_img_box").getElementsByTagName("img");
	this.pages=document.getElementById("scroll_page_box").getElementsByTagName("a");
	this.currentPage=0;
	this.doRoll=function(index){
		if(index || index==0){
			this.currentPage=index;
		}
		this.currentPage=this.currentPage%this.images.length;
		this.changeClass(this.images,"scroll_img hidden","scroll_img");
		this.changeClass(this.pages,"scroll_page","scroll_page scroll_page_select");
		this.currentPage++;
	}
	this.changeClass=function(obj,oldclass,newclass){
		var i=0;
		for(i=0;i<obj.length;i++){
			if(i==this.currentPage){
				obj[i].className=newclass;
			}else{
				obj[i].className=oldclass;
			}
		}
	}
}



var roller=null;
function goTo(index){
	clearInterval(timer);
	
	roller.doRoll(index);
	setTimeout("run()",3000);
}

var timer=null;
function run(){
	if(!roller){
		roller=new Roller();
	}
	if(timer){
		clearInterval(timer);
	}
	timer=setInterval("roller.doRoll()",3000);
}