$(document).ready(function() {

	// Loop through each AREA in the imagemap
	$('#counties area').each(function() {

		// Assigning an action to the mouseover event
		$(this).mouseover(function(e) {
			$country_id = $(this).attr('id').replace('area_', '');
			$("#spritemap li[id!=$country_id]").hide();			
			$('#'+$country_id).show();				
			$("#countyname").html($(this).attr('alt'));

		});
		
		// Assigning an action to the mouseout event
		$(this).mouseout(function(e) {
			$country_id = $(this).attr('id').replace('area_', '');
			$('#'+$country_id).hide();
			 $("#countyname").html("State of Indiana");
		});
	});
	//displays the proper county on the map and text div when selected from the dropdown
	$("#sites").change(function() {
		$("#spritemap li").hide();
		$index = $(this).val();
		if ($index != '--'){
			$("#countyname").html($index + " County");
		}
		else{
			$("#countyname").html("State of Indiana");
		}
		$('#'+$index.toLowerCase()).show();	
	});
	
});

//drives the dropdown form
	function surfto(form) {
  var myindex2=form.select2.selectedIndex;
  var urlpath=window.location.pathname;
  if (myindex2 > 0) {
	 if (urlpath == '/gov/countyarra.htm'){
	 	location=form.select2.options[myindex2].value + "_arra.htm";
	 }
	 else{
	 	location=form.select2.options[myindex2].value + ".htm";
	 }
 }
} 