
/*
 * 
 * ==============================================================================================
 * 名称：unit.js
 * 
 * 功能： 成员单位更新时间。
 * 
 * 包括：
 * 
 * 
 * 作者：郭奇
 * 
 * 日期：2009-12-01
 * ==============================================================================================
 * 
 */
/*
 * 
 * ==============================================================================================
 * 函数名称： _startLoadXmlNotice(sSrc) 功能说明： 创建xmlhttp对象,并且开始装载XML文件 使用参数： sSrc：链接。
 * 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
 var subPath;
 
function _startLoadXmlUnit(sSrc) {
	var xmlHttp = XmlHttp.create();
	xmlHttp.open("GET", sSrc, true); // async
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4) {
			_xmlUnitLoaded(xmlHttp.responseXML);
		}
	};
	// call in new thread to allow ui to update
	window.setTimeout(function() {
				xmlHttp.send(null);
			}, 10);
}
/*
 * 
 * ==============================================================================================
 * 函数名称： _xmlUnitLoaded(oXmlDoc) 功能说明： 装载XML文件 使用参数： oXmlDoc：XML文件。 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _xmlUnitLoaded(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 == "unit") {
				bAnyChildren = true;
				jsUnit += _xmlUnitToJsUnit(cs[i]);
			}
		}

		// if no children we got an error
		if (!bAnyChildren) {
			errorText = "读取数据失败，请重试。";
		}
	}
	// build js Unit
	if (jsUnit != "") {
		_buildJsUnit(jsUnit);
	} else {
		errorText = "读取数据失败，请重试。";
	}

	// show error
	if (errorText != "") {
		_buildJsUnitError(errorText);
	}
}
/*
 * 
 * ==============================================================================================
 * 函数名称： _xmlUnitToJsUnit(oNode) 功能说明： 组建js信息 使用参数： oNode：XML文件节点。 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _xmlUnitToJsUnit(oNode) {
	// retreive attributes
	var unitId = oNode.getAttribute("unitId");
	var unitName = oNode.getAttribute("unitName");
	var checkDate = oNode.getAttribute("checkDate");
	// create jsNode
	var jsNode;
	if (checkDate != "") {
	   if(unitId=="10039" || unitId=="10018"){
	   		return "";
	   }
		if("10024,10025,10035,10041,10044".indexOf(unitId) != -1){
			jsNode = "<tr><td align=\"left\">"+bullet+"<a target=\"_blank\" href=\""+subPath+"/website/webTempl/infoDetails.jsp?id="+unitId+"&channelId=4028aabb24fa8e940124fa97b0b90019"
				+ "\">"+ unitName + "<span class=\"yellow p11\">"
				+ ("")
				+ "</span></a></td></tr>";
		}else{
			jsNode = "<tr><td align=\"left\">"+bullet+"<a target=\"_blank\" href=\""+subPath+"/website/webTempl/infoDetails.jsp?id="+unitId+"&channelId=4028aabb24fa8e940124fa97b0b90019"
				+ "\">"+ unitName + "<span class=\"yellow p11\">"
				+ (checkDate != "" ? "[" +checkDate +"]" : "")
				+ "</span></a></td></tr>";
		}		
	} else {
		jsNode = bullet + "<span class=\"blue\">" + unitName + "</span><BR>";

	}

	return jsNode;
}
/*
 * 
 * ==============================================================================================
 * 函数名称： _buildJsUnit(str) 功能说明： 组织页面显示js信息 使用参数： str：js信息。 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _buildJsUnit(str) {
	var _html = "<marquee behavior=\"scroll\" direction=\"up\" width=\"200\" height=\"250\" scrollamount=\"2\" onMouseOver=\"this.stop()\" onMouseOut=\"this.start()\">";
	_html += "<table width=\"190\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" class=\"unitList\">";
	_html += str;
	_html += "</table>"
	_html += "</marquee>";
	//alert(_html);
	document.getElementById("unitInfo").height = "100%";
	document.getElementById("unitDate").innerHTML = _html;
}
/*
 * 
 * ==============================================================================================
 * 函数名称： _buildJsUnitError(str) 功能说明： 组织页面显示js错误信息 使用参数： str：错误信息。 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _buildJsUnitError(str) {
	//str = bullet + "<a href=\"javascript:LoadUnitDate();\">" + str + "</a><BR>";
	//document.getElementById("unitDate").innerHTML = str;
	var _loading = "<table width=\"190\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" class=\"unitList\">";
	_loading += "<tr class=\"p11\">";
	_loading += "<td valign=\"middle\" align=\"right\" width=\"35\"><img src=\""
			+ path
			+ "/resource/website/images/flash-loading-001.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("unitInfo").height = "";
	document.getElementById("unitDate").innerHTML = _loading;
}

var bullet;

/*
 * 
 * ==============================================================================================
 * 函数名称： ShowUnitDate(path) 功能说明： 显示成员单位更新时间 使用参数： path：路径 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function ShowUnitDate(path) {
	subPath = path;
	bullet = "<img src=\""
			+ path
			+ "/resource/website/images/arrow.gif\" border=\"0\"  style=\"vertical-align:middle\"/>&nbsp;";
		
	_createUnitDateLoading(path);
	_startLoadXmlUnit(path + "/mainIndex.do?method=unitUpdateDate");
}

/*
 * 
 * ==============================================================================================
 * 函数名称： _createLoading(path) 功能说明： Loading 使用参数： path：路径 返回结果：
 * 
 * 使用说明：
 * 
 * ==============================================================================================
 * 
 */
function _createUnitDateLoading(path) {
	var _loading = "<table width=\"190\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" class=\"unitList\">";
	_loading += "<tr class=\"p11\">";
	_loading += "<td valign=\"middle\" align=\"right\" width=\"35\"><img src=\""
			+ path
			+ "/resource/website/images/flash-loading-001.gif\" border=0 ></td>";
	_loading += "<td valign=\"middle\" width=\"155\">&nbsp;&nbsp;\u8bfb\u53d6\u6570\u636e\u4e2d\u002e\u002e\u002e</td>";
	_loading += "</tr></table>";
	document.getElementById("unitInfo").height = "";
	document.getElementById("unitDate").innerHTML = _loading;
}

