var Klick = Class.create({

	photoIndex: 0,
	selectedCustomer: 'sb',
	
	nextImg: function() {
		klick.timedOn = false;
		klick.nextImage(.3);
	},

	nextImage: function(duration) {
		
		var photos = $(klick.selectedCustomer+'-screenshots').getElementsByTagName("img");
		var currentPhoto = photos[klick.photoIndex];
		klick.photoIndex++;
		if(klick.photoIndex == photos.length) {
			klick.photoIndex = 0;
		}
		$(currentPhoto).hide();
		new Effect.Appear(photos[klick.photoIndex],{duration:duration});
	},

	prevImg: function() {
		klick.timedOn = false;
		klick.previousImage(.3);
	},

	previousImage: function(duration) {
		var photos = $(klick.selectedCustomer+'-screenshots').getElementsByTagName("img");
		var currentPhoto = photos[klick.photoIndex];
		klick.photoIndex--;
		if(klick.photoIndex == -1) {
			klick.photoIndex = photos.length-1;
		}
		$(currentPhoto).hide();
		new Effect.Appear(photos[klick.photoIndex],{duration:duration});
	},
	
	reset: function() {
		var photos = $(klick.selectedCustomer+'-screenshots').getElementsByTagName("img");
		var currentPhoto = photos[klick.photoIndex];
		klick.photoIndex = 0;
		$(currentPhoto).hide();
		$(photos[0]).show();
	},

	timedOn: true,
	timedNext: function() {		
		setTimeout("if (klick.timedOn) {klick.nextImage(true,.5);klick.timedNext();}", 4000);
	},
	
	changeCustomer: function(cust) {
		
		$(klick.selectedCustomer+'-sel').hide();
		$(klick.selectedCustomer+'-unsel').show();
		$(cust+'-unsel').hide();
		$(cust+'-sel').show();
		$(klick.selectedCustomer+'-screenshots').hide();
		klick.reset();
		klick.selectedCustomer = cust;		
		klick.startSlideShow();
	},
	
	startSlideShow: function() {
		new Effect.Appear(klick.selectedCustomer+'-screenshots',{duration:1});
	}

});
var klick = new Klick();