$(function () {
	var k = [];
	var l = [];	
	var m = '/ajax/graphdata_pie.asp?graphid=' + graphid + '&temptable=' + temptable;
	var n = "";
	n = graphtitle;

	$.getJSON(m, function (h) {	
		$.each(h.results, function (i, a) {
			var b = new Array(a.shorttitle, a.value);			
			if (a.title == "maintitle") {
				//n = a.value
			} else {
				k.push(a.tooltip);
				l.push(b)
			}
		});		

		var j = $.jqplot('chartdiv' + chartid, [l], {
			title: n,
			seriesDefaults: {
				renderer: $.jqplot.PieRenderer,
				rendererOptions: {
					// Put data labels on the pie slices.          
					// By default, labels show the percentage of the slice.          
					showDataLabels: true,
					padding:5
				}
			},
			legend: { show:true, location: 'e', border: 'none' },
			seriesColors: ["#00C3FF","#0B8BFF","#0061C9","#00349E","#697070","#343737"]
		});	
		
		$('#chartdiv' + chartid).bind('jqplotDataHighlight', function (a, b, c, d) {
			var e = a.pageX;
			var f = a.pageY;
			$('#chartpseudotooltip').html(k[c]).show();
			var g = {
				'color': '#00C3FF',
				'z-index': '9999',
				'position': 'absolute',
				'font-family': 'Arial',
				'font-weight': 'normal',
				'padding': '3px',
				'font-size': '11px',
				'background-color': '#FFFFFF',
				'text-align': 'center',
				'left': parseInt(e) + 10 + 'px',
				'top': f + 'px',
				'border': '1px solid #00C3FF'
			};
			$('#chartpseudotooltip').css(g)
		});
		$('#chartdiv' + chartid).bind('jqplotDataUnhighlight', function (a) {
			$('#chartpseudotooltip').html('').hide()
		})			
	})
});
