var productDB = new Array();
var total_ordered = 0;

function product(productid, name, price, quantity, image)
{
	this.productid = productid;
	this.name = name;
	this.price = price;
	this.quantity = quantity;
	this.image = image;
}

function createProductDB()
{	
	productDB[0] = new product(0, "BUTTERSCOTCH TOFFEE<br><br><br><br><br><br><br>", 14.99, 0, "butterscotchtoffee.png");
	
	productDB[1] = new product(1, "CHOCOLATE RASPBERRY:  <br><br>Rich, creamy chocolate blended with sweet-tart raspberries, dusted with more chocolate to create a fine confection coffee.<br><br><br>", 14.99, 0, "chocolateraspberry.png");
	
	productDB[2] = new product(2, "HAZELNUT CLASSIQUE:  <br><br>A rich, smooth European hazelnut flavor creates this fine confectionery coffee.<br><br><br><br>", 14.99, 0, "hazelnutclassic.png");
	
	productDB[3] = new product(3, "IRISH CREAM:  <br><br>Rich and smooth.  To duplicate the full body and creaminess of this popular cordial, blend cream into the brewed beverage.<br><br><br>", 14.99, 0, "irishcream.png");
	
	productDB[4] = new product(4, "ORGANIC SUMATRA<br><br><br><br><br><br><br>", 14.99, 0, "organicsumatra.png");
	
	productDB[5] = new product(5, "SNICKERDOODLE<br><br><br><br><br><br><br>", 14.99, 0, "snickerdoodle.png");
	
	productDB[6] = new product(6, "SOUTHERN PECAN:  <br><br>This special blend of fine Arabica coffees is combined with pecan flavoring.  Pecan pieces are then added to create a sweet, nutty coffee.<br><br>", 14.99, 0, "southernpecan.png");
	
	productDB[7] = new product(7, "TIRAMISU (FRENCH ROAST):  <br><br>A deep, rich vanilla flavor with just a hint of Marsala wine on french roasted beans.  Only the finest preparations of this popular dessert measure up to this rich, creamy coffee!", 14.99, 0, "tiramisufrenchroast.png");
	
	productDB[8] = new product(8, "TOASTED MACAROON:  <br><br>The unique, rich taste of a toasted coconut flavor creates a coffee with extraordinary flavor and aroma.<br><br><br>", 14.99, 0, "toastedmacaroon.png");
	
	productDB[9] = new product(9, "FRENCH VANILLA ROYALE:  <br><br>An ultra-rich vanilla custard flavor reminiscent of Creme Brulee or Creme Caramel.  The ultimate vanilla lover's coffee.<br><br>", 14.99, 0, "frenchvanillaroyale.png");
	
	productDB[10] = new product(10, "VIENNESE WITH CINNAMON:  <br><br>Combines smoothness and good body, add ground and stick Korintje cinnamon, and you have your own classic cup.  A coffee great for any time of day.<br><br>", 14.99, 0, "viennesecinnamon.png");
	
	productDB[11] = new product(11, "WHITE CHOCOLATE<br><br><br><br><br><br><br>", 14.99, 0, "whitechocolate.png");
	
	productDB[12] = new product(12, "MOUNTAIN KONA:  <br><br>A unique blend of fancy Kona #1 and other fien Arabica coffees from the Pacific Region.  Full bodied and sweet in the cup.<br><br><br>", 14.99, 0, "kona.png");
	
	productDB[13] = new product(13, "HAWAIIAN KONA:  <br><br>The finest of the Hawaiian Konas.  A high-grown, superb bean, it is aromatic and medium-bodied with a distinctive but delicate flavor.<br><br>", 14.99, 0, "hawaiiankona.png");
	
	productDB[14] = new product(14, "MEXICAN ALTURA (Organic):  <br><br>This certified organic coffee has excellent flavor and a very good aroma.  It is tangy, smooth and firm in the cup.<br><br><br>", 14.99, 0, "mexicanalturaorganic.png");
	
	productDB[15] = new product(15, "MEXICAN ALTURA OAXACA:  <br><br>Tracing its heritage to coffees organically grown near Maragogipe.  This certified organic coffee has excellent flavor and a very good aroma.  It is tangy, smooth and firm in the cup.", 14.99, 0, "mexicanaltura.png");
	
	productDB[16] = new product(16, "SUMATRA MANDHELING:  <br><br>Considered to be one of the finest coffees in the world.  A rich flavor combined with a smooth, heavy body.  An excellent choice for coffee connoisseurs.<br><br>", 14.99, 0, "sumatra.png");
	
	productDB[17] = new product(17, "TANZANIA KILAMANJARO:  <br><br>Grown on the slopes of Mt. Kilamanjaro, this bean produces one of the finest African coffees.  Rich and full bodied with a winey aftertaste.<br><br>", 14.99, 0, "tanzaniakilamanjaro.png");
	
	productDB[18] = new product(18, "COSTA RICAN TARRAZU:  <br><br>Grown at high elevations on the country's Pacific side.  Rich in body and sharp in flavor, with a snap of very dry wine.<br><br><br>", 14.99, 0, "costaricantarrazu.png");
	
	productDB[19] = new product(19, "PLANTATION KENYA AA:  <br><br>A rich coffee.  In the cup it is smooth and rich with a delicate tang and a dry, winey aftertaste.  Blends well with Colombian coffees.<br><br>", 14.99, 0, "plantationkenyaaa.png");
	
	productDB[20] = new product(20, "ESPRESSO ROAST:  <br><br>Dark roasted to bring out real coffee flavor.  These dark and oily beans make a heavy-bodied and sharp-flavored beverage.  The perfect after dinner coffee.<br><br>", 14.99, 0, "espressoroast.png");
	
	productDB[21] = new product(21, "HAZELNUT DECAF<br><br>A rich, smooth European hazelnut flavor creates this fine confectionery coffee.<br><br><br><br>", 14.99, 0, "hazelnutdecaf.png");
	
	productDB[22] = new product(22, "SNICKERDOODLE DECAF<br><br><br><br><br><br><br>", 14.99, 0, "snickerdoodledecaf.png");
	
	productDB[23] = new product(23, "SOUTHERN PECAN DECAF<br><br>This special blend of fine Arabica coffees is combined with pecan flavoring.  Pecan pieces are then added to create a sweet, nutty coffee.<br><br>", 14.99, 0, "southernpecandecaf.png");
	
	productDB[24] = new product(24, "TOASTED MACAROON DECAF<br><br>The unique, rich taste of a toasted coconut flavor creates a coffee with extraordinary flavor and aroma.<br><br><br>", 14.99, 0, "toastedmacaroondecaf.png");
	
	productDB[25] = new product(25, "VIENNESE WITH CINNAMON DECAF<br><br>Combines smoothness and good body, add ground and stick Korintje cinnamon, and you have our own classic cup.  A coffee great for any time of day.<br><br>", 14.99, 0, "viennesecinnamondecaf.png");
	
	productDB[26] = new product(26, "BREKFAST BLEND:  <br><br>A combination of light and dark roasted coffees to produce a rich and mellow blend.  A perfect way to start your day!<br><br><br>", 14.99, 0, "breakfastblend.png");
	
	checkQuantity();
}

function checkQuantity()
{
	var ordersCookie = findOrder("orders");
	if (!ordersCookie)
	{
		return;
	}
	var userOrders = ordersCookie.split("+");
	for (var n = 0; n < userOrders.length; n++)
	{
		var orderNum = userOrders[n];
		productDB[n].quantity = orderNum;
		if (orderNum > 0)
		{
			total_ordered++;
		}
	}
}

function findOrder(findName)
{
	var entireCookie;
	var cookieName;
	var cookieValue;
	var cookieArray = document.cookie.split("; ");
	for (var n = 0; n < cookieArray.length; n++)
	{
		entireCookie = cookieArray[n].split("=");
		cookieName = entireCookie[0];
		cookieValue = entireCookie[1];
		if (cookieName == findName)
		{
			return unescape(cookieValue);
		}
	}
	return null;
}