﻿// Javascript to make drop-down menus work. TS 7/2/2010

// Array of menu items. All entries of a menu must be contiguous.
// Which menu, text to display, link, menu width (1st entry only)
var items = new Array (
  //[1, "Join Our Cheese Club", "../index.cfm?category=4",155],
  [1, "Cheese Lover's Special", "../index.cfm?fuseaction=product.display&product_id=9",155],
  [1, "Sampler Pack", "../index.cfm?fuseaction=product.display&product_ID=19",155],
  //[1, "Friends & Family Pack", "../index.cfm?fuseaction=product.display&product_id=14",155],
  [1, "Aged White Cheddar", "../index.cfm?fuseaction=product.display&product_ID=1",155],
  [1, "Cumin Cheddar", "../index.cfm?fuseaction=product.display&product_ID=7&ParentCat=3",155],
  [1, "Cherry-Sage Cheddar", "../index.cfm?fuseaction=product.display&product_id=22",155],
  [1, "Maple-Basil Cheddar", "../index.cfm?fuseaction=product.display&product_id=23",155],
  [1, "Award Winning Smoked White Cheddar", "../index.cfm?fuseaction=product.display&product_ID=5",155],
  //[1, "Utah\'s Best Mozzarella", "../index.cfm?fuseaction=product.display&product_ID=3&ParentCat=3",155],
  [1, "Feta - Fresh & Salty", "../index.cfm?fuseaction=product.display&product_ID=4",155],
  [1, "Old Fashioned Parmesan", "../index.cfm?fuseaction=product.display&product_ID=2",155],
  [1, "Award Winning Smoked Parmesan", "../index.cfm?fuseaction=product.display&product_ID=24",155],
  [1, "Find a Retailer", "../index.cfm?category=11",155],
    //[1, "Squeaky Curd", "../index.cfm?fuseaction=product.display&product_ID=6&ParentCat=3",155],
  [2, "Gift Bag - Made to Order", "../index.cfm?fuseaction=product.display&product_id=43",168],
  [2, "Gift Basket - Made to Order", "../index.cfm?fuseaction=product.display&product_id=44",168],[2, "Berry Merlot Cream Soap", "../index.cfm?fuseaction=product.display&product_id=25",168],
  [2, "Chocolate Espresso Cream Soap", "../index.cfm?fuseaction=product.display&product_id=26",168],
  [2, "English Rose Cream Soap", "../index.cfm?fuseaction=product.display&product_id=28",168],
  [2, "Lilac Lavender Cream Soap", "../index.cfm?fuseaction=product.display&product_id=29",168],
  [2, "Mojitto-Mogitto Cream Soap", "../index.cfm?fuseaction=product.display&product_id=30",168],
  [2, "Pumpkin Pie Cream Soap", "../index.cfm?fuseaction=product.display&product_id=31",168],
  [2, "Raw Honey & Oatmeal Cream Soap", "../index.cfm?fuseaction=product.display&product_id=32",168],
  [2, "Sage Lemongrass Cream Soap", "../index.cfm?fuseaction=product.display&product_id=33",168],
  [2, "Vanilla Bean Cream Soap", "../index.cfm?fuseaction=product.display&product_id=34",168],
  [2, "Whiskey Sour Cream Soap", "../index.cfm?fuseaction=product.display&product_id=35",168],
  [2, "Peppermint Swirl Vegan Soap", "../index.cfm?fuseaction=product.display&product_id=37",168],
  [2, "Sandalwood Swirl Vegan Soap", "../index.cfm?fuseaction=product.display&product_id=38",168],
  [2, "Sweet Grapefruit Vegan Soap", "../index.cfm?fuseaction=product.display&product_id=39",168],
  [2, "Crisp Mint Lip Butter", "../index.cfm?fuseaction=product.display&product_id=40",168],
  [2, "Sun-Ripened Strawbery Lip Butter", "../index.cfm?fuseaction=product.display&product_id=41",168],
  [2, "Vanilla Bean Lip Butter", "../index.cfm?fuseaction=product.display&product_id=42",168],
  [3, "In the News", "../index.cfm?category=12",175],
  [3, "History", "../index.cfm?fuseaction=product.display&product_ID=10",175],
  [3, "Contact Us", "../index.cfm?fuseaction=page.contactUs",175],
  [4, "My Account", "../index.cfm?fuseaction=users.manager",160],
  [4, "View Cart", "../index.cfm?fuseaction=shopping.basket",160],
  [4, "Shipping", "../index.cfm?fuseaction=page.display&page_id=22",160],
  [4, "Privacy Policy", "../index.cfm?fuseaction=page.display&page_id=23",160],
  [4, "Refund/Return Policy", "../index.cfm?fuseaction=page.display&page_id=24",160],
  [4, "Search", "../index.cfm?fuseaction=page.search",160],
  // The last item must have menu=0 to successfully end this array.
  [0, "", "",0]
);

function pgInit () {
	var savedMenu = 0;
	// DO for all the menu item entries
	for (var i = 0; items [i][0] != 0; i++) {
		// IF this is a new menu THEN
		if (items [i][0] != savedMenu) {
			// Put together the menu header
			var inner = "<table id=\'table0" + items [i][0] +
			  "\' class=\'menuTable\'" +
			  "onmouseover=\"swapImages (true, \'0" + items [i][0] + "\');\"" +
			  "onmouseout=\"swapImages (false, \'0" + items [i][0] + "\');\"" +
			  " border=0 cellpadding=0 cellspacing=0>" +
			  "<tr>" +
			  "<td id=td0" + items [i][0] + " class=menuInv>" +
			  "<table width=" + items [i][3] + " class=menuTable cellspacing=0>";
			savedMenu = items [i][0];
			// Put in item-specific stuff for each menu item
			for (; items [i][0] == savedMenu; i++) {
				inner += "<tr><td class=menuItem onmouseover=\'this.className=\"" +
				  "hoverMenuItem\";ifIE(1.0);\' onmouseout=\'this.className=\"" +
				  "menuItem\";ifIE(0.8);\'><a class=hv href=\'javascript:menuChoice (\"" +
				  items [i][2] +"\");\'>" + items [i][1] +
				  "<span class=arrowLeft></span></a>" +
                                  "</tr></td>";
			}
			i--;
			// Put together the menu trailer
			inner += "</table></td></tr></table>";
			// Put the entire shebang in place
			document.getElementById ('div0' + savedMenu).innerHTML = inner;
		}
	}
}			
			  
function ifIE (opac) {
	if (this.filters != null) {
		this.filters.alpha.opacity = opac;
		if (opac == 1.0) {
			this.style.background = 0xFEBC06;
		} else {
			this.style.background = white;
		}
	}
}

function menuChoice (url) {
	location.href = url;
}

function showmenu (elt) {
	document.getElementById (elt).style.visibility = "visible";
}

function hidemenu (elt) {
	document.getElementById (elt).style.visibility = "hidden";
}

function swapImages (on, num) {
	if (on == true) {
		changeImages ('menu2_off_' + num, '../nav/images/menu2_on_' + num + '.jpg');
	} else {
		changeImages ('menu2_off_' + num, '../nav/images/menu2_off_' + num + '.jpg');
	}
}

