// Menu image rollovers using jQuery v1.5 on 2/22/2011
$(document).ready(function() {
	// all menu images require id='m-3', etc. starting with 'm-0'
	// user defined
	var skip		= 1, // Use '2' for 1 image between each menu item, 12, 14, 16, etc.
		path		= '/graphics_slices/WalkinthePark_', //path incl. filename prefix
		start		= 8, // starting menu image id number
		sticky		= '-sticky', // suffix for sticky item
		over		= '-over',  // suffix for hover item
		type		= '.gif', // .jpg, .gif, .png, etc.
	// end user defined
		section		= $('input#section').attr('value'), // this is value of hidden field id='section'
		tab_sticky	= new Array(),
		tab_over	= new Array(),
		enter, leave;

	$('img[id|="m"]').each(function (i) {
		$(this).hover(enter, leave);
		imgid = ((i*skip) + start); if (imgid < 10){imgid="0"+imgid};
		if (section == i){
			$(this).attr({ src: path+imgid+sticky+type });
			$(this).click(function (e) { e.preventDefault(); }).css("cursor","default"); // kills link cuz you're already there
		} else {
			tab_sticky[i]	=	path+imgid+type;
			tab_over[i]		=	path+imgid+over+type;
		};
		// preloads all hidden menu images on page load
		(new Image()).src	=	path+imgid+over+type; 
		(new Image()).src	=	path+imgid+sticky+type;
	});
	function enter(event) { // mouseenter
		j = $(this).attr('id').replace(/m-/, ""); // same 'j' used in mouseout
		if (section != j){$(this).attr("src",tab_over[j]);};
	};
	function leave(event) { // mouseout
		if (section != j){$(this).attr("src",tab_sticky[j]);};
	};
});
