function x717(element,top,right,bottom,left){
	document.getElementById(element).style.clip='rect('+top+'px, '+right+'px, '+bottom+'px, '+left+'px)';
};

function AJScroller(){
	this.width=120;
	this.height=150;
	this.scrollspeed=50;
	this.pausedelay=2000;
	this.spacing=10;
	this.y_offset=0;
	this.x_offset=0;
	this.name='ajscroller';
	this.currentspeed=50;
	this.curTopItem=1;
	this.numItems=0;
	this.stop=true;
	this.x=0;
	this.y=0;
	this.timeoutId=0;
	this.add=function(){
		var text=arguments[0];
		var itemwidth;
		itemwidth=this.width;
		this.numItems++;
			document.writeln('<div id="'+this.name+'itm'+this.numItems+'" style="visibility:hidden;position:absolute;width:'+itemwidth+'px;z-index:3" onmouseover="'+this.name+'.mouseover()"  onmouseout="'+this.name+'.mouseout()">');
			if(arguments.length>=1){
				document.writeln(text);
				document.writeln('</div>');
			}
	};
	this.display=function(){
			document.write('<div id="'+this.name+'" style="position:absolute;width:1px;height:1px;"></div>');
			document.write('<div style="width:'+this.width+'px;height:'+this.height+'px;z-index:2" onmouseover="'+this.name+'.mouseover()" onmouseout="'+this.name+'.mouseout()"></div>');
	};
	this.mouseover=function(){
		this.pause();
	};
	this.mouseout=function(){
		this.timeoutId=setTimeout(this.name+'.resume()',50);
	};
	this.scroll=function(){
		var x=0;
		var y=0;
		var i;
		var name=this.name+'itm';
		var cur_name=name+this.curTopItem;
		if(getTop(cur_name)+this.getHeight(cur_name,this.curTopItem)<this.y){
			incrementY(cur_name,-800);
			if(this.curTopItem==this.numItems){
				this.curTopItem=1;
			}else{
				this.curTopItem++;
			}
			cur_name=name+this.curTopItem;
		}
		y=getTop(cur_name)+this.y_offset;
		this.currentspeed=this.scrollspeed;
		for(i=this.curTopItem;i<=this.numItems;i++){
			y=this.scrollTop(name+i,i,y);
		}
		for(i=1;i<this.curTopItem;i++){
			y=this.scrollTop(name+i,i,y);
		}
		if(!this.stop){
			this.timeoutId=setTimeout(this.name+'.scroll()',this.currentspeed);
		}
	};
	this.scrollTop=function(cur_name,i,y){
		var item_y=getTop(cur_name)+this.y_offset;
		var item_h=this.getHeight(cur_name,i);
		if(y<this.height+this.y){
			if(item_y==this.y+this.y_offset&&this.pausedelay>this.scrollspeed){
				this.currentspeed=this.pausedelay;
			}
			if(item_y>-800){
				incrementY(cur_name,item_y-1);
			}else{
				incrementY(cur_name,y);
			}
			x717(cur_name,Math.max(0,this.y+this.y_offset-item_y),this.width,Math.min(this.y+this.y_offset+this.height-item_y,item_h),0);y+=item_h+this.spacing;
			ShowHide(cur_name,true);
		}else{
			incrementY(cur_name,-800);
		}
		return y;
	};
	this.load=function(){
		var name=this.name+'itm';
		var x;
		var w;
		this.y=getTop(this.name);
		this.curTopItem=1;
		y=this.y-1+this.y_offset;
		for(var i=this.curTopItem;i<=this.numItems;i++){
			if(y<this.y+this.height+this.y_offset){
				incrementY(name+i,y);
				h=getHeight2(name+i);
				x717(name+i,Math.max(0,this.y+this.y_offset-y),this.width,Math.min(this.y+this.y_offset+this.height-y,h),0);y+=h+this.spacing;
				ShowHide(name+i,true);
			}else{
				incrementY(name+i,-800);
			}
		}
	};
	this.start=function(){
		this.load();
		if(this.stop){
			this.stop=false;
			this.currentspeed=this.scrollspeed;
			this.timeoutId=setTimeout(this.name+'.scroll()',this.pausedelay);
		}
	};
	this.pause=function(){
		clearTimeout(this.timeoutId);this.stop=true;
	};
	this.resume=function(){
		if(this.stop){
			clearTimeout(this.timeoutId);
			this.stop=false;
			this.currentspeed=this.scrollspeed;
			this.scroll();
		}
	};
	this.getHeight=function(element,index){
		return(document.getElementById(element).offsetHeight);
	};
};

function ShowHide(element,show){
	if(document.getElementById(element)!=null){
		if(show){
			document.getElementById(element).style.visibility="visible";
		}else{
			document.getElementById(element).style.visibility="hidden";
		}
	}
};

function incrementY(element,top,parent){
	document.getElementById(element).style.top=top+'px';
};

function getTop(element,parent) {
	return(document.getElementById(element).offsetTop);
};

function getHeight2(element,parent) {
	return(document.getElementById(element).offsetHeight);
};
