
// Gallery object
function Gallery()
{
	// variables
	var parent_obj = this;  // for reference in sub-functions

	// properties
	this.name = "Gallery";
	this.base_url = "/secure/images/gallery/";
	this.options = new Array();
	this.image_cache = new Array();
	this.option_cnt = 0;

	// methods
	this.add_option = function(img, title)
	{
		// cache the image
		this.image_cache[this.image_cache.length] = new Image().src = img;

		// add it to the array
		this.options[this.options.length] = {"img": img, "title": title, "images": new Array()};

		// increment the counter
		this.option_cnt++;
	}

	this.add_image = function(option_id, img_thumb, img_full, title)
	{
		// cache the images
		this.image_cache[this.image_cache.length] = new Image().src = this.base_url + img_thumb;
		this.image_cache[this.image_cache.length] = new Image().src = this.base_url + img_full;

		// add it to the array
		this.options[option_id].images[this.options[option_id].images.length] = {"img_thumb": img_thumb, "img_full": img_full, "title": title};
	}

	this.switch_option = function(option_id)
	{
		// turn 'em all off
		for (i = 0; i < this.options.length; i++)
		{
			document.getElementById('product_gallery_' + i).style.display = 'none';
		}

		document.getElementById('product_gallery_' + option_id).style.display = 'block';

		// reset to the first image in the gallery
		this.switch_image(option_id, 0);
	}

	this.switch_image = function(option_id, image_id)
	{
		document.getElementById('product_image').src = this.base_url + this.options[option_id].images[image_id].img_full;
	}
}
