// JavaScript Document
$(function(){
					 
	PennardScroller = new function(){
		
		var scrollSpeed = 9000;
		var current = 2;
		var maxBgs = 10;
		
		this.construct = function(){
			PennardScroller.setBackgroundScroller();
			setInterval("PennardScroller.doScrollBg()", this.scrollSpeed);
		}
		
		this.setBackgroundScroller = function(){
			this.scrollSpeed = 9000;
			PennardScroller.setCurrent(2);
		}
		
		this.setCurrent = function(curr){
			this.current = curr;
		}
		
		this.getCurrent = function(){
			return this.current;
		}
		
		this.doScrollBg = function(){
			if(this.current == 1){
				$('#background1').fadeOut('slow',function(){
					$('#background' + PennardScroller.getCurrent()).fadeIn('slow');
					PennardScroller.setCurrent((Number(this.current) + Number(1)))								  
				});
			} else if(this.current <= 10) { 
				$('#background' + (Number(PennardScroller.getCurrent()) - Number(1))).fadeOut('slow',function(){
					$('#background' + PennardScroller.getCurrent()).fadeIn('slow');	
					PennardScroller.setCurrent((Number(PennardScroller.getCurrent()) + Number(1)))
				});
			} else {
				$('#background10').fadeOut('slow',function(){
					$('#background1').fadeIn('slow');	
					PennardScroller.setCurrent(2);
				});
			}			
		}
	}
	PennardScroller.construct();
});
