	var chart_cppi;
    $(document).ready(function(){
		var options_cppi = {
			chart: {
				renderTo: 'chart-container-cppi',
				defaultSeriesType: 'line',
				height: 180,
				style: {
					fontFamily: '"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif',
					fontSize: '10px'
				},
				backgroundColor: 'rgba(0,0,0,0)',
				spacingLeft: 5,
				spacingRight: 10,
				zoomType: 'x',
				animation: false //need to disable animation for IE if you want zoom function
			},
			title: {
				text: '',
				align: 'left',
				style: {
					fontFamily: 'CallunaSans, Arial',
					fontSize: '12px',
					color: '#000000'
				}
			},
			xAxis: {
				labels: {
					style: {
						fontSize: '10px'
					}
				},
				startOnTick: false,
				endOnTick: false,
				tickInterval: 63072000000,
				tickLength: 0,
				lineWidth: 0,
				type: 'datetime',
				dateTimeLabelFormats: {
					year: '\'%y'   
				}
			},
			yAxis: {
				title: {
				   text: null
				},
				labels: {
					style: {
						fontSize: '10px'
					}
				},
				//max: 105,
				//min: 40,
				startOnTick: false,
				endOnTick: false,
				tickInterval: 10,
				gridLineColor: '#E8E8E8'
			},
			series: [
/*			{
				name: 'GSA CPPI',
				data: [],
				lineWidth: 2
			} */
			],
			plotOptions: {
				series: {
					marker: {
						enabled: false
					}
				},
				line: {
					dataLabels: {
						enabled: (navigator.appName == 'Microsoft Internet Explorer') ? false : true,
						formatter: function() {
							this.series.options.dataLabels.y = -5;
							if (this.x == lastX) {
								return (Math.round(Math.pow(10,1)*this.y)/Math.pow(10,1)).toFixed(1);
							}
							if (this.x == Date.parse('08/01/2007')) {
								return (Math.round(Math.pow(10,0)*this.y)/Math.pow(10,0)).toFixed(0);
							}
							if (this.x == Date.parse('05/01/2009')) {
								this.series.options.dataLabels.y = 15;
								return (Math.round(Math.pow(10,1)*this.y)/Math.pow(10,1)).toFixed(1);
							}
						}
					}
				}
			},
			legend: {
				enabled: false
			},
			tooltip: {
				formatter: function() {
					var s = '<b>' + Highcharts.dateFormat('%b-%Y', this.x) + '</b>: ' + (Math.round(Math.pow(10,1)*this.y)/Math.pow(10,1)).toFixed(1);
					return s;
				}
			},
			colors: [
				'rgba(85,155,35,0.8)'
			],
			exporting: {
				enabled: false
			},
			credits: {
				enabled: false
			}
		}
		var date = new Date();
		var lastX;
		$.ajax({ //need to use this method instead of getJSON because of crappy IE
			url: '/index.php?module=data&action=cppi&timestamp='+date.getTime(), //timestamping for IE caching issues 
			cache: false,
			dataType: 'json',
			contentType: 'application/json', //need to specify explicitly for IE
			success: function(returnData) {
				var series = {
					name: 'GSA CPPI',
					data: [],
					lineWidth: 2
				};
				for(var i=0; i< returnData.items.length;i++) {
					var sDate;
					sDate = parseDate(returnData.items[i].date, 'yyyy-mm-dd').getTime();
					series.data.push([sDate, parseFloat(returnData.items[i].cppi)]);
					if (i == returnData.items.length-1) { 
						lastX = sDate;
					}
				}
				options_cppi.series.push(series);
				var chart = new Highcharts.Chart(options_cppi);
			},
			error: function(xhr, status, error) {
				alert(xhr.status);
			}
		});
    });
