//-------------针对Asp页面的初始化  add by chenmin 20070119

function InitDocumentEx(isfirstload)
{	
	var jcs=GetJcElements(document);
	
	for(var i=0;i<jcs.length;i++)
	{	var type=null;
		var tag=jcs[i].tagName.toLowerCase();
		var obj=null;
		
		if(tag=="form")
			type="jcform";
		else			
			type=jcs[i].getAttribute("jctype");
			
		if(jcs[i].Co)  continue;//已经初始化

		if(!type || InputElements.indexOf(type)>0)continue;
	
		switch(type.toLowerCase())
		{	
			case "jcasptable":
			{
			    if (isfirstload) {  //第一次载入页面,获取xml数据
			   
					var posturl=jcs[i].Codebehind
						    
					var pos=posturl.indexOf("?");
					var len=posturl.length;
					if (pos<0)
					{ 
					  if (posturl=="self_xml")
					    posturl= ECIDI.Util.GetXml.Codebehind;
					}
					else
					{
					   var urlfilename=posturl.substr(0,pos)
						var urlpara=posturl.substr(pos,len)
						if (urlfilename=="self_xml")
						{
						 posturl= ECIDI.Util.GetXml.Codebehind+urlpara;
						}
	
					}
		
					jcs[i].Codebehind=posturl
			    
			      ECIDI.Form.Datagrid.LoadXmlData(jcs[i].Codebehind,jcs[i].QueryFormName) ;
			      
			      break;  //开始获取xml数据
			     
			    }
			    else
			    {  //获取xml数据之后，进行格式化
			       obj=new JcAspTable(jcs[i]);  ////开始对JcTable进行填充数据
		
			    }
				
				
			}
			
			
			if(obj)CoArray[CoArray.length]=obj;
		    if(obj && jcs[i].id){Co[jcs[i].id]=obj;}
			

		}
		
	}
  
}

function InitDocument2()
{	
	var jcs=GetJcElements(document);
	

	for(var i=0;i<jcs.length;i++)
	{	var type=null;
		var tag=jcs[i].tagName.toLowerCase();
		var obj=null;
		
		if(tag=="form")
			type="jcform";
		else			
			type=jcs[i].getAttribute("jctype");
			
		if(jcs[i].Co)  continue;//已经初始化

		if(!type || InputElements.indexOf(type)>0)continue;
		switch(type.toLowerCase())
		{	
			case "jcasptable":	obj=new JcAspTable(jcs[i]);break;  //开始对JcTable进行填充数据	

		}
		if(obj)CoArray[CoArray.length]=obj;
		if(obj && jcs[i].id){Co[jcs[i].id]=obj;}
	}
  
}











//
//--------------------------------JcAspTable对象定义开始---------------------------------------------------
//

/**<doc type="objdefine" name="JcAspTable">
	<desc>JcAspTable定义</desc>
	<input>
		<param name="ele" type="object">构建JcAspTable的XML元素/param>
	</input>	
	<property>
		<prop name="ListData" type="object">JcAspTable所关联的DataList</param>
		<prop name="ShowTitle" type="object">是否显示Title,默认值为true</param>
		<prop name="SelectMode" type="string">是否为允许单选,多选或禁止选择(none/single/multi)</param>
		<prop name="Border" type="string">是否显示Border,默认值为true</param>
		<prop name="ColDef" type="string">DataItem对应的类型</param>
		<prop name="_DefRow" type="string">JcAspTable的表头定义</param>
		<prop name="_TmplRow" type="string">JcAspTable的表的主体模块定义</param>
		<prop name="HighLight" type="boolean">是否高亮显示,默认值为false</param>
		<prop name="IsFullRowSelect" type="string">DataItem对应的类型</param>
		<prop name="CrossRowStyle" type="string">是否有记录间斑马线的样式,默认值为false</param>
		<prop name="SelectedIndex" type="string">DataItem对应的类型</param>
		<prop name="SelectedRow" type="string">DataItem对应的类型</param>
		<prop name="_HLRow" type="object">JcAspTable的原高亮行</param>
	</property>		
</doc>**/


