/*******************************************************/
/* Shopping List JS (avoids page reload when shopping) */	
/*******************************************************/
function findShoppingList()
	{
	var i, inputs, divs;
	// Type options
	inputs = document.getElementById("type_menu").getElementsByTagName("input");
	for(i=0;i<inputs.length;i++)
		if (inputs[i].className=="button")
			inputs[i].onclick = changeShoppingDisplay;
	// Back buttons
	divs = document.getElementById("shoppinglist").getElementsByTagName("div");
	for(i=0;i<divs.length;i++)
		if (divs[i].className=="backbutton")
			divs[i].getElementsByTagName("a")[0].onclick = resetShoppingDisplay;
	}
function changeShoppingDisplay()
	/* Go from the first menu level (id="type_menu") with print, mounted, framed and
	 * greetings card options on display, to the specific menus for each of these options.
	 * Note that the buttons on the first level have 'name' attributes that match the "id"s of the
	 * corresponding <div>s that they cause to be displayed (hence (*) below). */
	{
	document.getElementById("type_menu").style.display="none";
	document.getElementById(this.name).style.display="block"; // (*) see above. 
	if (this.name=="greetings") document.getElementById("card_qty").focus();
	return false;
	}
function resetShoppingDisplay()
	{
	this.parentNode.parentNode.style.display = "none";
	document.getElementById("type_menu").style.display="block";
	return false;	
	}
	
if (window.addEventListener) // DOM Level 2 API
	window.addEventListener("load", findShoppingList, 0);
else if (window.attachEvent) // IE workaround
	window.attachEvent("onload", findShoppingList);
	
