var ProductDetails = Class.create();	
ProductDetails.prototype = {
	initialize: function() {
		var popUp = $("prod-detail-popup");
		if( popUp ) {
			var prodViews = $("prod-views-popup");
			var prodImg = $("productimage-popup");
			var me = this;
			
			// Add event handlers fr the small images
			$A(prodViews.getElementsByTagName("a")).each(
				function(a) {
					a.href = "#";
					a.onclick = me.smallClick( a, me ).bindAsEventListener( me );
				}
			);
			
			// Setup the state variables
			$A(prodImg.getElementsByTagName("img")).each(
				function(img) {
					if( img.style.display != "none" ) {
						me.selected = img;
					}
				}
			);
		}
	},
	
	smallClick: function( a, me ) {
		a.id.match(/thumbImg(\d+)/);
		var clickedIndex = RegExp.$1;
		return function(e) {
			Element.hide( me.selected );
			me.selected = $("largeImg" + clickedIndex);
			Element.show( me.selected );
			Event.stop(e);
		}
	}
};