function JcAspTable(ele)
{	

   
    this.Type="jcasptable";
	if(!ele)ele=document.createElement("<span class='jcasptable' jctype='jcasptable'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;
	 
	 if (ele.FirstTable)   //如果对象存在，则表明本次是分页，排序的操作，同时把表头加入span中 for asp 
     {
         ele.appendChild(ele.FirstTable)
     }
     
     
     
     
     
	this.HtmlEle.FirstTable=this.HtmlEle.childNodes[0].cloneNode(true); //克隆JcAspTable的表头定义,给分页，排序时用  add by chenmin  for asp
	this.Codebehind=null;                //后台xml代码  add by chenmin  for asp
	this.QueryFormName=null;             //查询表单名   add by chenmin  for asp
	this.SortPageFormName=null;             //分页，排序表单名   add by chenmin  for asp
	
	
	this.Css=ele.className;
		
	if(!this.Css)
	{	
		this.Css="jcasptable";
	}	
	
	this.NoRecordNotify=null             //add by chenmin 20061019  没有记录的提示语
	
	this.ListData=null;
	this.SelectMode="none";    //single/multi
	this.Border=true;
	this.ColDef=new Array();
	this._DefRow=null;
	this._TmplRow=null;
	this.HighLight=false;
	this.IsFullRowSelect=false;
	this.CrossRowStyle=false;
	this.UsingIconRowStyle = null;
	this.SelectedIndex=-1;
	this.SelectedRow=null;
	this._HLRow=null;
	this.PageBar=null;
	this.SummaryBar=null;
	this.PageIndex=null;
	this.QueryForm=null;
	this.Render="client";
	this.Event=new Object();
	this.Init(ele);
	
	
	// add by chenmin 20071213  数据列表表头css重新显示，防止表头样式被其他css所替代
	if (ele.getAttribute("TitleCss") != null)	
	   this.HtmlEle.childNodes[0].childNodes[0].childNodes[0].className=ele.getAttribute("TitleCss");

	else
	   this.HtmlEle.childNodes[0].childNodes[0].childNodes[0].className=this.SubCss("TitlePic");
	   
	
	
}


JcAspTable.prototype.SubCss=function(name)
{ 
//add by chenmin 20070428  支持自动换行
  if (this.HtmlEle.getAttribute("AutoNewLine")!=null )  
     return this.Css + "_" + name+"_AutoNewLine";
  else
	return this.Css + "_" + name;
}


/**<doc type="protofunc" name="JcAspTable.Init">
	<desc>JcAspTable的构建器</desc>
	<input>
		<param name="ele" type="object">JcAspTable对应的HTML元素</param>
	</input>	
</doc>**/
JcAspTable.prototype.Init=function(ele)
{	

   //add by chenmin 20070120  针对aspTable的设置
 
   if(ele.getAttribute("Codebehind") ){
    
    
		this.Codebehind =ele.getAttribute("Codebehind");
		 
   }
   else{
   
     alert("请设置后台处理xml程序：在 jcasptable的span中 设置 Codebehind='**_xml.asp'");
     return ;
   }
   
   if(ele.getAttribute("QueryFormName") )
   {     
   
     
		this.SortPageFormName ="_SortPage_"+ele.getAttribute("QueryFormName"); //排序，分页表单，该表单系统自动创建 add by chenmin 20070813
			

		
		this.QueryFormName =ele.getAttribute("QueryFormName"); //查询表单数据
		
	
		var objSortPageForm=null;
		
		 if( !document.all(this.SortPageFormName)) 
		 {
		     objSortPageForm = document.createElement("<form id='"+ this.SortPageFormName  +"'  name='"+ this.SortPageFormName  +"'>");		
	         document.appendChild(objSortPageForm);
		 }
		 else
		 { 
		 
		    objSortPageForm=document.all(this.SortPageFormName) ;
		 }
		
	    
		if( !document.all("DataGrid_PageNO")) //如果没有创建 分页 排序字段，则系统自动创建
		{
			var objPageNo = document.createElement("<Input type='hidden' name='DataGrid_PageNO'>");							
  			var objOrderField = document.createElement("<Input type='hidden' name='DataGrid_OrderField'>");					
			var objOrderBy = document.createElement("<Input type='hidden' name='DataGrid_OrderBy'>");					
			
			
	
  			objSortPageForm.appendChild(objPageNo);
			objSortPageForm.appendChild(objOrderField);
			objSortPageForm.appendChild(objOrderBy);
			
		}
     
     
     
      //this.HtmlEle.appendChild(div2);
   }
   else
   {
     alert("请设置查询表单名字：在 jcasptable的span中 设置 QueryFormName='QueryForm' 或者其他变量名")
     return ;
   }
   

	if(ele.getAttribute("ListData") )
	{	
	     
	
	    this.ListData = GetDsNode(ele.getAttribute("ListData"));
	
	
		if(!this.ListData){
		  alert("Error! 获取xml出错");
		  return ;
		
		};
	}
	else
		this.ListData = new DataList();
			
   //=============================================== 
   //增加没有记录提示,add by chenmin 20061019
   
    if( this.ListData.GetItemCount()==0 && ele.getAttribute("NoRecordNotify")!=null )
    {
       //	var div = document.createElement("<div class='JcAspTable_body' style='width:100%;height:100%;'>");
	   // div.appendChild(this.HtmlEle.childNodes[0]);
	    
	    var div2 = document.createElement("<div   style='width:100%;height:100%;'  class='"+this.SubCss("NORecord")+"' >");
	   
	     if(ele.getAttribute("NoRecordNotify")=="")
	     {
	       div2.innerText="没有记录,请重新选择条件查询!" 
	     }
	     else
	     {
	       div2.innerText=ele.getAttribute("NoRecordNotify")
	     }
	   // alert(div2.innerHtml)
	    this.HtmlEle.appendChild(div2);
	    return ;
    }
//---------------------------============================//
			
	if(ele.getAttribute("SelectMode"))
		this.SelectMode =ele.getAttribute("SelectMode").toLowerCase();
	if(ele.getAttribute("QueryForm"))
		this.QueryForm =GetDsNode(ele.getAttribute("QueryForm"));		
	if(this.QueryForm)
		this.PageIndex = new StringParam(this.QueryForm.GetAttr("PageIndex"));		
			
			
	//保留原来的span第一个儿子节点 table 的设置		
	// Firsttable=this.HtmlEle.childNodes[0].cloneNode(true);
	//this.HtmlEle.appendChild(objtable);		
			
	//添加滚动条控制元素
	var div = document.createElement("<div class='JcAspTable_body' style='width:100%;height:100%;'>");
	div.appendChild(this.HtmlEle.childNodes[0]);
	this.HtmlEle.appendChild(div);
	

	if( ele.getAttribute("IconRowStyle") != null )
		this.UsingIconRowStyle = "Icon";
	
	
	if(ele.getAttribute("HighLight")!=null)
		this.HighLight = true;
	if(ele.getAttribute("HasPageBar")!=null)
		this.PageBar = this.GetPageBar();//取得翻页条
		

	if(ele.getAttribute("HasSummaryBar")!=null)
	{
		this.SummaryBarHtmlEle=this.GetSummaryBar();	//取得总计条
	}	
	this.IsAsyncRender=GetAttr(this.HtmlEle,"IsAsyncRender",false,"bool");//是否异步绘制

	this._InitDefine();
	this.RenderObject();
	this.InitEvent();

}
JcAspTable.prototype.Destroy=function()
{
	this.HtmlEle.removeChild(this.HtmlEle.childNodes[0]);
}

JcAspTable.prototype.GetSummaryBar=function()
{
	var apb = document.createElement("<DIV>");
	var pageBarHTML="<TABLE cellspacing=0 cellpadding=0 border=0 width=100% height=20 ID=SummaryBar>" +
					"<TD ID='Total' class='"+this.SubCss("SummaryTotal")+"'>共" + this.ListData.GetItemCount() + "条</TD>" + 
					"<TD ID='Content' class='"+this.SubCss("SummaryContent")+"'></TD>" + 
					"</TABLE>";
	apb.innerHTML=pageBarHTML;
	this.SummaryBar=apb;
	this.HtmlEle.appendChild(apb);
	return apb;	
}

///TRC:总的记录数;TPC:总的页数;RCPP:每页记录数;CPN:当前页页码;CPRC:当前页记录数
JcAspTable.prototype.GetPageBar=function()
{	

	var apb = document.createElement("<DIV>");
	var pageBarHTML="<TABLE  cellspacing=0 cellpadding=0 border=0 width=100% height=20 ID=PageBar class='"+this.SubCss("PageBar")+"'>" +
					"<TD ID='PageInfo' class='"+this.SubCss("PageInfo")+"'></TD>" + 
					"<TD ID='PageNum' class='"+this.SubCss("PageNum")+"'></TD>" + 
					"<TD ID='PageArea' align=right class='"+this.SubCss("PageArea")+"'>" + 
						"<BUTTON ID='PageFirst' class='"+ this.SubCss("PageFirst")+"'>&nbsp;|<<&nbsp;首页</BUTTON>&nbsp;" +
						"<BUTTON ID='PagePre' class='"+this.SubCss("PagePre")+"'><&nbsp;上一页</BUTTON>&nbsp;" +
						"<BUTTON ID='PageNext' class='"+this.SubCss("PageNext")+"'>下一页&nbsp;></BUTTON>&nbsp;" +
						"<BUTTON ID='PageLast' class='"+this.SubCss("PageLast")+"'>尾页&nbsp;>>|</BUTTON>" + 
					"</TD>" + 
					"</TABLE>";
	var trc = this.PageIndex.Get("TRC");
	apb.innerHTML=pageBarHTML;
	if(trc != null && trc != "0")					
	{
		apb.all("PageFirst").onclick = JcAspTable.DoPageEvent;
		apb.all("PagePre").onclick = JcAspTable.DoPageEvent;
		apb.all("PageNext").onclick = JcAspTable.DoPageEvent;
		apb.all("PageLast").onclick = JcAspTable.DoPageEvent;
	}
	
	if(this.PageIndex)
	{
		this.SetPageInfo(apb);
		this.SetPageNum(apb);
	}
	this.HtmlEle.appendChild(apb);
	return apb;
}
JcAspTable.prototype.SetPageNum=function(apb)
{	
	var MaxPageNo=10;
	if (this.PageIndex==null) return;
	var pnhtml = "";
	var pnum = parseInt(this.PageIndex.Get("TPC"));
	var cpnum = parseInt(this.PageIndex.Get("CPN"));
	if (pnum<= 0) return;
	
	//modify by chenmin 
	var MinPage = cpnum - parseInt(MaxPageNo/2 )
	
	if( MinPage<0 ) MinPage=0
	
	for (var i=MinPage; i<MinPage+MaxPageNo; i++)
	{	
	   if (i<pnum)
	   {
		var spn = document.createElement("<SPAN PageNo='" + (i+1) + "'>");
			if (cpnum == i+1)
			{	spn.title="当前为第"+cpnum+"页";
				spn.className = this.SubCss("CurPageNo");
			}else
			{	spn.title="跳转至第"+(i+1)+"页";
				spn.className = this.SubCss("PageNo");
				spn.id="PageJump";
			}
			spn.innerText = i+1;
			if (pnhtml.length == 0 )		
				pnhtml = spn.outerHTML ;
			else
				pnhtml =  pnhtml +"," + spn.outerHTML ;
		}	
		/*	
		if (i>MaxPageNo)
		{	pnhtml = pnhtml + ",...";
			break;
		}
		*/
	}
	if(pnhtml.trim() != "")
		apb.all("PageNum").innerHTML = "<nobr>第 "+pnhtml+" 页</nobr>";   //modify by chenmin 此处为 页数显示
	var nods = apb.all("PageNum").all("PageJump");
	if(nods)
	{
		if(nods.length)
			for (var i=0; i<nods.length;i++)
			{	nods[i].onclick = JcAspTable.PageJumpEvent;
			}
		else
			nods.onclick = JcAspTable.PageJumpEvent;	
	}
}
JcAspTable.PageJumpEvent=function()
{
	JcAspTable.DoPageEvent(event.srcElement.PageNo);
}

JcAspTable.OnPerPageCountChange = function()
{
	if(event.keyCode == 13)
	{
		JcAspTable.DoPageEvent();
	}
}
JcAspTable.prototype.SetPageInfo=function(apb)
{	
	if (this.PageIndex!=null)
	{
		var trc = this.PageIndex.Get("TRC");
		var tpc = this.PageIndex.Get("TPC");
		apb.all("PageInfo").innerHTML = 
		"<nobr>共<B>"+(trc==null?0:trc)+"</B>条/<B>" +(tpc==null?0:tpc)+ "</B>页"+
		"&nbsp;<input type=hidden onkeypress='JcAspTable.OnPerPageCountChange();' type='text' style='width:20' class='jctext' id='RecPerPage'></nobr>";
		//"&nbsp;每页<input type=hidden onkeypress='JcAspTable.OnPerPageCountChange();' type='text' style='width:20' class='jctext' id='RecPerPage'>条</nobr>"; //modify by chenmin for asp
		
	}
	apb.all("RecPerPage").value = this.PageIndex.Get("RCPP");
}

JcAspTable.prototype.Fire=function(type)
{	
  
 var onfunc=this.HtmlEle.getAttribute(type);
	try
	{
		if(onfunc)
			eval(onfunc);
	}
	catch(e)
	{
	}
}

JcAspTable.FunctionButtonClick=function()
{


	var evele=event.srcElement;
	var ele =GetParentJcElement(evele);
	var obj =ele.Co;
	obj.Event = new Object();
	var funcEle=evele;
	while(!funcEle.functype)
	{
		funcEle=funcEle.parentNode;
	}	
	obj.Event.FuncType=funcEle.functype;
	var trEle=evele;
	while(!trEle.Record)
	{
		trEle=trEle.parentNode;
	}
	obj.Event.returnValue=true;
	obj.Event.Record=trEle.Record;
	
	var rows= obj.HtmlEle.childNodes[0].childNodes[0].childNodes[1].childNodes;
	for(var i=0;i<rows.length;i++)
	{
		if(rows[i].Record == trEle.Record)
		{
			obj.Event.Index = i;
		}
	}		
	
	obj.Fire("OnFunction");
	if(!obj || !obj.Event || !obj.Event.returnValue)
	{	event.cancelBubble=true;
		event.returnValue=false;
	}
	else
	{
		JcAspTable.LinkTo();
	}
}

JcAspTable.prototype.SetRecPerPage=function(frm)
{	
	if (this.PageBar==null)return true;
	var rpp = this.PageBar.all("RecPerPage");
	if (!IsInt(rpp.value)||rpp.value <= 0)
	{	alert("请在每页的记录数中填入整数页");
		rpp.value = this.PageIndex.Get("RCPP");
		return false;
	}else
	{	var pi=frm.GetAttr("PageIndex");
		if (pi!=null && pi!="")
		{	var sp = new StringParam(pi);
			sp.Set("RCPP",rpp.value);
			frm.SetAttr("PageIndex",sp.ToString());
		}
		return true;
	}
}

//--------分页事件---------------------需要修改
JcAspTable.DoPageEvent=function(jumpno)
{	
	var evele=event.srcElement;
	var ele =GetParentJcElement(evele);
	var obj =ele.Co;
	if (obj.QueryForm == null)
	{	alert("没有设定查询DataForm！");
		return;
	}
	obj.Event = new Object();
	if(jumpno)
	{
		obj.Event.PageNo=jumpno;
		obj.QueryForm.SetAttr("JumpNo",jumpno);
	}	
	obj.Event.PageAction=event.srcElement.id;
	obj.QueryForm.SetAttr("PageAction",event.srcElement.id);
	obj.Event.returnValue=true;
	if(!obj.SetRecPerPage(obj.QueryForm))
		return false;
	
	
	//df.SetAttr("PageAction",pageAction);
	//if(typeof(jumpno)!="undefined")df.SetAttr("PageJumpNo",jumpno);	
	obj.Fire("OnPageChange");
	if(!obj.Event || !obj.Event.returnValue)return;
	else
          // Submit.Get("Query",obj.QueryForm);   //BE原来的代码，采用下面的方法分页
		obj._PreGetData();  //add by chenmin 20070121 无刷新的分页

}

//------重新获取xml数据----------------
JcAspTable.prototype._PreGetData=function()
{

  var ele = this.HtmlEle;
  
  var pnum = parseInt(this.PageIndex.Get("TPC"));
  var cpnum = parseInt(this.PageIndex.Get("CPN"));
  var strob=this.QueryForm.GetAttr("OrderBy");
  if (strob!=null)
	var sortSp = new StringParam(strob);

   
  var PageAction=this.QueryForm.GetAttr("PageAction");
   
  var DataGrid_PageNO=1
  
  if (PageAction=="PageFirst" )
      DataGrid_PageNO=1;
  else if (PageAction=="PagePre" )
      DataGrid_PageNO=cpnum-1;   
  else if (PageAction=="PageNext" )
      DataGrid_PageNO=cpnum+1;     
  else if (PageAction=="PageLast" )
      DataGrid_PageNO=pnum;
  else if (PageAction=="PageJump")
      DataGrid_PageNO=this.QueryForm.GetAttr("JumpNo")  
  else
      DataGrid_PageNO=1; //表明是排序
      
   if ( DataGrid_PageNO>pnum) 
       DataGrid_PageNO=pnum;
       
/*
   document.all("DataGrid_OrderField").value=sortSp.Keys[0];
   document.all("DataGrid_OrderBy").value=sortSp.Values[0];
   document.all("DataGrid_PageNO").value=DataGrid_PageNO;
*/

	document.all("DataGrid_OrderBy").value=strob;
   document.all("DataGrid_PageNO").value=DataGrid_PageNO;
	  

   ECIDI.Form.Datagrid.ShowMessage(true)
   
   var url=this.Codebehind
   var othis=this
   var postform=this.SortPageFormName    //分页的表单，采用查询的表单

   
  window.setTimeout( function(){ECIDI.Form.Datagrid.GetData(url,othis,postform,0)},10)

  
 // ECIDI.Form.Datagrid.GetData(this.Codebehind,this,this.QueryFormName,0)
}


JcAspTable.prototype.DestroySelf=function()
{
  var length=this.HtmlEle.childNodes.length;
  for ( var i=0;i<length;i++)
	this.HtmlEle.removeChild(this.HtmlEle.childNodes[0]);
	
  this.HtmlEle.Co=null;
  
}


//-----排序事件----------------------

JcAspTable.DoSortEvent=function()
{

	var evele=event.srcElement;
	var ele =GetParentJcElement(evele);
	var obj =ele.Co;
	if (obj.QueryForm == null)
	{	alert("没有设定查询DataForm！");
		return;
	}
	var objTD = event.srcElement;
	while(objTD.tagName!="TD")
	{	objTD=objTD.parentNode;
	}
	var cursortst,newsortst;
	if (objTD.getAttribute("SortState") != null)
		cursortst = objTD.getAttribute("SortState");
	else
		cursortst ="ASC";
	if( cursortst == "ASC")
		newsortst = "DESC";
	else
		newsortst = "ASC";
	
	//add by chenmin 20070404排序的字段
	if (objTD.getAttribute("SortFieldName") != null)	
	    obj.QueryForm.SetAttr("OrderBy",objTD.getAttribute("SortFieldName")+":"+newsortst+";");
	else
	   obj.QueryForm.SetAttr("OrderBy",objTD.getAttribute("Name")+":"+newsortst+";"); 
	
	if(!obj.SetRecPerPage(obj.QueryForm))
		return false;
	obj.Event = new Object();
	obj.Event.returnValue=true;
	obj.Fire("OnSort");
	if(!obj.Event || !obj.Event.returnValue)return;
	else
		//Submit.Get("Query",obj.QueryForm); //BE原来的代码，采用下面的方法分页
		 obj._PreGetData();  //add by chenmin 20070121 无刷新的排序
		 
}

/**<doc type="protofunc" name="JcAspTable._InitDefine">
	<desc>构建JcAspTable的结构</desc>
</doc>**/
JcAspTable.prototype._InitDefine=function()
{	var ele = this.HtmlEle;
	this._DefRow=ele.getElementsByTagName("tr")[0];
	var drow=this._DefRow;
	// add by chenmin 20070425 标题的css
	if (ele.getAttribute("TitleCss") != null)	
	    drow.className=this.SubCss(ele.getAttribute("TitleCss"));
	else
	   drow.className=this.SubCss("TitlePic");
	
	var colnum=drow.childNodes.length;
	var trow = drow.cloneNode(false);
	var sortSp=null;
	trow.style.display="";
	
	if (this.QueryForm !=null)
	{	var strob=this.QueryForm.GetAttr("OrderBy");
		if (strob!=null)
			sortSp = new StringParam(strob);
	}		
	for(var i=0;i<colnum;i++)
	{	var tcell=document.createElement("td");
		var cell=drow.childNodes[i];
		//cell.className=this.SubCss("TitleTd");   //edit by chenmin 20070428 支持标题自动2行
		this._SetSortColumn(cell,sortSp);
		
		tcell.style.cssText = GetAttr(cell,"CellStyle"," ");
		var type=GetAttr(cell,"Type","Data").toLowerCase();
		//设置选择框
		var defobj=this.ColDef[i]=new Object();
		defobj["Type"]=type;
		if(this.SelectMode!="none" && type =="selector")
		{	
			this._SetSelectBox(tcell,cell);
		}else
		{	
			if(type=="function")
			{
				tcell.innerHTML=this._GetFunctionHtml(cell);
			}else
			{	defobj["Name"]=GetAttr(cell,"Name","");
				this.ColDef[defobj["Name"]]=defobj;
				//defobj["DataType"]=GetAttr(cell,"DataType","string");
				defobj["DataType"]=GetAttr(cell,"DataType","string");
				defobj["Enum"]=GetAttr(cell,"Enum",null);
				if(defobj["Enum"])
					defobj["EnumObject"] = GetDsNode(defobj["Enum"]);
				defobj["Format"]=GetAttr(cell,"Format",null);
				defobj["Icon"]=GetAttr(cell,"Icon",null);
				//defobj["MyOnclick"]=GetAttr(cell,"MyOnclick",null);
				
			}
			defobj["FuncType"]=GetAttr(cell,"FuncType","default");			
			defobj["LinkUrl"]=GetAttr(cell,"LinkUrl",null);
			defobj["LinkTarget"]=GetAttr(cell,"LinkTarget",null);
			defobj["LinkStyle"]=GetAttr(cell,"LinkStyle",null);
			defobj["LinkData"]=GetAttr(cell,"LinkData",null);
			defobj["DateOnly"]=GetAttr(cell,"DateOnly",null);
			defobj["FilterTime"]=GetAttr(cell,"FilterTime",null);
			defobj["OnlyFileName"]=GetAttr(cell,"OnlyFileName",null);
			defobj["AllowEdit"]=GetAttr(cell,"AllowEdit",null);
		}
		trow.appendChild(tcell);
	}
	this._TmplRow=trow;
}

JcAspTable.prototype._SetSortColumn=function(cell,sortSp)
{
	if (cell==null||sortSp==null||cell.getAttribute("AllowSort")==null)return;
	var ele=document.createElement("<div width='100%' height='100%'>");
	cell.onclick = JcAspTable.DoSortEvent;
	ele.innerHTML=cell.innerHTML;cell.innerHTML="";//将原Td中的内容放到Div中去
	cell.appendChild(ele);
	if (sortSp.Get(cell.getAttribute("Name"))!=null)
	{	
		if (sortSp.Get(cell.getAttribute("Name")).toUpperCase() == "ASC")
		{	
			ele.className=this.SubCss("SortInc");
			cell.setAttribute("SortState","ASC");	
		}else
		{	
			ele.className=this.SubCss("SortDes");
			cell.setAttribute("SortState","DESC");
		}
	}//自定义排序 add by chenmin 20070723
	else if (sortSp.Get(cell.getAttribute("SortFieldName"))!=null)
	{	
		if (sortSp.Get(cell.getAttribute("SortFieldName")).toUpperCase() == "ASC")
		{	
			ele.className=this.SubCss("SortInc");
			cell.setAttribute("SortState","ASC");	
		}else
		{	
			ele.className=this.SubCss("SortDes");
			cell.setAttribute("SortState","DESC");
		}
	}
	else
	{	ele.className=this.SubCss("Sort");
		cell.setAttribute("SortState","none");;//ASC/DESC
	}
}
JcAspTable.prototype._GetFunctionHtml=function(cell)
{	var ele = this.HtmlEle;	
	var html="";
	var type = cell.getAttribute("FuncType");
	if(!type)return html;
	var type0 = type.toLowerCase();
	html="<img  id='funcflag' onclick='JcAspTable.FunctionButtonClick();' functype='"+type+"' src='[icon]'>";
	switch(type0)
	{	case "delete":
			html = html.replace("[icon]",ECIDI.Util.Const.AppServer+"/images/jsctrl/delete.gif");
			break;
		case "modify":
			html = html.replace("[icon]",ECIDI.Util.Const.AppServer+"/images/jsctrl/edit.gif");
			break;
		case "default":
			html = html.replace("[icon]",ECIDI.Util.Const.AppServer+"/images/jsctrl/edit.gif");
			break;
		default:
			if(cell.getAttribute("Icon"))
			{
				html = html.replace("[icon]",cell.getAttribute("Icon"));
			}
			else
			{
				html = "<span onclick='JcAspTable.FunctionButtonClick();' functype='"+type+"' >" + GetAttr(cell,"FuncHtml","") + "</span>";
			}	
			break;
	}
	return "<span id='_FunctionHtml' content='" + escape(html) + "' class='" + this.SubCss("Link") + "'></span>";
}
JcAspTable.prototype._SetSelectBox=function(tcell,cell)
{	var ele = this.HtmlEle;	
	// edit by chenmin 20070424 高度可以自己调整 
	tcell.style.width=20;   
	cell.style.width=20;
	if(this.SelectMode == "multi")
	{	tcell.innerHTML="<input type='checkbox' id='selector' name='sel_"+ele.id+"'>";
		cell.innerHTML="<input type='checkbox' id='selmaster'>";
	}else if(this.SelectMode == "single")
	{	tcell.innerHTML="<input type='radio' id='selector' name='sel_"+ele.id+"'>";
		cell.innerHTML="<input type='radio' id='selmaster'>";
	}
}
/**<doc type="protofunc" name="JcAspTable._GetOutput">
	<desc>设置某单元格内的显示格式</desc>
	<input>
		<param name="def" type="object">单元格的定义对象</param>
		<param name="item" type="DataItem">单元格内所设的DataItem</param>
	</input>
	<output type="string">单元格内的显示文本</output>	
</doc>**/
JcAspTable.prototype._GetOutput=function(index,def,item)
{	
	var txt=(item.GetAttr(def["Name"])+"").filterNull();
	return this._GetColText(index,def["Name"],txt);
}

/**<doc type="protofunc" name="JcAspTable._GetColText">
	<desc>设置某单元格内的显示文本</desc>
	<input>
		<param name="name" type="string">单元格名称</param>
		<param name="value" type="string">单元格内所设的值</param>
	</input>
	<output type="string">单元格内的显示文本</output>		
</doc>**/
JcAspTable.prototype._GetColText=function(index,name,value)
{	if(this.ColDef[index].DataType.toLowerCase() != "enum")
		return value;
	else
	{	
		var txt=this.ColDef[index].EnumObject.GetText(value);
		if(!txt)return "";
		return txt;
	}
}

JcAspTable.prototype._GetLinkUrl=function(item,linkUrl,linkData)
{

	var returnUrl="";
	if(linkData)
	{
		returnUrl=item.GetAttr(linkData);
	}
	else if(linkUrl)
	{	returnUrl=linkUrl;
		while(returnUrl.indexOf("[")!=-1)
		{
			var replaceParam=returnUrl.substring(returnUrl.indexOf("[")+1,returnUrl.indexOf("]"));
			var replaceValue=(item.GetAttr(replaceParam)+"").filterNull();
			returnUrl=returnUrl.replace("[" + replaceParam + "]",escape(replaceValue));
		}
		if(returnUrl.indexOf("{")!=-1)
		{
			var replaceParam=returnUrl.substring(returnUrl.indexOf("{")+1,returnUrl.indexOf("}"));
			var replaceValue=AppServer[replaceParam];
			returnUrl=returnUrl.replace("{" + replaceParam + "}",replaceValue);
		}
	}
	return returnUrl;	
}

JcAspTable.prototype.RenderAsyncObject=function()
{	var tbody = this.HtmlEle.all("tbody");
	var row = this._TmplRow.cloneNode(true);

	if(this._CurRenderIndex%2==0)
		row.className=this.SubCss("Row1");
	else
		row.className=this.SubCss("Row2");
	row.setAttribute("PreClassName",row.className);
	this.RenderRow(row,this.ListData.GetItem(this._CurRenderIndex));
	tbody.appendChild(row);	
	this._CurRenderIndex++;
	var rowcount=this.ListData.GetItemCount();
	if(this._CurRenderIndex<rowcount)
		this._AsyncCall.execTimeout();
}

JcAspTable.prototype._RenderFunctionHtml=function(tbody)
{
	var funcSpan=tbody.all("_FunctionHtml");
	if(funcSpan)
	{
		if(funcSpan.length)
		{
			for(var i=0;i<funcSpan.length;i++)
			{
				funcSpan.item(i).innerHTML=unescape(funcSpan.item(i).content);
			}
		}
		else
		{
			funcSpan.innerHTML=unescape(funcSpan.content);
		}
	}
}

/**<doc type="protofunc" name="JcAspTable.RenderObject">
	<desc>根据ListData绘制JcAspTable的主体</desc>
</doc>**/
JcAspTable.prototype.ClearRows=function()
{
	while( this.ListData.GetItemCount() > 0 )
	       this.RemoveRow( 0 );
	//this.HtmlEle.childNodes[0].childNodes[0].removeChild( this.HtmlEle.childNodes[0].childNodes[0].childNodes[0] );
}

/**<doc type="protofunc" name="JcAspTable.RenderObject">
	<desc>根据ListData绘制JcAspTable的主体</desc>
</doc>**/
JcAspTable.prototype.RenderObject=function()
{	
	if(this.HtmlEle.clientHeight>60 )
	{	if(this.PageBar!=null || this.SummaryBar!=null)
			this.HtmlEle.childNodes[0].style.height=this.HtmlEle.clientHeight-24;
		else
			this.HtmlEle.childNodes[0].style.height=this.HtmlEle.clientHeight;
	}
	
	this.HtmlEle.childNodes[0].style.overflow="auto";

    var tbody = null;
    if ( this.HtmlEle.childNodes[0].childNodes[0].childNodes.length < 2 )
    {
		tbody = document.createElement("<tbody id='tbody'>"); 
		this.HtmlEle.childNodes[0].childNodes[0].appendChild(tbody);
    }
    else
        tbody = this.HtmlEle.childNodes[0].childNodes[0].childNodes[1];
//	if ( !this.HtmlEle.childNodes[0].childNodes[0].childNodes[0] )
//	else 
//	     tbody = this.HtmlEle.childNodes[0].childNodes[0].childNodes[0];


	if( this.ListData && this.Render=="client")
	{	/*this._CurRenderIndex=0;
		if(this.IsAsynRender)
		{	this._AsyncCall = new JcCaller(this,10,"RenderAsyncObject");
			this._AsyncCall.execTimeout();
			return;
		}*/
		
		var rowcount=this.ListData.GetItemCount();
		for(var i=0;i<rowcount;i++)
		{	var row = this._TmplRow.cloneNode(true);
			var pos = i;//GetNodeIndex(row);
			if(pos%2==0)
				row.className=this.SubCss("Row1");
			else
				row.className=this.SubCss("Row2");
			row.setAttribute("PreClassName",row.className);
			this.RenderRow(row,this.ListData.GetItem(i));
			tbody.appendChild(row);	
		}
		

		
		this._RenderFunctionHtml(tbody);
	}
}
/*   不需要nobr,
JcAspTable.prototype.RenderRow=function(row,item)
{	if(item)
		row.Record=item;
	var colcount = this.ColDef.length;
	for(var j=0;j<colcount;j++)
	{	var def = this.ColDef[j];
		var cell=row.childNodes[j];
		var type=def["Type"].toLowerCase();
	
		if(type!="selector"&&type!="function")
		{	//cell.innerHTML="";
			var output = this._GetOutput(j,def,item);
			if( def["Icon"] != null && def["Icon"].toLowerCase() != "" )
			{
				if( output.trim() == "" )
					cell.innerHTML="<span style='width:0;height:0;'></span>";
				else
					cell.innerHTML="<span style='width:1;height:1;'><img height='60' src='CheckFile.aspx?Id=" + escape(output) + "'></span>";
			}
   			else if( def["OnlyFileName"] != null && def["OnlyFileName"].toLowerCase() != "false" && def["OnlyFileName"].toLowerCase() != "" )
			{
			    var fileArray = output.split(",");
			    var fileName = "";
			    for ( var i = 0; i < fileArray.length; i++ )
			    {
			          if ( fileArray[i].indexOf("++") > 0 )
			               fileName += fileArray[i].split("++")[1] + ",";
			          else
			               fileName += fileArray[i].split("_")[1] + ",";
			    }
			    
				if( fileName != null && fileName.trim() == "" )
					cell.innerHTML="<span></span>";
				else
					cell.innerHTML="<span alt=\""+fileName.substring( 0, fileName.length - 1 )+"\"><nobr>"+fileName.substring( 0, fileName.length - 1 )+"</nobr></span>";
			}
			else
			{
				if(def["DateOnly"] != null && def["DateOnly"].toLowerCase() != "false" && output.indexOf(" ") >= 0)
				{
					if(output.substring(0,8) == "1900-1-1" || output.substring(0,10) == "1900-01-01")
						cell.innerHTML="<span style='width:1;height:1;'><nobr></nobr></span>";
					else
						cell.innerHTML="<span style='width:1;height:1;'><nobr>" + output.substring(0,output.indexOf(" ")) + "</nobr></span>";
				}
				else if(def["FilterTime"] != null && def["FilterTime"].toLowerCase() != "false" && output.indexOf(" ") >= 0)
				{
					if(output.substring(0,8) == "1900-1-1" || output.substring(0,10) == "1900-01-01")
						cell.innerHTML="<span style='width:1;height:1;'><nobr></nobr></span>";
					else	
						cell.innerHTML="<span style='width:1;height:1;'><nobr>" + output + "</nobr></span>";					
				}
				else
					cell.innerHTML="<span style='width:1;height:1;'><nobr>" + output + "</nobr></span>";					
					
			}

			if( def["AllowEdit"] )
			{
			    cell.onclick = JcAspTable.EditText;
				var txt = document.createElement("<input type='text' style='width:100%;height:100%;MARGIN:0px;BORDER-TOP-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BORDER-BOTTOM-STYLE:none'>"); 
				txt.value = output;
				cell.appendChild(txt);
				txt.style.display = "none";
				txt.onblur = JcAspTable.LeaveText;
				txt.onkeydown = JcAspTable.EnterText;
            }

			if( def["LinkUrl"] || def["LinkData"] )
			{	
				cell.childNodes(0).className = this.SubCss("Link");
				cell.childNodes(0).onclick = JcAspTable.LinkTo;
			}
		}
		else if( type == "function" )
		{
			//cell.className = this.SubCss("Link");
			//cell.onclick=JcAspTable.LinkTo;
		}
		
		
	    //add by chenmin20060421 增加提示数据，当数据长的时候
		cell.title=output
		
		
	}
}*/
//表格可以自动换行 20070428 chenmin 
JcAspTable.prototype.RenderRow=function(row,item)
{	

	
   var AutoNewLine=false;
  if  (this.HtmlEle.getAttribute("AutoNewLine")!=null)
          AutoNewLine=true;
          
  if(item)
		row.Record=item;
	var colcount = this.ColDef.length;
	for(var j=0;j<colcount;j++)
	{	var def = this.ColDef[j];
		var cell=row.childNodes[j];
		var type=def["Type"].toLowerCase();
		
	   //var functype
		if(type!="selector"&&type!="function")
		{	//cell.innerHTML="";
		   var functype = def["FuncType"].toLowerCase();  //增加 事情方法add by chenmin 20071114
			var output = this._GetOutput(j,def,item);
			
			if( def["Icon"] != null && def["Icon"].toLowerCase() != "" )
			{
				if( output.trim() == "" )
					cell.innerHTML="<span style='width:0;height:0;'></span>";
				else
					cell.innerHTML="<span style='width:1;height:1;'><img height='60' src='CheckFile.aspx?Id=" + escape(output) + "'></span>";
			}
   			else if( def["OnlyFileName"] != null && def["OnlyFileName"].toLowerCase() != "false" && def["OnlyFileName"].toLowerCase() != "" )
			{
			    var fileArray = output.split(",");
			    var fileName = "";
			    for ( var i = 0; i < fileArray.length; i++ )
			    {
			          if ( fileArray[i].indexOf("++") > 0 )
			               fileName += fileArray[i].split("++")[1] + ",";
			          else
			               fileName += fileArray[i].split("_")[1] + ",";
			    }
			    
				if( fileName != null && fileName.trim() == "" )
					cell.innerHTML="<span></span>";
				else
				 {  
				    if (AutoNewLine)
				  	    cell.innerHTML="<span alt=\""+fileName.substring( 0, fileName.length - 1 )+"\">"+fileName.substring( 0, fileName.length - 1 )+"</span>";
				    else
				       cell.innerHTML="<span alt=\""+fileName.substring( 0, fileName.length - 1 )+"\"><nobr>"+fileName.substring( 0, fileName.length - 1 )+"</nobr></span>";	    
				}	
			}
			else
			{
				if(def["DateOnly"] != null && def["DateOnly"].toLowerCase() != "false" && output.indexOf(" ") >= 0)
				{
					if(output.substring(0,8) == "1900-1-1" || output.substring(0,10) == "1900-01-01")
					   {   
					      if (AutoNewLine)
					     	cell.innerHTML="<span style=''></span>";
					      else
					        cell.innerHTML="<span style=''><nobr></nobr></span>";	
					   }
					else
					{ 
					   if (AutoNewLine)
						  cell.innerHTML="<span style=''>" + output.substring(0,output.indexOf(" ")) + "</span>";
					    else
					      cell.innerHTML="<span style=''><nobr>" + output.substring(0,output.indexOf(" ")) + "</nobr></span>";   
						
						
					}
				}
				else if(def["FilterTime"] != null && def["FilterTime"].toLowerCase() != "false" && output.indexOf(" ") >= 0)
				{
					if(output.substring(0,8) == "1900-1-1" || output.substring(0,10) == "1900-01-01")
					{
					   if (AutoNewLine)
						 cell.innerHTML="<span style=''></span>";
					   else
					    cell.innerHTML="<span style=''><nobr></nobr></span>"; 	
					}
					else	
					{
						if (AutoNewLine)
						  cell.innerHTML="<span style=''>" + output + "</span>";					
						else
						   cell.innerHTML="<span style=''><nobr>" + output + "</nobr></span>";					 
					}
				}
				else  //数据一般显示在这里 20071024
					{
					    if (AutoNewLine)
						 {  //cell.innerHTML="<span style=''>" + output + "</span>";
						  
						  	if (functype=="default"|| functype==""||functype==null){ 
								cell.innerHTML="<span style=''  >" + output + "</span>";		
							}
							else//20071024 增加 一般数据增加onclick功能
							{
								cell.innerHTML="<span style='' onclick='JcAspTable.FunctionButtonClick();' functype='"+functype+"' ><nobr>" + output + "</nobr></span>";		
								cell.childNodes(0).className = this.SubCss("Link");
							}
							
						  }					
						else
						{
							if (functype=="default"|| functype==""||functype==null){ 
								cell.innerHTML="<span style=''  ><nobr>" + output + "</nobr></span>";		
							}
							else//20071024 增加 一般数据增加onclick功能
							{
								cell.innerHTML="<span style='' onclick='JcAspTable.FunctionButtonClick();' functype='"+functype+"' ><nobr>" + output + "</nobr></span>";		
								cell.childNodes(0).className = this.SubCss("Link");
							}
						   
						 }  
						  			
					}
					
			}

			if( def["AllowEdit"] )
			{
			    cell.onclick = JcAspTable.EditText;
				var txt = document.createElement("<input type='text' style='width:100%;height:100%;MARGIN:0px;BORDER-TOP-STYLE:none;BORDER-RIGHT-STYLE:none;BORDER-LEFT-STYLE:none;BORDER-BOTTOM-STYLE:none'>"); 
				txt.value = output;
				cell.appendChild(txt);
				txt.style.display = "none";
				txt.onblur = JcAspTable.LeaveText;
				txt.onkeydown = JcAspTable.EnterText;
            }
            
          
			if( def["LinkUrl"] || def["LinkData"] )
			{	
				cell.childNodes(0).className = this.SubCss("Link");
				cell.childNodes(0).onclick = JcAspTable.LinkTo;
			}
		
		}
		else if( type == "function" )
		{
			//cell.className = this.SubCss("Link");
			//cell.onclick=JcAspTable.LinkTo;
		}
		
		
	    //add by chenmin20060421 增加提示数据，当数据长的时候
	    if (type=="data" )
		    cell.title=output
		
		
	}
}


JcAspTable.EnterText = function()
{
}
JcAspTable.LeaveText = function()
{
    event.srcElement.style.display = "none";
    td = event.srcElement.parentNode;

	//获取单元格所属的行
	var myRow = td.parentNode;
	var myTable = GetParentJcElement( myRow );

    //
	var jcCollection = myTable.Co;
	var myColumn = jcCollection.ColDef[ GetNodeIndex( td ) ];
	var myItem = myRow.Record;

	myItem.SetAttr( myColumn["Name"], event.srcElement.value );

    td.childNodes[0].style.display = "";
	td.childNodes[0].innerHTML = "<nobr>"+event.srcElement.value+"</nobr>";
}
JcAspTable.EditText = function()
{
	var me = event.srcElement;

	while( me.tagName != "TD" )
		   me = me.parentNode;

	//获取单元格所属的行
	var myRow = me.parentNode;
	var myTable = GetParentJcElement( myRow );

    //
	var jcCollection = myTable.Co;
	var myColumn = jcCollection.ColDef[ GetNodeIndex(me) ];
	var myItem = myRow.Record;

    //
	//var linkUrl = jcCollection._GetLinkUrl( myItem, myColumn["LinkUrl"], myColumn["LinkData"] );
	//var linkTarget = myColumn["LinkTarget"];
	//var linkStyle = CenterWin( myColumn["LinkStyle"] );

    //
	jcCollection.Event = new Object;
	jcCollection.Event.Record = myItem;
	jcCollection.Event.Name = myColumn["Name"];
	jcCollection.Event.FuncType = myColumn["FuncType"];

    //
	var tableRows = jcCollection.HtmlEle.childNodes[0].childNodes[0].childNodes[1].childNodes;

	for( var i = 0; i < tableRows.length; i++ )
	{
		if( tableRows[i].Record == myItem )
			jcCollection.Event.Index = i;
	}

	//jcCollection.Event.LinkUrl = linkUrl;
	jcCollection.Event.returnValue = true;
	jcCollection.Fire("OnEdit");

    me.childNodes[0].style.display = "none";
	me.childNodes[1].style.display = "";
	me.childNodes[1].focus();
}

JcAspTable.LinkTo=function()
{	var cell=event.srcElement;
	while(cell.tagName!="TD")
	{	cell = cell.parentNode;
	}
	var row=cell.parentNode;
	var ele =GetParentJcElement(row);
	var obj =ele.Co;
	var def = obj.ColDef[GetNodeIndex(cell)];
	var item = row.Record;
	var url=obj._GetLinkUrl(item,def["LinkUrl"],def["LinkData"]);
	var target=def["LinkTarget"];
	var style= CenterWin(def["LinkStyle"]);
	obj.Event = new Object;
	obj.Event.Record=item;
	obj.Event.Name=def["Name"];
	obj.Event.FuncType=def["FuncType"];
	
	var rows= obj.HtmlEle.childNodes[0].childNodes[0].childNodes[1].childNodes;
	for(var i=0;i<rows.length;i++)
	{
		if(rows[i].Record == item)
		{
			obj.Event.Index = i;
		}
	}	
		
	obj.Event.LinkUrl=url;
	obj.Event.returnValue=true;
	obj.Fire("OnLink");
	
	if(!obj || !obj.Event || !obj.Event.returnValue)
	{	
		event.returnValue=false;
		event.cancelBubble=true;
	}
	else
	{
		var win=LinkTo(url,target,style);
		if(win) win.focus();
	}	
}

/**<doc type="protofunc" name="JcAspTable.InitEvent">
	<desc>初始化JcAspTable的相关事件</desc>
</doc>**/
JcAspTable.prototype.InitEvent=function()
{	var tbl=this.HtmlEle.childNodes[0].childNodes[0];

	tbl.onmouseover=JcAspTable.MouseOver;
	tbl.onmouseout=JcAspTable.MouseOut;
	tbl.onclick=JcAspTable.MouseClick;
}

JcAspTable.prototype.MasterSelect=function(state)
{
	var rows= this.HtmlEle.childNodes[0].childNodes[0].childNodes[1].childNodes;//span/div/table/tbody[1]/rows
	for(var i=0;i<rows.length;i++)
	{
		if(this.SelectMode=="single")
		{
			this.SelectRow(rows[i],false);
		}	
		else if(this.SelectMode=="multi")
			this.SelectRow(rows[i],state);
	}
}

JcAspTable.prototype.GetSelected=function(type)
{
	var rows= this.HtmlEle.childNodes[0].childNodes[0].childNodes[1].childNodes;//span/div/table/tbody[1]/rows
	var items=new Array();
	for(var i=0;i<rows.length;i++)
	{
		if(rows[i].className.indexOf("RowSelected")>0 || (rows[i].all("selector") && rows[i].all("selector").checked))
		{
			if(type&&type.toLowerCase()=="htmlele")
				items[items.length]=rows[i];
			else
				items[items.length]=this.ListData.GetItem(i);
		}	
	}
	return items;
}

/**<doc type="protofunc" name="JcAspTable.SelectRow">
	<desc>设置某一行是否被选中</desc>
	<input>
		<param name="row" type="object">设置的行</param>
		<param name="state" type="boolean">是否选择该行</param>
	</input>
</doc>**/
JcAspTable.prototype.SelectRow = function(row,state)
{
	//不能选中Title
	if(!row.getAttribute("PreClassName"))
	{
		event.returnValue=false;
		return false;
	}
		
	if(this.SelectMode=="single")
	{
		var prow=this.SelectedRow;
		if(prow)
		{	prow.selected = false;
			prow.className=prow.getAttribute("PreClassName");
		}
		row.selected = state;
		if(row.all("selector"))
		{
			row.all("selector").checked=state;
		}	
		if(state)
		{	
			row.className=this.SubCss("RowSelected");
			this.SelectedRow=row;
		}else
		{	
			row.className=row.getAttribute("PreClassName");
		}		
	}
	else if(this.SelectMode=="multi")
	{
		row.selected = state;
		if(row.all("selector"))
		{
			row.all("selector").checked=state;
		}	
		if(state)
		{	
			row.className=this.SubCss("RowSelected");
		}else
		{	
			row.className=row.getAttribute("PreClassName");
		}	
	}
	this.Event = new Object;
	this.Event.Record=row.Record;
	this.Event.returnValue=true;
	this.Fire("OnRowStateChange");	
}

JcAspTable.prototype.SelectRowByFieldValue=function(fieldName,fieldValue,state)
{	
	if(typeof(state)=="undefined"||state==null)
		var state=true;
		
	var rows= this.HtmlEle.childNodes[0].childNodes[0].childNodes[1].childNodes;
	for(var i=0;i<rows.length;i++)
	{
		var item=rows[i].Record;
		if(item.GetAttr(fieldName)==fieldValue)
		{
			this.SelectRow(rows[i],state);
		}
	}
}


/**<doc type="protofunc" name="JcAspTable.HighLightRow">
	<desc>设置某一行是否被高亮显示</desc>
	<input>
		<param name="row" type="object">设置的行</param>
		<param name="state" type="boolean">是否高亮显示该行</param>
	</input>
</doc>**/
JcAspTable.prototype.HighLightRow = function(row,state)
{	var prow=this._HLRow;
	if(prow)
	{	if(prow.selected)
			prow.className=this.SubCss("RowSelected");
		else
			prow.className=prow.getAttribute("PreClassName");
	}
	this._HLRow=row;
	if(row.selected)
		if(this.HighLight)
			row.className=this.SubCss("RowSelHighLight");	
		else
			row.className = this.SubCss("RowSelected");	
	else
		if(this.HighLight)
			row.className = this.SubCss("RowHighLight");	
		else
			row.className=row.getAttribute("PreClassName");
}

/**<doc type="protofunc" name="JcAspTable.ClearHighLight">
	<desc>清除高亮显示</desc>
</doc>**/
JcAspTable.prototype.ClearHighLight=function()
{	var prow=this._HLRow;
	if(prow)
	{	if(prow.selected)
			prow.className=this.SubCss("RowSelected");
		else
		{
			prow.className = prow.getAttribute("PreClassName");	
		}	
	}
}

/**<doc type="protofunc" name="JcAspTable.ClearSelected">
	<desc>清除选择</desc>
</doc>**/
JcAspTable.prototype.ClearSelected=function()
{			
	var rows= this.HtmlEle.childNodes[0].childNodes[0].childNodes[1].childNodes;//span/div/table/tbody[1]/rows
	for(var i=0;i<rows.length;i++)
		this.SelectRow(rows[i],false);
}

JcAspTable.prototype.GetRowByRecord=function(rec)
{
	var rows= this.HtmlEle.childNodes[0].childNodes[0].childNodes[1].childNodes;
	for(var i=0;i<rows.length;i++)
	{
		var item=rows[i].Record;
		if(item==rec)
			return rows[i];
	}
	return null;
}
JcAspTable.prototype.RemoveRowByFieldValue = function()
{
	var tbody=this.HtmlEle.childNodes(0).childNodes(0).childNodes(1);
	var removeTr = new Array();
	for(var i = 0;i < tbody.childNodes.length;i++)
	{
		var flag = true;
		var tr = tbody.childNodes(i);

		for(var j = 0;j < arguments.length;j = j + 2)
		{
			if(tr.Record.GetAttr(arguments[j]) != arguments[j + 1])
				flag = false;
		}
		if(flag == true)
			removeTr[removeTr.length] = tr;
	}
	for(var i = 0;i < removeTr.length;i++)
	{
		this.ListData.Remove(removeTr[i].Record);
		tbody.removeChild(removeTr[i]);	
	}
}
JcAspTable.prototype.RemoveRow=function(index,type)
{
	var tbody=this.HtmlEle.childNodes(0).childNodes(0).childNodes(1);
	var tr=null;
	
	if(!type)
		type="htmlele";
	if(typeof(index)=="number")
		tr=tbody.childNodes(index);
	else if(type.toLowerCase()=="htmlele")
	{
		tr=index;
	}
	else if(type.toLowerCase()=="record")
	{
		tr=this.GetRowByRecord(index);
	}
	
	if(tr)
	{	
		this.ListData.Remove(tr.Record);
		tbody.removeChild(tr);
	}
}
JcAspTable.prototype.AddRow=function()
{
	var row = this._TmplRow.cloneNode(true); 
	var item=this.ListData.NewItem();
	for(var i=0;i<arguments.length;i=i+2)
	{
		var name=arguments[i];
		var value=arguments[i+1];
		item.SetAttr(name,value);
	}
	var table=this.HtmlEle.childNodes(0).childNodes(0);
	var tbody=table.childNodes(1);
	if(tbody.childNodes.length==0)
		row.className="JcAspTable_row1";
	else
	{
		var preRowClass=tbody.childNodes(tbody.childNodes.length-1).className;
		if(preRowClass.toLowerCase()=="JcAspTable_row1")
			row.className="JcAspTable_row2";
		else
			row.className="JcAspTable_row1";	
	}

	row.setAttribute("PreClassName",row.className);	

	this.RenderRow(row,item);
	
	tbody.appendChild(row);
	this._RenderFunctionHtml(tbody);
	table.scrollIntoView(false);
	return row;
}
JcAspTable.prototype.UpdateRow=function(row)
{
	var item = row.Record;
	for(var i=1;i<arguments.length;i=i+2)
	{
		var name=arguments[i];
		var value=arguments[i+1];
		item.SetAttr(name,value);
	}
	this.RenderRow(row,item);
}

/**<doc type="protofunc" name="JcAspTable.MouseOver">
	<desc>定义MouseOver事件</desc>
</doc>**/
JcAspTable.MouseOver=function()
{	
	var evele=event.srcElement;
	var ele =GetParentJcElement(evele);
	var row=GetTableTr(event.srcElement);
	if(!row||row==ele.childNodes[0].childNodes[0].childNodes[0].childNodes[0])return;//span/div/table/tbody/tr/
	var obj =ele.Co;
	if(obj.HighLight)
		obj.HighLightRow(row,true);
		
	
}

/**<doc type="protofunc" name="JcAspTable.MouseClick">
	<desc>定义MouseClick事件</desc>
</doc>**/
JcAspTable.MouseClick=function()
{	var evele=event.srcElement;
	var ele =GetParentJcElement(evele);
	var obj =ele.Co;
	//由于在点选中响应的可能是Table本身,或者是TBody,此时将该事件Cancel掉
	if(evele.tagName.toLowerCase()=="table"||evele.tagName.toLowerCase()=="tbody")
	{
		event.returnValue = false;
		return false;
	}	
	var row=GetTableTr(evele);
	if(row)
	{
		if(evele.tagName!="INPUT")
		{
			obj.Event = new Object;
			obj.Event.Record=row.Record;
			obj.Event.returnValue=true;
			obj.Fire("OnRowClick");
			if(!obj.Event.returnValue)
			{	return;
			}	
		}
		if(evele.tagName.toLowerCase()=="input" && evele.id=="selmaster")
		{	
			obj.MasterSelect(evele.checked);
			return;
		}
		if(!row||row.all("selmaster"))return;
		if(obj.SelectMode=="single")
		{
			obj.SelectRow(row,true);
		}
		else if(obj.SelectMode=="multi")
		{
			obj.SelectRow(row,!row.selected);	
		}	
	}
}

/**<doc type="protofunc" name="JcAspTable.MouseOut">
	<desc>定义MouseOut事件</desc>
</doc>**/
JcAspTable.MouseOut=function()
{	var ele =GetParentJcElement(event.srcElement);
	var obj =ele.Co;
	obj.ClearHighLight();
	
	
	
}



//================JcAspTable对象定义结束====================




/**<doc type="命名空间常量变量的定义" name="jcasptable.js">
	<desc>本文件共有3个命名空间：
	
	    1. ECIDI.Form:各类表单静态类的命名空间 ；包含以下类:
	          1.1 ECIDI.Form.Datagrid:          标准查询结果列表的显示，分页，排序；
	           
        2. ECIDI.Util:标准控件静态类的命名空间 ;包含以下类:
              2.1  ECIDI.Util.Const:            服务器相关信息的配置
              2.2  ECIDI.Util.Loading:          通用进度条
              2.3  ECIDI.Util.UploadFile:       通用的多文件上传
              2.4  ECIDI.Util.Window:           打开窗口统一模式
              2.5  ECIDI.Util.GetXml:           通用的无刷新数据提交方传
               
         
        3. ECIDI.Class; 一些标准类，辅助类的命名空间
        
             3.1  ECIDI.Class.AutoSuggest:      自动提示完成控件
             
             3.2  ECIDI.Class.ExecResult :      返回数据的统一处理类(ECIDI.Util.GetXml会调用本类)
             
           
             
        
	</desc>
</doc>**/

 
if (typeof ECIDI == "undefined") {
    ECIDI = {};
}


ECIDI.namespace = function(ns) {

    if (!ns || !ns.length) {
        return null;
    }
    var levels = ns.split(".");
    var nsobj = ECIDI;
    for (var i=(levels[0] == "ECIDI") ? 1 : 0; i<levels.length; ++i) {
        nsobj[levels[i]] = nsobj[levels[i]] || {};
        nsobj = nsobj[levels[i]];
    }
    return nsobj;
};


ECIDI.extend = function(subclass, superclass) {
    var f = function() {};
    f.prototype = superclass.prototype;
    subclass.prototype = new f();
    subclass.prototype.constructor = subclass;
    subclass.superclass = superclass.prototype;
    if (superclass.prototype.constructor == Object.prototype.constructor) {
        superclass.prototype.constructor = superclass;
    }
};


ECIDI.namespace("Form");  //数据格式的处理
ECIDI.namespace("Util");  //实用性的函数
ECIDI.namespace("Class"); //功能类






/**<doc type="静态类" name=" ECIDI.Form.Datagrid">
	<desc>标准查询结果列表的显示，分页，排序；</desc>
</doc>**/



ECIDI.Form.Datagrid ={

   DivResult:null,   //放数据的div
   IsDebug:false,
   tr_curColor:null,


	//----初始化，载入----
	LoadXmlData:function(url,formId){
	 
		var pageReturn = ECIDI.Util.GetXml.Execute(url, "firstload", formId, "post" );
		
		if( pageReturn.HasError ){	
		
			pageReturn.ShowDebug();
			
		}
		else{
		
			var  obj=document.all("Rds")
			if ( obj==null || typeof(obj ) !="object"){
			
				obj =  document.createElement("<XML id='Rds'></XML>");//URL格式化
				document.appendChild(obj);
				
			}
			
			obj.XMLDocument=pageReturn.ReturnDs.XmlDoc;
			
			//  alert(o.responseXML.xml)
			InitDocumentEx(false);
			//if (ECIDI.Form.Datagrid.IsDebug) alert(pageReturn.ReturnDs.XmlDoc.xml)
		}
						
	},


	//----分页或排序获取数据，显示数据---
	GetData:function(url,co,formId,isall){
	
	
           //isall=1,表示新的查询
           //isall=0,排序 或 分页
         var pageReturn = null;
        
		if( isall!=0 ){//新的查询
             //1.先清空分页和排序字段
			document.all("DataGrid_OrderField").value="";
			document.all("DataGrid_OrderBy").value="";
			document.all("DataGrid_PageNO").value="";
			//2.把上次查询的内容清空
			//alert( ECIDI.Util.GetXml._sFormData)
			ECIDI.Util.GetXml._sQueryFormData=null;
	       
	       pageReturn=ECIDI.Util.GetXml.Execute(url, "queryload", formId, "post" );

		}
		else //分页，排序
		{
		  
		  pageReturn=ECIDI.Util.GetXml.Execute(url, "queryload", formId, "post",formId);
		}
		

		
  		if( pageReturn.HasError ){	
	  	
    		pageReturn.ShowDebug();
	 	
		}
		else{

			var  obj=document.all("Rds")
			
			if ( obj==null || typeof(obj ) !="object"){
			
				obj =  document.createElement("<XML id='Rds'></XML>");//URL格式化
				document.appendChild(obj);
			}
			
			obj.XMLDocument=pageReturn.ReturnDs.XmlDoc;
			//  alert(o.responseXML.xml)
			co.DestroySelf(); 
			InitDocumentEx(false);
			//if (ECIDI.Form.Datagrid.IsDebug) alert(pageReturn.ReturnDs.XmlDoc.xml)
		
		}
		
		//window.setTimeout(  "eval(\"document.all('SYS_Loadinng').style.display='none'\")",10 );
		this.ShowMessage(false)
	
      //自动调整iframe的高度 add by chenmin 20070723
		try{
			if  (window.parent.window.document.all("CatalogManageFrame"))
				window.parent.window.document.all("CatalogManageFrame").height=document.body.scrollHeight+20;
		}
		catch(e){}


			
	},
	

		ShowMessage:function ( isshow)
	{
	
		   //处理提示消息开始显示
	   
			var  loading=document.all("SYS_Loadinng")
			
			if (isshow){
			
				if ( loading==null || typeof(loading ) !="object"){
				loading =  document.createElement("<div id='SYS_Loadinng'   style='Z-INDEX: 1; LEFT: 297px; WIDTH: 150px; POSITION: absolute; background-color: yellow; ' >数据处理中,请稍候...</div>")
				document.body.appendChild(loading);
				}
					

				var x=document.body.scrollLeft+event.clientX;
				var y=document.body.scrollTop+event.clientY;
				
				loading=document.all("SYS_Loadinng")
				loading.style.top=y-35;
				loading.style.left=x-50;
				loading.innerHTML="<font color=black>数据处理中,请稍候...</font>"
				loading.style.display="";//显示
            }
            else {
               if (loading!=null ){
              
                loading.style.display="none";//隐藏
              }
            }
          
        //处理提示消息  
	},
	
	//  鼠标经过颜色改变
	TR_MouseOver : function ( oRow ){
	
		//this.tr_curColor=mRow.style.backgroundColor;
		oRow.style.backgroundColor='#CCD9E8';
		//oRow.style.cursor='hand';
		//alert(this.tr_curColor)
    
   },

    TR_MouseOut : function ( oRow ){

	       //alert(this.tr_curColor)
			//oRow.style.backgroundColor=this.tr_curColor;
			oRow.style.backgroundColor="";
	
	    
    },
    
    TR_OnClick :function (oRow){
    
    
    }


};




 /**<doc type="静态类" name=" ECIDI.Util.Const ">
	<desc> 服务器相关信息的配置</desc>
</doc>**/

ECIDI.Util.Const={

  AppServer:"http://doc.simulate.com/ecidi/common/",  
  MachineName:"doc.simulate.com"
   
};




 /**<doc type="静态类" name="  ECIDI.Util.Loading  ">
	<desc> 通用进度条</desc>
</doc>**/

 ECIDI.Util.Loading ={

     IsLoad:false,
    _url : null, 
    _targeturlpath :null,
    
	//---打开---
	Open:function (targeturl,msg){ 
         
         this._url =ECIDI.Util.Const.AppServer+"asp/sys_loading.asp";
         
		if( typeof targeturl !="undefined" )
			targeturl=escape(targeturl);
		else 
			targeturl="";

		if( typeof msg !="undefined" )               
			msg=escape(msg);
		else
			msg=""

		var href=window.location.href;
		var pos=href.lastIndexOf("\/")
		var _targeturlpath=href.substring(0,pos);

		if ( targeturl.lastIndexOf(":")==-1 ){

		   if (targeturl!="") targeturl=_targeturlpath+"\/"+targeturl;

		}


		this._InitOpen(this._url+"?targeturl="+targeturl+"&msg="+msg);  
	 
  },


   //---关闭---
	Close:function (){
      this._url =ECIDI.Util.Const.AppServer+"asp/sys_loading.asp";
      this._InitOpen(this._url+"?AutoClose=1");
	},
	
	
	//---显示进度条---
   Show:function(){

       var oloadBar=document.all("oloadBar") 
       
		if( oloadBar !=null ){
		
			if( oloadBar.width<300 ){	
				  
				if( oloadBar.width+50>=300 )
					oloadBar.width=300
				else   
					oloadBar.width=oloadBar.width+50
				    
				window.setTimeout(Show, 100);

			}
			else{
			
				oloadBar.width=0
				window.setTimeout(Show, 100);

			}
		}
		
   } ,
 
 //---打开---
  _InitOpen:function(url){
  
  		var left = (window.screen.availWidth - 350 + 25)/2;
		var top = (window.screen.availHeight - 130 - 30)/2;
		
		if(left<0) left=0;
		if(top<0) top=0;
		var width = 350;
		var height = 130;
		var openstr = 'left=' + left + ',top=' + top + ',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,width=' + width + ',height=' + height;
		
		window.open(url,'Sys_Loading', openstr);	
  
  }
	
	

};



 /**<doc type="静态类" name="  ECIDI.Util.Window  ">
	<desc> 打开窗口统一模式</desc>
</doc>**/


 ECIDI.Util.Window={
    
     //----打开固定窗口----
     Open:function(filename,ntype){
	
		if (ntype == 0){	//满屏
		
			var left = 0;
			var top = 0;
			var width = window.screen.availWidth-10;	//屏幕宽度减去窗体边框宽度
			var height = window.screen.availHeight-30;	//屏幕高度减去窗体边框高度
			var openstr = 'left=' + left + ',top=' + top + ',titlebar=no,toolbar=no,status=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width=' + width + ',height=' + height;
			
			OpenWnd = window.open(filename,'', openstr);
			
		}
	
		else if (ntype == 1){	//大窗口
  
		    //ECIDI.Util.Loading.Open(filename)//进度条 
		    
			var top = (window.screen.availHeight - 600 - 30)/2;
			var left = (window.screen.availWidth - 800 + 25)/2;
			
			if(left<0) left=0;
			if(top<0) top=0;
			
			var width = 800;
			var height = 600;
			var openstr = 'left=' + left + ',top=' + top + ',titlebar=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height;
			//alert(openstr)
			OpenWnd = window.open(filename,'', openstr);
		 
		   
		}

		else if (ntype == 720){	//大窗口
  
		    //ECIDI.Util.Loading.Open(filename)//进度条 
		    
			var top = (window.screen.availHeight - 690 - 30)/2;
			var left = (window.screen.availWidth - 800 + 25)/2;
			
			if(left<0) left=0;
			if(top<0) top=0;
			
			var width = 800;
			var height = 690;
			var openstr = 'left=' + left + ',top=' + top + ',titlebar=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height;
			//alert(openstr)
			OpenWnd = window.open(filename,'', openstr);
		 
		   
		}
		else if (ntype == 860){	//大窗口
  
		    //ECIDI.Util.Loading.Open(filename)//进度条 
		    
			var top = (window.screen.availHeight - 620 - 30)/2;
			var left = (window.screen.availWidth - 860 + 25)/2;
			
			if(left<0) left=0;
			if(top<0) top=0;
			
			var width = 860;
			var height = 630;
			var openstr = 'left=' + left + ',top=' + top + ',titlebar=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height;
			//alert(openstr)
			OpenWnd = window.open(filename,'', openstr);
		 
		   
		}
		else if (ntype == 800){	//大窗口
  
		    //ECIDI.Util.Loading.Open(filename)//进度条 
		    
			var top = (window.screen.availHeight - 620 - 30)/2;
			var left = (window.screen.availWidth - 800 + 25)/2;
			
			if(left<0) left=0;
			if(top<0) top=0;
			
			var width = 800;
			var height = 630;
			var openstr = 'left=' + left + ',top=' + top + ',titlebar=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height;
			//alert(openstr)
			OpenWnd = window.open(filename,'', openstr);
		 
		   
		}
		else if (ntype == 900){	//大窗口
  
		    //ECIDI.Util.Loading.Open(filename)//进度条 
		    
			var top = (window.screen.availHeight - 600 - 30)/2;
			var left = (window.screen.availWidth - 900 + 25)/2;
			
			if(left<0) left=0;
			if(top<0) top=0;
			
			var width = 900;
			var height = 600;
			var openstr = 'left=' + left + ',top=' + top + ',titlebar=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height;
			//alert(openstr)
			OpenWnd = window.open(filename,'', openstr);
		 
		   
		}
		else if (ntype == 1000){	//大窗口
  
		    //ECIDI.Util.Loading.Open(filename)//进度条 
		    
			var top = (window.screen.availHeight - 600 - 30)/2;
			var left = (window.screen.availWidth - 1000 + 25)/2;
			
			if(left<0) left=0;
			if(top<0) top=0;
			
			var width = 1000;
			var height = 600;
			var openstr = 'left=' + left + ',top=' + top + ',titlebar=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height;
			//alert(openstr)
			OpenWnd = window.open(filename,'', openstr);
		 
		   
		}
		else if (ntype == 2){	//新闻浏览窗口
		
			var top = (window.screen.availHeight - 500 - 30)/2;
			var left = (window.screen.availWidth - 450 + 25)/2;
			
			if(left<0) left=0;
			if(top<0) top=0;
			
			var width = 450;
			var height = 500;
			var openstr = 'left=' + left + ',top=' + top + ',toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollbars=yes,width=' + width + ',height=' + height;
			
			OpenWnd = window.open(filename,'', openstr);
		}
		
		else if (ntype == 3){  //消息提示窗口
		
			var left = (window.screen.availWidth - 250 + 25)/2;
			var top = (window.screen.availHeight - 150 - 30)/2;
			if(left<0) left=0;
			if(top<0) top=0;
			var width = 250;
			var height = 150;
			var openstr = 'left=' + left + ',top=' + top + ',titlebar=no,toolbar=no,resizable=no,directions=no,scrollbars=no,width=' + width + ',height=' + height;
			OpenWnd = window.open(filename,'', openstr);
		}
	
	  else if (ntype == 4){  //隐藏窗口
		
			var left = 0;
			var top = 0;
			var width = 0;
			var height =0;
			var openstr = 'left=' + left + ',top=' + top + ',titlebar=no,toolbar=no,resizable=no,directions=no,scrollbars=no,width=' + width + ',height=' + height;
			OpenWnd = window.open(filename,'', openstr);
		}
	   else if (ntype == 5){	//大窗口,有滚动条，可以判定窗口是否有广告拦截
		   
		    ECIDI.Util.Loading.Open(filename)//进度条 
		     
			var top = (window.screen.availHeight - 550 - 30)/2;
			var left = (window.screen.availWidth - 830 + 25)/2;
			if(left<0) left=0;
			if(top<0) top=0;
			var width = 830;
			var height = 550;
			var openstr = 'left=' + left + ',top=' + top + ',titlebar=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height;
			
			OpenWnd = window.open(filename,'', openstr);
	       
		   
		}
	

   },
   
   //----打开自定义窗口----
    FreeOpen:function(filename,wwidth,wheight,wtop,wleft,wresizeable,wscrollbar,winid,adcheck){
	
		if(wtop==''){
		
			wtop = (window.screen.availHeight - wheight - 30)/2;
			wleft = (window.screen.availWidth - wwidth + 25)/2;
			if(wleft<0) wleft=0;
			if(wtop<0) wtop=0;
			
		}
		
		if ( typeof(adcheck)!="undefined" ) 
		   ECIDI.Util.Loading.Open(filename)//进度条 
		       
		var openstr = 'left=' + wleft + ',top=' + wtop + ',titlebar=no,toolbar=no,status=no,directories=no,menubar=no,';
		openstr+= 'scrollbars=' + wscrollbar + ',resizable=' + wresizeable + ',width=' + wwidth + ',height=' + wheight;
		OpenWnd = window.open(filename,winid, openstr);

    }


};


 /**<doc type="静态类" name="  ECIDI.Util.UploadFile  ">
	<desc> 通用的多文件上传</desc>
</doc>**/


 ECIDI.Util.UploadFile =
{
 

    _url : ECIDI.Util.Const.AppServer+"asp/UploadMulti.asp", 
    _selectobj:"",
   

//---打开添加操作--
//--跟表单的多文件上传，文件名以字符串形式返回--	
Open:function (selectobj,url,dwfselectobj){


	if (typeof selectobj=="undefined" || selectobj==""){
	    
		selectobj=document.all("JcAspFiles")
    
	}
	
     this._selectobj=selectobj
  
	if (typeof url=="undefined" || url=="")
	{
        this._url=ECIDI.Util.Const.AppServer+"asp/UploadMulti.asp";
     	url=this._url;
    }   
	 
	var returnValue;
	
	returnValue = window.showModalDialog(url,1,"dialogHeight:468px; dialogWidth:568px;edge:Sunken; help:No; resizable:no; status:No;scroll=no;");	//用模态窗体打开上传页面以获得返回值

	if(typeof(returnValue)!="undefined"){

		this._AddValue(returnValue, selectobj,dwfselectobj); //将返回的文件名添加到本页的表单对象中
		
	}
		
},
	


//---删除操作----
Delete:function (selectobj,dwfselectobj){	

try{

    if (typeof selectobj =="undefined" || selectobj=="")
         selectobj=this._selectobj;
         
	if(typeof(selectobj.options.length)!="undefined"){
	
		var optionlen = selectobj.options.length;
		
		for(var i=optionlen-1;i>=0;i--){
		
			if(selectobj.options[i].selected){
			
				selectobj.options.remove(i);
				if (typeof dwfselectobj =="object")
				{
				   dwfselectobj.options.remove(i);
				}
				
			}
		}
	}
	
	
	
}catch(e)
    {
      // alert("没有选择文件")
       return "";
    }

},


//---获取文件列表-----
GetFileList:function (selectobj)
{
	 if (typeof selectobj =="undefined" || selectobj=="")
         selectobj=this._selectobj;
         
	var strReturn="";
	 
    try {
		  for ( var i=0;i<selectobj.options.length;i++)
         {
         
                if (strReturn=="")
                    strReturn=selectobj.options[i].value
                else
                   strReturn=strReturn+"\|"+selectobj.options[i].value;
             
         }
         return strReturn;
    }catch(e)
    {
      // alert("没有选择文件")
       return "";
    }
         
},

//---dwf获取文件列表-----,去除null
GetdwfFileList:function (selectobj)
{
	 if (typeof selectobj =="undefined" || selectobj=="")
     {
       alert("请指定存放dwf文件的select列表")
     }
         
	var strReturn="";
	 
    try {
		  for ( var i=0;i<selectobj.options.length;i++)
         {
             if( selectobj.options[i].value!="null")
             {
                if (strReturn=="")
                    strReturn=selectobj.options[i].value
                else
                   strReturn=strReturn+"\|"+selectobj.options[i].value;
             }
             
         }
         return strReturn;
    }catch(e)
    {
      // alert("没有选择文件")
       return "";
    }
         
},

	
//----向表单对象中添加值------
_AddValue:function (options,selectobj,dwfselectobj){

	var pathFileName;
	var fileName;
	var Filelist;
	var DwfFilelist;
	
	if( options.indexOf("*")>0)
	{
	   var arrfile=options.split("*");
	    Filelist=arrfile[0]
	    DwfFilelist=arrfile[1]
	    
	    	//要上传的dwf文件
	
		var myarray = DwfFilelist.split("\<<");

		for(var i=0;i<myarray.length;i++){
			
			pathFileName = myarray[i]; //存储于服务器上的文件真实名称，带有特定格式的前缀
			if(pathFileName.length>0){
				
				fileName=pathFileName.substring(pathFileName.lastIndexOf("+")+1,pathFileName.length); //获取去除前缀后的文件名称，这里这样做只是为了显示更友好
				dwfselectobj.add(new Option(fileName,pathFileName)) //添加
			}
		}
	
	    
	}
	else
	{
	    Filelist=options;
	}
	
	//正常要上传的文件
	
	var myarray = Filelist.split("\<<");

	for(var i=0;i<myarray.length;i++){
		
		pathFileName = myarray[i]; //存储于服务器上的文件真实名称，带有特定格式的前缀
		if(pathFileName.length>0){
			
			fileName=pathFileName.substring(pathFileName.lastIndexOf("+")+1,pathFileName.length); //获取去除前缀后的文件名称，这里这样做只是为了显示更友好
			selectobj.add(new Option(fileName,pathFileName)) //添加
		}
	}
		
	
	
}

};


 /**<doc type="静态类" name="  ECIDI.Util.UploadFile  ">
	<desc> 通用的单文件上传</desc>
</doc>**/


 ECIDI.Util.UploadSingleFile =
{
 

     _url : ECIDI.Util.Const.AppServer+"asp/UploadSingle.asp", 
    _selectobj:"",
   

//---打开添加操作--
//--跟表单的多文件上传，文件名以字符串形式返回--	
Open:function (selectobj,url){


	if (typeof selectobj=="undefined" || selectobj==""){
	    
		selectobj=document.all("JcAspFiles")
    
	}
	
     this._selectobj=selectobj


	if (typeof url=="undefined" || url=="")
	{ 
      this._url=ECIDI.Util.Const.AppServer+"asp/UploadSingle.asp";
       url=this._url;

     }
	    
	var returnValue;
	
	returnValue = window.showModalDialog(url,1,"dialogHeight:364px; dialogWidth:495px;edge:Sunken; help:No; resizable:no; status:No;scroll=no;");	//用模态窗体打开上传页面以获得返回值

	if(typeof(returnValue)!="undefined"){
        this.Delete(); 
		this._AddValue(returnValue, selectobj); //将返回的文件名添加到本页的表单对象中
		
	}
		
},
	


//---删除操作----
Delete:function (selectobj){	

try {
   
		if (typeof selectobj =="undefined" || selectobj=="")
			selectobj=this._selectobj;
	         
		if(typeof(selectobj.options.length)!="undefined"){
		
			var optionlen = selectobj.options.length;
			
			for(var i=optionlen-1;i>=0;i--){
		
					selectobj.options.remove(i);
				
			}
		}
	}catch(e)
    {
      // alert("没有选择文件")
       return "";
    }
	

},


//---获取文件列表-----
GetFileList:function (selectobj)
{
	 if (typeof selectobj =="undefined" || selectobj=="")
         selectobj=this._selectobj;
         
	var strReturn="";
	 
    try {
		  for ( var i=0;i<selectobj.options.length;i++)
         {
         
                if (strReturn=="")
                    strReturn=selectobj.options[i].value
                else
                   strReturn=strReturn+"\|"+selectobj.options[i].value;
             
         }
         return strReturn;
    }catch(e)
    {
      // alert("没有选择文件")
       return "";
    }
         
},

	
//----向表单对象中添加值------
_AddValue:function (options,selectobj){

	var pathFileName;
	var fileName;
	var myarray = options.split("\<<");
	
	for(var i=0;i<myarray.length;i++){
		
		pathFileName = myarray[i]; //存储于服务器上的文件真实名称，带有特定格式的前缀
		if(pathFileName.length>0){
		   
			fileName=pathFileName.substring(pathFileName.lastIndexOf("+")+1,pathFileName.length); //获取去除前缀后的文件名称，这里这样做只是为了显示更友好
			selectobj.add(new Option(fileName,pathFileName)) //添加
		}
	}
	
}

};

 /**<doc type="静态类" name="  ECIDI.Util.GetXml  ">
	<desc> 通用的无刷新数据提交方传</desc>
</doc>**/

 ECIDI.Util.GetXml ={
 
 
 
     _sFormData:null,
     _sQueryFormData:null,
    _sSortPageFormData:null,
    _isFormSubmit:false,
    Codebehind:null,
    _msxml_progid:['MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'],
    _transaction_id:0,
    Xmlhttp:null,
    
// ECIDI.Util.GetXml.Execute(url,action,data,method)    
//提交客户端DataStore数据
//url--目的URL
//datastr--要提交的DataStore XML字符串
//action--页面的Action代码
//method : post or get
Execute:function (url,action,data,method,sortpageform){

	var acturl = url+"";
	var hrf =  document.createElement("<A href='"+url+"'>");//URL格式化
	
	document.appendChild(hrf);
	acturl= hrf.href;
	
	if(url=="#"){	
	    acturl=acturl.replace("#","");
		var pos=acturl.indexOf("?");
		if(pos>0)acturl=acturl.substr(0,pos);
	}
	if (acturl.indexOf("?") > 0)
		acturl = acturl + "&IsExec=True&RequestAction=" + action;
	else
		acturl = acturl + "?IsExec=True&RequestAction=" + action;
	
	var o = this.getConnectionObject(); //获取xmlhttp的链接对象
	this.Xmlhttp=o.conn;
	var execdata=""; //传入的数据
	var resdata;//返回的数据
	
    if(!method)method="post";
	
	if(method.toLowerCase() == "get"){
			
		resdata = this.GetRequest(acturl);
	}
	else{
	
		if(typeof(data)=="object"){ //直接传入查询表单对象
		
			//this._sFormData=this.setForm("QueryForm")	
			this._sFormData=this.setForm(data)	;
			resdata = this.PostRequest(acturl,this._sFormData);	 
					
		}
		else if(typeof(data)=="string"){
		
			var formId=data;
			var oForm = (document.getElementById(formId) || document.forms[formId]);
		 
			if(typeof oForm == 'object'){ //查询表单Id
		        
		        
		        //查询表单数据
		        if (this._sQueryFormData==null)
				  this._sQueryFormData= this.setForm(oForm)    
				
				//分页及排序隐藏字段     
				 if( typeof(sortpageform)=="string")   
				 { 
				  var oForm2= document.getElementById(sortpageform)
				  this._sSortPageFormData= this.setForm(oForm2)    
				  this._sFormData=this._sQueryFormData+"&"+ this._sSortPageFormData
				 }
				 else
				 {
				   this._sFormData=this._sQueryFormData;
				 }
				 
				     
				resdata = this.PostRequest(acturl,this._sFormData);		
		    }  
		  else
		  	{
		  		 alert("你所指定的查询表单"+ formId +"不存在！");
	        return ;	
		  	}  
		    
	    }
	    else{
	    
	        alert("调用ECIDI.Util.GetXml.Execute()，请指定查询表单（QueryForm）的名字");
	        return ;
	    }
	    
	 }

      if( ECIDI.Form.Datagrid.IsDebug==true)
      {
         var debugxml=this.ExecResult(resdata,acturl,action,unescape(this._sFormData),method)
         debugxml.ShowDebug()
      }
	//return  this.ExecResult(resdata,acturl,action,unescape(this._sFormData),method);  //调用自己内部的函数
	return  new ECIDI.Class.ExecResult(resdata,acturl,action,unescape(this._sFormData),method);
	
	
},

//------创建xmlhttp对象----
getConnectionObject:function()
{
	var o;
	var tId = this._transaction_id;

	try{
		o = this.createXhrObject(tId);
		if(o) this._transaction_id++;	
	}
	
	catch(e){}
	
	finally{
		return o;
	}
},	

createXhrObject_old:function(transactionId)
{
	var obj,http;
	try{
	
		http = new XMLHttpRequest();
		obj = { conn:http, tId:transactionId };
	
	}
	catch(e){
	
		for(var i=0; i<this._msxml_progid.length; ++i){
		
			try{
				http = new ActiveXObject(this._msxml_progid[i]);
				obj = { conn:http, tId:transactionId };
				break;
			}
			catch(e){}
		}
	}
	finally{
	
		return obj;
	}
},
createXhrObject:function(transactionId)
{
	var obj,http;

	
		for(var i=0; i<this._msxml_progid.length; ++i){
		
			try{
				http = new ActiveXObject(this._msxml_progid[i]);
				obj = { conn:http, tId:transactionId };
				break;
			}
			catch(e){}
		}

	
		return obj;
	
},
	
	
//-----post方法	---
PostRequest:function (url,data){

	//var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	
	if (this.Xmlhttp==null)	
	{ 	var o = this.getConnectionObject(); //获取xmlhttp的链接对象
		this.Xmlhttp=o.conn;
	}
	
	var xmlhttp=this.Xmlhttp
  xmlhttp.onreadystatechange=this.ProcessRequest;
	xmlhttp.Open("POST",url,false);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

 data = data.replace(/\xB7/g,"%B7");//由于服务器端Request处理中点，解码时会变成问号
 data = data.replace(/\+/g,"%2B")//由于服务器端Request处理"+"解码时会变成空格


	xmlhttp.send(data);
	
	return xmlhttp.responseText;
},

//-----get方法---
GetRequest:function (url)
{
	//var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	
	if (this.Xmlhttp==null)	
	{ 	var o = this.getConnectionObject(); //获取xmlhttp的链接对象
		this.Xmlhttp=o.conn;
	}
	
	var xmlhttp=this.Xmlhttp
	xmlhttp.onreadystatechange=this.ProcessRequest;
	xmlhttp.Open("GET",url,false);
	xmlhttp.send();

	return xmlhttp.responseText;
},

//----对结果进行统计的处理-----
ExecResult:function (rtndata,url,action,data,method)
{
	
		rtndata = unescape(rtndata);


		ExecRe={
			ExecUrl:url,
			ExecAction:action,
			ExecData :data,
			ExecMethod:method,
			ReturnDs:null,
			RetrunParam:null,
			Result:0,
			ErrorMsg:null,
			ErrorParam:null,
			ErrorSrc:null,
			HasError:true,
			ShowDebug:function(){//对错误进行统一的处理	
				try{
					var win = window.open("about:blank","_Error","width=600,height=540,left=0,top=0,resizable=yes,compact");
					if(ExecRe.ReturnDs!=null)
						var rtnxml=BeautyXml(ExecRe.ReturnDs.ToString());
					else
						var rtnxml = ExecRe.ErrorSrc;
						var errmsg=	"<html><body><table height=100% width=100%>"+
										"<tr style='height:20;font-color:red;font-size:20;'><td>查看调用信息</td></tr>"+
										"<tr style='height:16;font-size:14;'><td>调用地址："+ExecRe.ExecUrl+"</td></tr>"+
										"<tr style='height:16;font-size:14;'><td>调用操作："+ExecRe.ExecAction+"</td></tr>"+
										"<tr style='height:16;font-size:14;'><td>调用方法："+ExecRe.ExecMethod+"</td></tr>"+
										"<tr style='height:16;font-size:14;'><td>表单信息：</td></tr>"+
										"<tr style='font-size:14;'><td><textarea style='width:100%;height:100%;'>"+ExecRe.ExecData+"</textarea></td></tr>"+
										"<tr style='height:16;font-size:14;'><td>错误类型："+DbResult[ExecRe.Result]+"</td></tr>"+
										"<tr style='height:16;font-size:14;'><td>错误信息："+ExecRe.ErrorMsg+"</td></tr>"+
										"<tr style='height:16;font-size:14;'><td>返回数据：</td></tr>"+
										"<tr style='height:200;font-size:14;'><td><textarea style='width:100%;height:100%;'>"+rtnxml+"</textarea></td></tr>"+
										"</table></body></html>"

					win.document.writeln(errmsg);
					
				}catch(e){}

		}
		   
		};	


         /*
			if(rtndata.indexOf("<DataStore") != 0)
			{	ExecRe.Result = DbResult.SystemError;
				ExecRe.ErrorSrc = rtndata;
			}else
			{	try{
					ExecRe.ReturnDs=new DataStore(unescape(rtndata));
					ExecRe.ReturnParam = ExecRe.ReturnDs.Params("ExecReturn");
					if(ExecRe.ReturnParam==null)
						throw new Error(0,"Can't find param node in return datastore!");
					ExecRe.Result = ExecRe.ReturnParam.GetAttr("Result");
					if(ExecRe.Result>0)
					{	ExecRe.ErrorMsg = ExecRe.ReturnParam.GetAttr("ErrorMsg");
						ExecRe.ErrorParam = ExecRe.ReturnParam.GetAttr("ErrorParam");
					}
				}catch(e)
				{	ExecRe.Result=1;
					ExecRe.ReturnDs=null;
					ExecRe.ErrorSrc = rtndata;
				}
			}
			if(ExecRe.Result==0)
				ExecRe.HasError=false;
				
				*/
				
			ExecRe.ErrorSrc = rtndata;	
		     
			return ExecRe;		
},


//----回调处理函数------
ProcessRequest:function (){

   if ( ECIDI.Util.GetXml.Xmlhttp.readyState==4){
   
		if ( ECIDI.Util.GetXml.Xmlhttp.status==200){
			//alert("ProcessRequest成功")    
		}
		else if ( ECIDI.Util.GetXml.Xmlhttp.status==404){
	     
			alert("ajax提交时，没有找到后台处理文件！");
		}
		else{
	     
		//alert("读取xml,出错了,jcasptalbe.js")
	       
		}
	    
  }

  
},	

	
 //--------------原本是用encodeURIComponent封装数据，   现在用escape    by chenmin 200612------------
 //把相关的表单，和span  post出去
setForm_old:function(formId, isUpload, secureUri){
		
		this._isFormSubmit = false;
		this._sFormData = "";
		
		var oForm;

		if(typeof formId == 'string'){

			oForm = (document.getElementById(formId) || document.forms[formId]);
		}
		else if(typeof formId == 'object'){
		
			oForm = formId;
		}
		else{
		
			return;
		}



		var oElement, oName, oValue, oDisabled;
		var hasSubmit = false;

		for (var i=0; i<oForm.elements.length; i++){
			oElement = oForm.elements[i];
			oDisabled = oForm.elements[i].disabled;
			oName = oForm.elements[i].name;
			oValue = oForm.elements[i].value;

			if(!oDisabled && oName)
			{
				switch (oElement.type)
				{
					case 'select-one':
					case 'select-multiple':
						for(var j=0; j<oElement.options.length; j++){
							if(oElement.options[j].selected){
								if(window.ActiveXObject){
								
									this._sFormData += escape(oName) + '=' + escape(oElement.options[j].attributes['value'].specified?oElement.options[j].value:oElement.options[j].text) + '&';
									
								}
								else{
									
									this._sFormData += escape(oName) + '=' + escape(oElement.options[j].hasAttribute('value')?oElement.options[j].value:oElement.options[j].text) + '&';
								}

							}
						}
						break;
					case 'radio':
					case 'checkbox':
						if(oElement.checked){
					
							this._sFormData += escape(oName) + '=' + escape(oValue) + '&';
						}
						break;
						
					case 'file':
						// stub case as XMLHttpRequest will only send the file path as a string.
					case undefined:
						// stub case for fieldset element which returns undefined.
					case 'reset':
						// stub case for input type reset button.
					case 'button':
						// stub case for input type button elements.
						break;
					case 'submit':
						if(hasSubmit == false){
											
							this._sFormData += escape(oName) + '=' + escape(oValue) + '&';
							hasSubmit = true;
						}
						break;
					default:
						this._sFormData += escape(oName) + '=' + escape(oValue) + '&';
						break;
				}
			}
		}

		this._isFormSubmit = true;
		this._sFormData = this._sFormData.substr(0, this._sFormData.length - 1);

		return this._sFormData;
	},
	
	
setForm:function(formId, isUpload, secureUri){
		
		this._isFormSubmit = false;
		
		var FormData="";
		var oForm;

		if(typeof formId == 'string'){

			oForm = (document.getElementById(formId) || document.forms[formId]);
		}
		else if(typeof formId == 'object'){
		
			oForm = formId;
		}
		else{
		
			return;
		}



		var oElement, oName, oValue, oDisabled;
		var hasSubmit = false;

		for (var i=0; i<oForm.elements.length; i++){
			oElement = oForm.elements[i];
			oDisabled = oForm.elements[i].disabled;
			oName = oForm.elements[i].name;
			oValue = oForm.elements[i].value;

			if(!oDisabled && oName)
			{
				switch (oElement.type)
				{
					case 'select-one':
					case 'select-multiple':
						for(var j=0; j<oElement.options.length; j++){
							if(oElement.options[j].selected){
								if(window.ActiveXObject){
								
									FormData += escape(oName) + '=' + escape(oElement.options[j].attributes['value'].specified?oElement.options[j].value:oElement.options[j].text) + '&';
									
								}
								else{
									
									FormData += escape(oName) + '=' + escape(oElement.options[j].hasAttribute('value')?oElement.options[j].value:oElement.options[j].text) + '&';
								}

							}
						}
						break;
					case 'radio':
					case 'checkbox':
						if(oElement.checked){
					
							FormData += escape(oName) + '=' + escape(oValue) + '&';
						}
						break;
						
					case 'file':
						// stub case as XMLHttpRequest will only send the file path as a string.
					case undefined:
						// stub case for fieldset element which returns undefined.
					case 'reset':
						// stub case for input type reset button.
					case 'button':
						// stub case for input type button elements.
						break;
					case 'submit':
						if(hasSubmit == false){
											
							FormData += escape(oName) + '=' + escape(oValue) + '&';
							hasSubmit = true;
						}
						break;
					default:
						FormData+= escape(oName) + '=' + escape(oValue) + '&';
						break;
				}
			}
		}

		this._isFormSubmit = true;
		FormData = FormData.substr(0, FormData.length - 1);

		return FormData;
	},	
	
	
	

// --- 获取后台的_xml.asp页面-----
 GetCodebehind:function(){
 
	//默认的后台代码为原文件加上_xml.asp
	var posturl=window.location.pathname
	posturl=posturl.substr(0,posturl.indexOf("."))
	posturl=posturl+"_xml.asp"
	this.Codebehind=posturl
	return posturl

  }	


//

};




 /**<doc type="静态类" name="  ECIDI.Class.ExecResult  ">
	<desc> 返回数据的统一处理类</desc>
</doc>**/

ECIDI.Class.ExecResult=function (rtndata,url,action,data,method)
{	
  rtndata = unescape(rtndata);
	this.ExecUrl=url;
	this.ExecAction=action;
	this.ExecData = data;
	this.ExecMethod=method;
	this.ReturnDs=null;
	this.RetrunParam=null;
	this.Result=0;
	this.ErrorMsg=null;
	this.ErrorParam=null;
	this.ErrorSrc=null;
	this.HasError=true;

	if(rtndata.indexOf("<DataStore") != 0)
	{	this.Result = DbResult.SystemError;
		this.ErrorSrc = rtndata;
	}else
	{	try{
			this.ReturnDs=new DataStore(unescape(rtndata));
			this.ReturnParam = this.ReturnDs.Params("ExecReturn");
			if(this.ReturnParam==null)
				throw new Error(0,"Can't find param node in return datastore!");
			this.Result = this.ReturnParam.GetAttr("Result");
			if(this.Result>0)
			{	this.ErrorMsg = this.ReturnParam.GetAttr("ErrorMsg");
				this.ErrorParam = this.ReturnParam.GetAttr("ErrorParam");
			}
		}catch(e)
		{	this.Result=1;
			this.ReturnDs=null;
			this.ErrorSrc = rtndata;
		}
	}
	if(this.Result==0)
		this.HasError=false;
};



ECIDI.Class.ExecResult.prototype.ShowDebug=function()
{	

	try{
		var win = window.open("about:blank","_Error","width=600,height=540,left=0,top=0,resizable=yes,compact");
		if(this.ReturnDs!=null)
			var rtnxml=BeautyXml(this.ReturnDs.ToString());
		else
			var rtnxml = this.ErrorSrc;
			var errmsg=	"<html><body><table height=100% width=100%>"+
							"<tr style='height:20;font-color:red;font-size:20;'><td>查看调用信息</td></tr>"+
							"<tr style='height:16;font-size:14;'><td>调用地址："+this.ExecUrl+"</td></tr>"+
							"<tr style='height:16;font-size:14;'><td>调用操作："+this.ExecAction+"</td></tr>"+
							"<tr style='height:16;font-size:14;'><td>调用方法："+this.ExecMethod+"</td></tr>"+
							"<tr style='height:16;font-size:14;'><td>提交表单：</td></tr>"+
							"<tr style='font-size:14;'><td><textarea style='width:100%;height:100%;'>"+this.ExecData+"</textarea></td></tr>"+
							"<tr style='height:16;font-size:14;'><td>错误类型："+DbResult[this.Result]+"</td></tr>"+
							"<tr style='height:16;font-size:14;'><td>错误信息："+this.ErrorMsg+"</td></tr>"+
							"<tr style='height:16;font-size:14;'><td>返回数据：</td></tr>"+
							"<tr style='height:200;font-size:14;'><td><textarea style='width:100%;height:100%;'>"+rtnxml+"</textarea></td></tr>"+
							"</table></body></html>"

		win.document.write(errmsg);
	}catch(e){}
	
};





 /**<doc type="动态控件类" name="  ECIDI.Class.AutoSuggest  ">
	<desc> 自动完成类</desc>
</doc>**/

ECIDI.Class.AutoSuggest = function (fldID, param){

	// 如果不支持DOM对象，退出
	//
	if (!document.getElementById)
		return false;
	

	
	// get field via DOM
	//
	this.fld = ECIDI.Util.DOM.getElement(fldID);

	if (!this.fld)
		return false;
	
	
	
	
	// init variables
	//
	this.sInput 		= "";
	this.nInputChars 	= 0;
	this.aSuggestions 	= [];
	this.iHighlighted 	= 0;
	
	
	
	
	// parameters object
	//
	this.oP = (param) ? param : {};
	
	// defaults	
	//
	if (!this.oP.minchars)									this.oP.minchars = 1;
	if (!this.oP.method)									this.oP.meth = "get";
	if (!this.oP.varname)									this.oP.varname = "input";
	if (!this.oP.className)									this.oP.className = "autosuggest";
	if (!this.oP.timeout)									this.oP.timeout = 2500;
	if (!this.oP.delay)										this.oP.delay = 500;
	if (!this.oP.offsety)									this.oP.offsety = -5;
	if (!this.oP.shownoresults)								this.oP.shownoresults = true;
	if (!this.oP.noresults)									this.oP.noresults = "No results!";
	if (!this.oP.maxheight && this.oP.maxheight !== 0)		this.oP.maxheight = 250;
	if (!this.oP.cache && this.oP.cache != false)			this.oP.cache = true;
	
	
	
	
	
	// set keyup handler for field
	// and prevent autocomplete from client
	//
	var pointer = this;
	
	// NOTE: not using addEventListener because UpArrow fired twice in Safari
	//ECIDI.Util.DOM.addEvent( this.fld, 'keyup', function(ev){ return pointer.onKeyPress(ev); } );
	
	this.fld.onkeypress 	= function(ev){ return pointer.onKeyPress(ev); }
	this.fld.onkeyup 		= function(ev){ return pointer.onKeyUp(ev); }
	
	this.fld.setAttribute("autocomplete","off");
}



ECIDI.Class.AutoSuggest.prototype.onKeyPress = function(ev)
{
	
	var key = (window.event) ? window.event.keyCode : ev.keyCode;



	// set responses to keydown events in the field
	// this allows the user to use the arrow keys to scroll through the results
	// ESCAPE clears the list
	// TAB sets the current highlighted value
	//
	var RETURN = 13;
	var TAB = 9;
	var ESC = 27;
	
	var bubble = true;

	switch(key)
	{

		case RETURN:
			this.setHighlightedValue();
			bubble = false;
			break;


		case ESC:
			this.clearSuggestions();
			break;
	}

	return bubble;
}



ECIDI.Class.AutoSuggest.prototype.onKeyUp = function(ev)
{
	var key = (window.event) ? window.event.keyCode : ev.keyCode;
	


	// set responses to keydown events in the field
	// this allows the user to use the arrow keys to scroll through the results
	// ESCAPE clears the list
	// TAB sets the current highlighted value
	//

	var ARRUP = 38;
	var ARRDN = 40;
	
	var bubble = true;

	switch(key)
	{


		case ARRUP:
			this.changeHighlight(key);
			bubble = false;
			break;


		case ARRDN:
			this.changeHighlight(key);
			bubble = false;
			break;
		
		
		default:
			this.getSuggestions(this.fld.value);
	}

	return bubble;
	

}



ECIDI.Class.AutoSuggest.prototype.getSuggestions = function (val)
{
	
	// if input stays the same, do nothing
	//
	if (val == this.sInput)
		return false;

	
	// input length is less than the min required to trigger a request
	// reset input string
	// do nothing
	//
	if (val.length < this.oP.minchars)
	{
		this.sInput = "";
		return false;
	}
	
	
	// if caching enabled, and user is typing (ie. length of input is increasing)
	// filter results out of aSuggestions from last request
	//
	if (val.length>this.nInputChars && this.aSuggestions.length && this.oP.cache)
	{
		var arr = [];
		for (var i=0;i<this.aSuggestions.length;i++)
		{
			if (this.aSuggestions[i].value.substr(0,val.length).toLowerCase() == val.toLowerCase())
				arr.push( this.aSuggestions[i] );
		}
		
		this.sInput = val;
		this.nInputChars = val.length;
		this.aSuggestions = arr;
		
		this.createList(this.aSuggestions);
		
		
		
		return false;
	}
	else
	// do new request
	//
	{
		this.sInput = val;
		this.nInputChars = val.length;


		var pointer = this;
		clearTimeout(this.ajID);
		this.ajID = setTimeout( function() { pointer.doAjaxRequest() }, this.oP.delay );
	}

	return false;
}





ECIDI.Class.AutoSuggest.prototype.doAjaxRequest = function ()
{
	
	var pointer = this;
	
	// create ajax request
	var url = this.oP.script+this.oP.varname+"="+escape(this.fld.value);
	var meth = this.oP.meth;
	
	var onSuccessFunc = function (req) { pointer.setSuggestions(req) };
	var onErrorFunc = function (status) { alert("AJAX error: "+status); };

	var myAjax = new ECIDI.Class.Ajax();
	myAjax.makeRequest( url, meth, onSuccessFunc, onErrorFunc );
}



ECIDI.Class.AutoSuggest.prototype.setSuggestions = function (req)
{
	this.aSuggestions = [];
	
	if (this.oP.json)
	{
		var jsondata = eval('(' + req.responseText + ')');
		
		for (var i=0;i<jsondata.results.length;i++)
		{
			this.aSuggestions.push(  { 'id':jsondata.results[i].id, 'value':jsondata.results[i].value, 'info':jsondata.results[i].info }  );
		}
	}
	else
	{

		var xml = req.responseXML;
	
		// traverse xml
		//
		var results = xml.getElementsByTagName('results')[0].childNodes;

		for (var i=0;i<results.length;i++)
		{
			if (results[i].hasChildNodes())
				this.aSuggestions.push(  { 'id':results[i].getAttribute('id'), 'value':results[i].childNodes[0].nodeValue, 'info':results[i].getAttribute('info') }  );
		}
	
	}
	
	this.idAs = "as_"+this.fld.id;
	

	this.createList(this.aSuggestions);

}




ECIDI.Class.AutoSuggest.prototype.createList = function(arr)
{
	var pointer = this;
	
	
	// get rid of old list
	// and clear the list removal timeout
	//
	ECIDI.Util.DOM.removeElement(this.idAs);
	this.killTimeout();
	
	
	// create holding div
	//
	var div = ECIDI.Util.DOM.createElement("div", {id:this.idAs, className:this.oP.className});	
	
	var hcorner = ECIDI.Util.DOM.createElement("div", {className:"as_corner"});
	var hbar = ECIDI.Util.DOM.createElement("div", {className:"as_bar"});
	var header = ECIDI.Util.DOM.createElement("div", {className:"as_header"});
	header.appendChild(hcorner);
	header.appendChild(hbar);
	div.appendChild(header);
	

	// create and populate ul
	//
	var ul = ECIDI.Util.DOM.createElement("ul", {id:"as_ul"});
	
	
	// loop throught arr of suggestions
	// creating an LI element for each suggestion
	//
	for (var i=0;i<arr.length;i++)
	{
		// format output with the input enclosed in a EM element
		// (as HTML, not DOM)
		//
		var val = arr[i].value;
		var st = val.toLowerCase().indexOf( this.sInput.toLowerCase() );
		var output = val.substring(0,st) + "<em>" + val.substring(st, st+this.sInput.length) + "</em>" + val.substring(st+this.sInput.length);
		
		
		var span 		= ECIDI.Util.DOM.createElement("span", {}, output, true);
		if (arr[i].info != "")
		{
			var br			= ECIDI.Util.DOM.createElement("br", {});
			span.appendChild(br);
			var small		= ECIDI.Util.DOM.createElement("small", {}, arr[i].info);
			span.appendChild(small);
		}
		
		var a 			= ECIDI.Util.DOM.createElement("a", { href:"#" });
		
		var tl 		= ECIDI.Util.DOM.createElement("span", {className:"tl"}, " ");
		var tr 		= ECIDI.Util.DOM.createElement("span", {className:"tr"}, " ");
		a.appendChild(tl);
		a.appendChild(tr);
		
		a.appendChild(span);
		
		a.name = i+1;
		a.onclick = function () { pointer.setHighlightedValue(); return false; }
		a.onmouseover = function () { pointer.setHighlight(this.name); }
		
		var li 			= ECIDI.Util.DOM.createElement(  "li", {}, a  );
		
		ul.appendChild( li );
	}
	
	
	// no results
	//
	if (arr.length == 0)
	{
		var li 			= ECIDI.Util.DOM.createElement(  "li", {className:"as_warning"}, this.oP.noresults  );
		
		ul.appendChild( li );
	}
	
	
	div.appendChild( ul );
	
	
	var fcorner = ECIDI.Util.DOM.createElement("div", {className:"as_corner"});
	var fbar = ECIDI.Util.DOM.createElement("div", {className:"as_bar"});
	var footer = ECIDI.Util.DOM.createElement("div", {className:"as_footer"});
	footer.appendChild(fcorner);
	footer.appendChild(fbar);
	div.appendChild(footer);
	
	
	
	// get position of target textfield
	// position holding div below it
	// set width of holding div to width of field
	//
	var pos = ECIDI.Util.DOM.getPos(this.fld);
	
	div.style.left 		= pos.x + "px";
	div.style.top 		= ( pos.y + this.fld.offsetHeight + this.oP.offsety ) + "px";
	div.style.width 	= this.fld.offsetWidth + "px";
	
	
	
	// set mouseover functions for div
	// when mouse pointer leaves div, set a timeout to remove the list after an interval
	// when mouse enters div, kill the timeout so the list won't be removed
	//
	div.onmouseover 	= function(){ pointer.killTimeout() }
	div.onmouseout 		= function(){ pointer.resetTimeout() }


	// add DIV to document
	//
	document.getElementsByTagName("body")[0].appendChild(div);
		
	// currently no item is highlighted
	//
	this.iHighlighted = 0;
	

	// remove list after an interval
	//
	var pointer = this;
	this.toID = setTimeout(function () { pointer.clearSuggestions() }, this.oP.timeout);
}




ECIDI.Class.AutoSuggest.prototype.changeHighlight = function(key)
{	
	var list = ECIDI.Util.DOM.getElement("as_ul");
	if (!list)
		return false;
	
	var n;

	if (key == 40)
		n = this.iHighlighted + 1;
	else if (key == 38)
		n = this.iHighlighted - 1;
	
	
	if (n > list.childNodes.length)
		n = list.childNodes.length;
	if (n < 1)
		n = 1;
	
	
	this.setHighlight(n);
}



ECIDI.Class.AutoSuggest.prototype.setHighlight = function(n)
{
	var list = ECIDI.Util.DOM.getElement("as_ul");
	if (!list)
		return false;
	
	if (this.iHighlighted > 0)
		this.clearHighlight();
	
	this.iHighlighted = Number(n);
	
	list.childNodes[this.iHighlighted-1].className = "as_highlight";


	this.killTimeout();
}


ECIDI.Class.AutoSuggest.prototype.clearHighlight = function()
{
	var list = ECIDI.Util.DOM.getElement("as_ul");
	if (!list)
		return false;
	
	if (this.iHighlighted > 0)
	{
		list.childNodes[this.iHighlighted-1].className = "";
		this.iHighlighted = 0;
	}
}


ECIDI.Class.AutoSuggest.prototype.setHighlightedValue = function ()
{
	if (this.iHighlighted)
	{
		this.sInput = this.fld.value = this.aSuggestions[ this.iHighlighted-1 ].value;
		
		// move cursor to end of input (safari)
		//
		this.fld.focus();
		if (this.fld.selectionStart)
			this.fld.setSelectionRange(this.sInput.length, this.sInput.length);
		

		this.clearSuggestions();
		
		// pass selected object to callback function, if exists
		//
		if (typeof(this.oP.callback) == "function")
			this.oP.callback( this.aSuggestions[this.iHighlighted-1] );
	}
}



ECIDI.Class.AutoSuggest.prototype.killTimeout = function()
{
	clearTimeout(this.toID);
}

ECIDI.Class.AutoSuggest.prototype.resetTimeout = function()
{
	clearTimeout(this.toID);
	var pointer = this;
	this.toID = setTimeout(function () { pointer.clearSuggestions() }, 1000);
}


ECIDI.Class.AutoSuggest.prototype.clearSuggestions = function ()
{
	
	this.killTimeout();
	
	var ele = ECIDI.Util.DOM.getElement(this.idAs);
	var pointer = this;
	if (ele)
	{
		var fade = new ECIDI.Class.Fader(ele,1,0,250,function () { ECIDI.Util.DOM.removeElement(pointer.idAs) });
	}
}




 /**<doc type="动态辅助类" name="  ECIDI.Class.Ajax  ">
	<desc>  AJAX 原型 PROTOTYPE</desc>
</doc>**/


ECIDI.Class.Ajax = function ()
{
	this.req = {};
	this.isIE = false;
}



ECIDI.Class.Ajax.prototype.makeRequest = function (url, meth, onComp, onErr)
{
	
	if (meth != "POST")
		meth = "GET";
	
	this.onComplete = onComp;
	this.onError = onErr;
	
	var pointer = this;
/*	
	//正对其他浏览器
	if (window.XMLHttpRequest){  
	
		this.req = new XMLHttpRequest();
		this.req.onreadystatechange = function () { pointer.processReqChange() };
		this.req.open("GET", url, true); 
		this.req.send(null);
	
	}
	//针对微软浏览器
	else if (window.ActiveXObject){  
	
		this.req = new ActiveXObject("Microsoft.XMLHTTP");
		if (this.req){
		
			this.req.onreadystatechange = function () { pointer.processReqChange() };
			this.req.open(meth, url, true);
			this.req.send();
			
		}
	}
*/
//add by chenmin 20070410

	var o = ECIDI.Util.GetXml.getConnectionObject()
	this.req=o.conn
	this.req.onreadystatechange = function () { pointer.processReqChange() };
	this.req.open(meth, url, true);
	this.req.send();
//==========	
	
}






ECIDI.Class.Ajax.prototype.processReqChange = function()
{
	
	// 数据返回
	if (this.req.readyState == 4) {
	     
	    //正确数据返回 
		if (this.req.status == 200){  
		
			this.onComplete( this.req );
			
		}  
		//错误数据返回 
		else {  
		
			this.onError( this.req.status );
			
		}
	}
	
	
}




 /**<doc type="动态辅助类" name="  ECIDI.Class.Ajax  ">
	<desc> DOM 对象原型PROTOTYPE</desc>
</doc>**/


ECIDI.Util.DOM = function ()
{

}


ECIDI.Util.DOM.createElement = function ( type, attr, cont, html )
{
	var ne = document.createElement( type );
	if (!ne)
		return false;
		
	for (var a in attr)
		ne[a] = attr[a];
		
	if (typeof(cont) == "string" && !html)
		ne.appendChild( document.createTextNode(cont) );
	else if (typeof(cont) == "string" && html)
		ne.innerHTML = cont;
	else if (typeof(cont) == "object")
		ne.appendChild( cont );

	return ne;
}



ECIDI.Util.DOM.clearElement = function ( id )
{
	var ele = this.getElement( id );
	
	if (!ele)
		return false;
	
	while (ele.childNodes.length)
		ele.removeChild( ele.childNodes[0] );
	
	return true;
}



ECIDI.Util.DOM.removeElement = function ( ele )
{
	var e = this.getElement(ele);
	
	if (!e)
		return false;
	else if (e.parentNode.removeChild(e))
		return true;
	else
		return false;
}


ECIDI.Util.DOM.replaceContent = function ( id, cont, html )
{
	var ele = this.getElement( id );
	
	if (!ele)
		return false;
	
	this.clearElement( ele );
	
	if (typeof(cont) == "string" && !html)
		ele.appendChild( document.createTextNode(cont) );
	else if (typeof(cont) == "string" && html)
		ele.innerHTML = cont;
	else if (typeof(cont) == "object")
		ele.appendChild( cont );
}


ECIDI.Util.DOM.getElement = function ( ele )
{
	if (typeof(ele) == "undefined")
	{
		return false;
	}
	else if (typeof(ele) == "string")
	{
		var re = document.getElementById( ele );
		if (!re)
			return false;
		else if (typeof(re.appendChild) != "undefined" ) {
			return re;
		} else {
			return false;
		}
	}
	else if (typeof(ele.appendChild) != "undefined")
		return ele;
	else
		return false;
}


ECIDI.Util.DOM.appendChildren = function ( id, arr )
{
	var ele = this.getElement( id );
	
	if (!ele)
		return false;
	
	
	if (typeof(arr) != "object")
		return false;
		
	for (var i=0;i<arr.length;i++)
	{
		var cont = arr[i];
		if (typeof(cont) == "string")
			ele.appendChild( document.createTextNode(cont) );
		else if (typeof(cont) == "object")
			ele.appendChild( cont );
	}
}



ECIDI.Util.DOM.getPos = function ( ele )
{
	var ele = this.getElement(ele);

	var obj = ele;

	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;


	var obj = ele;
	
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;

	return {x:curleft, y:curtop}
}





// FADER 控制原型 PROTOTYPE _____________________________________________


ECIDI.Class.Fader = function (ele, from, to, fadetime, callback)
{	
	if (!ele)
		return false;
	
	this.ele = ele;
	
	this.from = from;
	this.to = to;
	
	this.callback = callback;
	
	this.nDur = fadetime;
		
	this.nInt = 50;
	this.nTime = 0;
	
	var p = this;
	this.nID = setInterval(function() { p._fade() }, this.nInt);
}




ECIDI.Class.Fader.prototype._fade = function()
{
	this.nTime += this.nInt;
	
	var ieop = Math.round( this._tween(this.nTime, this.from, this.to, this.nDur) * 100 );
	var op = ieop / 100;
	
	if (this.ele.filters) // internet explorer
	{
		try
		{
			this.ele.filters.item("DXImageTransform.Microsoft.Alpha").opacity = ieop;
		} catch (e) { 
			// If it is not set initially, the browser will throw an error.  This will set it if it is not set yet.
			this.ele.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+ieop+')';
		}
	}
	else // other browsers
	{
		this.ele.style.opacity = op;
	}
	
	
	if (this.nTime == this.nDur)
	{
		clearInterval( this.nID );
		if (this.callback != undefined)
			this.callback();
	}
}



ECIDI.Class.Fader.prototype._tween = function(t,b,c,d)
{
	return b + ( (c-b) * (t/d) );
}


function GridView1_MOUSEOVER( mRow )
{
    GridView1_curColor=mRow.style.backgroundColor;
    mRow.style.backgroundColor='#E2DED6';
    mRow.style.cursor='hand';
    mRow.style.fontWeight='';
}

function GridView1_MOUSEOUT( mRow )
{
    if( mRow!=GridView1_sRow)
    {
        mRow.style.backgroundColor=GridView1_curColor;
        mRow.style.fontWeight='';
    } 
    else 
    {
        mRow.style.backgroundColor='#E2DED6';
    }
} 



function EcidiInit()
{

	//每个页面都要执行滚动条代码
	if (ECIDI.Util.Loading.IsLoad)
	{
	 ECIDI.Util.Loading.Open()//进度条开
	 ECIDI.Util.Loading.Close();//进度条关
	}
	
	ECIDI.Util.GetXml.Codebehind=ECIDI.Util.GetXml.GetCodebehind()
	//ECIDI.Util.Const.AppServer="http://publish.ecidi.com/doc/common/";  //publish2-server
	//ECIDI.Util.Const.AppServer="http://doc.ecidi.com/ecidi/common/";    //doc-server
	//ECIDI.Util.Const.AppServer="http://doc.simulate.com/ecidi/common/";  //dns1-server  
    // ECIDI.Util.Const.AppServer="http://oa.simulate.com/doc/common/";  //sim-server
    // ECIDI.Util.Const.AppServer="http://oa.ecidi.com/common/";  //oa-server
    ECIDI.Util.Const.AppServer="http://www.ecidi.com/common/";  //外网正式环境
   
    ECIDI.Util.Const.MachineName="www.ecidi.com";//
}

EcidiInit();







