﻿function FilterData(rootname,nodename){
  var lsFanChou = document.form1.FanChou.value;
  var doc=xmldsoAll.XMLDocument;
  var rootnode=doc.documentElement;
  var listNode;
  var outstr;

  if (lsFanChou != "ALL"){
    listNode = rootnode.selectNodes("//" + nodename + "[CID=" + lsFanChou + "]");
     outstr = "<"+rootname+">";

    for (i=0;i< listNode.length;i++){
     outstr = outstr + listNode[i].xml;
    }

    outstr = outstr + "</"+rootname+">";
  }
  else
    outstr = rootnode.xml;

  xmldso.loadXML(outstr);
  DisplayPage();
}

function callbyname(htmlurl,name,wid,hig){
  var newwin=window.open(htmlurl,name,"top=20,left=20,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+wid+",height="+hig);
  newwin.focus();
  return false;
}
  function LoadData(){
    var doc=xmldso.XMLDocument;
    var rootnode=doc.documentElement;
    xmldso.loadXML(rootnode.xml);
    //tbl.dataPageSize = 10;
    DisplayPage();
    resetchecked()
  }
  
function DisplayPage(){
    CurrPage.innerText = 1;
    var doc=xmldso.XMLDocument;
    var rootnode=doc.documentElement;
    var TotalRecords = rootnode.childNodes.length;
    var PageSize = tblhy.dataPageSize;

    var modnum = TotalRecords % PageSize;
    var pages = TotalRecords / PageSize;

    if (modnum != 0){
   	TotalPages.innerText = (TotalRecords - modnum)/PageSize + 1;
	}
    else {
   	TotalPages.innerText = pages;
	}

	if (rootnode.childNodes.length == 0){
		//window.alert();
		window.document.all.show.style.display = "none";
	}
}

 function checkXml(){
   if(xmldso.documentElement.childNodes.length == 0)
   {
       $('show').style.display = "none";	
   }
   else
   {
	   
	   $('show').style.display = "";
	   if(xmldso.documentElement.childNodes.length > tblhy.dataPageSize)
	   {
		  $('tblpage').style.display = ""; 
	      DisplayPage();
	   }
	   else
	   {
	       $('tblpage').style.display = "none"; 
	   }	  
   }
}
