var docObj = null;

var nowObj ="1";
//HTML Outline对象
var m_objSrcContent = null;
//HTML Column对象
var m_arSingleRec = null;
//隐藏对象,位于m_arSingleRec下
var hiddenObj = null;
var hiddenObjArr = new Array();

//获取分页参数
var m_nPageSize   = 5; //常量每页条数
var m_nRecSize   = 1; //常量每行条数

//设定XML的检索方式


//DocumentsDataSrc.XMLDocument.setProperty("SelectionLanguage", "XPath");
//检索所有的节点
var m_arNodes = null;
//记录数


var m_nRecCount   = 0;
//总页数


var m_nPageCount = 0;

//是否显示历史信息
var showHistory = false;

//页码文字输出区

var CP = document.getElementById("CP"+nowObj);

//初始化各种分页变量


function initPage(){
	setObj(nowObj);
	//默认定位到第一页


	toPage_my(1);
	//将标志位设回
	m_bFirst  = false;
}

//===========规范跳转页码函数;_currentPage 跳转页码输入值===
function getCurrPage(_currentPage){
	var cPage =1;
	if( _currentPage<=0 || _currentPage=="")
		cPage =1;
	else if(_currentPage>m_nPageCount)
		cPage = m_nPageCount;
	else
		cPage = _currentPage;

	return cPage;
}

//==========把全局变量设置为当前插件=====================================
function setObj(obj){
	nowObj = obj;  //设置当前插件ID

	m_objSrcContent = document.all("OutlineContent"+nowObj);
	if(m_objSrcContent == null){
		alert( "没有定义Outline区域！分页代码发生异常！\n请检查模板的HTML标签已添加 xmlns:x" );
		return false;
	}
	m_arSingleRec = m_objSrcContent.all("ColumnContent"+nowObj);
	if(m_arSingleRec == null){
		alert( "没有定义Column区域！分页代码发生异常！\n请检查模板的HTML标签已添加 xmlns:x" );
		return false;
	}
        if(m_arSingleRec.children){
          if(m_arSingleRec.children.length>0){
            if(typeof(m_arSingleRec.children[0])){
              hiddenObj = m_arSingleRec.children[0];
            }
          }
        }else if(m_arSingleRec.length){
			for(var x=0;x<m_arSingleRec.length;x++){
				hiddenObjArr[hiddenObjArr.length] = m_arSingleRec[x].children[0]; 
			}
		}
	//获取分页参数
	if(m_objSrcContent.PageSize && !isNaN(m_objSrcContent.PageSize)){
		m_nPageSize = parseInt(m_objSrcContent.PageSize);
	}
	if(m_arSingleRec != null && m_arSingleRec.length) m_nRecSize = m_arSingleRec.length;

	//提取数据
	//默认提取所有的数据
	var sPath = "//INFO";

	if(!showHistory){
		//alert("更新之前:"+docObj);
    if(!docObj)

		//docObj = null;

		docObj = document.getElementById("DocumentsDataSrc"+nowObj);
		//alert("更新之后:"+docObj);
		//m_arNodes = DocumentsDataSrc.XMLDocument.selectNodes(sPath);
		//m_arNodes = docObj.XMLDocument.selectNodes(sPath);
	    m_arNodes = docObj.getElementsByTagName("INFO");
	}
	
	m_nRecCount   = m_arNodes.length;

	m_nPageCount = 0;
	//计算总页数


	if(m_nRecCount%m_nPageSize>0)
	{
		m_nPageCount = (m_nRecCount - (m_nRecCount%m_nPageSize))/m_nPageSize +1;
	}else{
		m_nPageCount = m_nRecCount/m_nPageSize;
	}

	CP = document.getElementById("CP"+nowObj);
}

//===============goto()直接跳转函数=============================================
function goto(obj){
	setObj(obj);
	var cpvObj = document.getElementById("CPV"+obj);
	if(cpvObj) CP.value = cpvObj.value;
	toPage_my(CP.value);
}

