function Collection(id, name)
{
	this.id = id;
	this.name = name;
	this.products = new Array();

	this.addProduct = function(product)
	{
		this.products.push(product);
		product.collection = this;
	}
	this.getProduct = function(id)
	{
		for (var i = 0; i < this.products.length; i ++)
		{
			if (this.products[i].id == id)
				return this.products[i];
		}
	}
	this.adjustVisibilityProducts = function(visibility)
	{
		for (var i = 0; i < this.products.length; i ++)
		{
			if (visibility)
				this.products[i].showImage();
			else
				this.products[i].hideImage();
		}
	}
	this.showProducts = function()
	{
		this.adjustVisibilityProducts(true);
	}
	this.hideProducts = function()
	{
		this.adjustVisibilityProducts(false);
	}
}

function Product(id, name, subtitle, text)
{
	this.id = id;
	this.name = name;
	this.subtitle = subtitle;
	this.text = text;
	this.collection = null;

	this.showImage = function()
	{
		eval('document.getElementById("productImage_' + this.id + '").style.visibility = "visible";');
		eval('document.getElementById("productInfo_' + this.id + '").style.visibility = "visible";');
	}
	this.hideImage = function()
	{
		eval('document.getElementById("productImage_' + this.id + '").style.visibility = "hidden";');
		eval('document.getElementById("productInfo_' + this.id + '").style.visibility = "hidden";');
	}
	this.getCollectionIndex = function()
	{
		if (this.collection == null)
			return null;
		for (var i = 0; i < this.collection.products.length; i ++)
		{
			if (this.collection.products[i] == this)
				return i;
		}
	}
}

function Collections()
{
	this.collections = new Array();
	this.add = function(collection)
	{
		this.collections.push(collection);
		return collection;
	}
	this.getCollection = function(id)
	{
		for (var i = 0; i < this.collections.length; i ++)
		{
			if (this.collections[i].id == id)
				return this.collections[i];
		}
	}
	this.hideAll = function()
	{
		for (var i = 0; i < this.collections.length; i ++)
		{
			this.collections[i].hideProducts();
		}
	}
}