// Simple Rollover -- By Michael Swain 2000

// To use:
//		1) every image that will have a rollover must have a unique name="" in the IMG tag.
//		2) the A tag that fires a rollover must have an onmouseover="" and onmouseout=""
//		3) preloading can be done in either the IMG tag as an onload or in script.

// This function forces a swapable image to be loaded during initial page loading.
// name is the name assigned to an IMG tag.
// src is the url of the image to load.
function preLoad(name, src) {
	var images, img, index;
	
	
	if(Image) { // Ony run if the browser supports the Image object.
		if(!window.images) // if the preload array does not exist creat and initialize it.
			window.images = new Array();
			
		images = window.images;
		
		img = new Image(); // create new image object.

		index = images.count;
		images[index] = img;
		images[name] = index;	// add the name to the array making it a hash table.

		img.src = src;
	} // end Image block
	
	return true; // some browsers will fail unless the see a true flag.
}

// This function will swap an old image for a new image by changign the src attribute.
// name is the name assigned to an IMG tag.
// src is the url of the image to load.
function swap(name, src) {
	var img, index, swp;

	if(document.images) // only run if the browser supports image access.
		if((img = document.images[name])) { //grab and verify that the named iamge exists.
			if(window.images) // only run if the preload array exists.
				if((index = window.images[name])) { //grab and verify that the preload exists.
					src = window.images[index].src;
					window.images[index].src = img.src; // swap the reload source with the new source.
				}
			img.src = src; //replace the image in the browser.
		}

	return true; // some browsers will not update unless they receive a true flag.
}
// preLoaded Images here
	preLoad("nav_menu", "images/nav_menu_ovr.jpg");
	preLoad("nav_celebrities", "images/nav_celebrities_ovr.jpg");
	preLoad("nav_wines", "images/nav_wines_ovr.jpg");
	preLoad("nav_directions", "images/nav_directions_ovr.jpg");
	preLoad("nav_reservations", "images/nav_reservations_ovr.jpg");
	preLoad("nav_awards", "images/nav_awards_ovr.jpg");
	preLoad("nav_about", "images/nav_about_ovr.jpg");
//-->