//===========showPageLineNum()页面显示状态条函数==================
function showPageLineNum(){
    if(!docObj)
  	docObj = document.getElementById("DocumentsDataSrc"+nowObj);
  	//var recsnode = docObj.XMLDocument.selectNodes("//RECS");
    var recsnode = docObj.getElementsByTagName("RECS");
	var infocount = recsnode[0].getAttribute("totalRecs");
	var infocountObj = document.getElementById("infocount"+nowObj);
	if(infocountObj) infocountObj.innerText = infocount;
	var recordcountObj = document.getElementById("recordcount"+nowObj);
	if(recordcountObj) recordcountObj.innerText = m_nRecCount;
	var totalpageObj = document.getElementById("totalpage"+nowObj);
	if(totalpageObj) totalpageObj.innerText = CP.value+"/"+m_nPageCount;
}
/*
function showPageLineNum(){
	var pL = "";
	if(CP.value!=1){
		pL+="<a href=# onclick=\"setObj("+nowObj+");toPage(1);\">首页</a>&nbsp;";
		pL+="<a href=# onclick=\"setObj("+nowObj+");toPage("+(CP.value-1)+");\">上一页</a>&nbsp;";
	}else{
		pL+="首页&nbsp;";
		pL+="上一页&nbsp;";
	}

	for(var pageN=1;pageN<=m_nPageCount;pageN++){
		if(pageN==CP.value)
			pL+="<font color=red><b>"+pageN+"</b></font>&nbsp;";
		else
			pL += "<a href=# onclick=\"setObj("+nowObj+");toPage("+pageN+");\">"+pageN+"</a>&nbsp;";
	}

	if(CP.value<m_nPageCount){
		pL+="<a href=# onclick=\"setObj("+nowObj+");toPage("+((CP.value)*1+1)+");\">下一页</a>&nbsp;";
		pL+="<a href=# onclick=\"setObj("+nowObj+");toPage("+m_nPageCount+");\">尾页</a>&nbsp;";
	}else{
		pL+="下一页&nbsp;";
		pL+="尾页&nbsp;";
	}
	pL += "共 "+m_nPageCount+" 页&nbsp;共"+m_nRecCount+"条记录";

	var showPageLine = document.getElementsByName("pl"+nowObj);
	for(var pls=0;pls<showPageLine.length;pls++){
		showPageLine[pls].innerHTML = pL;
	}
}
*/

//===============toPage(_pageNo)跳转函数;_pageNo要跳转的页号====================
function toPage_my(_pageNo){
	if(m_nRecCount <= 0) return false;
	//删除原有代码
	removeAllOldNodes();
 	//设置复制节点
	m_bFirst = true;

	var cP = getCurrPage(_pageNo);

	
	var startPos = cP*m_nPageSize - m_nPageSize;
	var endPos = 0;
	if(cP*m_nPageSize>m_nRecCount)
		endPos=m_nRecCount;
	else
		endPos = cP*m_nPageSize;

	var nOutlineCount = 0;
/*	if(typeof(document.all.fathernodid.length)!="undefined"){ //设定根节点显示状态

		 document.all.fathernodid[0].style.display = "";
	}
	else document.all.fathernodid.style.display = ""; */




	//alert(document.all.fathernodid[0].style.display);
        if(hiddenObj!=null){
          hiddenObj.style.display="";
        }
		if(hiddenObjArr!=null){
			for(var x=0;x<hiddenObjArr.length;x++){
				hiddenObjArr[x].style.display="";
			}
		}
	for(var i=startPos; i<endPos; i++){
		var nTemp = createItemHTML(i, endPos, nOutlineCount);
		if(nTemp <= 0) break;
		i = i + nTemp;
		i--;
		nOutlineCount++;
	}
        if(hiddenObj!=null){
          hiddenObj.style.display="none";
        }
		if(hiddenObjArr!=null){
			for(var x=0;x<hiddenObjArr.length;x++){
				hiddenObjArr[x].style.display="none";
			}
		}
	//异常剩下的元素
	//document.all.fathernodid[i-startPos].style.display = "none";//复制完节点隐藏根节点
	for( ;!m_bFirst && nOutlineCount<m_nPageSize; nOutlineCount++)
	{
		if(m_arOutLine.length <= nOutlineCount) break;
		//m_arOutLine[nOutlineCount].style.display = "none";
	}
	
	//设置当前页面值
    if(CP!=null) CP.value = cP;
	var cpvObj = document.getElementById("CPV"+nowObj);
	if(cpvObj) cpvObj.value= cP;

	showPageLineNum();
	//设置为已经有节点
	m_bFirst  = false;
	var innoarray = document.all.inno;
	if(innoarray!=null && innoarray.length>0)
	{
		for(i=0;i<innoarray.length-1;i++)
		{
			innoarray[i].innerText = startPos + i+1 ;
		}
	}
}

