// ------------------------------------------------------------
// initialize event handlers
// ------------------------------------------------------------
$(document).ready(
	function() 
	{
		// $("dl#main dd.nav-main li.main").hide();
		
		$("dl#main dd.nav-main li.main, dl#main dd.nav-main li.main ul").hover(
			function ()
			{
				$(this).addClass("hover");
			},
			function ()
			{
				$(this).removeClass("hover");
			}
		);
		
		$("#fields_email").val($("#fields_email").attr("default-value"));
		$("#fields_email").focus(handleAlertFocus);
		$("#fields_email").blur(handleAlertBlur);
		
		$("#map-tooltip").hide();
		$("#map area").hover(handleMapOver, handleMapOut);
		$("#map").mousemove(handleMapMove);
	}
);

// ------------------------------------------------------------
// 
// ------------------------------------------------------------
function handleAlertFocus ()
{
	var el = $(this);
	
	if (el.val() == el.attr("default-value"))
	{
		el.val("");
	};
};

function handleAlertBlur ()
{
	var el = $(this);
	
	if (el.val() == "")
	{
		el.val(el.attr("default-value"));
	};
};

// ------------------------------------------------------------
// 
// ------------------------------------------------------------
function handleMapOver ()
{
	var tooltipEl = $("#map-tooltip");
	
	$("span.city", tooltipEl).html($(this).attr("city"));
	$("span.mayor", tooltipEl).html($(this).attr("mayor"));
	
	tooltipEl.show();
};

function handleMapOut ()
{
	$("#map-tooltip").hide();
};

function handleMapMove (e)
{
	var tooltipEl = $("#map-tooltip");
	var mapEl = $("#map");
	
	tooltipEl.css({
		top: e.pageY - mapEl.offset().top + 5,
		left: e.pageX - mapEl.offset().left + 15
	});
};


