//改函数将从指定的 URL 装载 XML 文档，在装载完毕时，
//把该文档和 URL 传递给指定的处理函数。（任何 XML 文档都可以使用该函数）
function load() {
	var url = "images/homepage/hqsj.xml";
	var handler = fuzhi;
	// 如果它受支持，则采用标准的 2 级 DOM 技术
	if(document.implementation && document.implementation.createDocument){
		// 创建新的 Document 对象
		var xmldoc = document.implementation.createDocument("", "", null);
		// 设置装载完毕时发生的情况
		xmldoc.onload = function(){ handler(xmldoc); }
		// 告诉它装载什么 URL
		xmldoc.load(url);
	}else if(window.ActiveXObject){  // 否则，用Microsoft 公司专有的用于 Internet Explorer 的 API
		var xmldoc=new ActiveXObject("Microsoft.XMLDOM"); // 创建文档
		xmldoc.onreadystatechange = function() {  // 设置 onload
			if(xmldoc.readyState == 4) handler(xmldoc);
		}
		xmldoc.load(url);  // 开始装载
	}
}
// 显示2个主要行情的基本数据
function fuzhi(xmldoc){
	var ms=xmldoc.getElementsByTagName('Record');
	for(var i=0; i<ms.length; i++){
		var cs=ms[i].getElementsByTagName('Item');
		var f_10, f_199112, f_19, f_6, f_38, f_37, f_39;
		if(cs[0].getElementsByTagName('Value')[0].firstChild.data == '1A0001'){
			f_10 = f_199112 = f_19 = f_6 = f_38 = f_37 = f_39 = '';
			for(var j=0; j<cs.length; j++){
				if(cs[j].getAttribute('Id')=='10'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_10 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
					}
				}
				if(cs[j].getAttribute('Id')=='199112'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_199112 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
					}
				}
				if(cs[j].getAttribute('Id')=='19'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_19 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
					}
				}
				if(cs[j].getAttribute('Id')=='6'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_6 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
					}
				}
				if(cs[j].getAttribute('Id')=='38'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_38 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
					}
				}
				if(cs[j].getAttribute('Id')=='37'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_37 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
						if(f_37 < 0) f_37 = 0;
					}
				}
				if(cs[j].getAttribute('Id')=='39'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_39 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
					}
				}
				if(f_10 > f_6){
					zs_1.innerHTML = '<font color=red>'+f_10+'</font>'; 
				}else{
					zs_1.innerHTML = '<font color=green>'+f_10+'</font>';
				}
				if(f_199112 > 0){
					zf_1.innerHTML = '<font color=red>'+f_199112+'%</font>'; 
				}else{
					zf_1.innerHTML = '<font color=green>'+f_199112+'%</font>';
				}
				je_1.innerHTML = '<font color=#000000>'+Math.round(f_19/1000000)/100+'亿</font>';
				sz_1.innerHTML = '<font color=red>'+f_38+'</font>';
				f_pp = (f_37-f_38-f_39 > 0)? f_37-f_38-f_39 : 0; 
				pp_1.innerHTML = '<font color=#000000>'+f_pp+'</font>';
				xd_1.innerHTML = '<font color=green>'+f_39+'</font>';
			}			
		}else if(cs[0].getElementsByTagName('Value')[0].firstChild.data == '399001'){
			f_10 = f_199112 = f_19 = f_6 = f_38 = f_37 = f_39 = '';
			for(var j=0; j<cs.length; j++){
				if(cs[j].getAttribute('Id')=='10'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_10 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
					}
				}
				if(cs[j].getAttribute('Id')=='199112'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_199112 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
					}
				}
				if(cs[j].getAttribute('Id')=='19'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_19 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
					}
				}
				if(cs[j].getAttribute('Id')=='6'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_6 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
					}
				}
				if(cs[j].getAttribute('Id')=='38'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_38 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
					}
				}
				if(cs[j].getAttribute('Id')=='37'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_37 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
						if(f_37 < 0) f_37 = 0;
					}
				}
				if(cs[j].getAttribute('Id')=='39'){
					if(cs[j].getElementsByTagName('Value')[0].firstChild != null){
						f_39 = cs[j].getElementsByTagName('Value')[0].firstChild.data;
					}
				}
				if(f_10 > f_6){
					zs_2.innerHTML = '<font color=red>'+f_10+'</font>'; 
				}else{
					zs_2.innerHTML = '<font color=green>'+f_10+'</font>';
				}
				if(f_199112 > 0){
					zf_2.innerHTML = '<font color=red>'+f_199112+'%</font>'; 
				}else{
					zf_2.innerHTML = '<font color=green>'+f_199112+'%</font>';
				}
				je_2.innerHTML = '<font color=#000000>'+Math.round(f_19/1000000)/100+'亿</font>';
				sz_2.innerHTML = '<font color=red>'+f_38+'</font>';
				f_pp = (f_37-f_38-f_39 > 0)? f_37-f_38-f_39 : 0; 
				pp_2.innerHTML = '<font color=#000000>'+f_pp+'</font>';
				xd_2.innerHTML = '<font color=green>'+f_39+'</font>';	
			}
		}
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3){
		if ((obj=MM_findObj(args[i]))!=null) { 
			v=args[i+2];
    		if (obj.style) { 
				obj=obj.style;
				v=(v=='show')?'visible':(v=='hide')?'hidden':v; 
			}
    		obj.visibility=v; 
		}
	}
}
function set_tab(n){
	for(i=1; i<=4; i++){
		if(n==i){
			document.getElementById("current"+i+"").style.background = "url(images/left_title04b.gif)";
			document.getElementById("current"+i+"").style.padding="2px 5px 3px 5px";
		}else{
			document.getElementById("current"+i+"").style.background = "url(images/left_title04.gif)";
			document.getElementById("current"+i+"").style.padding="2px 5px 2px 5px";
		}
	}
}