//删除原有的节点


function removeAllOldNodes(){
	var arTemp = document.all("OutlineClone"+nowObj);
	if(!arTemp) return false;
	if(arTemp.length){
		for(var i=arTemp.length-1; i>=0; i--){
			if(arTemp[i].children[0].children[0] && arTemp[i].children[0].children[0].tagName=="LI"){
				arTemp[i].children[0].children[0].removeNode(true);
			}
			arTemp[i].removeNode(true);
		}
	}else{
		arTemp.removeNode(true);
	}
	return true;
}

var m_bFirst    = true;
var m_arOutLine = new Array();
/**
  * 复制分页节点
  *
**/
function createItemHTML(_nCurrIndex, _nEndIndex, _nOutlineIndex){
	if(m_arNodes.length < _nCurrIndex) return 0;

	var objContent = null;
	if(m_bFirst){//创建节点
		//复制Outline节点
		objContent = m_objSrcContent.cloneNode(true);
		//设置ID
		objContent.id = "OutlineClone"+nowObj;
		m_arOutLine[m_arOutLine.length] = objContent;
	}else{
		if(_nOutlineIndex >= m_arOutLine.length)
		{
			//需要重新复制节点


			//复制Outline节点
			objContent = m_objSrcContent.cloneNode(true);
			//设置ID
			objContent.id = "OutlineClone"+nowObj;
			m_arOutLine[m_arOutLine.length] = objContent;
			m_bFirst = true;
		}else
			objContent = m_arOutLine[_nOutlineIndex];
	}

	//设置Display

	objContent.style.display = "";
	//修改ID
	var arSingleRec = objContent.all("ColumnContent"+nowObj);
	if(arSingleRec==null) arSingleRec = objContent
		var recCount = 1;
	if(arSingleRec.length) recCount = arSingleRec.length;
	var i = 0;

	for(i=0; i<recCount; i++){

		//判断当前索引是否有效
		if(m_arNodes.length <= (_nCurrIndex+i) || _nCurrIndex+i >= _nEndIndex) break;

		//获取当前的XML节点
		var xmlNode = m_arNodes[_nCurrIndex+i];
		//遍历所有属性子节点，从XML中提取数据


		var objSingleRec = null;
		if(recCount>1) objSingleRec = arSingleRec[i];
		else objSingleRec = arSingleRec;
		var arAllField = objSingleRec.all;

		//alert(arAllField.length);    
		objSingleRec.style.display = "";
		var today = new Date();
		var pdateNode = xmlNode.selectSingleNode("PublishedTime");
		var showIMG = false;
		var infoday ;
		if(pdateNode) {
			var tmpDtext=pdateNode.text;
			infoday = new Date(Date.parse(tmpDtext.replace(/-/g,"/")));
		}
		if (infoday){
			if((today.getYear()-infoday.getYear()==0) && (today.getMonth()-infoday.getMonth()==0) && (today.getDate()-infoday.getDate()==0)){
				showIMG = true;
			}
		}
		for(var j=0; j<arAllField.length; j++){
			var sFieldName = arAllField[j].FieldName;
			var sTagName = arAllField[j].tagName;
			var shortTitleLength = 1000;
			//alert("sFieldName:"+sFieldName+"\n"+"sTagName:"+sTagName);  
			if(arAllField[j].ShortLen) shortTitleLength = arAllField[j].ShortLen; 
            if((sTagName=="A" && arAllField[j].href=="about:blank<x:INFOURL></x:INFOURL>") || (sTagName=="A" && arAllField[j].href=="about:<x:INFOURL></x:INFOURL>")) {
            	sFieldName = "InfoURL";
            }
			if(sFieldName){
				var sValue = "";
				//获取属性节点


				var xmlNodeTemp = xmlNode.selectSingleNode(sFieldName);
				if(xmlNodeTemp) sValue = xmlNodeTemp.text;
				//图片新闻扩展字段，不能取节点的TEXT，要取XML
				//注释时间-卫生部项目-阿汉--暂不放到产品
				/*if(sTagName=="INFOEXPIMG" && xmlNodeTemp.childNodes(0)) {
					sValue = xmlNodeTemp.childNodes(0).xml;   
				}else if(xmlNodeTemp.childNodes.item(0)){
					sValue = xmlNodeTemp.childNodes.item(0).xml;       
				   }
				}*/
				var reg=new RegExp("&gt;","g"); 
				sValue = sValue.replace(reg,">");
				reg=new RegExp("&lt;","g");
				sValue = sValue.replace(reg,"<");

                  // alert(sValue);  
				switch(sTagName){//暂时只支持四种HTML置标定义数据源


				case "A":
                    if(sFieldName=="InfoURL"){
                      var tmpValue = sValue.toLowerCase();
                      if((tmpValue.indexOf("http://")>-1) || (tmpValue.indexOf("/")==0)){
                        arAllField[j].href = sValue;
                      }else{
                        arAllField[j].href = "/publicfiles/business/htmlfiles/"+sValue;
                      }
                    }
					break;
				case "INFOTITLE":
					arAllField[j].innerHTML = sValue;
					arAllField[j].title = sValue; //显示alt
					if(arAllField[j].innerText!=arAllField[j].innerHTML) sValue = arAllField[j].innerText;
					if(arAllField[j].ShortLen && sValue.length>shortTitleLength){
						//带格式截取标题
						//sValue = arAllField[j].innerHTML.replace(arAllField[j].innerText,sValue.substring(0,shortTitleLength)+"..");
						//不带格式截取标题
						arAllField[j].innerHTML = sValue.substring(0,shortTitleLength)+"..";
					}
					// -- zhaozh 2008年9月2日14:37:54 用户普遍反映这个功能不显示，因为不能控制
					//if(showIMG)
						//arAllField[j].innerHTML = arAllField[j].innerHTML + "<IMG border=0 src=\"/publicfiles/business/cmsresources/cmsimages/topnew.gif\">";
					
					break;
				case "INFOSUBTITLE":
					arAllField[j].innerHTML = sValue;
					arAllField[j].title = sValue;

					if(arAllField[j].ShortLen && sValue.length>shortTitleLength){
						arAllField[j].innerHTML = sValue.substring(0,shortTitleLength)+"..";
					}
					break;
				case "INFOWRITER":
					arAllField[j].innerText = sValue;
					break;
				case "INFOSOURCE":
					arAllField[j].innerText = sValue;
					break;
				case "INFOMNUMBER":
					arAllField[j].innerText = sValue;
					break;
				case "INFODATE":
					arAllField[j].innerText = sValue;
					break;
				case "INFOEXPIMG":
					sValue = sValue.replace("&gt;",">");
					sValue = sValue.replace("&lt;","<");
					arAllField[j].innerHTML = sValue;
					break;	
					
				case "INFO_ABSTRACT":    
					arAllField[j].innerText = sValue;
					break; 
	
				case "INFO_EXPSTR2":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR3":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR4":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR5":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR6":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR7":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR8":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR9":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR10":    
					arAllField[j].innerText = sValue;      
					break; 
				case "INFO_EXPSTR11":    
					arAllField[j].innerText = sValue;      
					break; 
				case "INFO_EXPSTR12":    
					arAllField[j].innerText = sValue;      
					break; 
				case "INFO_EXPSTR13":    
					arAllField[j].innerText = sValue;      
					break; 
				case "INFO_EXPSTR14":    
					arAllField[j].innerText = sValue;      
					break; 
				case "ZWGKFILECODE":    
					arAllField[j].innerText = sValue;      
					break; 
			    case "ZWGKOPENDATE":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGKADDFILE":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGKBUMEN":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGKSUOYINHAO":   
					arAllField[j].innerText = sValue;
					break; 

				case "ZWGKFILECODE":    
					arAllField[j].innerText = sValue;      
					break; 
			    case "ZWGKOPENDATE":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGKADDFILE":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGKBUMEN":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGKSUOYINHAO":   
					arAllField[j].innerText = sValue;
					break; 
						
				case "INFO_EXPSTR15":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR16":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR17":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR18":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR19":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGKOPENTYPE":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGKOPENSHIXIAN":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGKOPENSCOPE":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR20":    
					arAllField[j].innerText = sValue;      
					break; 
			
				case "INFO_EXPSTR21":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR22":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR23":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR24":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR25":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR26":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR27":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR28":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR29":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR30":    
					arAllField[j].innerText = sValue;      
					break; 
				case "INFO_EXPSTR31":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR32":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR33":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR34":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR35":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR36":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR37":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR38":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR39":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR40":    
					arAllField[j].innerText = sValue;      
					break; 
				case "INFO_EXPSTR41":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_EXPSTR42":    
					arAllField[j].innerText = sValue;      
					break;   
					
				case "INFCATEID":      
					arAllField[j].innerText = sValue;      
					break; 	
								case "INFO_ExpStr1":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpSt2":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr3":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr4":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr5":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr6":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr7":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr8":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr9":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGK_EXPSTR10":    
					arAllField[j].innerText = sValue;      
					break; 
			   
			    case "ZWGK_EXPSTR11":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGK_EXPSTR12":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGK_EXPSTR13":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGK_EXPSTR14":   
				  //alert(sValue);	 
				   arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr15":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr16":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGK_EXPSTR17":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGK_EXPSTR18":    
					arAllField[j].innerText = sValue;
					break; 
				case "ZWGK_EXPSTR19":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr20":    
					arAllField[j].innerText = sValue;      
					break; 
			
				case "INFO_ExpStr21":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpSt22":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr23":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr24":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr25":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr26":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr27":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr28":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr29":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr30":    
					arAllField[j].innerText = sValue;      
					break; 
				case "INFO_ExpStr31":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpSt32":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr33":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr34":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr35":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr36":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr37":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr38":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr39":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr40":    
					arAllField[j].innerText = sValue;      
					break; 
				case "INFO_ExpStr41":    
					arAllField[j].innerText = sValue;
					break; 
				case "INFO_ExpStr42":    
					arAllField[j].innerText = sValue;      
					break;   				 					
				default:
					//arAllField[j].innerText = sValue;
					break;
					
				}
			}
		} 
 	}
	//将没有填充内容的Column隐藏
	for(; arSingleRec.length && i<arSingleRec.length; i++) arSingleRec[i].style.display = "none";

	if(m_bFirst)m_objSrcContent.insertAdjacentElement("beforeBegin", objContent);
	return i;
}


