		// Preload images for Menu Bar and Product Menu
		(function($) {
			var cache = [];
			// Arguments are image paths relative to the current page.
			$.preLoadImages = function() {
				var args_len = arguments.length;
				for (var i = args_len; i--;) {
				  var cacheImage = document.createElement('img');
				  cacheImage.src = arguments[i];
				  cache.push(cacheImage);
				}
			}
		})(jQuery)
	
		jQuery.preLoadImages(
			//Home Page Images
			"img/Background.jpg",                  "img/WoodBackDrop.png",
			
			// Slideshow Images
			"img/slideshow/SlideshowBG.png",       "img/slideshow/Slide1.png",
			"img/slideshow/Slide2.png",            "img/slideshow/Slide3.png",
			
			//Main Menu Images
			"img/menuBar/About_lo.png",              "img/menuBar/About_hi.png",
			"img/menuBar/Contact_lo.png",            "img/menuBar/Contact_hi.png",
			"img/menuBar/Locations_lo.png",          "img/menuBar/Locations_hi.png",
			"img/menuBar/Produce_lo.png",            "img/menuBar/Produce_hi.png",
			"img/menuBar/Recipes_lo.png",            "img/menuBar/Recipes_hi.png",
			"img/menuBar/NavBar.png",
			//Product Menu Images
			"img/productMenu/Melons_lo.png",         "img/productMenu/Melons_hi.png",
			"img/productMenu/Onions_lo.png",         "img/productMenu/Onions_hi.png",
			"img/productMenu/Potatoes_lo.png",       "img/productMenu/Potatoes_hi.png",
			"img/productMenu/Tomatoes_lo.png",       "img/productMenu/Tomatoes_hi.png",
			"img/productMenu/Vegetables_lo.png",     "img/productMenu/Vegetables_hi.png",
			//Overlay Images
			"/img/overlay/close.png",
			//Postcard Images
			"img/postcard/PostcardPopup.png",      "img/postcard/PostcardSend1.png",
			"img/postcard/PostcardSend2.png",
			//Product Popup Images
			"img/productPopups/PotatoPopup.png",   "img/productPopups/OnionPopup.png",
			"img/productPopups/TomatoPopup.png", "img/productPopups/VegetablePopup.png", 
			"img/productPopups/MelonPopup.png"
		);





