/*	*********************************************************************************************
	*****************						ItemsCache Class					*****************
	*********************************************************************************************
*/

function ItemData() /* User defined data type */
	{
	this.ProductCode = 0;
	this.ItemName = "";
	this.ImageName = "";
	this.ImageHeight = 0;
	this.ImageWidth = 0;
	this.MinimumQuantity = 0;
	this.MaximumQuantity = 0;
	}

function ItemsCache() /* Class */
	{
	/* Properties */
	this.ItemTable = Array();
	this.NumItems = 0;
	
	/* Methods */
	this.AddItem = ItemCacheAddItem;
	this.GetItemName = ItemCacheGetItemName;
	this.GetImageName = ItemCacheGetImageName;
	this.GetImageHeight = ItemCacheGetImageHeight;
	this.GetImageWidth = ItemCacheGetImageWidth;
	}

/* Implementation of ItemsCache method 'AddItem' */	
function ItemCacheAddItem(ProductCode, ItemName, ImageName, ImageHeight, ImageWidth, MinimumQuantity, MaximumQuantity)
	{
	this.ItemTable[this.NumItems] = new ItemData;
	this.ItemTable[this.NumItems].ProductCode = ProductCode;
	this.ItemTable[this.NumItems].ItemName = ItemName;
	this.ItemTable[this.NumItems].ImageName = ImageName;
	this.ItemTable[this.NumItems].ImageHeight = ImageHeight;
	this.ItemTable[this.NumItems].ImageWidth = ImageWidth;
	this.ItemTable[this.NumItems].MinimumQuantity = MinimumQuantity;
	this.ItemTable[this.NumItems].MaximumQuantity = MaximumQuantity;
	this.NumItems+=1;
	}

/* Implementation of ItemsCache method 'GetItemName' */	
function ItemCacheGetItemName(ProductCode)
	{
	var a=0;
	for (a=0; a<this.NumItems ; a++)
		{
		if (ProductCode==this.ItemTable[a].ProductCode) return this.ItemTable[a].ItemName;
		}
	}

/* Implementation of ItemsCache method 'GetImageName' */	
function ItemCacheGetImageName(ProductCode)
	{
	var a=0;
	for (a=0; a<this.NumItems ; a++)
		{
		if (ProductCode==this.ItemTable[a].ProductCode) return this.ItemTable[a].ImageName;
		}
	}

function ItemCacheGetImageHeight(ProductCode)
	{
	var a=0;
	for (a=0; a<this.NumItems ; a++)
		{
		if (ProductCode==this.ItemTable[a].ProductCode) return this.ItemTable[a].ImageHeight;
		}
	}

function ItemCacheGetImageWidth(ProductCode)
	{
	var a=0;
	for (a=0; a<this.NumItems ; a++)
		{
		if (ProductCode==this.ItemTable[a].ProductCode) return this.ItemTable[a].ImageWidth;
		}
	}
/*	*****************************************************************************************
	*****************					End Of ItemsCache Class				*****************
	*****************************************************************************************

	
	*****************************************************************************************
	*****************						SpecCache Class					*****************
	*****************************************************************************************
*/
	
function SpecData()	/* User defined data type */
	{
	ProductCode = 0;
	SpecName = "";
	SpecDetail = "";
	}
	
function SpecCache()	/* Class */
	{
	/* Properties */
	this.SpecTable = Array();	
	this.NumSpecs = 0;

	/* Methods */
	this.AddSpec = SpecCacheAddSpec;
	this.GetSpecTable = SpecCacheGetSpecTable;
	}

/* Implementation of SpecCache method 'AddSpec' */
function SpecCacheAddSpec(ProductCode, SpecName, SpecDetail)
	{
	this.SpecTable[this.NumSpecs] = new SpecData;
	this.SpecTable[this.NumSpecs].ProductCode = ProductCode;
	this.SpecTable[this.NumSpecs].SpecName = SpecName;
	this.SpecTable[this.NumSpecs].SpecDetail = SpecDetail;
	this.NumSpecs+=1;
	}

/* Implementation of SpecCache method 'GetSpecTable' */	
function SpecCacheGetSpecTable(ProductCode)
	{
	var a = 0;
	var temp = "<table class='spectable' style='position: relative; left: 3%; width: 90%;'>";
	var found = false;
	var Alternate = false;
	
	for (a=0; a < this.NumSpecs; a++)
		{
		if (this.SpecTable[a].ProductCode==ProductCode)
			{
			found=true;
			
			Alternate = (!Alternate);
			if (Alternate==true)
				{
				temp += "<tr><td class='spectdleft1'>" + this.SpecTable[a].SpecName + ":</td><td class='spectdright1'>" + this.SpecTable[a].SpecDetail + "</td></tr>";
				}
			else
				{
				temp += "<tr><td class='spectdleft2'>" + this.SpecTable[a].SpecName + ":</td><td class='spectdright2'>" + this.SpecTable[a].SpecDetail + "</td></tr>";
				}
			}
		}
	
	if (found==true)
		{
		temp += "</table>";
		return temp;
		}
	else
		{
		return;
		}
	}
	
/*	*****************************************************************************************
	*****************					End Of SpecCache Class				*****************
	*****************************************************************************************
*/

