
new function()
{
	function init()
	{
		// Top level nav items
		$("spry_target").select("li").each(function(item) {
			item.observe("mouseover", function() {
				$(this);
				
				// Flag this item as hovered
				if (this.hover_timeout_handle) {
					clearTimeout(this.hover_timeout_handle);
					this.hover_timeout_handle = undefined;
				}
				this.addClassName("hover");
				
				// Find the appropriate image file for this menu item
				var img_file = false;
				switch (this.getAttribute("id")) {
					case "spry_target_home":
						img_file = "petsafe-hover.jpg";
						break;
					case "spry_target_photos":
						img_file = "photos-hover.jpg";
						break;
					case "spry_target_videos":
						img_file = "videos-hover.jpg";
						break;
					case "spry_target_search":
						img_file = "search-hover.jpg";
						break;
				}
				if (img_file) {
					// Create a hover image
					var img = $(document.createElement("img"));
					img.setAttribute("src", "images/" + img_file);
					img.setAttribute("alt", "");
					img.addClassName("hover_img");
					
					// Position it
					var my_offset = this.positionedOffset();
					//alert(my_offset);
					img.style.position = "absolute";
					img.style.left = my_offset.left + "px";
					img.style.top = (my_offset.top - 70) + "px";
					
					// Keep a record of it
					this.hover_img = img;
					
					// Add it to the document
					$("top").appendChild(img);
				}
			});
			item.observe("mouseout", function() {
				if (this.hover_img) {
					$("top").removeChild(this.hover_img);
				}
				
				// Remove the hover flag
				var item_ref = this;
				this.hover_timeout_handle = setTimeout(function() {
					item_ref.removeClassName("hover");
					
					/*
					if (item_ref.hover_img) {
						//alert(item_ref + "\n" + item_ref.hover_img);
						$("top").removeChild(item_ref.hover_img);
					}
					*/
					/*
					if (item_ref.hover_img) {
						$("top").removeChild(item_ref.hover_img);
						item_ref.hover_img = undefined;
					}
					*/
				}, 500);
			});
		});
	}
	
	if (typeof Prototype != "undefined") {
		document.observe("dom:loaded", init);
	}
};