//------------------------------------------------------
		var currentPage;
		var currentProduct;


		function showContent(contentDiv)
		{
			$(contentDiv).css("visibility", "visible");
			$(contentDiv).animate({"opacity": "1"}, // Animate opacity to 1
			{
				duration: 500, // animation time ms
				easing: 'easeOutSine', // the type of easing
				complete: function() 
				{ /* the callback */ }
			});
		}

		function hideContent(contentDiv)
		{
			$(contentDiv).animate({"opacity": "0"}, // Animate opacity to 0
			{
				duration: 500, // animation duration ms
				easing: 'easeInSine', // easing type
				complete: function() 
				{ // the callback
					$(contentDiv).css("visibility", "hidden");
				}
			});
		}


		function hidePreviousPageObjects(prevPage)
		{
			//hide previous page objects
			//hideContent("#"+prevPage.toLowerCase()+"Content");
			$("#"+prevPage.toLowerCase()+"Content").animate({"opacity": "0"}, // Animate opacity to 0
			{
				duration: 300, // animation duration ms
				easing: 'easeInSine', // easing type
				complete: function() 
				{ // the callback
					$("#"+prevPage.toLowerCase()+"Content").css("visibility", "hidden");
					switch (prevPage) 
					{
						case "Home" :
							$('#homeProduceMenu').css("visibility", "hidden");
							$('.slideshowBG').css("visibility", "hidden");
							$('#newsBackground').css("visibility", "hidden");
							$('#newsHeader').css("visibility", "hidden");
							break;
						case "Produce" :
							$('#produceProduceMenu').css("visibility", "hidden");
							$('#contactUsHeader').css("visibility", "hidden");
							$('#contactUs').css("visibility", "hidden");
							$('#videoHeader').css("visibility", "hidden");
							$('#video').css("visibility", "hidden");
							break;
						case "About" :
							
							break;
						case "Locations" :
							
							break;
						case "Contact" :
							
							break;
						case "Recipes" :
							
							break;
					}
				}
			});
		}


		function showNewPageObjects(newPage)
		{
			//show new page objects
			switch (newPage) 
			{
				case "Home" :
					$('#homeProduceMenu').css("visibility", "visible");
					$('.slideshowBG').css("visibility", "visible");
					$('#newsBackground').css("visibility", "visible");
					$('#newsHeader').css("visibility", "visible");
					break;
				case "Produce" :
					$('#produceProduceMenu').css("visibility", "visible");
					$('#contactUsHeader').css("visibility", "visible");
					$('#contactUs').css("visibility", "visible");
					$('#videoHeader').css("visibility", "visible");
					$('#video').css("visibility", "visible");
					break;
				case "About" :
					
					break;
				case "Locations" :
					
					break;
				case "Contact" :
					
					break;
				case "Recipes" :
					
					break;
			};
			$("#"+newPage.toLowerCase()+"Content").css("visibility", "visible");
			$("#"+newPage.toLowerCase()+"Content").animate({"opacity": "1"}, // Animate opacity to 1
			{
				duration: 300, // animation time ms
				easing: 'easeOutSine', // the type of easing
				complete: function() 
				{ /* the callback */ }
			});
		}


		function switchPages(prevPage, newPage)
		{
			//hide previous page objects
			//hideContent("#"+prevPage.toLowerCase()+"Content");
			$("#"+prevPage.toLowerCase()+"Content").animate({"opacity": "0"}, // Animate opacity to 0
			{
				duration: 300, // animation duration ms
				easing: 'easeInSine', // easing type
				complete: function() 
				{ // the callback
					$("#"+prevPage.toLowerCase()+"Content").css("visibility", "hidden");
					switch (prevPage) 
					{

						case "Home" :
							$('#homeProduceMenu').css("visibility", "hidden");
							$('.slideshowBG').css("visibility", "hidden");
							$('#newsBackground').css("visibility", "hidden");
							$('#newsHeader').css("visibility", "hidden");
							break;
						case "Produce" :
							$('#produceProduceMenu').css("visibility", "hidden");
							$('#scrollableHeader').css("visibility", "hidden");
							$('#produceScrollable').css("visibility", "hidden");
							$('#contactUsHeader').css("visibility", "visible");
							$('#contactUs').css("visibility", "visible");
							$('#videoHeader').css("visibility", "visible");
							$('#video').css("visibility", "visible");
							break;
						case "About" :
							
							break;
						case "Locations" :
							
							break;
						case "Contact" :
							
							break;
						case "Recipes" :
							
							break;
					}
					//show new page objects
					switch (newPage) 
					{
						case "Home" :
							$('#homeProduceMenu').css("visibility", "visible");
							$('.slideshowBG').css("visibility", "visible");
							$('#newsBackground').css("visibility", "visible");
							$('#newsHeader').css("visibility", "visible");
							break;
						case "Produce" :
							$('#produceProduceMenu').css("visibility", "visible");
							$('#scrollableHeader').css("visibility", "visible");
							$('#produceScrollable').css("visibility", "visible");
							$('#contactUsHeader').css("visibility", "hidden");
							$('#contactUs').css("visibility", "hidden");
							$('#videoHeader').css("visibility", "hidden");
							$('#video').css("visibility", "hidden");
							if (( BrowserDetect.browser == "Explorer" ) && ( parseFloat(BrowserDetect.version) < 9 )) {
								$('#produceText').css("background-color", "white");
							}
							break;
						case "About" :
							if (( BrowserDetect.browser == "Explorer" ) && ( parseFloat(BrowserDetect.version) < 9 )) {
								$('#aboutText').css("background-color", "white");
							}
							break;
						case "Locations" :
							
							break;
						case "Contact" :
							
							break;
						case "Recipes" :
							
							break;
					};
					$("#"+newPage.toLowerCase()+"Content").css("visibility", "visible");
					$("#"+newPage.toLowerCase()+"Content").animate({"opacity": "1"}, // Animate opacity to 1
					{
						duration: 300, // animation time ms
						easing: 'easeOutSine', // the type of easing
						complete: function() 
						{ /* the callback */ }
					});
				}
			});
		}

		function loadPage(page)
		{
			// if selected page is not the current page, then do this
			if (currentPage != page) 
			{
				// Remove active state from old menu option
				$('.menuItem').removeClass('active');
				
				if (page != 'Home')
				{
					// Set active state on home menu option
					$('#'+ page.toLowerCase()).addClass('active');
				}
				// Switch page content
				switchPages(currentPage, page)
				
				// hide previous page content
				//hidePreviousPageObjects(currentPage);
				
				// load new page content
				//showNewPageObjects(page);
				
				// Update currentPage variable
				currentPage = page;
			}
			
		}

		function swapContent(whichDiv, contentPath){
			// Show progress indicator until content loads
			//$(whichDiv).html('<img src="img/progress.gif" width="100" height="100" alt="">').show();
			// Load content
			$(whichDiv).load(contentPath);
		}

		// Called from onLoad to select and display the first recipe
		function initRecipe(contentPath, tabText, courtesyText, courtesyLink){
			$('#recipeTableDiv').load(contentPath);
			$('#recipeCardTabDiv').replaceWith("<div id='recipeCardTabDiv'><h2>"+tabText+"*</h2></div>");
			$('#courtesyOfDiv').replaceWith("<div id='courtesyOfDiv'><p>*recipe courtesy of "+courtesyText+" - <a target='_blank' href='http://"+courtesyLink+"'>"+courtesyLink+"</a></p></div>");
		}

		// Called from the onclick events of the recipe list items
		function displayRecipe(elementClicked, contentPath, tabText, courtesyText, courtesyLink){
			$('#recipeTableDiv').load(contentPath);
			$('#recipeCardTabDiv').replaceWith("<div id='recipeCardTabDiv'><h2>"+tabText+"*</h2></div>");
			$('#courtesyOfDiv').replaceWith("<div id='courtesyOfDiv'><p>*recipe courtesy of "+courtesyText+" - <a target='_blank' href='http://"+courtesyLink+"'>"+courtesyLink+"</a></p></div>");
			$(".activeRecipe").removeClass("activeRecipe");
			$(elementClicked).addClass("activeRecipe");
		}

	function displayProduceInfo(product){
		if (currentProduct != product)
		{
			switch (product) 
			{
				case "Potatoes" :
					swapContent('#produceContent #produceText', "product/potatoes.htm");
					$('#produceContent #produceTextHead #produceTextHeadLabel').css("background-image", "url(../img/product/prodHeadPotatoes.png)");
					break;
				case "Onions" :
					swapContent('#produceContent #produceText', "product/onions.htm");
					$('#produceContent #produceTextHead #produceTextHeadLabel').css("background-image", "url(../img/product/prodHeadOnions.png)");
					break;
				case "Tomatoes" :
					swapContent('#produceContent #produceText', "product/tomatoes.htm");
					$('#produceContent #produceTextHead #produceTextHeadLabel').css("background-image", "url(../img/product/prodHeadTomatoes.png)");
					break;
				case "Vegetables" :
					swapContent('#produceContent #produceText', "product/vegetables.htm");
					$('#produceContent #produceTextHead #produceTextHeadLabel').css("background-image", "url(../img/product/prodHeadVegetables.png)");
					break;
				case "Melons" :
					swapContent('#produceContent #produceText', "product/melons.htm");
					$('#produceContent #produceTextHead #produceTextHeadLabel').css("background-image", "url(../img/product/prodHeadMelons.png)");
					break;
			}
			currentProduct = product;
		}
	}

	function showPlanks(){
		$('#planks').animate({"top": "0px"}, // what we are animating
		{
			duration: 2000, // how fast we are animating
			easing: 'easeOutBounce', // the type of easing
			complete: function() 
			{ // the callback
			
			}
		});
	}

	function showContactUs(){
		$('#contactUsHeader').animate({"left": "90px"}, // what we are animating
		{
			duration: 500, // how fast we are animating
			easing: 'easeOutBack', // the type of easing
			complete: function() 
			{ // the callback
			
			}
		});

		$('#contactUs').animate({"left": "75px"}, // what we are animating
		{
			duration: 500, // how fast we are animating
			easing: 'easeOutBack', // the type of easing
			complete: function() 
			{ // the callback
			
			}
		});
	}

	function showVideo(){
		$('#videoHeader').animate({"left": "400px"}, // what we are animating
		{
			duration: 500, // how fast we are animating
			easing: 'easeOutBack', // the type of easing
			complete: function() 
			{ // the callback
			}
		});

		$('#video').animate({"left": "395px"}, // what we are animating
		{
			duration: 500, // how fast we are animating
			easing: 'easeOutBack', // the type of easing
			complete: function() 
			{ // the callback
			}
		});
	}

	function atLoad()
	{
		// Set current page to "home" at startup
		currentPage = "Recipes";
		currentProduct = "Potatoes"
		loadPage("Home");
		showContactUs();
		showVideo();
		showPlanks();
		// Load Potato Text into Produce Text Area
		swapContent('#produceContent #produceText', "product/potatoes.htm");
		// Load Idaho Falls Staff Text into Staff Text Area
		swapContent('#staffTableDiv', 'contacts/idahoFallsContacts.htm')
		initRecipe('recipes/potatoBread.htm', 'Potato Bread','Michael Ballon, Castle Street Café, MA','www.idahopotato.com/recipes');
	}

	window.onload=atLoad;

