 
if(_initPage && typeof _initPage == "function") window.onload = _initPage;

function jumpUrl(v) {
	if(v != "") {
		var strArr = v.split("||");
		var url = strArr[0];
		var target = strArr[1];
		if(target == "_blank") {
			window.open(url);
		} else {
			window.location.href = url;
		}
	}
}

function c$(obj) {
		return document.createElement(obj);
}

//
function t$(text) {
	if(text == "") {
		var span = document.createElement("span");
		span.innerHTML = "&nbsp;";
		return span;
	} else {
		return document.createTextNode(text);
	}
}

function setCookie(name, value){
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;
	
	var newcookie = name + "=" + value +
	((expires == null) ? "" : ("; expires="+expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");

	document.cookie = newcookie;
}


function getCookie(name) {
	var result="";
	var myCookie=" " + document.cookie +";";
	var searchName = " " + name + "=";
	var startOfCookie = myCookie.indexOf(searchName);
	var endOfCookie;
	
	if(startOfCookie != -1) {
		startOfCookie += searchName.length;
		endOfCookie = myCookie.indexOf(";",startOfCookie);
		result = unescape(myCookie.substring(startOfCookie,endOfCookie));
	}

	return result;
}

//函 数 名：loading
//功能描述：显示数据加载进度提示
//参数说明：
//  containerId : 父容器ID（可选）
//返 回 值：无
function loading() {
	//初始化容器对象
	var container;
	container = c$("div");
	container.setAttribute("id",LOADING_ID);
	container.setAttribute("class",LOADING_CLASS);
	
	//初始化进度提示图片
	var img = c$("img");
	img.src = LOADING_IMAGE;
	//img.setAttribute("src",LOADING_IMAGE);
	img.setAttribute("align","absmiddle");
	img.setAttribute("class",LOADING_IMAGE_CLASS);
	
	//初始化进度提示信息
	container.appendChild(img);
	//图片与文字之间增加空格
	container.appendChild(t$(" "));
	container.appendChild(t$(LOADING_TEXT));
	
	//判断是否提供父容器ID
	if(arguments.length > 0) {
		//如果调用时提供父容器ID，则获取父容器对象
		var parent = $(arguments[0]);
		if(parent) parent.innerHTML = container.innerHTML;
		
	} else {
		//如果未提供父容器ID，则创建div容器
		document.write(container.innerHTML);
	}
}


//含义：记录总数
//用途：文章列表分页使用
var docInfo_TotalCount = 0;			

//含义：当前导航页码
//用途：文章列表分页使用
var docInfo_CurrentPageNum = 1;

//含义：分页总页数
//用途：文章列表分页使用
var docInfo_PageCount = 0;

//含义：每页显示的最大记录条数
//用途：文章列表分页使用
var docInfo_PageSize = 18;

//含义：当前分页实际记录条数
//用途：文章列表分页使用
var docInfo_CurrentPageSize = 0;



var DocInfo = Class.create();
DocInfo.prototype = {
	//构造方法
	initialize: function(){},
	
	//服务器提供的服务的标识
	OBJECTID: "DocInfo",
	
	//文件上传后保存目录的虚拟路径，即URL基址
	uploadPath : UPLOAD_PATH,
	
	//用于显示文章正义的URL基址
	urlBase : CONTEXT_PATH + "portal/common/NewsDetail.jsp?ID=",
	
	action	: "getList",
	setAction : function(s) {this.action = s;},
	getAction : function()	{return this.action;},
	
	//系统主题对应的URL基址
	themePath : IMAGE_PATH,
	preimage : "docList_Dot.gif",
	setPreimage : function(s) { this.preimage = s; },
	getPreimage : function() { return this.preimage ;},
	start 	: 1,
	rows 	: 18,
	length 	: 0,	
	key 	: "",
	source : "",
	year : "",
	author : "",
	setKey 	: function(s) { this.key = s; },
	
	setStart : function(s) {
		this.start = s;
	},
	
	setRows : function(r) {
		this.rows = r;
	},
	
	setLength : function(l) {
		this.length = l;
	},
	
	setUploadPath : function(u) {
		this.uploadPath = u;
	},
	
	setUrlBase : function(s) {
		this.urlBase = s;
	},
	
	getTotalCount : function(alias) {
		var url = "getXML?object=" + this.OBJECTID 
			+ "&action=getTotalCount"
			+ "&alias=" + alias

		var args = new Array();
		var j = 0;
		args[0] = alias;
		j++ ;
		for(var i=2 ; i < arguments.length ; i++) {
			args[j++] = arguments[i];
		}
		
		var process = this.renderTotalCount;
		
		if(arguments.length > 1 && typeof(arguments[1]) == "function") {
			process = arguments[1];
		}
		
		//发起向服务器的调用
		var ajaxObj = new Ajax.Request(
			url,
			{
				method : 'get',
				onComplete : function(resp) {
					process(resp,args);
				}
			}
		);
		
	},
	//默认显示文章总数的函数
	//用途：本函数只用于设置docInfo_TotalCount全局变量的值，不作界面显示
	renderTotalCount : function(resp,args) {
		//获取XML数据
		var data = resp.responseXML;
		
		//获取链接结点数组
		var node = data.getElementsByTagName("totalCount");
		
		if(node.length > 0) {
			docInfo_TotalCount = node[0].firstChild.nodeValue;
			docInfo_TotalCount = parseInt(docInfo_TotalCount)
		}
	},
	/*\
	
	\*/
	getAllList : function(alias,listID,pageNavID) {
		loading(listID,this.themePath);
		
		if(arguments.length > 3) docInfo_CurrentPageNum = parseInt(arguments[3]);
		if(arguments.length > 4) docInfo_PageSize = parseInt(arguments[4]);
		
		var s = getRecordStartNum(docInfo_CurrentPageNum,docInfo_PageSize);
		
		this.setStart(s);
		this.setRows(docInfo_PageSize);
		this.getList(alias,listID);
		this.getPageNavigation(alias, listID, pageNavID);
		
	},
	
	getAllPicsList : function(alias,listID,pageNavID) {
		loading(listID,this.themePath);
		
		if(arguments.length > 3) docInfo_CurrentPageNum = parseInt(arguments[3]);
		if(arguments.length > 4) docInfo_PageSize = parseInt(arguments[4]);
		
		var s = getRecordStartNum(docInfo_CurrentPageNum,docInfo_PageSize);
		
		this.setStart(s);
		this.setRows(docInfo_PageSize);
		this.getPicsList(alias,listID);
		this.getPageNavigation(alias, listID, pageNavID);
		
	},
	
	getPicsList: function(alias,containerID) {
		
		loading(containerID, this.themePath);
		
		var url = CONTEXT_PATH + "getXML?object=" + this.OBJECTID 
			+ "&action=getList"
			+ "&alias=" 	+ alias
			+ "&start=" 	+ this.start
			+ "&rows=" 		+ this.rows 
			+ "&length="	+ this.length
			+ "&year=" 		+ this.year 
			+ "&source="	+ this.source
			+ "&author="	+ this.author		
			+ "&key="			+ this.key;
		
		var process 		= this.renderPics;
		var newsUrlBase 	= this.urlBase;
		var uploadPathBase 	= this.uploadPath;
		var themePathBase 	= this.themePath;
		
		var parent = this;
		
		if(arguments.length > 2 && typeof(arguments[2]) == "function") {
			this.renderPics = arguments[2];
		}
		
		var ajaxObj = new Ajax.Request(
			url,
			{
				method : 'get',
				onComplete : function(resp) {
					parent.renderPics(resp,containerID,newsUrlBase,uploadPathBase,themePathBase);
				}
			}
		);
		
	},	
	
	renderPics : function(resp,containerID,newsUrlBase,uploadPathBase,themePathBase) {
		
		//获取XML数据
		var data = resp.responseXML;
		
		//获取链接结点数组
		var docs = data.getElementsByTagName("row");
		
		docInfo_CurrentPageSize = docs.length;
		
		//用于呈现图片链接的容器
		var container = $(containerID);
		
		if(docInfo_CurrentPageSize == 0) {
			container.innerHTML = "未找到符合条件的记录！";
			return ;
		}
		
		//创建表格，以一行一列的形式显示图片链接
		var buf = new Array();
		
		buf.push("<table cellspacing='15' cellpadding='0' align='center'>");
		buf.push("<tr>");
		var counter = 0;
		
		//循环显示每条记录
		for(var i=0 ; i<docs.length ; i++) {
			
			var id 				= getValue(docs[i],"id");
			var fullTitle 		= getValue(docs[i],"title");
			var title 			= getValue(docs[i],"title");
			var contentType		= getValue(docs[i],"contenttype");
			var createdDate		= getValue(docs[i],"createddate");
			var row_next		= getValue(docs[i],"row_next");
			var hits			= getValue(docs[i],"hits");
			var mainpic			= getValue(docs[i],"mainpic");
			var serialnumber	= getValue(docs[i],"serialnumber");

			if(row_next == "") row_next = 0;
			row_next = parseInt(row_next);
			
			if(this.length >0 && title.length > this.length) title = title.substring(0,this.length) + "...";
			
			createdDate = createdDate.substring(0,10);
			
			var url = newsUrlBase + id;
			
			if(counter == 3) {
				buf.push("</tr><tr>");
				counter = 0;
			}
			
			counter++;
			
			var w = 200;
			var newWidth = w;
			var h = 133;
			var newHeight = h;
			
			var tmp = serialnumber.split(":");
			if(tmp.length == 2) {
				w = parseInt(tmp[0]);
				h = parseInt(tmp[1]);
				
				if((w/h) > 1.0) {
					
					if(w > 200){
						newWidth = 200;
					} else newWidth = w;
					
					h = (newWidth * h / w);

				} else {
					if(h > 133) {
						newHeight = 133;
					} else newHeight = h;
					
					newWidth = (newHeight * w / h);
				}
				
			}
			
			buf.push("<td align='center'><div style='background-color:#BBBBBB;width:200px; height:133px;'>");
			buf.push("<a href='" + url + "' target='_blank'>");
			buf.push("<img src='" + UPLOAD_PATH + mainpic + "' width='" + newWidth + "' height='" + newHeight + "' ");
			buf.push(" alt='" + fullTitle + "' class='pic_class'  hspace='3' vspace='3'/></a></div><br>");
			buf.push("<a href='" + url + "' target='_blank'>" + title + "</a></td>");
	
		}
		
		for(var i = counter ; i < 3 ; i++) {
			buf.push("<td><img src='" + IMAGE_PATH + "blank.gif' width=200 heigth=133 /></td>");
		}
		
		buf.push("</tr>");
		buf.push("</table>");
		
		container.innerHTML = buf.join("");
	},
	
	//获取文章列表数据，并调用展现函数显示
	getImageList: function(alias,containerID) {
		
		loading(containerID,this.themePath);
		
		var url = "getXML?object=" + this.OBJECTID 
			+ "&action=getImageList"
			+ "&alias=" 	+ alias;
			
		var parent = this;

		var ajaxObj = new Ajax.Request(
			url,
			{
				method : 'get',
				onComplete : function(resp) {
					parent.renderImageList(resp,containerID);
				}
			}
		);
		
	},
	
	renderImageList : function(resp,containerID) {
		//获取XML数据
		var data = resp.responseXML;
		
		//获取链接结点数组
		var docs = data.getElementsByTagName("row");
		//用于呈现图片链接的容器
		var container = $(containerID);
		
		
	},
	
	//获取文章列表数据，并调用展现函数显示
	getList: function(alias,containerID) {
		
		loading(containerID, this.themePath);
		
		var url = CONTEXT_PATH + "getXML?object=" + this.OBJECTID 
			+ "&action=getList"
			+ "&alias=" 	+ alias
			+ "&start=" 	+ this.start
			+ "&rows=" 		+ this.rows 
			+ "&length="	+ this.length
			+ "&key="		+ this.key;
		
		var process 		= this.renderList;
		var newsUrlBase 	= this.urlBase;
		var uploadPathBase 	= this.uploadPath;
		var themePathBase 	= this.themePath;
		
		var parent = this;
		
		if(arguments.length > 2 && typeof(arguments[2]) == "function") {
			this.renderList = arguments[2];
		}
		
		var ajaxObj = new Ajax.Request(
			url,
			{
				method : 'get',
				onComplete : function(resp) {
					parent.renderList(resp,containerID,newsUrlBase,uploadPathBase,themePathBase);
				}
			}
		);
		
	},
	renderList : function(resp,containerID,newsUrlBase,uploadPathBase,themePathBase) {
		
		//获取XML数据
		var data = resp.responseXML;
		
		//获取链接结点数组
		var docs = data.getElementsByTagName("row");
		
		docInfo_CurrentPageSize = docs.length;
		
		//用于呈现图片链接的容器
		var container = $(containerID);
		
		if(docInfo_CurrentPageSize == 0) {
			container.innerHTML = "未找到符合条件的记录！";
			return ;
		}
		
		//创建表格，以一行一列的形式显示图片链接
		var table = document.createElement("table");
		table.setAttribute("class","docList_Class");
		table.setAttribute("cellspacing","0");
		table.setAttribute("cellpadding","0");
		
		//循环显示每条记录
		for(var i=0 ; i<docs.length ; i++) {
			
			var id 				= docs[i].getElementsByTagName("id")[0].firstChild.nodeValue;
			var fullTitle 		= docs[i].getElementsByTagName("title")[0].firstChild.nodeValue;
			var title 			= docs[i].getElementsByTagName("title")[0].firstChild.nodeValue;
			var contentType		= docs[i].getElementsByTagName("contenttype")[0].firstChild.nodeValue;
			var createdDate		= docs[i].getElementsByTagName("createddate")[0].firstChild.nodeValue;
			var row_next		= getValue(docs[i],"row_next");
			var hits			= getValue(docs[i],"hits");
			
			if(row_next == "") row_next = 0;
			row_next = parseInt(row_next);
			
			if(this.length >0 && title.length > this.length) title = title.substring(0,this.length) + "...";
			
			createdDate = createdDate.substring(0,10);
			
			var url ;
			contentType = parseInt(contentType);
			
			switch(contentType) {
				case 1:
					url = newsUrlBase + id;
					break;
				case 2:
					var contentURL = docs[i].getElementsByTagName("contenturl")[0].firstChild.nodeValue;
					url = CONTEXT_PATH + "portal/common/getFile.jsp?ID=" + id + "&file=" + contentURL;
					break;
				case 3:
					var contentURL = docs[i].getElementsByTagName("contenturl")[0].firstChild.nodeValue;
					url = CONTEXT_PATH + "portal/common/getFile.jsp?ID=" + id + "&file=" + uploadPathBase + contentURL;
					break;
			}
			
			var tr 		= document.createElement("tr");
			var td1 	= document.createElement("td");
			var td2 	= document.createElement("td");
			var img 	= document.createElement("img");
			var a 		= document.createElement("a");
			
			img.setAttribute("class","docList_DotImgClass");
			img.setAttribute("src",themePathBase + "docList_Dot.gif");
			
			
			img.setAttribute("alt",fullTitle);
			img.setAttribute("align","absmiddle");
			img.setAttribute("border","0");
			
			
			var newimg = c$("img");
			newimg.setAttribute("src",IMAGE_PATH + "new.gif");
			newimg.setAttribute("align","absmiddle");
			newimg.setAttribute("border","0");
			
			
			a.setAttribute("class","logoLinks_LinkClass");
			a.setAttribute("href",url);
			a.setAttribute("target","_blank");
			a.setAttribute("title",fullTitle);
			//a.appendChild(img);
			a.appendChild(t$(" " + title));
			
			td1.setAttribute("align","left");
			td1.setAttribute("class","docList_title");
			td1.appendChild(a);
			
			td2.setAttribute("align","right");
			td2.setAttribute("class","docList_date");
			td2.appendChild(t$("(" + createdDate + " 点击" + hits + "次)"));
			
			tr.appendChild(td1);
			tr.appendChild(td2);
			
			table.appendChild(tr);
		}
		container.innerHTML = "";
		container.appendChild(table);
		container.innerHTML = container.innerHTML;
	},
	
	getStat : function() {
		
		var url = "getXML?object=" + this.OBJECTID 
			+ "&action=getStat";
		
		var ajaxObj = new Ajax.Request(
			url,
			{
				method : 'get',
				onComplete : function(resp) {
						var data = resp.responseXML;
						
						var counter 	= getValue(data,"counter");
						var totalhits 	= getValue(data,"totalhits");
						
						$("docInfoStat_counter").innerHTML = counter;
						$("docInfoStat_totalhits").innerHTML = totalhits;

				}
			}
		);
	}	,
	//
	//分页导航
	//
	getPageNavigation : function(alias,listID,containID) {
		var url = CONTEXT_PATH + "getXML?object=" + this.OBJECTID 
			+ "&action=getCount"
			+ "&key="			+ this.key
			+ "&alias=" 		+ alias;
			
		var keystr = this.key;
		
		//发起向服务器的调用
		var ajaxObj = new Ajax.Request(
			url,
			{
				method : 'get',
				onComplete : function(resp) {
					
					//获取XML数据
					var data = resp.responseXML;
					
					//获取链接结点数组
					var node = data.getElementsByTagName("counter");
					
					if(node.length > 0) {
						docInfo_TotalCount = node[0].firstChild.nodeValue;
						docInfo_TotalCount = parseInt(docInfo_TotalCount)
					}
					
					if(docInfo_TotalCount == 0) return ;
					
					var container = $(containID);
					
					docInfo_PageCount = Math.floor((docInfo_TotalCount + docInfo_PageSize - 1)/ docInfo_PageSize);
									
					//创建表格，以一行一列的形式显示图片链接
					var table = document.createElement("table");
					table.setAttribute("class","docList_Class");
					table.setAttribute("cellspacing","0");
					table.setAttribute("cellpadding","3");
					table.setAttribute("width","99%");
					
					var tr = document.createElement("tr");
					var td1 = document.createElement("td");
					var td2 = document.createElement("td");
					
					td1.setAttribute("align","left");
					td2.setAttribute("align","right");
					
					var b = document.createElement("strong");
					b.appendChild(document.createTextNode("总计："));
					td1.appendChild(b);
					td1.appendChild(document.createTextNode("共" + docInfo_TotalCount + "条记录，"
						+ "第" + docInfo_CurrentPageNum + "/" + docInfo_PageCount + "页"));
					
					if(docInfo_CurrentPageNum > 1 ) {
						var previousA = document.createElement("a");
						previousA.setAttribute("href","javascript:gotoPage("
							+ "'" + alias + "',"
							+ (docInfo_CurrentPageNum - 1) + "," 
							+ docInfo_PageSize + ","
							+ "'" + listID + "',"
							+ "'" + containID + "',"
							+ "'" + keystr + "')");
						previousA.setAttribute("title","上一页");
						
						previousA.appendChild(document.createTextNode("《 "));
						td2.appendChild(previousA);
					}
					
					for(var i = 1 ; i <= docInfo_PageCount ; i++) {
						if(i == docInfo_CurrentPageNum) {
							var strong = document.createElement("strong");
							strong.appendChild(document.createTextNode("[" + i + "]"));
							td2.appendChild(strong);
						} else {
							var a = document.createElement("a");
						
							a.setAttribute("href","javascript:gotoPage("
								+ "'" + alias + "',"
								+ i + "," 
								+ docInfo_PageSize + ","
								+ "'" + listID + "',"
								+ "'" + containID + "',"
								+ "'" + keystr + "')");
							a.setAttribute("title","转到第" + i + "页");
							
							a.appendChild(document.createTextNode(i));
							td2.appendChild(a);
						}
						
						if(i < docInfo_PageCount) {
							td2.appendChild(document.createTextNode(" - "));
						}
						
					}
					
					if(docInfo_PageCount > 1 && docInfo_CurrentPageNum < docInfo_PageCount) {
						var nextA = document.createElement("a");
						nextA.setAttribute("href","javascript:gotoPage("
							+ "'" + alias + "',"
							+ (docInfo_CurrentPageNum + 1) + "," 
							+ docInfo_PageSize + ","
							+ "'" + listID + "',"
							+ "'" + containID + "',"
							+ "'" + keystr + "')");
						nextA.setAttribute("title","下一页");
						
						nextA.appendChild(document.createTextNode(" 》"));
						td2.appendChild(nextA);
					}
					
					
					tr.appendChild(td1);
					tr.appendChild(td2);
					
					table.appendChild(tr);
					
					container.innerHTML = "";
					container.appendChild(table);
					container.innerHTML = container.innerHTML;
					
				}
			}
		);
	}
}

function getRecordStartNum(pageNum,pageSize) {
	pageNum = parseInt(pageNum);
	pageSize = parseInt(pageSize);
	
	var r = (pageNum - 1) * pageSize + 1;
	r = parseInt(r);
	if(r < 1 ) r = 1;
	return parseInt(r);
}

function gotoPage(alias,p,size,lid,nid,keystr) {
	$(lid).innerHTML = "";
	$(nid).innerHTML = "";
	var list = new DocInfo();
	
	list.setKey(keystr);
	list.getAllList(alias,lid,nid,p,size);
	
}


//
//通知公告类栏目展现类
//
var Information = Class.create();
Information.prototype = {
	//构造方法
	initialize: function(){},
	OBJECTID : "getInformation",
	baseUrl	: "showInformation.jsp?id=",
	setBaseUrl : function (s) {
		this.baseUrl = s;
	},
	themePathBase : "/themes/",
	setThemePathBase : function(s) {
		this.themePathBase = s;
	},
	getCurrentList : function(alias,containerID) {
		var url = "getXML?object=" + this.OBJECTID
			+ "&action=currentList" 
			+ "&alias=" + alias;
			
		var process = this.renderCurrentList;
		
		if(arguments.length > 2 && typeof(arguments[2]) == "function") {
			process = arguments[2];
		}
		
		var base = this.baseUrl;
		var theme = this.themePathBase;
		
		var ajaxObj = new Ajax.Request(
			url,
			{
				method : 'get',
				onComplete : function(resp) {
					process(resp,containerID,base,theme);
				}
			}
		);
	},
	renderCurrentList : function(resp,containerID,baseUrl,themePathBase) {
		//获取XML数据
		var data = resp.responseXML;
		
		//获取链接结点数组
		var infos = data.getElementsByTagName("information");
		
		//用于呈现图片链接的容器
		var container = $(containerID);
		
		//循环显示每条记录
		for(var i=0 ; i<infos.length ; i++) {
			
			var id 		= infos[i].getElementsByTagName("id")[0].firstChild.nodeValue;
			var title 	= infos[i].getElementsByTagName("title")[0].firstChild.nodeValue;
			
			var img = document.createElement("img");
			var a = document.createElement("a");
			
			img.setAttribute("class","informationList_DotImgClass");
			img.setAttribute("src",themePathBase + "images/informationList_Dot.gif");
			img.setAttribute("alt",title);
			img.setAttribute("align","absmiddle");
			img.setAttribute("border","0");
			
			a.setAttribute("class","information_LinkClass");
			a.setAttribute("href",baseUrl + id);
			a.setAttribute("target","_blank");
			a.setAttribute("title",title);
			a.appendChild(img);
			a.appendChild(document.createTextNode(" " + title));
			
			container.appendChild(a);
			container.appendChild(document.createElement("br"));
			
		}
		
		container.innerHTML = container.innerHTML;	
	}
	
}

//
//总计信息
//
var Statistic = Class.create();
Statistic.prototype = {
	//构造方法
	initialize: function(){},
	OBJECTID : "getStatistic",
	getArticleTotalCount : function(containerID) {
		var url = "getXML?object=" + this.OBJECTID
			+ "&action=articleTotalCount" ;

		var ajaxObj = new Ajax.Request(
			url,
			{
				method : 'get',
				onComplete : function(resp) {
					var container = $(containerID);
					
					//获取XML数据
					var data = resp.responseXML;
					
					//获取结点数组
					var node = data.getElementsByTagName("articleTotalCount");
					
					var v = 0;
					
					if(node.length > 0) v = node[0].firstChild.nodeValue;
					
					//IE 有innerHTML和innerText属性
					//FireFox 只有innerHTML属性，没有innerText属性
					container.innerHTML = v + container.innerHTML;
					
				}
			}
		);
		
	},
	getArticleTotalHits : function(containerID) {
		var url = "getXML?object=" + this.OBJECTID
			+ "&action=articleTotalHits" ;
		
		var ajaxObj = new Ajax.Request(
			url,
			{
				method : 'get',
				onComplete : function(resp) {
					var container = $(containerID);
					
					//获取XML数据
					var data = resp.responseXML;
					
					//获取结点数组
					var node = data.getElementsByTagName("articleTotalHits");
					
					var v = 0;
					
					if(node.length > 0) v = node[0].firstChild.nodeValue;
					
					
					//IE 有innerHTML和innerText属性
					//FireFox 只有innerHTML属性，没有innerText属性
					container.innerHTML = v + container.innerHTML;
					
				}
			}
		);		
	},
	getAssociatorTotalCount : function(containerID) {
		var url = "getXML?object=" + this.OBJECTID
			+ "&action=associatorTotalCount" ;
		
		var ajaxObj = new Ajax.Request(
			url,
			{
				method : 'get',
				onComplete : function(resp) {
					var container = $(containerID);
					
					//获取XML数据
					var data = resp.responseXML;
					
					//获取结点数组
					var node = data.getElementsByTagName("associatorTotalCount");
					
					var v = 0;
					
					if(node.length > 0) v = node[0].firstChild.nodeValue;
					
					//IE 有innerHTML和innerText属性
					//FireFox 只有innerHTML属性，没有innerText属性
					container.innerHTML = v + container.innerHTML;
					
				}
			}
		);
	}
}


var MyNavigation_CurrentNode = "";

//
//页面导航类
//
var MyNavigation = Class.create();

MyNavigation.prototype = {
	//构造方法
	initialize: function(){},
	
	OBJECTID : "NavigationBar",
	
	navUrlBase : "PageController?",
	
	setNavUrlBase : function(s) {
		this.navUrlBase = s;
	},
	
	getNavigationPath : function(palias,alias,containerID) {
		var url = "getXML?object=" + this.OBJECTID
			+ "&action=getNavigationPath"
			+ "&palias=" + palias
			+ "&alias=" + alias;
			
		var ajaxObj = new Ajax.Request(
			url,
			{
				method : 'get',
				onComplete : function(resp) {
					var container = $(containerID);
					
					//获取XML数据
					var data = resp.responseXML;
					
					//获取结点数组
					var node = data.getElementsByTagName("navigationPath");
					
					var v = "";
					
					if(node.length > 0) v = node[0].firstChild.nodeValue;
					
					container.innerHTML = container.innerHTML + v;
					
				}
			}
		);
	},
	
	getNavigationBar : function(palias,alias,containerID) {
	
		MyNavigation_CurrentNode = alias;
		
		var action = "children";
		if(palias.length == 0) action = "top";
		
		var url = "getXML?object=" + this.OBJECTID
			+ "&action=" + action
			+ "&palias=" + palias;
			
		var process = this.renderNavigationBar;
		
		if(arguments.length > 3 && typeof(arguments[3]) == "function") {
			process = arguments[3];
		}
		
		var base = this.navUrlBase;
		
		var ajaxObj = new Ajax.Request(
			url,
			{
				method : 'get',
				onComplete : function(resp) {
					process(resp,containerID,base);
				}
			}
		);
	},
	
	renderNavigationBar : function(resp,containerID,navUrlBase) {
	
	}
}


function getValue(node,key) {
	if(!node) return "";
	
	var elements = node.getElementsByTagName(key);
	if(elements && elements.length > 0) {
		if(elements[0].firstChild) {
			return 	elements[0].firstChild.nodeValue;
		}
	}
	
	return "";	
}

//四舍五入函数
function rnd(v,e) {
	var t=1; 
	for(;e>0;t*=10,e--); 
	return Math.round(v*t)/t; 
}

function createMainNavigation(navs) {
	for(var i = 0 ; i < navs.length ; i++) {
		var navItem = $(navs[i][1]);
		
		if(navItem) {
			navItem.href 	= CONTEXT_PATH + navs[i][3];
			navItem.title 	= navs[i][0];
			navItem.target	= navs[i][2];
		}
	}
}


function setContentPanel(_id) {
	var panel = $(_id);
	
	if(!panel) return ;
	
	var deviation = 452;
	if(arguments.length > 1) deviation = arguments[1];
	
	var docWidth 	= document.body.clientWidth;
	var docHeight 	= document.body.clientHeight;
	
	if((docHeight - deviation) > 400) panel.style.height = docHeight - deviation;	
}


String.prototype.trim = function() { 
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
}

String.prototype.ltrim = function() {
	return this.replace(/(^\s*)/g, ""); 
}  

String.prototype.trim = function() { 
	return this.replace(/(\s*$)/g, ""); 
}

String.prototype.lenB = function(){
	return this.unHtmlReplace().replace(/\*/g," ").replace(/[^\x00-\xff]/g,"**").length;
}

String.prototype.unHtmlReplace = function () {
	var s = (this).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g," ").replace(/&quot;/g,"\"");
	return s.replace(/&#(\d{2});/g, function($0,$1) {return unescape("%" + parseInt($1).toString(16));});
}

String.prototype.htmlReplace = function () {
	var s = (this).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;").replace(/\"/g,"&quot;");
	return s;
}


String.prototype.replaceAll		= _replaceAll;
String.prototype.appendFormat	= _appendFormat;
String.prototype.startWith		= _startWith;
String.prototype.endWith		= _endWith;
String.prototype.contain		= _contain;
String.prototype.create			= _create;


function _appendFormat() {
	
	var str = new String(this);
	var args = _appendFormat.arguments;
	
	for(var i=0 ; i<args.length; i++) {
		str=str.replaceAll("{" + i + "}",args[i]);
	}
	
	return str;
}

/*
	在当前字符串中搜索参数1指定的字符串，并替换成参数2指定的字符串。
*/
function _replaceAll(find, replace) {

	/* 实现方法二 */
	var str = new String(this);
	
	return str.split(find).join(replace);
}

/*
	判断当前字符串是否由参数指定的字符串开始
*/
function _startWith(__find) {
	var str = new String(this);
	
	if(str.indexOf(__find) == 0) return true;
	else return false; 
}

/*
	判断当前字符串是否由参数指定的字符串结尾
*/
function _endWith(__find) {
	var str = new String(this);
	
	if(str.lastIndexOf(__find) == (str.length - __find.length)) return true;
	else return false; 	
}

/*
	判断当前字符串是否包含参数指定的字符串
*/
function _contain(__find) {
	var str = new String(this);
	
	if(str.indexOf(__find) != -1) return true;
	else return false; 
}
/*
	创建一个新的字符串，以当前字符串内容填充，填充次数由参数count指定。
*/
function _create(count) {
	var str = new String(this);
	var buf = new Array(count);
	count = parseInt(count);
	for(var i=0 ; i<count; i++) buf.push(str);
	
	return buf.join("");
}


function createDropList(url, target) {
	
	//获取目标对象
	var container = $(target);
	if(!container) return ;
	
	var currValue = null;
	var callback  = null;
	var firstTip = true;
	
	if(arguments.length > 2) currValue 	= arguments[2];
	if(arguments.length > 3) callback 	= arguments[3];
	if(arguments.length > 4) firstTip 	= arguments[4];
	
	if(firstTip) {
		container.length = 0;
		var option = new Option("请选择...","");
		container.options[container.options.length] = option;
	}

	var ajaxObj = new Ajax.Request(
		url,
		{
			method 			: 'get',
			onComplete 		: function(resp) {
				//获取XML数据
				var data = resp.responseXML;
				
				//获取链接结点数组
				var rows = data.getElementsByTagName("row");

				for(var i = 0 ; i < rows.length ; i++) {
					var key 	= getValue(rows[i],"key");
					var value 	= getValue(rows[i],"value");

					var option = new Option(key, value);
					if(currValue == value) option.selected = true;
					
					container.options[container.options.length] = option;							
				}

				//回调
				if(callback != null && typeof(callback) == "function") {
					callback(rows, data);
				}
			}
		}
	);	
}