$(document).ready(function()
{	
	// hide the employee "popups" (unless js is disabled in which case anchor tags are used)	
	$("#employeeDetailsHolder").addClass("employeeDetails");


	// popups:
	$("ul#employeesList li a").fancybox();
	$("#locationsList a").fancybox();
	
	// autoselect input field
	//$defaultValue = "type here...";
	$("input[name=fd_terms]").focus(function()
	{
			//$(this).select();
			this.value = "";
			$(this).removeClass("grayedOutInput");
	});



	//////////////////////////////////////////////////////////////////////////////////////////////
	
	var flyOutSpeed = 200;
	
	if($.browser.msie)
	{
		flyOutSpeed = 80;	
	}

	var flyOutStartPositionTop = "141px";
	
	// set fly inital state
	$("ul#navMain li ul").css({"display" : "none"});
	$("ul#navMain li ul").css({"top" : flyOutStartPositionTop});
	
	
	// center flyout below button (css right offset)
	$("ul#navMain li ul li a").each(
		function()
		{
			flyOutWidth = $(this).parent().parent("ul").width();
			parentButtonWidth = $(this).parent().parent().parent("li").width();
			cssValue = flyOutWidth / 2 - parentButtonWidth / 2;
			
			if($.browser.msie) // && $.browser.version <= 7)
			{
				cssValue = 0;
			}
			
			//alert("TEMP DEBUGGING: " + cssValue);
			
			$(this).css({ "right" : cssValue + "px" });
		}
	);
	
	

	$("li.flyOut").hover(function()
	{
		$(this).children("ul").css({"display" : "block" });
		$(this).children("ul").stop().animate({"opacity" : 1, "top" : "146px"}, flyOutSpeed, "easeOutQuad");
	},
	function()
	{
		$(this).children("ul").stop().animate({"opacity" : 0}, flyOutSpeed, "easeOutQuad", 
			function()
			{
				$(this).css({"display" : "none", "top" : flyOutStartPositionTop, "opacity" : 0 });
			});
	});


	//===================================================================================
	
	// Hot spot animations on map pages
	
	//===================================================================================
	var totalHotSpots = null
	var hotSpotPositionsLeft = [];
	var hotSpotPositionsTop = [];
	
	var thisHotSpot = null;
	var thisHotSpotPositionLeft = null;
	var thisHotSpotPositionTop = null;
	var thisHotSpotID = null;
	
	totalHotSpots = jQuery(".hotspot").size();

	for(i = 0; i < totalHotSpots; i++)
	{
		hotSpotPositionsLeft[i] = jQuery('.hotspot:eq('+i+')').position().left;
		hotSpotPositionsTop[i] = jQuery('.hotspot:eq('+i+')').position().top;
	}

	// make map hotspots light up
	$(".hotspot").hover(
	function()
	{
		thisHotSpot = $(".hotspot").index(this)+1;
		thisHotSpotID = thisHotSpot - 1;
		thisHotSpotPositionLeft = parseInt(hotSpotPositionsLeft[thisHotSpotID]) - 5;
		thisHotSpotPositionTop = parseInt(hotSpotPositionsTop[thisHotSpotID]) - 5;


		$(this).stop().animate({
							 "width" : "31px", "height" : "31px", 
							"left" : thisHotSpotPositionLeft, "top" : thisHotSpotPositionTop
							},
							100, "easeOutQuad");
	},
	function()
	{
		thisHotSpot = $(".hotspot").index(this)+1;
		thisHotSpotID = thisHotSpot - 1;
		thisHotSpotPositionLeft = parseInt(hotSpotPositionsLeft[thisHotSpotID]);
		thisHotSpotPositionTop = parseInt(hotSpotPositionsTop[thisHotSpotID]);
		
		$(this).stop().animate({
							"width" : "24px", "height" : "24px", 
							"left" : thisHotSpotPositionLeft, "top" : thisHotSpotPositionTop
							},
							120, "easeOutQuad");
	});
	
	//===================================================================================


	// footer logo rollovers
	$("#logosList a, #button1 a, #button2 a, #button3 a").hover(function()
	{
		//$("ul#navMain li p").stop().animate({"height" : "45px"}, 250, "easeOutQuad");
		$(this).css({"opacity" : 0.5});
	},
	function()
	{
		$(this).css({"opacity" : 1});
	});
	
	
	// tweaks to last-child currentVacanciesHolder box
	$("#currentVacanciesHolder div:last-child").css({"border-bottom" : "none", "margin-bottom" : "30px" });
		

	// remove dividing line on fly out nav last child
	$("ul#navMain li ul li:last-child a").css({"background-image" : "none"});

});