// JavaScript Document
function pan_update(data){
	var classname,i,length,_period_price,_open,_high,_low,p,_fluctuation,$this,old;
	$("#zhipan_table tr,#jiaocha_table tr").each(function(){
		i=1;
		p=3;
		$this=$(this);
		classname=$this.find("td").eq(0).attr("value");
		length=$this.find("td").length;
		_old=(data[classname]["1"]["close"]);
		_period_price=(data[classname]["1440"]["period_price"])
		if(_period_price>10){p=2;}else{if(_period_price>100){p=1;}else{if(_period_price>1000){p=0;}}}
		_period_price=_period_price.toFixed(p);	
		_open=(data[classname]["1440"]["open"]).toFixed(p);
		_close=(data[classname]["1440"]["close"]).toFixed(p)
		_high=(data[classname]["1440"]["high"]).toFixed(p);
		_low=(data[classname]["1440"]["low"]).toFixed(p);
		_fluctuation=((_close-_open)/_open*100).toFixed(2)+"%";
		var arr=[_close,_high,_low,_fluctuation];
		$("td:not(:first)",this).each(function(i){$(this).html(arr[i])});
		if(parseFloat(_close)>parseFloat(_old)){
			$this.closest("tr").addClass("green").removeClass("red");
		}else{
			if(parseFloat(_close)<parseFloat(_old)){
				$this.closest("tr").addClass("red").removeClass("green");
				}else{
					$this.closest("tr").removeClass("green").removeClass("red");
				}
		}
	})	
}

function zhishu_update(data){
	var classname,i,length,_period_price,_open,_high,_low,p,_fluctuation,_fluctuationNum,$this,old;
	$("#zhishu_table tr").each(function(){
		i=1;
		p=3;
		$this=$(this);
		classname=$this.find("td").eq(0).attr("value");
		length=$this.find("td").length;
		_old=(data[classname]["1"]["close"]);
		_period_price=(data[classname]["1440"]["period_price"]);
		if(_period_price>10){p=2;}else{if(_period_price>100){p=1;}else{if(_period_price>1000){p=0;}}}
		_period_price=_period_price.toFixed(p);	
		_open=(data[classname]["1440"]["open"]).toFixed(p);
		_close=(data[classname]["1440"]["close"]).toFixed(p)
		_high=(data[classname]["1440"]["high"]).toFixed(p);
		_low=(data[classname]["1440"]["low"]).toFixed(p);
		_fluctuationNum=(_close-_open).toFixed(p);
		_fluctuation=(_fluctuationNum/_open*100).toFixed(2)+"%";
		var arr=[_close,_fluctuationNum,_fluctuation]
		$("td:not(:first)",this).each(function(i){$(this).html(arr[i])});
		if(parseFloat(_close)>parseFloat(_old)){
			$("#foot").html("true");
			$this.closest("tr").addClass("green").removeClass("red");
		}else{
			if(parseFloat(_close)<parseFloat(_old)){
				$this.closest("tr").addClass("red").removeClass("green");
				}else{
					$this.closest("tr").removeClass("green").removeClass("red");
				}
		}
		})	

}

