function ssh() {
//http://bdchart.hexun.com/stock/chart/index/index_1_000001.png
	fetchPic('http://bdchart.hexun.com/stock/chart/index/index_1_000001.png', 'a1');
	fetchPic('http://minpic.quote.stock.hexun.com/WebPic/SZ/Min/399001_www3.gif', 'a2');
	fetchPic('http://bdchart.hexun.com/stock/chart/index/index_1_399300.png?57142.209', 'a3');
	fetchData1();
}

function fetchPic(url, id) {
	$("#" + id).html("<img src='" + url + "?" +  Math.random() + "' width='210px;' />");
}

function fetchData1() {
	 
	$.ajax({
		url:'AjaxPage/funddataquery.aspx?type=4&num='+ getCurrTimeStamp(),
		type:'GET',
		dataType:'json',
		success:function(data){
			findIDs("bfn2_", data, {la:{percent:false, color:true,prop:'zde'},zde:{percent:false, color:true},pc:{percent:false, color:false}});
		}
	});
	$.ajax({
		url:'AjaxPage/funddataquery.aspx?type=4&num=2&m_=' + Math.random(),
		type:'GET',
		dataType:'json',
		success:function(data){
			findIDs("bfn1_", data, {zdf:{percent:true,color:true},la:{percent:false,color:true,prop:'zde'},zde:{percent:false, color:true}});
			var name = data["000001.sh"].na;
			var la = data["000001.sh"].la;
			var pc = data["000001.sh"].pc;
			var pd = ForDight(la - pc, 2);
			var pp = ForDight((pd/la)*100, 2);
			if(pd >= 0) {
				pd = "<font size='2'>↑</font>" + pd;
				$("#000001_sh").attr('class', 'RedText');
			} else {
				pd = "<font size='2'>↓</font>" + pd;
				$("#000001_sh").attr('class', 'GreenText');
			}
			$("#000001_sh").html("<font color='#333' size='2'>" + name + "</font>" + "&nbsp;&nbsp;" + formatnumber(la, 2) + "&nbsp;&nbsp;" + pd + "&nbsp;&nbsp;" + pp + "%");
			name = data["399001.sz"].na;
			la = data["399001.sz"].la;
			pc = data["399001.sz"].pc;
			pd = ForDight(la - pc, 2);
			pp = ForDight((pd/la)*100, 2);
			if(pd >= 0) {
				pd = "<font size='2'>↑</font>" + pd;
				$("#399001_sz").attr('class', 'RedText');
			} else {
				pd = "<font size='2'>↓</font>" + pd;
				$("#399001_sz").attr('class', 'GreenText');
			}
			$("#399001_sz").html("<font color='#333' size='2'>" + name + "</font>" + "&nbsp;&nbsp;" + formatnumber(la, 2) + "&nbsp;&nbsp;" + pd + "&nbsp;&nbsp;" + pp + "%");
			name = data["399300.sz"].na;
			la = data["399300.sz"].la;
			pc = data["399300.sz"].pc;
			pd = ForDight(la - pc, 2);
			pp = ForDight((pd/la)*100, 2);
			if(pd >= 0) {
				pd = "<font size='2'>↑</font>" + pd;
				$("#399300_sz").attr('class', 'RedText');
			} else {
				pd = "<font size='2'>↓</font>" + pd;
				$("#399300_sz").attr('class', 'GreenText');
			}
			$("#399300_sz").html("<font color='#333' size='2'>" + name + "</font>" + "&nbsp;&nbsp;" + formatnumber(la, 2) + "&nbsp;&nbsp;" + pd + "&nbsp;&nbsp;" + pp + "%");
		}
	});
}

function findIDs(start, data, options) {
	$('span[id^="' + start + '"]').each(function() {
		var id = $(this).attr("id");
		var _f = id.lastIndexOf("_");
		var obj = id.substring(_f+1);
		var attr = id.substring(start.length, _f);
		var result = eval('data["' + obj + '"].' + attr);
		if(result) {
			var out = result;
			options = options || {all:{color:true}};
						
			if((options.hasOwnProperty("all")&&options["all"].color)
				||options.hasOwnProperty(attr)&&options[attr].color) {
				if(result > 0) {
					if(options.hasOwnProperty(attr)&&options[attr].prop) {
						if(Number(eval('data["' + obj + '"].' + options[attr].prop)) < 0) {
							$(this).attr("class", "GreenText");
						} else if(Number(eval('data["' + obj + '"].' + options[attr].prop)) > 0) {
							$(this).attr("class", "RedText");
						}
					} else {
						$(this).attr("class", "RedText");
					}
				} else if(result <0) {
					$(this).attr("class", "GreenText");
				}
			}
			
			if(options.hasOwnProperty(attr)&&options[attr].percent) {
				out += "%";
			}
			$(this).html(out);
		}
		
	});
}


function getCurrTimeStamp(){
var a=new Date(),b=a.getHours()*3600+a.getMinutes()*60+a.getSeconds()+a.getMilliseconds()/1000;return b;}
