// JavaScript Document
// ballard.js
// Andy Rova
// andy@rovaconsulting.com
// last revised Nov. 12, 2007
//-----------------------------------------------------------------------------

$(document).ready(function(){
	$("#locationHighlight").hide(); 	// no location is highlighted initially
	// set up the  onmouseover() functions for the menu links and hotspots:
	$(".placesNav li a, #imageMap area").bind("mouseover", showLocationHighlight);
	/*$("#imageMap area").bind("mouseover", showLocationHighlight);*/
}); // end ready() anonymous function

function showLocationHighlight() {
		$(".placesNav li").removeClass("current"); 	// un-highlight all menu items
		$("#locationHighlight").hide(); 			// hide the location marker
		
		var offsetPx = 9; // CSS positions based on top left, we want to use center of highlight dot. Hence offset by dot radius
		
		// Determine if this function was called via rollover of a menu or of a hotspot:
		// This is only necessary because the menu has the classes applied to the <li>s rather than <a>s
		if($(this).is(	"area")) {
			curClass = $(this).attr("class").toString(); // imageMap hotspot was the rollover trigger
		}
		else {
			curClass = $(this).parent().attr("class").toString(); // menu link was the trigger
		}
		// parse out current location's x and y positions:
		curCoords = $("#imageMap area." + curClass).attr("coords").toString();
		xCoord = curCoords.substring(0,3);
		yCoord = curCoords.substring(4,7);
		
		h = $("#locationHighlight"); // the div containing the location highlight overlay image
		h.show(); // in case not yet visible
		h.css({ left: (xCoord-offsetPx)+"px", top: (yCoord-offsetPx)+"px" }); // move to new location
		
		$(".placesNav li." + curClass).addClass("current"); // highlight the current menu link
}
