var current = "pancake";
	
var titles = {
	"chicken":"Chicken",
	"steak":"Rib Steak",
	"steak2":"Rib Steak",
	"pork":"Pork Chops",
	"salmon":"Atlantic Salmon Filet",
	"salmon2":"Atlantic Salmon Filet",
	"potato":"Yukon Gold Potatoes",
	"hamburger":"Hamburgers",
	"hamburger2":"Hamburgers",
	"cookies":"Cookies",
	"cookies2":"Cookies",
	"pancake":"Pancakes",
	"grilled":"Grilled Cheese",
	"grilled2":"Grilled Cheese",
	"omelet":"Omelet",
	"vegetable":"Vegetable Stir Fry"
}
		
function showSection(id) {
	switchOil(id);

	document.getElementById(current).style.display = "none";
	document.getElementById(id).style.display = "block";

	current = id;
	
	var imgs = document.getElementsByTagName("img");

	for (var i=0;i<imgs.length;i++) {
		var t = imgs[i].className.split(" ");

		if (t[0] == "foodimage" && id == t[1]) {
			imgs[i].src = "img/recipes_"+t[1]+".jpg";
		}
	}
}
	
window.onload = function() {
	var d = document.getElementsByTagName("a");

	for (var i=0;i<d.length;i++) {
		var t = d[i].className.split(" ");

		if (t[0] == "foodlink" || t[0] == "nextbutton") {
			d[i].href = '#' + t[1].toString();
				
			d[i].onclick = function() {
				var f = this.className.split(" ")[1];
				showSection(f);	
				//document.location = "#" + f

				return false;
			}
			/*
			var agt=navigator.userAgent.toLowerCase();
			if (agt.indexOf("safari") != -1) return 'Safari';
			*/
		} 
	}

	showSection(current);
}

/*
function handleChange(evt) {    
	var value = SWFAddress.getValue();
	var path = SWFAddress.getPath();

	if (path == "") {
		path = "pancake";
	}

	SWFAddress.setTitle("PAM - " + titles[path]);	
	showSection (path);
}
	
SWFAddress.addEventListener('change', handleChange);
*/

function turnOffAllOil() {
	turnOffOil("whycanola");
	turnOffOil("whyolive");
	turnOffOil("whysoybean");
	turnOffOil("whypalm");
}

function turnOnOil(oilName) {
	document.getElementById(oilName).style.display = "block";
}

function turnOffOil(oilName) {
	document.getElementById(oilName).style.display = "none";
}

function switchOil(foodName) {
	turnOffAllOil();

	switch (foodName) {
		case "chicken":
			turnOnOil("whycanola");
			turnOnOil("whyolive");
			break;
		case "steak":
			turnOnOil("whypalm");
			break;
		case "steak2":
			turnOnOil("whycanola");
			break;
		case "pork":
			turnOnOil("whycanola");
			turnOnOil("whyolive");
			break;
		case "salmon2":
			turnOnOil("whypalm");
			break;
		case "salmon":
			turnOnOil("whyolive");
			turnOnOil("whycanola");
			break;
		case "potato":
			turnOnOil("whycanola");
			break;
		case "hamburger2":
			turnOnOil("whycanola");
			break;
		case "hamburger":
			turnOnOil("whypalm");
			break;
		case "cookies":
			turnOnOil("whysoybean");
			turnOnOil("whycanola");
			break;
		case "cookies2":
			turnOnOil("whysoybean");
			turnOnOil("whycanola");
			break;
		case "pancake":
			turnOnOil("whycanola");
			break;
		case "grilled":
			turnOnOil("whycanola");
			break;
		case "grilled2":
			turnOnOil("whycanola");
			break;
		case "omelet":
			turnOnOil("whycanola");
			turnOnOil("whyolive");
			break;
		case "vegetable":
			turnOnOil("whycanola");
			turnOnOil("whyolive");
			break;
	}
}
