function killerrors() { 
return true; 
} 
 window.onerror = killerrors; 
function paixu(dataarr){
	var dd=[];
	for(var i=dataarr.length-1;i>=0;i--){
		dd.push(dataarr[i]);
	}
	return dd;
}
function commontable(obj,columnnum,rowindexmin,rowindexmax,arrcolumn){
	var temptr=[];
	  $("#datacon").find("tr").each(function (index) {
	  var tr =$(this); 
	  if(index>rowindexmin){
		  if(index<=rowindexmax){
		  temptr.push('<tr>');
		  if(columnnum>0){
		  for(var i=0;i<columnnum;i++)
		  temptr.push('<td>'+$("td:eq("+i+")",tr).html()+'</td>');
		  }else{
			  for(var i=0;i<arrcolumn.length;i++){
				  temptr.push('<td>'+$("td:eq("+arrcolumn[i]+")",tr).html()+'</td>');
			  } 
		  }
		  temptr.push('</tr>');
		  }
	  }
	  });
	  obj.find("tbody").html(temptr.join(""));
}
 
 
function xzxd(){
	 var temptr=[],tempdata1=[],temptitle=[];
	  $("#datacon").find("tr").each(function (index) {
	  var tr =$(this); 
	  if(index>1){
		  temptitle.push($("td:eq(0)",tr).html());
		  tempdata1.push(parseFloat($("td:eq(1)",tr).html()));
		  if(index<=9){
		  temptr.push('<tr>');
		  temptr.push('<td>'+$("td:eq(0)",tr).html()+'</td>');
		  temptr.push('<td>'+$("td:eq(1)",tr).html()+'</td>');
		  temptr.push('<td>'+$("td:eq(2)",tr).html()+'</td>');
		  temptr.push('</tr>');
		  }
	  }
	  });
	   temptitle=paixu(temptitle);
	   tempdata1=paixu(tempdata1);
	  $("#xindtable").find("tbody").html(temptr.join(""));
	  var xd = new Highcharts.Chart({
			chart: {
				renderTo: 'xd',
				defaultSeriesType: 'line',
				margin: [50, 170, 60, 80],
				min:'0'
			},
			yAxis: {
				title: {
					text: ''
				},
				labels: {
					style: {
						color: '#000000'
					}
				},					
				plotLines: [{
					value: 0,
					width: 1,
					color: '#808080'
				}]
			},
			tooltip: {
				formatter: function() {
		                return '<b>'+ this.series.name +'</b><br/>'+
						this.x +': '+ this.y +'';
				}
			},
			legend: {
				layout: 'vertical',
				style: {
					left: 'auto',
					bottom: 'auto',
					right: '10px',
					top: '40px'
				},
	       	itemStyle: {
	              color: "#000000"
	          }
			},	
			title: {
				text: '<b>\u56fd\u5185\u751f\u4ea7\u603b\u503c(GDP)(\u4ebf\u5143)</b>',
				style: {
					margin: '10px 100px 0 0' // center it
				}
			},
			xAxis: {
				categories: 
					temptitle,
				labels: {
					rotation: -30,	align: 'right',	
					style: { font: 'normal 13px Verdana, sans-serif'}}
					},
				series: [
				    {name: '\u5f53\u6708(\u4ebf\u5143)',data: tempdata1}
					]			
					});  
}
function cpi(){
	 var temptr=[],tempdata1=[],tempdata2=[],tempdata3=[],temptitle=[];
	  $("#datacon").find("tr").each(function (index) {
		
	  var tr =$(this); 
	 
	  if(index>1){
		  temptitle.push($("td:eq(0)",tr).html());
		  tempdata1.push(parseFloat($("td:eq(1)",tr).html()));
		  tempdata2.push(parseFloat($("td:eq(4)",tr).html()));
		  tempdata3.push(parseFloat($("td:eq(7)",tr).html()));
//		  tempdata=[]
		  if(index<=9){
		  
		  temptr.push('<tr>');
		  temptr.push('<td>'+$("td:eq(0)",tr).html()+'</td>');
		  temptr.push('<td>'+$("td:eq(1)",tr).html()+'</td>');
		  temptr.push('<td>'+$("td:eq(2)",tr).html()+'</td>');
		  temptr.push('</tr>');
		  }
	  }
	  });
	   temptitle=paixu(temptitle);
	   tempdata1=paixu(tempdata1);
	   tempdata2=paixu(tempdata2);
	   tempdata3=paixu(tempdata3); 
	  $("#cpitable").find("tbody").html(temptr.join(""));
	  var cpi = new Highcharts.Chart({
			chart: {
				renderTo: 'cpi',
				defaultSeriesType: 'line',
				margin: [50, 170, 60, 80],
				min:'0'
			},
			yAxis: {
				title: {
					text: ''
				},
				labels: {
					style: {
						color: '#000000'
					}
				},					
				plotLines: [{
					value: 0,
					width: 1,
					color: '#808080'
				}]
			},
			tooltip: {
				formatter: function() {
		                return '<b>'+ this.series.name +'</b><br/>'+
						this.x +': '+ this.y +'';
				}
			},
			/*
			credits: {
	          enabled: true, //是否显示右下角LOGO
	          text: 'gjscn.com'
	   	},*/
			legend: {
				layout: 'vertical',
				style: {
					left: 'auto',
					bottom: 'auto',
					right: '10px',
					top: '40px'
				},
	       	itemStyle: {
	              color: "#000000"
	          }
			},	
			title: {
				text: '<b>\u5c45\u6c11\u6d88\u8d39\u4ef7\u683c\u6307\u6570(CPI)</b>',
				style: {
					margin: '10px 100px 0 0' // center it
				}
			},
			xAxis: {
				categories: 
					temptitle,
				labels: {
					rotation: -30,	align: 'right',	
					style: { font: 'normal 13px Verdana, sans-serif'}}
					},
				series: [
						{name: '\u5168\u56fd\u5f53\u6708',data: tempdata1}, 
						{name: '\u57ce\u5e02\u5f53\u6708',data: tempdata2}, 
						{name: '\u519c\u6751\u5f53\u6708',data: tempdata3}
					]			
					});  
}
function gdp(){
	var temptr=[],tempdata1=[],tempdata2=[],tempdata3=[],tempdata4=[],temptitle=[];
	  $("#datacon").find("tr").each(function (index) {
	  var tr =$(this); 
	  if(index>1){
		  temptitle.push($("td:eq(0)",tr).html());
		  tempdata1.push(parseFloat($("td:eq(1)",tr).html()));
		  tempdata2.push(parseFloat($("td:eq(3)",tr).html()));
		  tempdata3.push(parseFloat($("td:eq(5)",tr).html()));
		  tempdata4.push(parseFloat($("td:eq(7)",tr).html()));
//		  tempdata=[]
		  if(index<=9){
		  
		  temptr.push('<tr>');
		  temptr.push('<td>'+$("td:eq(0)",tr).html()+'</td>');
		  temptr.push('<td>'+$("td:eq(1)",tr).html()+'</td>');
		  temptr.push('<td>'+$("td:eq(2)",tr).html()+'</td>');
		  temptr.push('</tr>');
		  }
	  }
	  });
	   temptitle=paixu(temptitle);
	   tempdata1=paixu(tempdata1);
	   tempdata2=paixu(tempdata2);
	   tempdata3=paixu(tempdata3); 
	   tempdata4=paixu(tempdata4);
	  $("#gdptable").find("tbody").html(temptr.join(""));
	  var gdp = new Highcharts.Chart({
			chart: {
				renderTo: 'gdp',
				defaultSeriesType: 'line',
				margin: [50, 170, 60, 80],
				min:'0'
			},
			yAxis: {
				title: {
					text: ''
				},
				labels: {
					style: {
						color: '#000000'
					}
				},					
				plotLines: [{
					value: 0,
					width: 1,
					color: '#808080'
				}]
			},
			tooltip: {
				formatter: function() {
		                return '<b>'+ this.series.name +'</b><br/>'+
						this.x +': '+ this.y +'';
				}
			},
			/*
			credits: {
	          enabled: true, //是否显示右下角LOGO
	          text: 'gjscn.com'
	   	},*/
			legend: {
				layout: 'vertical',
				style: {
					left: 'auto',
					bottom: 'auto',
					right: '10px',
					top: '40px'
				},
	       	itemStyle: {
	              color: "#000000"
	          }
			},	
			title: {
				text: '<b>\u56fd\u5185\u751f\u4ea7\u603b\u503c(GDP)(\u4ebf\u5143)</b>',
				style: {
					margin: '10px 100px 0 0' // center it
				}
			},
			xAxis: {
				categories: 
					temptitle,
				labels: {
					rotation: -30,	align: 'right',	
					style: { font: 'normal 13px Verdana, sans-serif'}}
					},
				series: [
				    {name: '\u56fd\u5185\u751f\u4ea7\u603b\u503c\u7edd\u5bf9\u503c',data: tempdata1}, 
					{name: '\u7b2c\u4e00\u4ea7\u4e1a\u7edd\u5bf9\u503c',data: tempdata2}, 
					{name: '\u7b2c\u4e8c\u4ea7\u4e1a\u7edd\u5bf9\u503c',data: tempdata3}, 
					{name: '\u7b2c\u4e09\u4ea7\u4e1a\u7edd\u5bf9\u503c',data: tempdata4}
					]			
					});  	 
}
//id 为 GDP等  ct是ID  mon是周期 gs取的个数
function getData(id,gs){
id=id.toUpperCase();
var mon='Enddatedate';
var ct='30';
if(!gs)gs='12';
switch(id){
case 'GDP':mon='Enddatedate';
ct='30';
break;
case 'CPI':mon='month';
ct='27';
break;
case 'PPI':mon='month';
ct=29;
break;
case 'PMI':mon='month';
ct=31;
break;
case 'GDSC':mon='month';
ct=32;
break;
case 'FXSS':mon='month';
ct=9;
break;
case 'XFXSS':mon='time';
ct=12;
break;
case 'GYSD':mon='month';
ct=34;
break;
case 'QYXX':mon='Enddatedate';
ct=33;
break;
case 'QYZP':mon='month';
ct=36;
break;
case 'CCI':mon='month';
ct=37;
break;
case 'XFP':mon='month';
ct=35;
break;
case 'HGJCK':mon='month';
ct=26;
break;
case 'HJWH':mon='month';
ct=24;
break;
case 'FDI':mon='month';
ct=23;
break;
case 'GPJYTJ':mon='month';
ct=25;
break;
case 'GPZHTJ':mon='Statisticalstartdate';
ct=13;
break;
case 'CZSR':mon='month';
ct=22;
break;
case 'SSSR':mon='id';
ct=21;
break;
case 'XZXD':mon='month';
ct=20;
break;
case 'CJLL':mon='month';
ct=19;
break;
case 'WBCK':mon='month';
ct=18;
break;
case 'WBDK':mon='month';
ct=17;
break;
case 'HBGYL':mon='month';
ct=28;
break;
case 'CKZBJ':mon='Publicationtime';
ct=16;
break;
case 'YHLL':mon='shangtiaodate';
ct=15;
break;
case 'CPY':mon='date';
ct=39;
break;
}	 
idd=id+'/'+ct+'/';
$.getJSON('http://app.cnfol.com/dataapi/index.php/welcome/table/'+idd+gs+'/1/'+mon+'/desc/1/0/1/data/hgsy?jsoncallback=?',
 function(json){
  $("#datacon").html(json);
  switch(id){
  case 'GDP':
	  gdp();
  break;
  case 'CPI': 
	  cpi();
  break;
  case 'XZXD':
   xzxd();
  break;
  case 'PPI':
	  commontable($("#ppitable"),4,0,3);
	  break;
  case 'PMI':
	  commontable($("#pmitable"),5,1,4);
	  break;
  case 'YHLL':
	  commontable($("#lilvtable"),0,1,4,[0,2,5]);
	  break;
  case 'CKZBJ':
	  commontable($("#cunktable"),0,1,4,[0,1,3,6]);
	  break;
  case 'HJWH':
	  commontable($("#whzbtable"),7,1,4);
	  break;
  case 'FDI':
	  commontable($("#fditable"),5,1,4);
	  break;
  }	 
//  for (var i = 0; i < tr.length; i++) {
       //alert(tr[i].find("td:eq(0)").html());
	//  console.log($("td:eq(0)",tr).html());
//  }
});
}