
/*
 * 
 * ==============================================================================================
 * 名称：xyjl.js
 * 
 * 功能： 信用交流。
 * 
 * 包括：
 * 
 * 
 * 作者：郭奇
 * 
 * 日期：2009-12-02
 * ==============================================================================================
 * 
 */
/*
 * 
 * ==============================================================================================
 * 函数名称： _startLoadXmlNotice(sSrc) 功能说明： 创建xmlhttp对象,并且开始装载XML文件 使用参数： sSrc：链接。
 * 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
 var img_path;
 
function _startLoadXmlXyjl(sSrc) {
	var xmlHttp = XmlHttp.create();
	xmlHttp.open("GET", sSrc, true); // async
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4) {
			_xmlXyjlLoaded(xmlHttp.responseXML);
		}
	};
	// call in new thread to allow ui to update
	window.setTimeout(function() {
				xmlHttp.send(null);
			}, 10);
}
/*
 * 
 * ==============================================================================================
 * 函数名称： _xmlUnitLoaded(oXmlDoc) 功能说明： 装载XML文件 使用参数： oXmlDoc：XML文件。 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _xmlXyjlLoaded(oXmlDoc) {
	var bAnyChildren = false;
	var errorText = "";
	var jsUnit = "";

	// check that the load of the xml file went well
	if (oXmlDoc == null || oXmlDoc.documentElement == null) {
		errorText = "读取数据失败，请重试。";
	} else {
		// there is one extra level of tree elements
		var root = oXmlDoc.documentElement;

		// loop through all tree children
		var cs = root.childNodes;
		var l = cs.length;
		for (var i = 0; i < l; i++) {
			if (cs[i].tagName == "xyjl") {
				bAnyChildren = true;
				jsUnit += _xmlUnitToJsXyjl(cs[i]);
			}
		}

		// if no children we got an error
		if (!bAnyChildren) {
			errorText = "读取数据失败，请重试。";
		}
	}
	// build js Unit
	if (jsUnit != "") {
		_buildJsXyjl(jsUnit);
	} else {
		errorText = "读取数据失败，请重试。";
	}

	// show error
	if (errorText != "") {
		_buildJsXyjlError(errorText);
	}
}
/*
 * 
 * ==============================================================================================
 * 函数名称： _xmlUnitToJsUnit(oNode) 功能说明： 组建js信息 使用参数： oNode：XML文件节点。 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _xmlUnitToJsXyjl(oNode) {
	// retreive attributes
	var unitName = oNode.getAttribute("title");
	var db = oNode.getAttribute("db");
	var id = oNode.getAttribute("id");
	var checkDate = oNode.getAttribute("memo");
	// create jsNode
	var jsNode;
	if (checkDate != "") {
		jsNode = "<tr><td align=\"left\"><a target=\"_blank\" href=\"http://www.cdcredit.gov.cn/lybbs/bbs_topic.do?forumID="+db+"&postID="+id + "\">"
				 + bullet+ unitName + " </a></td>"
				 + "</tr>";
	} else {
	//	jsNode = bullet + "<span class=\"blue\">" + unitName + "</span><BR>";
		jsNode = "<tr><td align=\"left\"><a target=\"_blank\" href=\"http://www.cdcredit.gov.cn/lybbs/bbs_topic.do?forumID="+db+"&postID="+id + "\">"
				 + bullet+ unitName + " </a></td>"
				 + "</tr>";
	}

	return jsNode;
}
/*
 * 
 * ==============================================================================================
 * 函数名称： _buildJsUnit(str) 功能说明： 组织页面显示js信息 使用参数： str：js信息。 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _buildJsXyjl(str) {
	var _html =  "<table width=\"370\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" class=\"idxList\">";
	_html += str;
	_html += "</table>";
	document.getElementById("dataInfo").height = "100%";
	document.getElementById("dataXyjl").innerHTML = _html;
}
/*
 * 
 * ==============================================================================================
 * 函数名称： _buildJsUnitError(str) 功能说明： 组织页面显示js错误信息 使用参数： str：错误信息。 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _buildJsXyjlError(str) {
	//str = bullet + "<a href=\"javascript:LoadUnitDate();\">" + str + "</a><BR>";
	//document.getElementById("dataXyjl").innerHTML = str;
	var _loading = "<table height=\"147\" width=\"370\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" >";
	_loading += "<tr>";
	_loading += "<td valign=\"middle\" align=\"right\" width=\"140\"><img src=\""
			+ img_path
			+ "/resource/website/images/flash-face.gif\" border=0 ></td>";
	_loading += "<td valign=\"middle\" width=\"230\">&nbsp;&nbsp;\u6ca1\u6709\u627e\u5230\u6570\u636e\uff01\uff01</td>";
	_loading += "</tr></table>";
	document.getElementById("dataInfo").height = "";
	document.getElementById("dataXyjl").innerHTML = _loading;
}

var bullet;

/*
 * 
 * ==============================================================================================
 * 函数名称： ShowXyjlData(path) 功能说明： 显示成员单位更新时间 使用参数： path：路径 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function ShowXyjlData(path) {
	bullet = "<img src=\""
			+ path
			+ "/resource/website/images/arrow.gif\" border=\"0\"  style=\"vertical-align:middle\"/>&nbsp;";
		
	_createXyjlDateLoading(path);
	_startLoadXmlXyjl(path + "/mainIndex.do?method=creditAlternate");
}

/*
 * 
 * ==============================================================================================
 * 函数名称： _createLoading(path) 功能说明： Loading 使用参数： path：路径 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _createXyjlDateLoading(path) {
	var _loading = "<table height=\"147\" width=\"370\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" >";
	_loading += "<tr>";
	_loading += "<td valign=\"middle\" align=\"right\" width=\"140\"><img src=\""
			+ path
			+ "/resource/website/images/flash-loading-001.gif\" border=0 ></td>";
	_loading += "<td valign=\"middle\" width=\"230\">&nbsp;&nbsp;\u8bfb\u53d6\u6570\u636e\u4e2d\u002e\u002e\u002e</td>";
	_loading += "</tr></table>";
	document.getElementById("dataInfo").height = "";
	document.getElementById("dataXyjl").innerHTML = _loading;
}


/*
 * 
 * ==============================================================================================
 * 函数名称： _startLoadXmlNotice(sSrc) 功能说明： 创建xmlhttp对象,并且开始装载XML文件 使用参数： sSrc：链接。
 * 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _startLoadXmlTop(sSrc) {
	var xmlHttp = XmlHttp.create();
	xmlHttp.open("GET", sSrc, true); // async
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4) {
			_xmlTopLoaded(xmlHttp.responseXML);
		}
	};
	// call in new thread to allow ui to update
	window.setTimeout(function() {
				xmlHttp.send(null);
			}, 10);
}
/*
 * 
 * ==============================================================================================
 * 函数名称： _xmlUnitLoaded(oXmlDoc) 功能说明： 装载XML文件 使用参数： oXmlDoc：XML文件。 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _xmlTopLoaded(oXmlDoc) {
	var bAnyChildren = false;
	var errorText = "";
	var jsUnit = "";

	// check that the load of the xml file went well
	if (oXmlDoc == null || oXmlDoc.documentElement == null) {
		errorText = "读取数据失败，请重试。";
	} else {
		// there is one extra level of tree elements
		var root = oXmlDoc.documentElement;

		// loop through all tree children
		var cs = root.childNodes;
		var l = cs.length;
		for (var i = 0; i < l; i++) {
			if (cs[i].tagName == "enterprise") {
				bAnyChildren = true;
				jsUnit += _xmlUnitToJsTop(cs[i],i+1);
			}
		}

		// if no children we got an error
		if (!bAnyChildren) {
			errorText = "读取数据失败，请重试。";
		}
	}
	// build js Unit
	if (jsUnit != "") {
		_buildJsTop(jsUnit);
	} else {
		errorText = "读取数据失败，请重试。";
	}

	// show error
	if (errorText != "") {
		_buildJsTopError(errorText);
	}
}
/*
 * 
 * ==============================================================================================
 * 函数名称： _xmlUnitToJsUnit(oNode) 功能说明： 组建js信息 使用参数： oNode：XML文件节点。 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _xmlUnitToJsTop(oNode,person) {
	// retreive attributes
	var qymc = oNode.getAttribute("qymc");
	var sum = oNode.getAttribute("sum");
	var qyId = oNode.getAttribute("qyId");
	var registerNo = oNode.getAttribute("registerNo");
	// create jsNode
	var jsNode = "<tr><td width=\"22\" align=\"left\"><img src=\"/resource/website/images/arrow_"+person+".gif\" width=\"12\" height=\"12\" /></td>"
				 +"<td align=\"left\"><a href=\"javascript:Detail('"+qyId+"','"+registerNo+"');\" >"
				 + qymc+ "</a></td>"
				 +"<td width=\"50\" align=\"right\">" + sum + "次</td>"
				 +"</tr>";
	return jsNode;
}
/*
 * 
 * ==============================================================================================
 * 函数名称： _buildJsUnit(str) 功能说明： 组织页面显示js信息 使用参数： str：js信息。 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _buildJsTop(str) {
	var _html =  "<table width=\"370\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" class=\"idxList\">";
	_html += str;
	_html += "</table>";
	document.getElementById("topInfo").height = "100%";
	document.getElementById("topData").innerHTML = _html;
}
/*
 * 
 * ==============================================================================================
 * 函数名称： _buildJsUnitError(str) 功能说明： 组织页面显示js错误信息 使用参数： str：错误信息。 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _buildJsTopError(str) {
	//str = bullet + "<a href=\"javascript:LoadUnitDate();\">" + str + "</a><BR>";
	//document.getElementById("topData").innerHTML = str;
	var _loading = "<table height=\"147\" width=\"370\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" >";
	_loading += "<tr>";
	_loading += "<td valign=\"middle\" align=\"right\" width=\"140\"><img src=\""
			+ img_path
			+ "/resource/website/images/flash-face.gif\" border=0 ></td>";
	_loading += "<td valign=\"middle\" width=\"230\">&nbsp;&nbsp;\u6ca1\u6709\u627e\u5230\u6570\u636e\uff01\uff01</td>";
	_loading += "</tr></table>";
	document.getElementById("topInfo").height = "";
	document.getElementById("topData").innerHTML = _loading;
}

var bullet;

/*
 * 
 * ==============================================================================================
 * 函数名称： ShowXyjlData(path) 功能说明： 显示成员单位更新时间 使用参数： path：路径 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function ShowTopData(path) {
	img_path = path;
	bullet = "<img src=\""
			+ path
			+ "/resource/website/images/arrow.gif\" border=\"0\"  style=\"vertical-align:middle\"/>&nbsp;";
		
	_createTopDateLoading(path);
	_startLoadXmlTop(path + "/mainIndex.do?method=enterpriseOrder");
}

/*
 * 
 * ==============================================================================================
 * 函数名称： _createLoading(path) 功能说明： Loading 使用参数： path：路径 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _createTopDateLoading(path) {
	var _loading = "<table height=\"147\" width=\"370\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" >";
	_loading += "<tr>";
	_loading += "<td valign=\"middle\" align=\"right\" width=\"140\"><img src=\""
			+ path
			+ "/resource/website/images/flash-loading-001.gif\" border=0 ></td>";
	_loading += "<td valign=\"middle\" width=\"230\">&nbsp;&nbsp;\u8bfb\u53d6\u6570\u636e\u4e2d\u002e\u002e\u002e</td>";
	_loading += "</tr></table>";
	document.getElementById("topInfo").height = "";
	document.getElementById("topData").innerHTML = _loading;
}


