(function($) {
	var options = {
		tracking: {
			enabled: false
		},
		series: {
			tracking: {
				label: function(item) {
					if (item.series.tracking.labels) {
						return item.series.tracking.labels[item.dataIndex];
					} else {
						return '(' + item.datapoint[0] + ', ' + item.datapoint[1] + ')';
					}
				}
			} 
		}
	};

	function init(plot) {
		var placeholder = $(plot.getPlaceholder());
		var label = $('<div style="display: none; text-align: center; padding: 5px; padding-bottom: 4px; position: absolute; bottom: 21px; right: 12px; background-color: black; color: white"></div>');
		label.fadeTo(0, 0.8);
		if ($.browser.msie) {
			label.css({right: '17px', bottom: '23px'});
		}
		placeholder.bind("plothover", function(event, pos, item) {
			if (!plot.getOptions().tracking.enabled) return;
			if (label.parent() != placeholder) {
				placeholder.append(label);
				label.corner("6px");
			}
			if (!item) {
				label.hide();
				return;
			};
			label.show();
			label.text(item.series.tracking.label(item));
		});	
	};

	$.plot.plugins.push({
		init: init,
		options: options,
		name: 'tracking',
		version: '0.1'
	});
})(jQuery)

