$(document).ready(function() {
	$('#graphroll_points li').bind('mouseover', function() {
		$('#graphroll_data li').fadeOut();
		var id = $(this).attr('id').replace(/graphroll_point_/,'');
		$('#graphroll_data_'+id).fadeIn();
	});
	$('#graphroll_points li').bind('mouseout', function() {
		var id = $(this).attr('id').replace(/graphroll_point_/,'');
		$('#graphroll_point_'+id).oneTime('0.1s', 'fade_graphroll_data', function() {
			$('#graphroll_data_'+id).fadeOut();
		} );
	});
	$('#graphroll_data li').bind('mouseover', function() {
		var id = $(this).attr('id').replace(/graphroll_data_/,'');
		$('#graphroll_point_'+id).stopTime('fade_graphroll_data');
	});
	$('#graphroll_data li').bind('mouseout', function() {
		var id = $(this).attr('id').replace(/graphroll_data_/,'');
		$('#graphroll_point_'+id).oneTime('0.1s', 'fade_graphroll_data', function() {
			$('#graphroll_data_'+id).fadeOut();
		} );
	});
});

$(document).ready( function() {
	$('#poverty_markers li').bind('mouseover', function() {
		$(window).stopTime('close_poverty_bubble');
		povertyShowBubble( this );
	} );
	$('#poverty_markers li').bind('mouseout', function() {
		console.log('marker_out');
		$(window).oneTime('1s', 'close_poverty_bubble', function() {
			povertyShowBubble('');
		});
	} );
	$('#poverty_bubbles li').bind('mouseover', function() {
		$(window).stopTime('close_poverty_bubble');
	} );
	$('#poverty_bubbles li').bind('mouseout', function() {
		console.log('bubble_out');
		$(window).oneTime(100, 'close_poverty_bubble', function() {
			povertyShowBubble('');
		});
	});

} );

function povertyShowBubble(marker) {
	var map_id = (marker)
		? $(marker).attr('id').replace(/poverty_marker_/, '')
		: null;
	$('#poverty_bubbles li').each(function() {
		if( $(this).attr('id').replace(/poverty_bubble_/,'') == map_id ) {
			$(this).fadeIn();
		}
		else {
			$(this).fadeOut();
		}
	});
}
