

// -------------------------------------------------------------------------------------------------------------------
// Preloads and manages rollovers for all main nav images 


function preloadMenuImages() {
	if (document.images) {
			if (typeof(document.menuImages) == 'undefined'){
      document.menuImages = new Object();
    	}
    	document.menuImages.loadedImages = new Array();
    		document.menuImages.loadedImages[0] = new Image();
    		document.menuImages.loadedImages[0].src = '/images/shared/nav_home_over.gif';
    		document.menuImages.loadedImages[1] = new Image();
    		document.menuImages.loadedImages[1].src = '/images/shared/nav_shop_over.gif';
    		document.menuImages.loadedImages[2] = new Image();
    		document.menuImages.loadedImages[2].src = '/images/shared/nav_about_over.gif';
    		document.menuImages.loadedImages[3] = new Image();
    		document.menuImages.loadedImages[3].src = '/images/shared/nav_contact_over.gif';
			document.menuImages.loadedImages[4] = new Image();
    		document.menuImages.loadedImages[4].src = '/images/shared/nav_links_over.gif';
	}	
}


// This function is called on page load after the main menu builds on. It checks to see what section the current page falls
// under and updates the main menu configuration to reflect this, switching the section's respective button to it's "on" state.

function updateNav (currentSection) {
	var currentSection_img = '/images/shared/nav_' + currentSection + '_on.gif';
	document.getElementById('nav_' + currentSection).src = currentSection_img;	
}


// This function swaps menu images when user rolls over them

function swapNavItem ( currentSection, swapSection) {
		// If User is not mousing over the Menu Button for the section of the website that User is currently in,
		// swap the "off state" for the "on state" of the Menu Button that the User is mousing over.
		if (swapSection != currentSection) {
				var swapSection_img = '/images/shared/nav_' + swapSection + '_over.gif'
				document.getElementById('nav_' + swapSection).src = swapSection_img;	
			}
 }
 
 
// This function swaps menu images back when user rolls back out

function swapNavItemBack ( currentSection, swapBackSection) {
		
		// If User is not mousing out of the Menu Button for the section of the website that User is currently in,
		// swap the "on state" back to the "off state" of the Menu Button that the User is mousing out of.
		if (swapBackSection != currentSection) {
				var swapBackSection_img = '/images/shared/nav_' + swapBackSection + '_off.gif';
				document.getElementById('nav_' + swapBackSection).src = swapBackSection_img;
			}
}



// -------------------------------------------------------------------------------------------------------------------
// Called at the bottom of each page, handles page initialization after document loads

function pageInit(currentSection) {
	// preload rollover images
	preloadMenuImages();	
	//Update main nav block to show the current section.
	updateNav(currentSection);
}