var SkepsisBanners = {

	properties: {
		elementId: 'imgCarousel',
		banners: ['img/_banners/banner_top.jpg','img/_banners/banner_loyalty.jpg','img/_banners/banner_purl.jpg'],
		currentBanner: 0,
		time: 8000,
		timeout: null
	},

	spin: function(reset) {
		if(reset) {
			clearTimeout(this.properties.timeout);
			this.properties.timeout = null;
		}
		var el = document.getElementById(this.properties.elementId);
		el.src = this.properties.banners[this.properties.currentBanner];
		this.properties.currentBanner = (this.properties.currentBanner + 1)%3;
		this.properties.timeout = setTimeout("SkepsisBanners.spin()", this.properties.time);
	},

	changeBanner: function(prevOrNext) {
		if(this.properties.timeout) {			
			this.properties.currentBanner = this.properties.currentBanner==0 ? 2 : (this.properties.currentBanner-1);
		}

		var el = document.getElementById(this.properties.elementId);
		if(prevOrNext==1) {
			this.properties.currentBanner = (this.properties.currentBanner + 1) % 3;
		} else if(prevOrNext==-1) {
			this.properties.currentBanner = (this.properties.currentBanner + 2) % 3;
		}
		el.src = this.properties.banners[this.properties.currentBanner];

		this.spin(true);
	}
}
