 ProductImage = Class.create({
  		initialize : function(options) {

  			this.options = options || {};
  			this.image = this.options.image;
  			
  			// preload image
  			var img = new Image(1,1);
  			img.src = this.image;	
  			
  			this.width = this.options.width;
  			this.height = this.options.height;

  			this.target = $('product-image');
  		},

  		show : function() {
  			this.target.src = this.image;
  			this.target.width = this.width;
  			this.target.height = this.height;
  		},

  		hide : function() {
  			this.el.removeClassName('active');
  		}
 });

 ProductImagesTab = Class.create({
 	initialize : function(id, images) {
 		this.el = $(id);
 		this.images = images;
 		var tabs = this;
 		this.el.select('a').each(function(e) {
 			e.onclick = function() {
 				tabs.setActive(e);
 				return false;
 			}
 		});
 		this.setActive(this.el.down('a'));
 	},

 	setActive : function(e) {
 		if (this.activeImage) {
 			this.activeImage.removeClassName('active');
 		}
 		this.activeImage = e;
 		this.activeImage.addClassName('active');
 		this.images[e.getAttribute('rel')].show();
 	}
 });