//This first line is to ensure the ready function fires if the back button is used to reach the page
history.navigationMode = 'compatible';
$(document).ready(function(){
	var ElementID = "";
	var ParentElementID = "";
	var LeftEdge = 0;
	var SubNavElement = null;
	var ParentElementLink = null;
	//var TestElement = $("#nursing > .dropdown");
	
	// Get positions of each section link
	var Positions = new Object;	
	Positions.about = $("#about").position();
	Positions.staff = $("#staff").position();
	Positions.services = $("#services").position();
	Positions.nursing = $("#nursing").position();
	Positions.experience = $("#experience").position();
	Positions.career = $("#career").position();

	//LeftEdge = Positions["nursing"].left-3;
	//TestElement.css("left",LeftEdge);
	//TestElement.show();

	// Toggle dropdown menu on section hover
	$(".section").hover(
		function () {
			ElementID = $(this).attr("id");
			SubNavElement = $("#" + ElementID + " > .dropdown");
			LeftEdge = Positions[ElementID].left-3;
			SubNavElement.css("left",LeftEdge);
			SubNavElement.show();
		}, 
		function () {
			SubNavElement.hide();
		}
	);
	// Toggle section highlight on dropdown hover
	$(".dropdown").hover(
			function () {
				ParentElementID = $(this).parent().attr("id");
				ElementID = $(this).attr("id");
				ParentElementLink = $(this).parent().find("a:first");
				ParentElementLink.addClass(ParentElementID + "-hilite");
			}, 
			function () {
				ParentElementLink.removeClass(ParentElementID + "-hilite");
			}
		);
});
