var VintageSlideShow = { };

VintageSlideShow.active = false; 
VintageSlideShow.images = false; 
VintageSlideShow.img_w = 250; 
VintageSlideShow.img_count = 0; 
VintageSlideShow.delay = 15;

VintageSlideShow.initialize = function () {
	
	this.images = $$('.vitageslideshow_img');
	
	if(!this.images || this.images.length === 0) return; 
	
	this.img_count = this.images.length; 
	
	var i = 0;
	
	for(i; i < this.images.length; i++) {
		
		var img = this.images[i];		
		img.addEvent('mouseover', function () { VintageSlideShow.active = false; });
		img.addEvent('mouseout', function () { VintageSlideShow.active = true; });	
		
	}
	
	if(!this.active) { this.active = true; }
	
	setInterval("VintageSlideShow.slide()", this.delay);
	
}; 

VintageSlideShow.slide = function () {
	if(this.active) {
		var i = 0; 
		
		for(i; i < this.images.length; i++) { 
			var img = this.images[i];				
			var left_offset = parseInt(img.getStyle('left'));
			
			if(left_offset > - (this.img_w - 1)) {
				img.setStyle('left', --left_offset + 'px');
			} else {	
				var farright = (this.img_count - 1) * this.img_w; 
				img.setStyle('left', farright + 'px');
			}
		}
	}
}; 

//--------------------------------------------------

window.addEvent('domready', function () {
	
	setTimeout("VintageSlideShow.initialize()", 1000);

});
