function ContentScroller(speed, interval){
	// ------------------------------------------------------- //
	// Properties //
	// ------------------------------------------------------- //
	this.interval= interval==null ? 40 : interval;
	this.speed= speed==null ? 2 : speed;
	
	var scroller_element;
	var scroller_height;
	var scroll_timer;
	var scroll_first;
	var scroll_last;
	var image_list=new Array();
	var image_count=0;
	
	var loading_index=0;
	var loading_y=0;
	
	var self;
	
	// ------------------------------------------------------- //
	// Methods //
	// ------------------------------------------------------- //
	this.Create=function(container){
		self=this;
		
		scroller_element=document.getElementById(container);
		scroller_element.style.position='relative';
		scroller_element.style.overflow='hidden';
		scroller_height=scroller_element.clientHeight;
		
		var image;
		var Y=0;
		image_count=scroller_element.children.length;
		for(var a=0; a<image_count; a++){
			var image=scroller_element.children[a];
			image.style.position='absolute';
			
			image_list[a]=new Object();
			image_list[a].image=scroller_element.children[a];
			image_list[a].y=Y;
			image.style.top=Y+'px';
			image_list[a].height=image.offsetHeight;
			Y+=image_list[a].height;
		}
		
		scroll_first=image_list[0];
		
		CompleteLoad();
	}
	
	function CompleteLoad(){
		// Add images until there is enough to fill the entire scroll area
		var scroll_height=image_list[image_list.length-1].y;
		var position_y=scroll_height+image_list[image_list.length-1].height;
		while(scroll_height<=scroller_height){
			var image;
			for(var a=0; a<image_count; a++){
				image=image_list[a].image.cloneNode(true);
				var new_image=new Object();
				new_image.image=image;
				new_image.y=position_y;
				new_image.height=image_list[a].height;
				image.style.top=position_y+'px';
				image_list[image_list.length]=new_image;
				scroller_element.appendChild(image);
				
				position_y+=new_image.height;
				scroll_height+=a>0 ? image_list[a-1].height : image_list[image_count-1].height;
			}
		}
		
		// Reposition the images
		if(self.speed>0){
			for(var a=image_list.length-1; a>=0; a--){
				image=image_list[a];
				if(image.y<scroller_height){
					scroll_last=image;
					break;
				}
				
				image.y=scroll_first.y-image.height;
				scroll_first=image;
			}
		}
		else{
			scroll_last=image_list[image_list.length-1];
		}
		
		self.scroll_timer=setInterval(function(){self.animate()}, self.interval);
	}
	
	this.animate=function(){
		for(var a=0; a<image_list.length; a++){
			var image=image_list[a];
			var Y=image.y;
			Y+=this.speed;
			
			// Scroll to the right
			if(this.speed>0){
				if(Y>scroller_height){
					if(a>0)
						scroll_last=image_list[a-1];
					else
						scroll_last=image_list[image_list.length-1];
					
					Y=scroll_first.y-image.height+(a<image_list.length-1 ? this.speed : 0);
					scroll_first=image;
				}
			}
			// Scroll to the left
			else{
				if(Y+image.height<0){
					if(a<image_list.length-1)
						scroll_first=image_list[a+1];
					else
						scroll_first=image_list[0];
					
					Y=scroll_last.y+(a==0 ? scroll_last.height+this.speed : scroll_last.height);
					scroll_last=image;
				}
			}
			
			image.y=Y;
			image.image.style.top=Y+'px';
		}
	}
}