//跳转到指定页面
function toPage(objid,pageid){
	
	if( typeof( pageid ) != "undefined" ){
		setObj(objid);
		//外部传递的值
		var cpObj = document.getElementById("CP"+objid);
		if( cpObj && typeof( cpObj.value ) != "undefined"){
			cpObj.value = pageid;
		}
		var cpvObj = document.getElementById("CPV"+objid);
		if( cpvObj && typeof( cpvObj.value ) != "undefined"){
			cpvObj.value = pageid;
		}
		toPage_my(pageid);
	}else{
		//内部执行切换,无pageid时，只有一个参数，调用方式类似：setObj("12");toPage(((CP.value)*1-1));
		toPage_my(objid);
	}
}

function toPrePage(objid){
	setObj(objid);
	var cpObj = document.getElementById("CP"+objid);
	if( cpObj && typeof( cpObj.value ) != "undefined"){
		var k = parseInt(cpObj.value);
		if( !isNaN( k ) && k > 1 ){
			cpObj.value = k-1;
			
			var cpvObj = document.getElementById("CPV"+objid);
			if( cpvObj && typeof( cpvObj.value ) != "undefined"){
				cpvObj.value = cpObj.value;
			}
		}
		toPage_my(cpObj.value);
	}
}
function toNextPage(objid){
	setObj(objid);
	var cpObj = document.getElementById("CP"+objid);
	if( cpObj && typeof( cpObj.value ) != "undefined"){
		var k = parseInt(cpObj.value);
		if( !isNaN( k ) && k < m_nPageCount ){
			cpObj.value = k + 1;
			var cpvObj = document.getElementById("CPV"+objid);
			if( cpvObj && typeof( cpvObj.value ) != "undefined"){
				cpvObj.value = cpObj.value;
			}
		}
		toPage_my(cpObj.value);
	}
}
function toLastPage(objid){
	setObj(objid);
	var cpObj = document.getElementById("CP"+objid);
	if( cpObj && typeof( cpObj.value ) != "undefined"){
		cpObj.value = m_nPageCount;
		
		var cpvObj = document.getElementById("CPV"+objid);
		if( cpvObj && typeof( cpvObj.value ) != "undefined"){
			cpvObj.value = cpObj.value;
		}
		toPage_my(cpObj.value);
	}
}
