/**<doc type="varible" name="Global.InputElements">
	<desc>所有表单元素串，用于快速过滤</desc>
</doc>**/
var InputElements="jctext,jctextarea,jcselect,jccheckbox,jcradiogrp,jcupdown,jcdropdown,jcpopup,jcenum,jcgrid,jcfile,jcpopupex";

/**<doc type="function" name="Global.CancelEvent">
	<desc>将事件的返回值置为false,从而终止事件的继续执行</desc>
</doc>**/
function CancelEvent()
{	event.returnValue=false;
	return false;
}

/**<doc type="function" name="Global.GetJcElements">
	<desc>得到某元素中的全部Jc元素数组</desc>
	<input>
		<param name="ele" type="object">包含Jc元素的元素</param>
	</input>
	<output type="Array">Jc元素数组</output>
</doc>**/
function GetJcElements(ele)
{	var jcs=new Array();
	var eles=ele.getElementsByTagName("span");
	for(var i=0;i<eles.length;i++)
	{
		if(eles[i].getAttribute("jctype"))
		{
			jcs[jcs.length]=eles[i];
		}	
	}	
	var eles=ele.getElementsByTagName("input");
	for(var i=0;i<eles.length;i++)
		if(eles[i].getAttribute("jctype"))jcs[jcs.length]=eles[i];
	var eles=ele.getElementsByTagName("select");
	for(var i=0;i<eles.length;i++)
		if(eles[i].getAttribute("jctype"))jcs[jcs.length]=eles[i];
	var eles=ele.getElementsByTagName("textarea");
	for(var i=0;i<eles.length;i++)
		if(eles[i].getAttribute("jctype"))jcs[jcs.length]=eles[i];
	var eles=ele.getElementsByTagName("form");
	for(var i=0;i<eles.length;i++)
		if(eles[i].getAttribute("jctype"))jcs[jcs.length]=eles[i];
	var eles=ele.getElementsByTagName("button");
	for(var i=0;i<eles.length;i++)
		if(eles[i].getAttribute("jctype"))jcs[jcs.length]=eles[i];
	return jcs;
}

/**<doc type="function" name="Global.GetParentJcElement">
	<desc>得到某元素的父Jc元素</desc>
	<input>
		<param name="eventele" type="object">待查找的元素</param>
	</input>
	<output type="object">父Jc元素</output>
</doc>**/
function GetParentJcElement(eventele)
{	var type,pnode,node;
	pnode = eventele;
	do{	node = pnode;
		if(node==document.body)return null;
		type = node.getAttribute("jctype");
		pnode = node.parentNode;
	}while(type == null && pnode != null);
	if (pnode == null)return null;
	return node;
}

/**<doc type="function" name="Global.GetTableTr">
	<desc>得到某元素的父Tr元素</desc>
	<input>
		<param name="eventele" type="object">待查找的元素</param>
	</input>
	<output type="object">父Tr元素</output>
</doc>**/
function GetTableTr(eventele)
{	var type,ptype,pnode,node;
	pnode = eventele;
	do{	node = pnode;
		type = node.tagName.toLowerCase();
		pnode = node.parentNode;
		ptype = pnode.tagName.toLowerCase();
	}while(type != "tr" && ptype != "table" && type != "table");
	if (ptype == "table" || type=="table")return null;
	return node;
}

/**<doc type="function" name="Global.GetJcChildElement">
	<desc>得到某元素的父Jc元素的指定类型子元素</desc>
	<input>
		<param name="eventele" type="object">待查找的元素</param>
		<param name="objtype" type="string">子元素的类型</param>
	</input>
	<output type="object">指定类型的子元素</output>
</doc>**/
function GetJcChildElement(eventele,objtype)
{	var type,jtype,pnode,node;
	pnode = eventele;
	do{	node = pnode;
		type = node.getAttribute("Type");
		pnode = node.parentNode;
		jtype = pnode.getAttribute("JcType");
	}while(type != objtype && jtype == null);
	if (jtype != null && type==null)return null;
	return node;
}

//
//--------------------------------JcInput对象定义开始---------------------------------------------------
//

/**<doc type="objdefine" name="JcInput">
	<desc>数值型Jc元素的基类JcInput定义</desc>
	<property>
		<prop name="Type" type="string">元素类型</param>
		<prop name="DefValue" type="string">元素默认值</param>
		<prop name="HtmlEle" type="object">该元素对应的HTML</param>
		<prop name="Readonly" type="boolean">是否只读，却省为false</param>
		<prop name="Disabled" type="boolean">是否禁用，却省为false</param>
		<prop name="AllowEmpty" type="boolean">是否允许为空，却省为true</param>
		<prop name="Render" type="enum">client(由客户端绘制)/server(由服务器端绘制)</param>
		<prop name="Css" type="string">该元素采用的样式</param>
	</property>
</doc>**/
function JcInput()
{	this.Type="";
	this.DefValue=null;
	this.HtmlEle=null;
	this.Readonly=false;
	this.Disabled=false;
	this.Css="";
	this.AllowEmpty=true;
	this.PreBgColor="";
	this.IsSubmit=true;
	this.Render="client";
}

/**<doc type="protofunc" name="JcInput.SuperInit">
	<desc>JcInput的默认构建器,主要用在继承初始化上</desc>
</doc>**/
JcInput.prototype.SuperInit=function()
{	var ele=this.HtmlEle;
	if(ele.getAttribute("NotSubmit")!=null)
		this.IsSubmit=false;
	if(ele.getAttribute("HideBorder")!=null)
		this.HideBorder();
	if(ele.getAttribute("RenderAtServer")!=null)
		this.Render="server";
	if(ele.getAttribute("DefValue")!=null)
		this.DefValue=ele.getAttribute("DefValue");
	if(ele.className!="")	
		this.Css=ele.className;	
	else
	{	if(this.Type.toLowerCase()!="jcselect")//下框设置样式后win2003ie无法下拉
			ele.className=this.Type;
		this.Css=this.Type;	
	}	
	if(ele.getAttribute("NotAllowEmpty")!=null)
	{
		this.HtmlEle.style.backgroundColor=MustInputBgColor;
		this.AllowEmpty=false;
	}
	if(this.HtmlEle.currentStyle)
		this.PreBgColor=this.HtmlEle.currentStyle.backgroundColor;
	//this.HtmlEle.onfocus=JcInput.OnFocus;
	if(ele.disabled)this.SetDisabled(true);
	var rd=ele.getAttribute("readonly")+"";
	//if(rd == "true" || rd == "" )this.SetReadonly(true);
	if(ele.getAttribute("Value")!=null)
		this.SetValue(ele.getAttribute("Value"));
}

JcInput.OnFocus=function()
{
	var ele=GetParentJcElement(event.srcElement);
	ele.style.backgroundColor=ele.Co.PreBgColor;	
}

/**<doc type="protofunc" name="JcInput.GetValue">
	<desc>取得JcInput的值</desc>
	<output type="string">JcInput的值</output>
</doc>**/
JcInput.prototype.GetValue=function(){return "";}

/**<doc type="protofunc" name="JcInput.SetValue">
	<desc>设置JcInput的值</desc>
	<input>
		<param name="value" type="string">待设置的值</param>
	</input>
</doc>**/
JcInput.prototype.SetValue=function(value){}

/**<doc type="protofunc" name="JcInput.Clear">
	<desc>设置JcInput为空</desc>
</doc>**/
JcInput.prototype.Clear=function()
{	this.SetValue(null);
}

/**<doc type="protofunc" name="JcInput.Reset">
	<desc>设置JcInput为初始值</desc>
</doc>**/
JcInput.prototype.Reset=function()
{	var dv=this.HtmlEle.getAttribute("DefValue");
	if(dv)this.SetValue(dv);
}

/**<doc type="protofunc" name="JcInput.Validate">
	<desc>验证JcInput的有效性</desc>
</doc>**/
JcInput.prototype.Validate=function()
{	
	var value=this.GetValue()
	var validateResult=new ValidateResult();

	var valstr=this.HtmlEle.getAttribute("ValString");
	if(valstr)
		validateResult.ValidateFormElement(value,valstr);		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
		return validateResult;	
	}		
	if(!this.AllowEmpty)
		validateResult.ValidateNotAllowEmpty(value); 

		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
	}
	return validateResult;	

	//ValString="DataType:String;Title:客户名称;Max:12;Min:5;RegExp:00000;"
}

/**<doc type="protofunc" name="JcInput.SetReadonly">
	<desc>设置JcInput是否只读</desc>
	<input>
		<param name="st" type="boolean">是否只读</param>
	</input>
</doc>**/
JcInput.prototype.SetReadonly=function(st)
{
	this.Readonly=st;
	this.HtmlEle.readOnly=st;
	if(!this.Disabled && this.Readonly)
		this.HtmlEle.style.backgroundColor=ReadonlyBgColor;
	else
		this.HtmlEle.style.backgroundColor=NormalBgColor;
}

/**<doc type="protofunc" name="JcInput.SetDisabled">
	<desc>设置JcInput是否禁止</desc>
	<input>
		<param name="st" type="boolean">是否禁止</param>
	</input>
</doc>**/
JcInput.prototype.SetDisabled=function(st)
{	this.Disabled=st;
	this.HtmlEle.disabled=st;
	if(this.Disabled){
		this.HtmlEle.style.backgroundColor=DisabledBgColor;
	}
	else{
		if(this.HtmlEle.getAttribute("NotAllowEmpty")!=null)
		{
			this.HtmlEle.style.backgroundColor = MustInputBgColor;
			
		}
		else{
			this.HtmlEle.style.backgroundColor=NormalBgColor;
		}
	  }
	//else if(this.Readonly)
	//	this.HtmlEle.style.backgroundColor=ReadonlyBgColor;
	//else
	//	this.HtmlEle.style.backgroundColor=NormalBgColor;
}

/**<doc type="protofunc" name="JcInput.HideBorder">
	<desc>设置JcInput隐藏边界</desc>
</doc>**/
JcInput.prototype.HideBorder=function(){}

/**<doc type="protofunc" name="JcInput.SubCss">
	<desc>设置JcInput的子样式</desc>
</doc>**/
JcInput.prototype.SubCss=function(name)
{
	return this.Css + "_" + name;
}

//
//--------------------------------JcInput对象定义结束---------------------------------------------------
//

//
//--------------------------------JcText对象定义开始 从JcInput继承---------------------------------------------------
//

/**<doc type="objdefine" name="JcText">
	<desc>JcText定义,由JcInput继承</desc>
	<property>
		<prop name="SubType" type="string">JcText元素的子元素类型</param>
	</property>
</doc>**/
function JcText(ele)
{	
	this.Type="jctext";
	this.SubType="";
	if(ele || typeof(ele)=="undefined"){this.Init(ele);}//为了便于JcTextara继承
}
JcText.prototype=new JcInput();

/**<doc type="protofunc" name="JcText.Init">
	<desc>JcText的构建器</desc>
	<input>
		<param name="ele" type="object">JcText对应的HTML元素</param>
	</input>	
</doc>**/
JcText.prototype.Init=function(ele)
{	if(!ele)ele=document.createElement("<input type='text' class='jctext' jctype='jctext'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;
	this.SetType(ele.type);
	this.SuperInit();
}

/**<doc type="protofunc" name="JcText.SetType">
	<desc>设置JcText的类型</desc>
	<input>
		<param name="type" type="string">JcText的类型(Text/Hidden/Password)</param>
	</input>	
</doc>**/
JcText.prototype.SetType=function(type)
{	
	type=type.toLowerCase();
	if(type=="text"||type=="hidden"||type=="password")
	{	this.HtmlEle.type=type;
		this.SubType=type;
	}else
	{	this.HtmlEle.type="text";
		this.SubType="text";
	}
}

/**<doc type="protofunc" name="JcText.GetValue">
	<desc>取得JcText的值</desc>
	<output type="string">JcText的值</output>
</doc>**/
JcText.prototype.GetValue=function()
{	return this.HtmlEle.value;
}

/**<doc type="protofunc" name="JcText.SetValue">
	<desc>设置JcText的值</desc>
	<input>
		<param name="value" type="string">待设置的值</param>
	</input>
</doc>**/
JcText.prototype.SetValue=function(value)
{	if(value==null)
		this.HtmlEle.value="";
	else
	{
		this.HtmlEle.value=value;
	}	
}

/**<doc type="protofunc" name="JcText.HideBorder">
	<desc>设置JcText隐藏边界</desc>
</doc>**/
JcText.prototype.HideBorder=function()
{	this.HtmlEle.style.borderWidth=0;
}

//
//--------------------------------JcText对象定义结束---------------------------------------------------
//

//
//--------------------------------JcTextArea对象定义开始 从JcText继承---------------------------------------------------
//

/**<doc type="objdefine" name="JcTextArea">
	<desc>JcTextArea定义,由JcText继承</desc>
</doc>**/
function JcTextArea(ele)
{	this.Type="jctextarea";
	this.Init(ele);
}
JcTextArea.prototype = new JcText(null);

/**<doc type="protofunc" name="JcTextArea.Init">
	<desc>JcTextArea的构建器</desc>
	<input>
		<param name="ele" type="object">JcTextArea对应的HTML元素</param>
	</input>	
</doc>**/
JcTextArea.prototype.Init=function(ele)
{	if(!ele)ele=document.createElement("<textarea type='text' class='jctextarea' jctype='jctextarea'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;
	this.SuperInit();
}

/**<doc type="protofunc" name="JcTextArea.HideBorder">
	<desc>设置JcTextArea隐藏边界</desc>
</doc>**/
JcTextArea.prototype.HideBorder=function()
{	this.HtmlEle.style.borderWidth=0;
	this.HtmlEle.style.overflow="hidden";
}

/**<doc type="protofunc" name="JcTextArea.SetType">
	<desc>设置JcTextArea的类型</desc>
	<input>
		<param name="type" type="string">JcTextArea的类型</param>
	</input>	
</doc>**/
JcTextArea.prototype.SetType=function(type){}

JcTextArea.prototype.GetValue=function()
{	return this.HtmlEle.value;
}

JcTextArea.prototype.SetValue=function(value)
{	if(value==null)
		this.HtmlEle.value="";
	else
	{
		this.HtmlEle.value=value;
		//this.HtmlEle.className="";
	}	
}
//
//--------------------------------JcTextArea对象定义结束---------------------------------------------------
//

//
//--------------------------------JcSelect对象定义开始 从JcInput继承---------------------------------------------------
//

/**<doc type="objdefine" name="JcSelect">
	<desc>JcSelect定义,由JcInput继承</desc>
	<property>
		<prop name="OptionList" type="string">JcSelect元素对应的Option列表(通常在DataStore中的DataEnum或DataList中获得),格式为:[DataStore名称].[Enum/List].[Enum名称/List名称]</param>
		<prop name="TextField" type="string">OptionList的DataEnum(或DataList)对应JcSelect的显示字段</param>
		<prop name="ValueField" type="string">OptionList的DataEnum(或DataList)对应JcSelect的值字段</param>
	</property>	
	<demo>
		ele对应的HTML为:
			<select jctype="jcselect" id="Age" optionlist="Rds.Enum.Test"></select>
		或:	
			<select jctype="jcselect" id="Age" optionlist="Rds.List.Test"></select>
		DataList的格式为:
			<List Name="Test">
				<Row TextField="Hello" ValueField="0001" />
				<Row TextField="You" ValueField="0002" />
				<Row TextField="Bye" ValueField="0003" />
			</List>	
	</demo>
</doc>**/
function JcSelect(ele)
{	this.Type="jcselect";
	this.OptionList=null;
	this.TextField=null;
	this.ValueField=null;
	this.Init(ele);
}
JcSelect.prototype=new JcInput();

/**<doc type="protofunc" name="JcSelect.Init">
	<desc>JcSelect的构建器</desc>
	<input>
		<param name="ele" type="object">JcSelect对应的HTML元素</param>
	</input>	
</doc>**/
JcSelect.prototype.Init=function(ele)
{	if(!ele)ele=document.createElement("<select class='jcselect' jctype='jcselect'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;
	this.SuperInit();
	if(ele.getAttribute("OptionList")!=null)
	{	this.OptionList = GetDsNode(ele.getAttribute("OptionList"));
		if(this.OptionList)
		{	var type=this.OptionList.Type.toLowerCase();
			this.Reset(type,this.OptionList);
		}
	}
}

JcSelect.prototype.Reset=function(type,dataSource)
{ 
  ele = this.HtmlEle;
	this.OptionList = dataSource;
	if(this.OptionList)
	{	
		if(type=="list")
		{	this.TextField=ele.getAttribute("TextField");
			if(!this.TextField)this.TextField="Text";
			this.ValueField=ele.getAttribute("ValueField");
			if(!this.ValueField)this.ValueField="Value";
		}else if(type=="enum")
		{	this.TextField="Text";
			this.ValueField="Value";
		}
	}
	if(this.Render=="client"&&this.OptionList)
		this.RenderObject();	
}

/**<doc type="protofunc" name="JcSelect.RenderObject">
	<desc>绘制JcSelect</desc>
</doc>**/
JcSelect.prototype.RenderObject=function()
{	var ele=this.HtmlEle;
	this.ClearOptionList();
	if(this.AllowEmpty)this.AddItem("","");
	if(!this.OptionList)return;
	var count=this.OptionList.GetItemCount();
	for(var i=0;i<count;i++)
	{	var dn=this.OptionList.GetItem(i);
		this.AddItem(dn.GetAttr(this.ValueField),dn.GetAttr(this.TextField));
	}
}

/**<doc type="protofunc" name="JcSelect.ClearOptionList">
	<desc>清空JcSelect的Option</desc>
</doc>**/
JcSelect.prototype.ClearOptionList=function()
{	var ele=this.HtmlEle;
	var count=ele.options.length;
	for(var i=0;i<count;i++)
		ele.options.remove(0);
}

JcSelect.prototype.GetText = function()
{
	var	ele = this.HtmlEle;
	return ele.options[ele.selectedIndex].text;
}

/**<doc type="protofunc" name="JcSelect.GetValue">
	<desc>取得JcSelect的值</desc>
	<output type="string">JcSelect的值</output>
</doc>  支持 多个选择项 add by chenmin 20060428**/
JcSelect.prototype.GetValue=function()
{	var ele=this.HtmlEle;
    if ( ele.type=="select-multiple")
    {  
    
         var strReturn="";
         for ( var i=0;i<ele.options.length;i++)
         {
           if ( ele.options[i].selected==true)
              { 
                if (strReturn=="")
                    strReturn=ele.options[i].value
                else
                   strReturn=strReturn+"\|"+ele.options[i].value;
              }
         }
         
         return strReturn;
    
    }
    else
    {  
		if(ele.selectedIndex < 0)
			return "";
		else
			return ele.options[ele.selectedIndex].value;
	}	
}

/**<doc type="protofunc" name="JcSelect.SetValue">
	<desc>设置JcSelect的值,如果传入的text值为null,则只匹配传入的value和Option列表中value的值;如果传入的text值不为null,则两者均要匹配</desc>
	<input>
		<param name="value" type="string">待设置的与Option列表中相对应的值</param>
		<param name="text" type="string">待设置的与Option列表中相对应的文本</param>
	</input>
	<demo>
		jcSelect.SetValue("value1",null);
		jcSelect.SetValue("value1","text1");
	</demo>
</doc>**/


JcSelect.prototype.SetValue=function(value,text)
{	var ele=this.HtmlEle;
	var count=ele.options.length;
	if(value==null)
		value = "";
	if(typeof(text)!="undefined")
	{	for(var i=0;i<count;i++)
			if(ele.options[i].value == value && ele.options[i].text == text)
			{	ele.selectedIndex=i;
				break;
			}
	}else 
		for(var i=0;i<count;i++)
			if(ele.options[i].value == value)
			{	
				ele.selectedIndex=i;//由于动态添加完Options后，立刻设置selectedIndex不产生效果
				try{ele.options[i].selected=true;}catch(e){}//使用此方法可以解决，但会产生异常
				break;
			}
}


/**<doc type="protofunc" name="JcSelect.AddItem">
	<desc>在JcSelect中加入一个Option</desc>
	<input>
		<param name="value" type="string">待加入的Option值</param>
		<param name="text" type="string">待加入的Option文本</param>
	</input>
</doc>**/
JcSelect.prototype.AddItem=function(value,text)
{	var opt=document.createElement("option");
	opt.value=value;
	opt.innerText=text;
	this.HtmlEle.appendChild(opt);
	return opt;
}

/**<doc type="protofunc" name="JcSelect.RemoveItem">
	<desc>在JcSelect中删除一个Option</desc>
	<input>
		<param name="index" type="object">如果index的类型为number,则删除Option列表的第index项;如果index的类型为string,则删除Option列表中与index值相同的项</param>
	</input>
</doc>**/
JcSelect.prototype.RemoveItem=function(index)
{	var ele=this.HtmlEle;
	var count=ele.options.length;
	if(typeof(index)=="number")
		ele.options.remove(index);
	else if(typeof(index)=="string")
	{	for(var i=0;i<count;i++)
			if(ele.options[i].value == index)
			{	ele.options.remove(i);
				break;
			}
	}	
}

/**<doc type="protofunc" name="JcSelect.SetReadonly">
	<desc>设置JcSelect是否只读</desc>
	<input>
		<param name="st" type="boolean">是否只读</param>
	</input>
</doc>**/
JcSelect.prototype.SetReadonly=function(st)
{	
	this.Readonly=st;
	this.HtmlEle.readOnly=st;
	this._OldIndex=null;
	this._OldHandle=null;
	if(st)
	{	this._OldIndex=this.HtmlEle.selectedIndex;
		this._OldHandle=this.HtmlEle.onchange;
		this.HtmlEle.onchange=function(){this.selectedIndex=this.Co._OldIndex;};
	}else
	{	this.HtmlEle.onchange=this._OldHandle;
	}
	if(!this.Disabled && this.Readonly)
		this.HtmlEle.style.backgroundColor=ReadonlyBgColor;
	else
		this.HtmlEle.style.backgroundColor=NormalBgColor;
}

//
//--------------------------------JcSelect对象定义结束---------------------------------------------------
//

//
//--------------------------------JcCheckBox对象定义开始 从JcInput继承---------------------------------------------------
//

/**<doc type="objdefine" name="JcCheckBox">
	<desc>JcCheckBox定义,由JcInput继承</desc>
</doc>**/
function JcCheckBox(ele)
{	this.Type="jccheckbox";
	this.Init(ele);
}
JcCheckBox.prototype=new JcInput();

/**<doc type="protofunc" name="JcCheckBox.Init">
	<desc>JcCheckBox的构建器</desc>
	<input>
		<param name="ele" type="object">JcCheckBox对应的HTML元素</param>
	</input>	
</doc>**/
JcCheckBox.prototype.Init=function(ele)
{	if(!ele)ele=document.createElement("<input type='checkbox' class='jccheckbox' jctype='jccheckbox'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;
	var chked = this.HtmlEle.checked;
	this.SuperInit();
	this.SetValue(chked);
}

/**<doc type="protofunc" name="JcCheckBox.GetValue">
	<desc>取得JcCheckBox的值</desc>
	<output type="string">JcCheckBox的值,为"true"或"false"</output>
</doc>**/
JcCheckBox.prototype.GetValue=function(isFullValue)
{	if(isFullValue)
		return this.HtmlEle.checked +"";
	else
		return this.HtmlEle.checked?"T":"F";
}

/**<doc type="protofunc" name="JcCheckBox.SetValue">
	<desc>设置JcCheckBox的值</desc>
	<input>
		<param name="value" type="string">待设置的值,为"true"或"false"</param>
	</input>
</doc>**/
JcCheckBox.prototype.SetValue=function(value)
{	if(value==null)
		this.HtmlEle.checked=false;
	else
		this.HtmlEle.checked=ToBool(value);
}

/**<doc type="protofunc" name="JcCheckBox.SetReadonly">
	<desc>设置JcCheckBox是否只读</desc>
	<input>
		<param name="st" type="boolean">是否只读</param>
	</input>
</doc>**/
JcCheckBox.prototype.SetReadonly=function(st)
{	this.Readonly=st;
	this.HtmlEle.readOnly=st;
	this._OldClick=null;
	this._OldKeyDown=null;
	if(st)
	{	this._OldClick=this.HtmlEle.onclick;
		this._OldKeyDown=this.HtmlEle.onkeydown;
		this.HtmlEle.onclick=CancelEvent;
		this.HtmlEle.onkeydown=CancelEvent;
	}else
	{	this.HtmlEle.onkeydown=this._OldKeyDown;
		this.HtmlEle.onclick=this._OldClick;
	}
	if(!this.Disabled && this.Readonly)
		this.HtmlEle.style.backgroundColor=ReadonlyBgColor;
	else
		this.HtmlEle.style.backgroundColor=NormalBgColor;
}

//
//--------------------------------JcCheckBox对象定义结束---------------------------------------------------
//

//
//--------------------------------JcRadioGrp对象定义开始 从JcInput继承-------------------------------------
//

/**<doc type="objdefine" name="JcRadioGrp">
	<desc>JcRadioGrp定义,由JcInput继承</desc>
	<property>
		<prop name="Radios" type="Array">JcRadioGrp对应的Radio组</param>
	</property>		
</doc>**/
function JcRadioGrp(ele)
{	
	this.Type="jcradiogrp";
	this.Radios=new Array();
	this.Init(ele);
}
JcRadioGrp.prototype=new JcInput();

/**<doc type="protofunc" name="JcRadioGrp.Init">
	<desc>JcRadioGrp的构建器</desc>
	<input>
		<param name="ele" type="object">JcRadioGrp对应的HTML元素</param>
	</input>	
</doc>**/
JcRadioGrp.prototype.Init=function(ele)
{	if(!ele)ele=document.createElement("<span class='jcradiogrp' jctype='jcradiogrp'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;
	var eles = document.getElementsByName(ele.id+"_Item");
	for(var i=0;i<eles.length;i++)
	{	var name = eles[i].name;
		if(name && name.toLowerCase()==ele.id.toLowerCase()+"_item")
		{
			this.Radios[this.Radios.length]=eles[i];
		}	
	}
	for(var i=0;i<this.Radios.length;i++)
		this.Radios[i].Co=this;
	this.SuperInit();
	
	for(var i=0;i<this.Radios.length;i++)
	{	
		this.Radios[i].onclick=JcRadioGrp.OnClick;	
		this.Radios[i].style.backgroundColor=this.PreBgColor;
	}
}

JcRadioGrp.OnClick=function()
{
	var obj=document.all((event.srcElement.name.split("_"))[0]).Co;
	for(var i=0;i<obj.Radios.length;i++)
	{	
		obj.Radios[i].style.backgroundColor=obj.PreBgColor;
	}
}

/**<doc type="protofunc" name="JcRadioGrp.GetCheckedRadio">
	<desc>得到JcRadioGrp被选中的Radio</desc>
	<output type="object">返回选中的Radio</output>
</doc>**/
JcRadioGrp.prototype.GetCheckedRadio=function()
{	for(var i=0;i<this.Radios.length;i++)
		if(this.Radios[i].checked)
			return this.Radios[i];
	return null;
}

/**<doc type="protofunc" name="JcRadioGrp.GetValue">
	<desc>取得JcRadioGrp的值</desc>
	<output type="string">JcRadioGrp的值</output>
</doc>**/
JcRadioGrp.prototype.GetValue=function()
{	for(var i=0;i<this.Radios.length;i++)
		if(this.Radios[i].checked)
			return this.Radios[i].value;
	return "";
}

/**<doc type="protofunc" name="JcRadioGrp.SetValue">
	<desc>设置JcRadioGrp的值</desc>
	<input>
		<param name="value" type="string">待设置的值</param>
	</input>
</doc>**/
JcRadioGrp.prototype.SetValue=function(value)
{	if(value==null)
	{	for(var i=0;i<this.Radios.length;i++)
		{	this.Radios[i].checked=false;
		}
	}else
	{	for(var i=0;i<this.Radios.length;i++)
		{	if(this.Radios[i].value==value)
				this.Radios[i].checked=true;
		}
	}
}

/**<doc type="protofunc" name="JcRadioGrp.CancelEvent">
	<desc>取消事件响应</desc>
</doc>**/
JcRadioGrp.CancelEvent=function()
{	event.returnValue=false;
	if(this.Co._OldChecked)
		this.Co._OldChecked.checked=true;
	return false;
}

/**<doc type="protofunc" name="JcRadioGrp.SetReadonly">
	<desc>设置JcRadioGrp是否只读</desc>
	<input>
		<param name="st" type="boolean">是否只读</param>
	</input>
</doc>**/
JcRadioGrp.prototype.SetReadonly=function(st)
{	this._OldClick=new Array();
	this._OldKeyDown=new Array();
	this._OldChecked=this.GetCheckedRadio();
	for(var i=0;i<this.Radios.length;i++)
	{	var rdo=this.Radios[i];
		this.Readonly=st;
		if(st)
		{	this._OldClick[i]=rdo.onclick;
			this._OldKeyDown[i]=rdo.onkeydown;
			rdo.onclick=JcRadioGrp.CancelEvent;
			rdo.onkeydown=JcRadioGrp.CancelEvent;
		}else
		{	rdo.onclick=this._OldClick[i];
			rdo.onkeydown=this._OldKeyDown[i];
		}
		if(!this.Disabled && this.Readonly)
			rdo.style.backgroundColor=ReadonlyBgColor;
		else
			rdo.style.backgroundColor=NormalBgColor;
			
	}
}

/**<doc type="protofunc" name="JcRadioGrp.SetDisabled">
	<desc>设置JcRadioGrp是否禁止</desc>
	<input>
		<param name="st" type="boolean">是否禁止</param>
	</input>
</doc>**/
JcRadioGrp.prototype.SetDisabled=function(st)
{	for(var i=0;i<this.Radios.length;i++)
	{	var rdo=this.Radios[i];
		this.Disabled=st;
		rdo.disabled=st;
		if(this.Disabled)
			rdo.style.backgroundColor=DisabledBgColor;
		else if(this.Readonly)
			rdo.style.backgroundColor=ReadonlyBgColor;
		else
			rdo.style.backgroundColor=NormalBgColor;
	}
}

/**<doc type="protofunc" name="JcRadioGrp.Validate">
	<desc>验证JcRadioGrp的有效性</desc>
</doc>**/
JcRadioGrp.prototype.Validate=function()
{	
	var selectRadio=this.GetCheckedRadio();
	var validateResult=new ValidateResult();
	
	if(!this.AllowEmpty)
		if(selectRadio==null)
		{
			validateResult.Message="必须选择！";
			validateResult.Passed=false;
		}	

	var valstr=this.HtmlEle.getAttribute("ValString");
	if(valstr)
		validateResult.ValidateFormElement("",valstr);
		
	if(!validateResult.Passed)	
	{
		for(var i=0;i<this.Radios.length;i++)
		{	
			this.Radios[i].style.backgroundColor=ErrorBgColor;
		}	
	}
	return validateResult;	
}

//
//--------------------------------JcRadioGrp对象定义结束---------------------------------------------------
//

//
//--------------------------------JcDropDown对象定义开始 从JcInput继承-------------------------------------
//

/**<doc type="objdefine" name="JcDropDown">
	<desc>JcDropDown定义,由JcInput继承</desc>
	<property>
		<prop name="DropType" type="string">JcDropDown的下拉类型:Calendar/List/Tree</param>
		<prop name="DropUrl" type="string">点击JcDropDown时对应的URL</param>
		<prop name="DropParam" type="string">JcDropDown的DropUrl对应的参数</param>
		<prop name="DropSize" type="string">JcDropDown的下拉框大小,以style的形式出现</param>
		<prop name="ReturnMode" type="string">JcDropDown返回的是单值(single)还是多值(multi)</param>
		<prop name="ReturnFields" type="string">JcDropDown返回的字段,以","分隔</param>
		<prop name="DropFrame" type="object">JcDropDown的下拉Frame</param>
	</property>		
</doc>**/
function JcDropDown(ele)
{
	this.Type="jcdropdown";
	this.DropType="";//所弹出的关联实体类型：Calendar,List,Tree
	this.DataType="";//日期类型:Normal,Start,End
	this.RelateDateID="";
	this.DropUrl="";
	this.DropParam="";
	this.DropSize="width:auto;height:auto;";
	this.ReturnMode="single";//single /multi
	this.ReturnFields=""; //id1,id2,id3
	this.DropFrame=null;
	this.Init(ele);
}
JcDropDown.prototype=new JcInput();

/**<doc type="protofunc" name="JcDropDown.Init">
	<desc>JcDropDown的构建器</desc>
	<input>
		<param name="ele" type="object">JcDropDown对应的HTML元素</param>
	</input>	
</doc>**/
JcDropDown.prototype.Init=function(ele)
{	if(!ele)ele=document.createElement("<span class='jcdropdown' jctype='jcdropdown'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;

	
	if(ele.getAttribute("DropParam"))
		this.DropParam = ele.getAttribute("DropParam");


	if(ele.getAttribute("ReturnMode"))
		this.ReturnMode =ele.getAttribute("ReturnMode").toLowerCase();
	if(ele.getAttribute("ReturnFields"))
		this.ReturnFields =ele.getAttribute("ReturnFields");
	
	this.DropType=ele.getAttribute("DropType");
	if(ele.getAttribute("DataType"))
		this.DataType =ele.getAttribute("DataType");
	if(ele.getAttribute("RelateDateID"))
		this.RelateDateID =ele.getAttribute("RelateDateID");		
	if(!this.DropType)this.DropType="List";
	if(this.DropType.toLowerCase()=="list")
	{	this.DropUrl = ECIDI.Util.Const.AppServer+"js/page/jclist.htm";
		this.DropUrl +="?CallElementId="+this.HtmlEle.id+"&CallParam="+this.DropParam;
	}

	this.SuperInit();
	this.RenderObject();
		
	
}

JcDropDown.OnContentChange = function()
{
	var ele=GetParentJcElement(event.srcElement);
	
		//alert(ele.Co.TempValue);
		if(!ele.Co.TempValue)
		{
			if(ele.Co.GetValue())
			{
			ele.Co.TempValue = ele.Co.GetValue();
			try{eval(ele.getAttribute("oncontentchange"))}catch(e){};//this对象指向的是Jc对象			
			}
		}
		else
		{
			if("" + ele.Co.TempValue != "" + ele.Co.GetValue())
			{
				ele.Co.TempValue = ele.Co.GetValue();
				try{eval(ele.getAttribute("oncontentchange"))}catch(e){};//this对象指向的是Jc对象
			}	
		}
	
}

/**<doc type="protofunc" name="JcDropDown.RenderObject">
	<desc>绘制JcDropDown</desc>
</doc>**/
JcDropDown.prototype.RenderObject=function()
{	
	var ele=this.HtmlEle;
	if(this.Render=="client")
	{	var elesrc = "<table cellspacing='0' cellpadding='0' border='0' style='width:100%'><tr>"+
			"<td><input id='_text' type=text class='" + this.SubCss("Text") + "' style='width:100%' readonly onpropertychange='JcDropDown.OnContentChange();'></td>";
		if(this.DropType.toLowerCase()=="calendar"){
			elesrc+="<td style='width:20;'><button id='_btn' class='" + this.SubCss("DateButton") + "' style='width:100%;height:21;'><img src='"+ECIDI.Util.Const.AppServer+"/images/jsctrl/datebtndropdown.gif'></button></td>";
		}
		else{
			if(this.DropType.toLowerCase()=="timer")
				elesrc+="<td style='width:20;'><button id='_btn' class='" + this.SubCss("DateButton") + "' style='width:100%;height:21;'><img src='"+ECIDI.Util.Const.AppServer+"/images/jsctrl/timebtndropdown.gif'></button></td>";
			else
				elesrc+="<td style='width:20;'><button id='_btn' class='" + this.SubCss("Button") + "' style='width:100%;height:21;'><img src='"+ECIDI.Util.Const.AppServer+"/images/jsctrl/btndropdown.gif'></button></td>";
		}
		elesrc+="</tr></table>";
		ele.innerHTML= elesrc;
	}
	ele.style.height=20;
	var drop=null;
	if(this.DropType.toLowerCase()=="list")
	{	
		//把Iframe元素添加到body元素中
		drop = document.createElement("<iframe id='_drop_"+ele.id+"' frameborder='0' scrolling='no' style='border:solid 1;position:absolute;z-index:10000;left:1;top:1;display:none;"+this.DropSize+"' src='"+this.DropUrl+"'></iframe>");
		//drop.className = this.SubCss("Drop");
		document.body.appendChild(drop);
	}	
	else if(this.DropType.toLowerCase()=="calendar")
	{
		drop = window.document.all("gToday:normal:agenda.js");
		if (drop==null)
		{	drop = window.document.createElement("<IFrame id='gToday:normal:agenda.js' frameborder='0' scrolling='no' name='gToday:normal:agenda.js' src='"+ECIDI.Util.Const.AppServer+"/js/date2/ipopeng.htm' style='position:absolute;top:0;left:0;display:none;'></iframe>");
			document.body.appendChild(drop);
		}
	}	
	else if(this.DropType.toLowerCase()=="timer")
	{
		drop = window.document.all("fp:fPickTime");
		if (drop==null)
		{	drop = window.document.createElement("<IFrame id='fp:fPickTime' frameborder='0' scrolling='no' name='fp:fPickTime' src='"+ECIDI.Util.Const.AppServer+"js/time2/ipopeng.htm' style='width:210px;height:27px;position:absolute;top:0;left:0;display:none;'></iframe>");
			document.body.appendChild(drop);
		}
	}	
	this.DropFrame = drop;
	this.DropFrame.Master=this;//把Iframe元素和控制元素建立关联
	
	ele.all("_btn").onclick=JcDropDown.BtnClick;
	drop.onblur=JcDropDown.DropBlur;
	if(!this.AllowEmpty)
		this.HtmlEle.all("_text").style.backgroundColor=MustInputBgColor;
}

JcDropDown.OnFocus=function()
{
	var ele=GetParentJcElement(event.srcElement);
	ele.all("_text").style.backgroundColor=ele.Co.PreBgColor;	
	ele.style.backgroundColor=ele.Co.PreBgColor;	
}

/**<doc type="protofunc" name="JcDropDown.BtnClick">
	<desc>定义JcDropDown的点击事件</desc>
</doc>**/
JcDropDown.BtnClick=function()
{	
	JcDropDown.OnFocus();
	var ele=GetParentJcElement(event.srcElement);
	var obj=ele.Co,drop=obj.DropFrame;
	if(obj.DropType.toLowerCase()=="list")
	{	
		if(drop.style.display== "none")
		{	drop.style.left = Position.Left(ele);
			drop.style.top = Position.Top(ele)+Position.Height(ele);
			drop.style.backgroundColor="blue";
			drop.style.display="block";
			drop.focus();
		}else
			drop.style.display="none";
	}	
	else if(obj.DropType.toLowerCase()=="calendar")
	{
		drop.style.display = "";
		if(obj.DataType.toLowerCase()=="normal")
		{
			gfPop.fPopCalendar(ele.all("_text"));
		}
		else if(obj.DataType.toLowerCase()=="start")
		{
			gfPop.fStartPop(ele.all("_text"),document.all(obj.RelateDateID).all("_text"));
		} 
		else if(obj.DataType.toLowerCase()=="end")
		{
			gfPop.fEndPop(document.all(obj.RelateDateID).all("_text"),ele.all("_text"));
		} 		
	}		
	else if(obj.DropType.toLowerCase()=="timer")
	{			
			//drop.style.display = "";
			if(obj.DataType.toLowerCase()=="normal")
			{
				gfPoptimer.fPopTimer(ele.all("_text"));
			}
			else if(obj.DataType.toLowerCase()=="start")
			{
				//gfPoptimer.fStartPop(ele.all("_text"),document.all(obj.RelateDateID).all("_text"));
				gfPoptimer.fPopTimer(ele.all("_text"));
			} 
			else if(obj.DataType.toLowerCase()=="end")
			{
				//gfPoptimer.fEndPop(document.all(obj.RelateDateID).all("_text"),ele.all("_text"));
				gfPoptimer.fPopTimer(ele.all("_text"));
			} 		
	}			
}

/**<doc type="protofunc" name="JcDropDown.DropBlur">
	<desc>定义JcDropDown的丢失焦点事件</desc>
</doc>**/
JcDropDown.DropBlur=function()
{	
	var obj=this.Master,drop=obj.DropFrame;
	if(drop.id="gToday:normal:agenda.js")
	{
	}
	else
	{
		drop.style.display="none";
	}	
}

/**<doc type="protofunc" name="JcDropDown.SetReturn">
	<desc>设置JcDropDown的返回值</desc>
	<input>
		<param name="rtnstr" type="string">JcDropDown的返回值</param>
	</input>	
</doc>**/
JcDropDown.prototype.SetReturn=function(rtnstr)
{	
		this.returnValue=true;
		this.ReturnString=rtnstr;
	try{	eval(this.HtmlEle.getAttribute("onreturnbefore"));//this对象指向的是Jc对象
	}catch(e){}
	
	if(this.returnValue)
	{	switch(this.ReturnMode)
		{	case "single":
				this.HtmlEle.all("_text").value = this.ReturnString;
				break;
			case "multi":
				var flds = this.ReturnFields.split(",");
				var sp = new StringParam(this.ReturnString);
				for(var i=0;i<flds.length;i++)
				{	if(sp[flds[i]])
						document.all(flds[i]).SetValue(sp[flds[i]]);
				}
				break;
		}
		
	}
	
	try{	eval(this.HtmlEle.getAttribute("onreturnafter"));//this对象指向的是Jc对象
	}catch(e){}
}

/**<doc type="protofunc" name="JcDropDown.GetValue">
	<desc>取得JcDropDown的值</desc>
	<output type="string">JcDropDown的值</output>
</doc>**/
JcDropDown.prototype.GetValue=function()
{
	return "" + this.HtmlEle.all("_text").value;
}

/**<doc type=
"protofunc" name="JcDropDown.SetValue">
	<desc>设置JcDropDown的值</desc>
	<input>
		<param name="value" type="string">待设置的值</param>
	</input>
</doc>**/
JcDropDown.prototype.SetValue=function(value)
{
	if(value == null)
		value = "";
	if(this.DropType.toLowerCase()=="calendar")
	{
		if(value.indexOf(" ") >= 0)
			value = value.substring(0,value.indexOf(" "));	
	}	
	this.HtmlEle.all("_text").value=value;
}

/**<doc type="protofunc" name="JcDropDown.SetDisabled">
	<desc>设置JcDropDown是否禁止</desc>
	<input>
		<param name="st" type="boolean">是否禁止</param>
	</input>
</doc>**/
JcDropDown.prototype.SetDisabled=function(st)
{	this.Disabled=st;
	this.HtmlEle.disabled=st;
	this.HtmlEle.all("_text").disabled=st;
	this.HtmlEle.all("_btn").disabled=st;//李虎添加于2006-9-25
	if(this.Disabled)
	{
		this.HtmlEle.all("_text").style.backgroundColor=DisabledBgColor;
		this.HtmlEle.style.backgroundColor = DisabledBgColor;
	}	
	else if(this.Readonly)
	{
		this.HtmlEle.all("_text").style.backgroundColor=ReadonlyBgColor;
		this.HtmlEle.style.backgroundColor = ReadonlyBgColor;
	}	
	else
	{
		if(this.HtmlEle.getAttribute("NotAllowEmpty")!=null)
		{
			this.HtmlEle.all("_text").style.backgroundColor=MustInputBgColor;
			this.HtmlEle.style.backgroundColor = MustInputBgColor;
			
		}
		else
		{
			this.HtmlEle.all("_text").style.backgroundColor=NormalBgColor;
			this.HtmlEle.style.backgroundColor = NormalBgColor;
		}
	}	
}

/**<doc type="protofunc" name="JcDropDown.SetReadonly">
	<desc>设置JcDropDown是否只读</desc>
	<input>
		<param name="st" type="boolean">是否只读</param>
	</input>
</doc>**/
JcDropDown.prototype.SetReadonly=function(st)
{	this.Readonly=st;
	this.HtmlEle.readOnly=st;
	//this.HtmlEle.all("_text").readOnly=st;
	this.HtmlEle.all("_text").className = st?"":this.SubCss("Text");
	this.HtmlEle.all("_btn").style.display=st?"none":"";
	if(!this.Disabled && this.Readonly)
	{
		this.HtmlEle.all("_text").style.backgroundColor=ReadonlyBgColor;
		this.HtmlEle.style.backgroundColor = ReadonlyBgColor;
	}	
	else
	{
		this.HtmlEle.all("_text").style.backgroundColor=NormalBgColor;
		this.HtmlEle.style.backgroundColor = NormalBgColor;
	}	
}

JcDropDown.prototype.Validate=function()
{	
	var value=this.GetValue()
	var validateResult=new ValidateResult();

	var valstr=this.HtmlEle.getAttribute("ValString");
	if(valstr)
		validateResult.ValidateFormElement(value,valstr);		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.all("_text").style.backgroundColor = ErrorBgColor;
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
		return validateResult;	
	}		
	if(!this.AllowEmpty)
		validateResult.ValidateNotAllowEmpty(value); 

		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.all("_text").style.backgroundColor = ErrorBgColor;
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
	}
	return validateResult;	

	//ValString="DataType:String;Title:客户名称;Max:12;Min:5;RegExp:00000;"
}

//
//--------------------------------JcDropDown对象定义结束---------------------------------------------------
//

//
//--------------------------------JcFile对象定义开始 从JcInput继承----------------------------------------
//

function JcFile(ele)
{
	this.Type = "jcfile";
	this.FileMode = "single";
	this.Init(ele);
}
JcFile.prototype=new JcInput();

JcFile.prototype.Init=function(ele)
{	
	if(!ele)
		ele = document.createElement("<span class='jcfile' jctype='jcfile'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co = this;
	
	if(ele.getAttribute("FileMode"))
		this.FileMode = ele.getAttribute("FileMode").toLowerCase();

	this.SuperInit();
			
	if(this.FileMode == "multi")
	{
		this.FileTemplateString =   "<table width=100%>" + 
										"<tbody>" +
											"<tr>" +
												"<td align=right width=5><input type=checkbox id=_FileId value=?FileId?></td>" +
												"<td width=16><img width=16 height=16 src='http://srfile.ecidi.com/share/image/jsctrl/JsCoolBar/ico/040_S.ico'></img></td>" +
												"<td align=left><nobr class='" + this.SubCss("MultiMode_FileName") + "' id=_FileName><a target=_blank href=CheckFile.aspx?IsExec=true&Key=Goodway_BE-DownLoad&Id=?TrueId?>?FileName?</a></nobr></td>" +
											"</tr>" +										
										"</tbody>" +									
									"</table>"; 	
	}	
    //alert(this.FileTemplateString);
	this.RenderObject();
	this.InitEvent();	
}

JcFile.prototype.InitEvent=function()
{	
	var ele=this.HtmlEle;
	ele.all("_addbtn").onclick=JcFile.AddBtnClick;
	ele.all("_clearbtn").onclick=JcFile.ClearBtnClick;
	//单文件附件没有删除按钮
	if(ele.all("_removebtn"))
		ele.all("_removebtn").onclick=JcFile.RemoveBtnClick;
}

JcFile.prototype.RenderSingleModeObject = function()
{
	var elesrc = "<table cellspacing='0' cellpadding='0' border='0' style='height:20;width:100%'>" +
					"<tr>" +
						"<td>" +
							"<input id='_value' value='' type='hidden'>" +
							"<input id='_text' readonly class='" + this.SubCss("Text") + "' style='width:100%'>" +
						"</td>" +
						"<td style='width:20;padding-right:4;padding-left:4'>" +
							"<button id='_addbtn' class='" + this.SubCss("AddButton") + "'>添加</button>" + 
						"</td>" +
						"<td style='width:20;padding-right:4;'>" +
							"<button id='_clearbtn' class='" + this.SubCss("ClearButton") + "'>清空</button>" + 
						"</td>" +						
					"</tr>" +
				  "</table>";
	this.HtmlEle.innerHTML = elesrc;
	this.ValidateEle = "_text";
}

JcFile.prototype.RenderMultiModeObject = function()
{
	var elesrc = "<table border='0' width='100%' id='table1'>" +
					"<tr>" +
						"<td>" +
							"<span id=_BodyMain class='" + this.SubCss("MultiMode_BodyMain") + "'></span>" +
						"</td>" +
						"<td width='40'>" +
							"<table border='0' width='100%'><tr><td><input type='button' value='添加'  class='" + this.SubCss("AddButton") + "' ID='_addbtn'></td></tr>" +
							"<tr><td><input type='button' value='删除'  class='" + this.SubCss("RemoveButton") + "' ID='_removebtn'></td></tr>" +
							"<tr><td><input type='button' value='清空'  class='" + this.SubCss("ClearButton") + "' ID='_clearbtn'></td></tr></table>" +
						"</td>" +
					"</tr>" +
				  "</table>"
	
	this.HtmlEle.innerHTML = elesrc;	
	this.ValidateEle = "_BodyMain";
}

JcFile.prototype.RenderObject=function()
{
	if(this.FileMode == "single")
		this.RenderSingleModeObject();
	else if(this.FileMode == "multi")
		this.RenderMultiModeObject();
	
	if(!this.AllowEmpty)
		this.HtmlEle.all(this.ValidateEle).style.backgroundColor=MustInputBgColor;					
}

JcFile.OnFocus=function()
{
	var ele=GetParentJcElement(event.srcElement);
	ele.all(ele.Co.ValidateEle).style.backgroundColor=ele.Co.PreBgColor;	
	ele.style.backgroundColor=ele.Co.PreBgColor;	
}

JcFile.ClearBtnClick = function()
{
	JcFile.OnFocus();
	var ele=GetParentJcElement(event.srcElement);
	var obj=ele.Co;
	obj.SetValue("");
}

JcFile.RemoveBtnClick = function()
{
	JcFile.OnFocus();
	var ele=GetParentJcElement(event.srcElement);
	var obj=ele.Co;
	obj.RemoveValue();	
}

JcFile.AddBtnClick = function()
{	
	JcFile.OnFocus();
	var ele=GetParentJcElement(event.srcElement);
	var obj=ele.Co;
	var returnValue = "";
	if(obj.FileMode == "single")
	{
		returnValue = window.showModalDialog("./upload/UploadSingle.aspx",1,"dialogHeight:364px; dialogWidth:495px;edge:Sunken; help:No; resizable:no; status:No;scroll=no;");
		obj.SetValue(returnValue);
	}
	else if(obj.FileMode == "multi")
	{
		returnValue = window.showModalDialog("./upload/UploadMulti.aspx",1,"dialogHeight:468px; dialogWidth:568px;edge:Sunken; help:No; resizable:no; status:No;scroll=no;");	
		obj.AddValue(returnValue);
	}	
	
}

JcFile.prototype.GetText = function()
{
	if(this.FileMode == "single")
		return this.HtmlEle.all("_text").value;
	else if(this.FileMode == "multi")
	{
		var names = "";
		var item = ToArray(document.all("_FileName"));
		for(var i = 0;i < item.length;i++)
		{
			names += item[i].innerHTML + ",";
		}	
		if(names.substring(names.length - 1,names.length) == ",")
			names = names.substring(0,names.length - 1);
		return names;
	}	
}

JcFile.prototype.GetValue = function()
{
	if(this.FileMode == "single")
		return this.HtmlEle.all("_value").value;
	else if(this.FileMode == "multi")
	{
		var ids = "";
		var item = ToArray(this.HtmlEle.all("_FileId"));
		for(var i = 0;i < item.length;i++)
		{
			ids += item[i].value + ",";
		}
		if(ids.substring(ids.length - 1,ids.length) == ",")
			ids = ids.substring(0,ids.length - 1);
		return ids;			
	}
}

JcFile.prototype.Clear = function()
{
	var item = this.HtmlEle.all("_BodyMain").childNodes;
	var itemCount = item.length;
	for(var i = 0;i < itemCount;i++)
		this.HtmlEle.all("_BodyMain").removeChild(item[0]);	
}

JcFile.prototype.AddValue = function(value)
{
	var fileId = value.split(",");
	for(var i = 0;i < fileId.length;i++)
	{
		if(fileId[i].trim() != "")
		{
			var span = document.createElement("<span style='width:100;height:20'>");
			this.HtmlEle.all("_BodyMain").appendChild(span);
			var name = "";
			var trueId = "";
			if(fileId[i].substring(3,4) == "+")
			{
				name = fileId[i].substring(fileId[i].lastIndexOf("+") + 1,fileId[i].length);
				trueId = fileId[i];
			}	
			else
			{
				name = fileId[i].substring(fileId[i].lastIndexOf("_") + 1,fileId[i].length);
				trueId = fileId[i].substring(0,fileId[i].lastIndexOf("_"));
			}
			span.innerHTML = this.FileTemplateString.replace("?FileName?",name).replace("?FileId?",fileId[i]).replace("?TrueId?",escape(trueId));			
		}
	}
}

JcFile.prototype.GetParantSpanElement = function(ele)
{
	while(ele != null & ele.tagName.toLowerCase() !="span")
		ele = ele.parentElement;
	return ele;
}

JcFile.prototype.RemoveValue = function()
{
	var item = ToArray(this.HtmlEle.all("_FileId"));
	var removeItem = new Array();
	for(var i = 0;i < item.length;i++)
	{
		if(item[i].checked == true)
		{
			var ele = this.GetParantSpanElement(item[i]);
			if(ele != null)
				removeItem[removeItem.length] = ele;
		}
	}
	for(var i = 0;i < removeItem.length;i++)
		this.HtmlEle.all("_BodyMain").removeChild(removeItem[i]);
}

JcFile.prototype.Fire=function(type)
{	var onfunc=this.HtmlEle.getAttribute(type);
	if(onfunc)
		eval(onfunc);
}

JcFile.prototype.SetValue = function(value)
{	
	this.Event = new Object();
	this.Event.returnValue=true;
	this.Event.Value=value;
	this.Fire("OnContentChange");
	if(!this.Event.returnValue)
	{	
		return false;
	}
	
	if(this.FileMode == "single")
	{
		this.HtmlEle.all("_value").value = value;
		if(value.trim() == "")
		{
			this.HtmlEle.all("_text").value = "";
		}
		else
		{	
			if(value.substring(3,4) == "+")
				this.HtmlEle.all("_text").value = value.substring(value.lastIndexOf("+") + 1,value.length);
			else
				this.HtmlEle.all("_text").value = value.substring(value.lastIndexOf("_") + 1,value.length);
		}
	}
	else if(this.FileMode == "multi")
	{
		this.Clear();
		this.AddValue(value);
	}
}

JcFile.prototype.SetCheckBoxState = function(state)
{
	var ele = this.HtmlEle.all("_FileId");
	if(ele)
	{
		ele = ToArray(ele);
		var eleCount = ele.length;
		for(var i = 0;i < eleCount;i++)
		{
			if(state)
				ele[i].style.visibility = "";
			else
				ele[i].style.visibility = "hidden";
		}
	}	
}

JcFile.prototype.SetState = function()
{
	this.HtmlEle.disabled = this.Disabled;
	this.HtmlEle.readOnly = this.Readonly;
	if(this.Disabled || this.Readonly)
	{
		this.HtmlEle.all("_addbtn").disabled = true;
		this.HtmlEle.all("_clearbtn").disabled = true;	
		if(this.HtmlEle.all("_removebtn"))
			this.HtmlEle.all("_removebtn").disabled = true;			
	}
	else
	{
		this.HtmlEle.all("_addbtn").disabled = false;
		this.HtmlEle.all("_clearbtn").disabled = false;	
		if(this.HtmlEle.all("_removebtn"))
			this.HtmlEle.all("_removebtn").disabled = false;		
	}
	if(this.Disabled)
	{
		if(this.FileMode == "single")
		{
			this.HtmlEle.all("_text").disabled = true;
			this.HtmlEle.all("_text").readonly = false;
			this.HtmlEle.all("_text").style.backgroundColor=DisabledBgColor;
		}
		else if(this.FileMode == "multi")
		{
			this.SetCheckBoxState(false);
			this.HtmlEle.all("_BodyMain").style.backgroundColor=DisabledBgColor;
		}
		this.HtmlEle.style.backgroundColor = DisabledBgColor;		
	}
	else if(this.Readonly)
	{
		if(this.FileMode == "single")
		{
			
			this.HtmlEle.all("_text").disabled = false;
			this.HtmlEle.all("_text").readonly = true;
			this.HtmlEle.all("_text").style.backgroundColor=ReadonlyBgColor;
		}
		else if(this.FileMode == "multi")
		{
			this.SetCheckBoxState(false);
			this.HtmlEle.all("_BodyMain").style.backgroundColor=ReadonlyBgColor;
		}	
		this.HtmlEle.style.backgroundColor = ReadonlyBgColor;		
	}
	else
	{
		if(this.FileMode == "single")
		{
			this.HtmlEle.all("_text").disabled = false;
			this.HtmlEle.all("_text").readonly = false;		
			this.HtmlEle.all("_text").style.backgroundColor=NormalBgColor;
		}
		else if(this.FileMode == "multi")
		{
			this.SetCheckBoxState(true);
			this.HtmlEle.all("_BodyMain").style.backgroundColor=NormalBgColor;
		}		
		this.HtmlEle.style.backgroundColor = NormalBgColor;		
	}
	
}

JcFile.prototype.SetDisabled=function(st)
{	
	this.Disabled=st;
	this.SetState();
}


JcFile.prototype.SetReadonly=function(st)
{	
	this.Readonly=st;
	this.SetState();
}

JcFile.prototype.Validate=function()
{	
	var value=this.GetValue()
	var validateResult=new ValidateResult();

	var valstr=this.HtmlEle.getAttribute("ValString");
	if(valstr)
		validateResult.ValidateFormElement(value,valstr);		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.all(this.ValidateEle).style.backgroundColor = ErrorBgColor;
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
		return validateResult;	
	}		
	if(!this.AllowEmpty)
		validateResult.ValidateNotAllowEmpty(value); 

		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.all(this.ValidateEle).style.backgroundColor = ErrorBgColor;
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
	}
	return validateResult;	

	//ValString="DataType:String;Title:客户名称;Max:12;Min:5;RegExp:00000;"
}

//
//--------------------------------JcFile对象定义结束---------------------------------------------------
//



//
//--------------------------------JcPopUp对象定义开始 从JcInput继承----------------------------------------
//

/**<doc type="objdefine" name="JcPopUp">
	<desc>JcPopUp定义,由JcInput继承</desc>
	<property>
		<prop name="PopType" type="string">JcPopUp的弹出类型:Calendar/List/Tree/Url</param>
		<prop name="PopUrl" type="string">JcPopUp所弹出的关联URL</param>
		<prop name="PopParam" type="string">JcPopUp所弹出的关联参数</param>
		<prop name="PopStyle" type="string">JcPopUp的弹出样式,默认值为compact</param>
		<prop name="PopMode" type="string">JcPopUp的弹出模式,默认值为window(dialog/window)</param>
		<prop name="PopSize" type="string">JcPopUp的弹出尺寸大小</param>
		<prop name="ReturnMode" type="string">JcPopUp返回的是单值(single)还是多值(multi),默认值为single</param>
		<prop name="ReturnFields" type="string">JcPopUp返回的字段,以","分隔</param>
	</property>		
</doc>**/
function JcPopUp(ele)
{
	this.Type="jcpopup";
	this.PopType="";//所弹出的关联实体类型：Calendar,List,Tree,Url
	this.PopUrl="";//所弹出的关联URL
	this.PopParam="";//所弹出的关联参数
	this.System="System";
	this.OnPopBefore="";
	this.OnPopAfter="";
	this.PopStyle="compact"; //
	this.PopMode="window"; //dialog/window
	this.PopSize="";
	this.ReturnMode="single";
	this.ReturnParam="";
	this.Init(ele);
}
JcPopUp.prototype=new JcInput();

/**<doc type="protofunc" name="JcPopUp.Init">
	<desc>JcPopUp的构建器</desc>
	<input>
		<param name="ele" type="object">JcPopUp对应的HTML元素</param>
	</input>	
</doc>**/
JcPopUp.prototype.Init=function(ele)
{	if(!ele)ele=document.createElement("<span class='jcpopup' jctype='jcpopup'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;
	
	if(ele.getAttribute("PopMode"))
		this.PopMode = ele.getAttribute("PopMode").toLowerCase();
	if(ele.getAttribute("PopStyle"))
		this.PopStyle = ele.getAttribute("PopStyle");
	else
	{ 
		if(this.PopMode=="window")
			this.PopStyle="compact";
		else(this.PopMode=="dialog")
			this.PopStyle="dialogHeight:400px;dialogWidth:400px;edge:Sunken;center:Yes;help:No;resizable:No;status:No;";	
	}
	if(ele.getAttribute("PopParam"))
		this.PopParam = ele.getAttribute("PopParam");
	if(ele.getAttribute("System"))
		this.System = ele.getAttribute("System");
		
	if(ele.getAttribute("ReturnMode"))
		this.ReturnMode =ele.getAttribute("ReturnMode").toLowerCase();
	if(ele.getAttribute("ReturnParam"))
		this.ReturnParam =ele.getAttribute("ReturnParam");

	if(ele.getAttribute("PopType"))
		this.PopType=ele.getAttribute("PopType");
	if(!this.PopType)this.PopType="List";

	if(ele.getAttribute("PopUrl"))
		this.PopUrl=ele.getAttribute("PopUrl");
	if(ele.getAttribute("OnPopBefore"))
		this.OnPopBefore=ele.getAttribute("OnPopBefore");
	if(ele.getAttribute("OnPopAfter"))
		this.OnPopAfter=ele.getAttribute("OnPopAfter");
		
	var lowerCasePopType=this.PopType.toLowerCase();
	switch(lowerCasePopType)
	{
		case "list":
			this.PopUrl = "http://srfile.ecidi.com/share/page/jclist.htm";
			this.PopUrl +="?CallElement="+this.HtmlEle.id+"&PopParam="+this.PopParam;//Page.List.Default
		break;
		case "url":
			if(this.PopUrl)
			{
				var prefix="";

				if(this.PopUrl.indexOf("?")>=0 )
					prefix="&";
				else
					prefix="?";
				if(this.OnPopAfter)	//如果设置了回调方法
					this.PopUrl +=prefix+"CallElementId="+this.HtmlEle.id+"&OnPopAfter="+this.OnPopAfter;//Page.List.Default
				else
				{
				
					this.PopUrl +=prefix+"CallElementId="+this.HtmlEle.id;//Page.List.Default
				}	
			}	
			else
			{
				alert("弹出框URL未设置!");
				return false;
			}		
		break;
	}
	this.SuperInit();
	this.RenderObject();
	this.InitEvent();	
	
}

/**<doc type="protofunc" name="JcPopUp.InitEvent">
	<desc>设置JcPopUp的绑定事件</desc>
</doc>**/
JcPopUp.prototype.InitEvent=function()
{	var ele=this.HtmlEle;
	ele.all("_btn").onclick=JcPopUp.BtnClick;
	if(!this.AllowEmpty)
		this.HtmlEle.all("_text").style.backgroundColor=MustInputBgColor;
}
JcPopUp.OnFocus=function()
{
	var ele=GetParentJcElement(event.srcElement);
	ele.all("_text").style.backgroundColor=ele.Co.PreBgColor;	
	ele.style.backgroundColor=ele.Co.PreBgColor;	
}

/**<doc type="protofunc" name="JcPopUp.RenderObject">
	<desc>绘制JcPopUp</desc>
</doc>**/
JcPopUp.prototype.RenderObject=function()
{	
	if(this.Render=="client")
	{	var elesrc = "<table cellspacing='0' cellpadding='0' border='0' style='height:20;width:100%'><tr>"+
			"<td><input id='_text' readonly class='" + this.SubCss("Text") + "' style='width:100%'></td>"+
			"<td style='width:20;'>";
		var popType=this.PopType.toLowerCase();	
		//if(popType=="ftpfile"||popType=="ftpmultifile"||popType=="ftpfolderfile")	
		//	elesrc+="<button id='_btn' class='" + this.SubCss("UploadButton") + "' style='width:100%;height:21;'><img src='http://srfile.ecidi.com/share/image/jsctrl/uploadbtnpopup.gif'></button>";
		//else
			elesrc+="<button id='_btn' class='" + this.SubCss("Button") + "' style='width:100%;height:21;'><img src='"+ECIDI.Util.Const.AppServer+"/images/jsctrl/btnpopup.gif'></button>";
		elesrc+="</td></tr></table>";
		//alert(elesrc);
		this.HtmlEle.innerHTML= elesrc;
		this.HtmlEle.style.height=20;
	}
	
}


/**<doc type="protofunc" name="JcPopUp.BtnClick">
	<desc>定义JcPopUp的点击事件</desc>
</doc>**/
JcPopUp.BtnClick=function()
{	
	JcPopUp.OnFocus();
	var ele=GetParentJcElement(event.srcElement);
	var obj=ele.Co;

	var popParam="";

	if(obj.PopParam)
	{
		var sp=new StringParam(obj.PopParam);
		for(var i=0;i<sp.GetCount();i++)
		{
			popParam+=sp.Keys[i]+":";
			if(document.all(sp.Get(i)).Co)
			{
				popParam+=document.all(sp.Get(i)).Co.GetValue()+";";
			}	
			else
				popParam+=document.all(sp.Get(i)).value+";";	
		}
	}
	else if(obj.OnPopBefore)
	{
		popParam=eval(obj.OnPopBefore)();
	}	
	var popUrl=obj.PopUrl;

	var params = obj.PopUrl.split( "[" )
	var autoUrl = "";
	for ( var i = 1; i < params.length; i++ )
	{
		if ( document.all( params[i].split("]")[0] ).Co )
			autoUrl = obj.PopUrl.replace( "["+params[i].split("]")[0]+"]", document.all( params[i].split("]")[0] ).Co.GetValue() );
		else
			autoUrl = obj.PopUrl.replace( "["+params[i].split("]")[0]+"]", document.all( params[i].split("]")[0] ).value );
	}
	
	if ( autoUrl != "" )
	     popUrl = autoUrl;

	if(obj.PopUrl.indexOf("?")>0)
		popUrl+="&PopParam=" + popParam;
	else
		popUrl+="?PopParam=" + popParam;	

	switch(obj.PopType.toLowerCase())
	{
		case "list":
			if(obj.PopMode.toLowerCase()=="window")
				window.open(popUrl,ele.id+"_win",CenterWin(obj.PopStyle));
			else
			{	window.showModalDialog(popUrl,window,CenterWin(obj.PopStyle,true));
			}
		break;
		default:
			if(obj.PopMode.toLowerCase()=="window")
			{
				window.open(popUrl,ele.id+"_win",CenterWin(obj.PopStyle));
			}	
			else
			{	
				window.showModalDialog(popUrl,window,CenterWin(obj.PopStyle,true));
			}
		break;		
	}		
}

/**<doc type="protofunc" name="JcPopUp.GetValue">
	<desc>取得JcPopUp的值</desc>
	<output type="string">JcPopUp的值</output>
</doc>**/
JcPopUp.prototype.GetValue=function()
{
	return this.HtmlEle.all("_text").value;
}

/**<doc type="protofunc" name="JcPopUp.SetValue">
	<desc>设置JcPopUp的值</desc>
	<input>
		<param name="value" type="string">待设置的值</param>
	</input>
</doc>**/
JcPopUp.prototype.SetValue=function(value)
{
	if(value == null) value = "";
	this.HtmlEle.all("_text").value=value;
}

/**<doc type="protofunc" name="JcPopUp.SetReturn">
	<desc>设置JcPopUp的返回值</desc>
	<input>
		<param name="rtnstr" type="string">JcPopUp的返回值</param>
	</input>	
</doc>**/
JcPopUp.prototype.SetReturn=function(rtnstr)
{	
	this.returnValue=true;
	this.ReturnString=rtnstr;
	try
	{
		eval(this.HtmlEle.getAttribute("onreturnbefore"));//this对象指向的是Jc对象
	}
	catch(e)
	{}
	
	if(this.returnValue)
	{	switch(this.ReturnMode.toLowerCase())
		{	
			case "single":
				switch(this.PopType.toLowerCase())
				{
					case "list":
						this.HtmlEle.all("_text").value = this.ReturnString;
					break;
				}		
			break;
			case "multi":
				var flds = this.ReturnParam.split(",");
				var sp = new StringParam(this.ReturnString);
				for(var i=0;i<flds.length;i++)
				{	if(sp[flds[i]])
						document.all(flds[i]).SetValue(sp[flds[i]]);
				}
			break;
			case "datalist":
				var sp=new StringParam(this.ReturnParam);
				var dataList=new DataList(rtnstr);
				var dataItems=dataList.GetItems();
				var fieldValues=new Array();
				for(var j=0;j<sp.GetCount();j++)
				{
					fieldValues[j]="";
				}			
				for(var i=0;i<dataItems.length;i++)
				{
					for(var j=0;j<sp.GetCount();j++)
					{
						fieldValues[j]+=dataItems[i].GetAttr(sp.Get(j))+","
					}
				}
				for(var j=0;j<sp.GetCount();j++)
				{
					if(fieldValues[j].substring(fieldValues[j].length-1,fieldValues[j].length)==",")
						fieldValues[j]=fieldValues[j].substring(0,fieldValues[j].length-1);
					var obj=document.all(sp.Keys[j]);
					if(obj.Co)
						obj.Co.SetValue(fieldValues[j]);
					else
						obj.value=fieldValues[j];
				}				
			break;
		}
		
	}
	
	try{	
		eval(this.HtmlEle.getAttribute("onreturnafter"));//this对象指向的是Jc对象
	}
	catch(e)
	{}
}

/**<doc type="protofunc" name="JcPopUp.SetDisabled">
	<desc>设置JcPopUp是否禁止</desc>
	<input>
		<param name="st" type="boolean">是否禁止</param>
	</input>
</doc>**/
JcPopUp.prototype.SetDisabled=function(st)
{	this.Disabled=st;
	this.HtmlEle.disabled=st;
	this.HtmlEle.all("_text").disabled=st;
	this.HtmlEle.all("_btn").disabled=st;
	if(this.Disabled)
	{
		this.HtmlEle.all("_text").style.backgroundColor=DisabledBgColor;
		this.HtmlEle.style.backgroundColor = DisabledBgColor;
	}	
	else if(this.Readonly)
	{
		this.HtmlEle.all("_text").style.backgroundColor=ReadonlyBgColor;
		this.HtmlEle.style.backgroundColor = ReadonlyBgColor;
	}	
	else
	{
		this.HtmlEle.all("_text").style.backgroundColor=NormalBgColor;
		this.HtmlEle.style.backgroundColor = NormalBgColor;
	}	
}

/**<doc type="protofunc" name="JcPopUp.SetReadonly">
	<desc>设置JcPopUp是否只读</desc>
	<input>
		<param name="st" type="boolean">是否只读</param>
	</input>
</doc>**/
JcPopUp.prototype.SetReadonly=function(st)
{	this.Readonly=st;
	this.HtmlEle.readOnly=st;
	this.HtmlEle.all("_text").readOnly=st;
	this.HtmlEle.all("_btn").disabled=st;
	if(!this.Disabled && this.Readonly)
	{
		this.HtmlEle.all("_text").style.backgroundColor=ReadonlyBgColor;
		this.HtmlEle.style.backgroundColor = ReadonlyBgColor;
	}	
	else
	{
		this.HtmlEle.all("_text").style.backgroundColor=NormalBgColor;
		this.HtmlEle.style.backgroundColor = NormalBgColor;
	}	
}

JcPopUp.prototype.Validate=function()
{	
	var value=this.GetValue()
	var validateResult=new ValidateResult();

	var valstr=this.HtmlEle.getAttribute("ValString");
	if(valstr)
		validateResult.ValidateFormElement(value,valstr);		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.all("_text").style.backgroundColor = ErrorBgColor;
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
		return validateResult;	
	}		
	if(!this.AllowEmpty)
		validateResult.ValidateNotAllowEmpty(value); 

		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.all("_text").style.backgroundColor = ErrorBgColor;
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
	}
	return validateResult;	

	//ValString="DataType:String;Title:客户名称;Max:12;Min:5;RegExp:00000;"
}

//
//--------------------------------JcPopUp对象定义结束---------------------------------------------------
//

//
//--------------------------------JcUpDown对象定义开始 从JcInput继承------------------------------------
//

/**<doc type="objdefine" name="JcUpDown">
	<desc>JcUpDown定义,由JcInput继承</desc>
	<property>
		<prop name="AllowEdit" type="boolean">是否允许编辑</param>
		<prop name="Increase" type="number">每次按箭头值的增减量</param>
	</property>		
</doc>**/
function JcUpDown(ele)
{
	this.Type="jcupdown";
    this.AllowEdit=true;//所弹出的关联实体类型：Calendar,List,Tree
    this.Increase=1;//所弹出的关联实体ID
    this.Render="client";
	this.Init(ele);
}
JcUpDown.prototype=new JcInput();

/**<doc type="protofunc" name="JcUpDown.Init">
	<desc>JcUpDown的构建器</desc>
	<input>
		<param name="ele" type="object">JcUpDown对应的HTML元素</param>
	</input>	
</doc>**/
JcUpDown.prototype.Init=function(ele)
{	if(!ele)ele=document.createElement("<span class='jcupdown' jctype='jcupdown'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;
	this.Css=ele.className;
	if(ele.getAttribute("Increase"))
     {
         var inc=ele.getAttribute("Increase");
         if(parseFloat(inc)+""!="NaN")
              this.Increase=parseFloat(inc);
     }
     if(ele.getAttribute("NotAllowEdit"))
         this.AllowEdit=false;
         
	this.SuperInit();
	this.RenderObject();
}

/**<doc type="protofunc" name="JcUpDown.RenderObject">
	<desc>绘制JcUpDown</desc>
</doc>**/
JcUpDown.prototype.RenderObject=function()
{	if(this.Render=="client")
	{	 var elesrc = "<table cellspacing='0' cellpadding='0' border='0' style='width:100%;height:20'><tr>" +
              "<td rowspan='2'><input id='_text' class='" + this.SubCss("text") + "' style='width:100%;'></td>" +
              "<td style='width:20;'><button id='_btnup' class='" + this.SubCss("button") + 
              "' style='width:100%;'><img src='"+ECIDI.Util.Const.AppServer+"/images/jsctrl/btnudup.gif'></button></td></tr>"+
              "<tr><td><button id='_btndown' class='" + 
              this.SubCss("button") + "' style='width:100%;'><img src='"+ECIDI.Util.Const.AppServer+"/images/jsctrl/btnuddown.gif'></button></td></tr></table>";
         this.HtmlEle.innerHTML= elesrc;
	}
	if(!this.AllowEmpty)
		this.HtmlEle.all("_text").style.backgroundColor=MustInputBgColor;
	this.HtmlEle.all("_text").onfocus = JcUpDown.OnFocus;	
	var ele=this.HtmlEle;
	 ele.all("_btnup").onclick=JcUpDown.BtnUpClick;
     ele.all("_btndown").onclick=JcUpDown.BtnDownClick;
}
JcUpDown.OnFocus=function()
{
	var ele=GetParentJcElement(event.srcElement);
	ele.all("_text").style.backgroundColor=ele.Co.PreBgColor;	
	ele.style.backgroundColor=ele.Co.PreBgColor;	
}

/**<doc type="protofunc" name="JcUpDown.BtnUpClick">
	<desc>定义JcUpDown的点击向上箭头事件</desc>
</doc>**/
JcUpDown.BtnUpClick=function()
{	
	JcUpDown.OnFocus();
	var ele=GetParentJcElement(event.srcElement);
	var obj=ele.Co;
	var val=ele.all("_text").value;
	if(parseFloat(val)+""=="NaN")val=0;
	ele.all("_text").value = parseFloat(val)+obj.Increase;
}

/**<doc type="protofunc" name="JcUpDown.BtnDownClick">
	<desc>定义JcUpDown的点击向下箭头事件</desc>
</doc>**/
JcUpDown.BtnDownClick=function()
{	
	JcUpDown.OnFocus();
	var ele=GetParentJcElement(event.srcElement);
	var obj=ele.Co;
	var val=ele.all("_text").value;
	if(parseFloat(val)+""=="NaN")val=0;
	ele.all("_text").value = parseFloat(val)-obj.Increase;
}

/**<doc type="protofunc" name="JcUpDown.GetValue">
	<desc>取得JcUpDown的值</desc>
	<output type="string">JcUpDown的值</output>
</doc>**/
JcUpDown.prototype.GetValue=function()
{
	return this.HtmlEle.all("_text").value;
}

/**<doc type="protofunc" name="JcUpDown.SetValue">
	<desc>设置JcUpDown的值</desc>
	<input>
		<param name="value" type="string">待设置的值</param>
	</input>
</doc>**/
JcUpDown.prototype.SetValue=function(value)
{
	this.HtmlEle.all("_text").value=value;
}

/**<doc type="protofunc" name="JcUpDown.SetDisabled">
	<desc>设置JcUpDown是否禁止</desc>
	<input>
		<param name="st" type="boolean">是否禁止</param>
	</input>
</doc>**/
JcUpDown.prototype.SetDisabled=function(st)
{	this.Disabled=st;
	this.HtmlEle.disabled=st;
	this.HtmlEle.all("_text").disabled=st;
	if(this.Disabled)
	{
		this.HtmlEle.all("_text").style.backgroundColor=DisabledBgColor;
		this.HtmlEle.style.backgroundColor=DisabledBgColor;
	}	
	else if(this.Readonly)
	{
		this.HtmlEle.all("_text").style.backgroundColor=ReadonlyBgColor;
		this.HtmlEle.style.backgroundColor=ReadonlyBgColor;
	}	
	else
	{
		this.HtmlEle.all("_text").style.backgroundColor=NormalBgColor;
		this.HtmlEle.style.backgroundColor=NormalBgColor;
	}	
}

/**<doc type="protofunc" name="JcUpDown.SetReadonly">
	<desc>设置JcUpDown是否只读</desc>
	<input>
		<param name="st" type="boolean">是否只读</param>
	</input>
</doc>**/
JcUpDown.prototype.SetReadonly=function(st)
{	this.Readonly=st;
	this.HtmlEle.readOnly=st;
	this.HtmlEle.all("_text").readOnly=st;
	this.HtmlEle.all("_btn").disabled=st;
	if(!this.Disabled && this.Readonly)
	{
		this.HtmlEle.all("_text").style.backgroundColor=ReadonlyBgColor;
		this.HtmlEle.style.backgroundColor=ReadonlyBgColor;
	}	
	else
	{
		this.HtmlEle.all("_text").style.backgroundColor=NormalBgColor;
		this.HtmlEle.style.backgroundColor=NormalBgColor;
	}	
}

JcUpDown.prototype.Validate=function()
{	
	var value=this.GetValue()
	var validateResult=new ValidateResult();

	var valstr=this.HtmlEle.getAttribute("ValString");
	if(valstr)
		validateResult.ValidateFormElement(value,valstr);		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.all("_text").style.backgroundColor = ErrorBgColor;
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
		return validateResult;	
	}		
	if(!this.AllowEmpty)
		validateResult.ValidateNotAllowEmpty(value); 

		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.all("_text").style.backgroundColor = ErrorBgColor;
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
	}
	return validateResult;	

	//ValString="DataType:String;Title:客户名称;Max:12;Min:5;RegExp:00000;"
}

//
//--------------------------------JcUpDown对象定义结束---------------------------------------------------
//

//
//--------------------------------JcForm对象定义开始-----------------------------------------------------
//

/**<doc type="objdefine" name="JcForm">
	<desc>JcForm定义</desc>
	<property>
		<prop name="HtmlEle" type="object">JcForm对应的HTML元素</param>
		<prop name="Elements" type="Array">JcForm下的Jc元素数组</param>
	</property>	
</doc>**/
function JcForm(ele)
{	
	this.HtmlEle = null;
	this.PreValue="";
	this.IsDirty="";
	this.OnDirty=null;
	this.Elements=new Array();
	this.Init(ele);
}

/**<doc type="protofunc" name="JcForm.Init">
	<desc>JcForm的构建器</desc>
	<input>
		<param name="ele" type="object">JcForm对应的HTML元素</param>
	</input>	
</doc>**/
JcForm.prototype.Init=function(ele)
{	if(!ele)ele=document.createElement("<form jctype='jcform' >");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;
	var eles=GetJcElements(this.HtmlEle);
	for(var i=0;i<eles.length;i++)
	{	var type=eles[i].getAttribute("jctype");
		if(type && InputElements.indexOf(type.toLowerCase())>=0)
		{
			this.Elements[this.Elements.length]=eles[i];
		}	
	}
	this.OnDirty=this.HtmlEle.getAttribute("OnDirty");
	if(this.HtmlEle.disabled)this.SetDisabled(true);
	if(this.HtmlEle.readOnly)this.SetReadonly(true);
}

/**<doc type="protofunc" name="JcForm.Clear">
	<desc>设置JcForm为空</desc>
</doc>**/
JcForm.prototype.Clear=function()
{	for(var i=0;i<this.Elements.length;i++)
	{	var obj=this.Elements[i].Co;
		if(InputElements.indexOf(obj.Type.toLowerCase())>=0)
		{	obj.Clear();
		}
	}
}

/**<doc type="protofunc" name="JcForm.Reset">
	<desc>设置JcForm为初始值</desc>
</doc>**/
JcForm.prototype.Reset=function()
{	for(var i=0;i<this.Elements.length;i++)
	{	var obj=this.Elements[i].Co;
		if(InputElements.indexOf(obj.Type.toLowerCase())>=0)
		{	obj.Reset();
		}
	}
}

/**<doc type="protofunc" name="JcForm.Validate">
	<desc>验证JcForm的有效性</desc>
</doc>**/
JcForm.prototype.Validate=function()
{	
	var jcObject=this.Elements;
	if(jcObject.length<=0)
		return true;
		
	var jcElement=new Array();
	for(var i=0;i<jcObject.length;i++)
	{
		jcElement[jcElement.length]=jcObject[i].Co;
	}	
	
	var msg="";	
	var j=1;
	for(var i=0;i<jcElement.length;i++)
	{
		var validateResult=jcElement[i].Validate();
		if(validateResult!=null&&!validateResult.Passed)
		{
			msg+=(j++)+")  "+validateResult.GetErrMsg()+"\n";
		}	
	}	
	
	//alert(msg);
	//return;
	
	if (msg.length>0)
	{	
	/*
		window.showModalDialog("http://srfile.ecidi.com/share/page/ValidteError.htm",msg,
			"dialogHeight:360px;dialogWidth:500px;edge:Sunken;center:Yes;help:No;resizable:Yes;status:No;scroll:no");
	*/		
			
	window.showModalDialog(ECIDI.Util.Const.AppServer+"asp/ValidteError.htm",msg,
			"dialogHeight:360px;dialogWidth:500px;edge:Sunken;center:Yes;help:No;resizable:Yes;status:No;scroll:no");
		
	

				
		return false;
	}else
	{	return true;
	}
}
JcForm._CheckForm=null;
JcForm.prototype.StartCheckDirty=function()
{
	this.PreValue=this.GetElementsValues();
	JcForm._CheckForm=this;
	window.setTimeout(JcForm.CheckDirty,200);
}

JcForm.prototype.Fire=function(eventname)
{
	this.IsDirty=true;
	if(this.OnDirty)
		eval(this.OnDirty);
}
JcForm.CheckDirty=function()
{
	var obj=JcForm._CheckForm;
	if(!obj)
		return;
	if(obj.PreValue!=obj.GetElementsValues())
	{
		obj.Fire("OnDirty");
		JcForm._CheckForm=null;
	}
	else
		window.setTimeout(JcForm.CheckDirty,200);		

}

JcForm.prototype.GetElementsValues=function()
{
	var value="";
	for(var i=0;i<this.Elements.length;i++)
	{	
		var obj=this.Elements[i].Co;
		if(InputElements.indexOf(obj.Type.toLowerCase())>=0)
		{	
			value+=obj.GetValue()+",";
		}
	}
	return value;
}

/**<doc type="protofunc" name="JcForm.SetReadonly">
	<desc>设置JcForm是否只读</desc>
	<input>
		<param name="st" type="boolean">是否只读</param>
	</input>
</doc>**/
JcForm.prototype.SetReadonly=function(st)
{	for(var i=0;i<this.Elements.length;i++)
	{	var obj=this.Elements[i].Co;
		if(InputElements.indexOf(obj.Type.toLowerCase())>=0)
		{	obj.SetReadonly(st);
		}
	}
}

/**<doc type="protofunc" name="JcForm.SetDisabled">
	<desc>设置JcForm是否禁止</desc>
	<input>
		<param name="st" type="boolean">是否禁止</param>
	</input>
</doc>**/
JcForm.prototype.SetDisabled=function(st)
{	for(var i=0;i<this.Elements.length;i++)
	{	var obj=this.Elements[i].Co;
		//alert(obj.Type.toLowerCase());
		
		if(InputElements.indexOf(obj.Type.toLowerCase())>=0)
		{	obj.SetDisabled(st);
		}
	}
}

/**<doc type="protofunc" name="JcForm.GetDataForm">
	<desc>从JcForm中获取DataForm</desc>
	<input>
		<param name="df" type="DataForm">从该DataForm中获取要从JcForm中获取哪些字段;如果该DataForm为null,则获取JcForm中所有的字段(忽略标记用NotSubmit的字段)</param>
	</input>
</doc>**/
JcForm.prototype.GetDataForm=function(df)
{
	if(typeof(df)=="object" && df != null)
	{
		for(var i=0;i<this.Elements.length;i++)
		{	
			var obj=this.Elements[i].Co;
			if(InputElements.indexOf(obj.Type.toLowerCase())>=0)
			{	
				if(df.GetValue(obj.HtmlEle.id)!=null)
				{
					if(obj.IsSubmit)
					{
						//df.SetValue(obj.HtmlEle.id,obj.GetValue(obj.HtmlEle.id));
						df.SetValue(obj.HtmlEle.id,obj.GetValue());
						//if(obj.GetValue(obj.HtmlEle.id)!="")
						//	alert(obj.GetValue());
					}	
				}
			}
		}		
		return df;
	}
	else
	{	if(typeof(df)=="string")
			var name = df;
		else
			var name = "";
		var dataForm=new DataForm();
		dataForm.SetName(name);
		for(var i=0;i<this.Elements.length;i++)
		{	
			var obj=this.Elements[i].Co;
			if(InputElements.indexOf(obj.Type.toLowerCase())>=0&&obj.HtmlEle.NotSubmit==null)
			{	
				if(obj.IsSubmit)
					dataForm.AddItem(obj.HtmlEle.id,obj.GetValue());
			}
		}
		return dataForm;	
	}
}

/**<doc type="protofunc" name="JcForm.SetDataForm">
	<desc>将DataForm设置到JcForm中</desc>
	<input>
		<param name="df" type="DataForm">被设置的DataForm</param>
	</input>
</doc>**/
JcForm.prototype.SetDataForm=function(df)
{
	for(var i=0;i<this.Elements.length;i++)
	{	
		var obj=this.Elements[i].Co;
		if(InputElements.indexOf(obj.Type.toLowerCase())>=0)
		{	
			if(df.GetValue(obj.HtmlEle.id)!=null)
			{
				obj.SetValue(df.GetValue(obj.HtmlEle.id));
			}
		}
	}
}

//
//--------------------------------JcForm对象定义结束---------------------------------------------------
//

//
//--------------------------------JcEnum对象定义开始 从JcInput继承-------------------------------------
//

/**<doc type="objdefine" name="JcEnum">
	<desc>JcEnum定义,由JcInput继承</desc>
	<property>
		<prop name="EnumData" type="string">JcEnum所关联的DataEnum</param>
		<prop name="ItemWidth" type="string">JcEnum的单位宽度</param>
		<prop name="ItemHeight" type="string">JcEnum的单位高度</param>
		<prop name="AllowMulti" type="boolean">是否允许多选,默认值为false</param>
		<prop name="HighLight" type="boolean">是否高亮显示,默认值为false</param>
		<prop name="ColumnCount" type="number">JcEnum显示的列数</param>
		<prop name="HasIcon" type="boolean">是否附有图标,默认值为false</param>
		<prop name="_HlItem" type="string">????</param>
	</property>		
</doc>**/
function JcEnum(ele)
{	this.Type="jcenum";
	this.GroupName = null;
	this.EnumData=null;
	this.ItemWidth="100%";
	this.ItemHeight=20;
	this.AllowMulti=false;//single/multi
	this.HighLight=false;
	this.ColumnCount=1;
	this.HasIcon=false;
	this._HlItem=null;
	this.Init(ele);
}
JcEnum.prototype=new JcInput();

/**<doc type="protofunc" name="JcEnum.Init">
	<desc>JcEnum的构建器</desc>
	<input>
		<param name="ele" type="object">JcEnum对应的HTML元素</param>
	</input>	
</doc>**/
JcEnum.prototype.Init=function(ele)
{	if(!ele)ele=document.createElement("<span class='jcenum' jctype='jcenum'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;
	this.Css=ele.className;
	
	if(ele.getAttribute("EnumData"))
	{	this.EnumData = GetDsNode(ele.getAttribute("EnumData"));
		if(!this.EnumData){alert("JcEnum Init Data Error!");};
	}else
		this.EnumData = new DataEnum();
			
	if(ele.getAttribute("AllowMulti")!=null)
		this.AllowMulti =true;
	if(ele.getAttribute("GroupName")!=null)
		this.GroupName = ele.getAttribute("GroupName");
	else
		this.GroupName = this.HtmlEle.id;	
		
	var count=ele.getAttribute("ColumnCount");
	if(count && parseInt(count)+""!="NaN")
	{	this.ColumnCount =parseInt(count);
		this.ItemWidth = parseInt(100/this.ColumnCount)+"%";	
	}
	if(ele.getAttribute("HighLight")!=null)
	{	this.HighLight = true;
	}
	ele.style.overflowY="auto";
	ele.style.cursor="default";
	this.SuperInit();	
	this.RenderObject();
}

/**<doc type="protofunc" name="JcEnum.RenderObject">
	<desc>绘制JcEnum</desc>
</doc>**/
JcEnum.prototype.RenderObject=function()
{	if( this.EnumData && this.Render=="client")
	{	var rowcount=this.EnumData.GetItemCount();
		var width = this.HtmlEle.clientWidth;
		//var eleitem = document.createElement("<span type='_jcenumitem' class='"+this.SubCss("Item")+"' style='width:"+this.ItemWidth+";height:"+this.ItemHeight+";overflow:hidden;'>");
		var eleitem = document.createElement("<span type='_jcenumitem' class='"+this.SubCss("Item")+"' style='width:"+this.ItemWidth+";height:"+this.ItemHeight+";'>");
		var type="radio";
		if(this.AllowMulti)type="checkbox";
		eleitem.innerHTML="<table height=100% cellSpacing=0 cellPadding=0 border=0 width=100%>"+
						"<tr><td width='20'><input type='"+type+"' name='sel_"+this.GroupName+"' id='_selector'></td><td id='_text' class='"+this.SubCss("Text")+"' ></td></tr></table>";
		for(var i=0;i<rowcount;i++)
		{		var item = this.EnumData.GetItem(i);
				var eletmp = eleitem.cloneNode(true);
				eletmp.all("_selector").setAttribute("value",item.GetAttr("Value"));
				eletmp.all("_text").innerHTML=item.GetAttr("Text");
				if(!this.AllowEmpty)
				{
					eletmp.style.backgroundColor=MustInputBgColor;				
				}	
				this.HtmlEle.appendChild(eletmp);
		}
	}
	this.HtmlEle.onmouseover=JcEnum.MouseOver;
	this.HtmlEle.onmouseout=JcEnum.MouseOut;
	this.HtmlEle.onclick=JcEnum.MouseClick;
}

/**<doc type="protofunc" name="JcEnum.SelectItem">
	<desc>改变JcEnum中某个Item的点选状态</desc>
	<input>
		<param name="item" type="object">要改变点选状态的Item(如果JcEnum设为单选,则设置与item相反的状态(与state无关),这儿的逻辑待商榷????</param>
		<param name="state" type="boolean">点选状态</param>
	</input>	
</doc>**/
JcEnum.prototype.SelectItem = function(item,state)
{	//if(!this.AllowMulti)
	//{
	item.all("_selector").checked = state;	
	//}else
	//{	var ischk=item.all("_selector").checked;
	//	if(ischk)
	//		item.all("_selector").checked = false;
	//	else
	//		item.all("_selector").checked = true;
	//}
}

/**<doc type="protofunc" name="JcEnum.ClearSelect">
	<desc>清除JcEnum中每个Item的"选择"状态</desc>
</doc>**/
JcEnum.prototype.ClearSelect=function()
{			
	var items= this.HtmlEle.childNodes;
	for(var i=0;i<items.length;i++)
		this.SelectItem(items[i],false);
}


/**<doc type="protofunc" name="JcEnum.GetSelectedItems">
	<desc>获得JcEnum中选中的Item</desc>
</doc>**/
JcEnum.prototype.GetSelectedItems=function()
{	
	var returnItems=new Array();
	//var items= this.HtmlEle.childNodes;
	var items = document.all("sel_"+this.GroupName);
	for(var i=0;i<items.length;i++)
	{
		//if(items[i].all("_selector").checked)
		if(items[i].checked)
			returnItems[returnItems.length]=items[i];
	}		
	return returnItems;
}

JcEnum.prototype.GetValue=function()
{
	var selectedItems=this.GetSelectedItems();
	//var selectedItems = document.all("sel_"+this.GroupName);
	var value="";
	for(var i=0;i<selectedItems.length;i++)
	{
		value+=selectedItems[i].getAttribute("Value")+",";
	}
	if(value.substring(value.length-1,value.length)==',')
		value=value.substring(0,value.length-1);
	return value;	
}

JcEnum.prototype.SetValue=function(values)
{
	values="," + values + ",";
	var items= this.HtmlEle.childNodes;
	for(var i=0;i<items.length;i++)
	{
		if(values.indexOf(","+items[i].getAttribute("Value")+",")>=0)
		{
			items[i].all("_selector").checked=true;
		}	
	}		
}

/**<doc type="protofunc" name="JcEnum.GetAllItems">
	<desc>获得JcEnum中所有的Item</desc>
</doc>**/
JcEnum.prototype.GetAllItems=function()
{
	return this.HtmlEle.childNodes;
}

/**<doc type="protofunc" name="JcEnum.ClearItems">
	<desc> 在JcEnum中清空Item</desc>
</doc>**/
JcEnum.prototype.ClearItems=function()
{	
	var items= this.HtmlEle.childNodes;
	for(var i=0;i<items.length;i++)
	{
		this.HtmlEle.removeChild(items[i]);
	}	
}

/**<doc type="protofunc" name="JcEnum.RemoveItems">
	<desc>往JcEnum中删除Item</desc>
</doc>**/
JcEnum.prototype.RemoveItems=function(items)
{	
	for(var i=0;i<items.length;i++)
		this.HtmlEle.removeChild(items[i]);
}

/**<doc type="protofunc" name="JcEnum.AddItems">
	<desc>往JcEnum中添加Item</desc>
</doc>**/
JcEnum.prototype.AddItems=function(items)
{	
	for(var i=0;i<items.length;i++)
		this.HtmlEle.appendChild(items[i]);
}

/**<doc type="protofunc" name="JcEnum.MouseOver">
	<desc>定义JcEnum的MouseOver事件</desc>
</doc>**/
JcEnum.MouseOver=function()
{	var item=GetJcChildElement(event.srcElement,"_jcenumitem");
	if(!item)return;
	var ele =GetParentJcElement(item);
	var obj =ele.Co;
	if(!obj.HighLight)return;
	var pitem=obj._HlItem;
	if(pitem)
		pitem.className = obj.SubCss("Item");	
	obj._HlItem=item;
	item.className = obj.SubCss("ItemHighLight");	
	item.all("_Text").className=obj.SubCss("TextHighLight");	
}

/**<doc type="protofunc" name="JcEnum.MouseClick">
	<desc>定义JcEnum的MouseClick事件</desc>
</doc>**/
JcEnum.MouseClick=function()
{	if(event.srcElement.tagName.toLowerCase()=="input")return;
	var item=GetJcChildElement(event.srcElement,"_jcenumitem");
	if(!item)return;
	var ele =GetParentJcElement(item);
	var obj =ele.Co;
	if(obj.AllowEmpty)
	{
		ele.style.backgroundColor=NormalBgColor;
		var ele = ToArray(obj.HtmlEle.childNodes);
		for(var i = 0;i < ele.length;i++)
			ele[i].style.backgroundColor = NormalBgColor;			
	}	
	else
	{
		ele.style.backgroundColor=MustInputBgColor;	
		var ele = ToArray(obj.HtmlEle.childNodes);
		for(var i = 0;i < ele.length;i++)
			ele[i].style.backgroundColor = MustInputBgColor;		
	}	
	if(!obj.AllowMulti)
		obj.SelectItem(item,true);
	else
	{
		obj.SelectItem(item,!item.all("_selector").checked)
	}	
	try{
		eval(obj.HtmlEle.getAttribute("onitemclick"));
	}catch(e){}
}

/**<doc type="protofunc" name="JcEnum.MouseOut">
	<desc>定义JcEnum的MouseOut事件</desc>
</doc>**/
JcEnum.MouseOut=function()
{	var ele =GetParentJcElement(event.srcElement);
	var obj =ele.Co;
	if(!obj.HighLight)return;
	var pitem=obj._HlItem;
	if(pitem)
	{
		pitem.className = obj.SubCss("Item");	
		pitem.all("_Text").className=obj.SubCss("Text");	
	}	
}

JcEnum.prototype.Validate=function()
{	
	var value=this.GetValue()
	var validateResult=new ValidateResult();

	var valstr=this.HtmlEle.getAttribute("ValString");
	if(valstr)
		validateResult.ValidateFormElement(value,valstr);		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
		var ele = ToArray(this.HtmlEle.childNodes);
		for(var i = 0;i < ele.length;i++)
			ele[i].style.backgroundColor = ErrorBgColor;
		return validateResult;	
	}		
	if(!this.AllowEmpty)
		validateResult.ValidateNotAllowEmpty(value); 

		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
		var ele = ToArray(this.HtmlEle.childNodes);
		for(var i = 0;i < ele.length;i++)
			ele[i].style.backgroundColor = ErrorBgColor;		
	}
	return validateResult;	

	//ValString="DataType:String;Title:客户名称;Max:12;Min:5;RegExp:00000;"
}

//
//--------------------------------JcEnum对象定义结束---------------------------------------------------
//

//
//--------------------------------JcGrid对象定义开始 从JcInput继承-------------------------------------
//

/**<doc type="objdefine" name="JcGrid">
	<desc>JcGrid定义,由JcInput继承</desc>
	<property>
		<prop name="ListData" type="DataList">JcGrid所关联的DataList</param>
		<prop name="ShowTitle" type="boolean">是否显示Title,默认值为true</param>
		<prop name="Border" type="string">是否显示Border,默认值为true</param>
		<prop name="ColDef" type="string"></param>
		<prop name="_DefRow" type="object">JcGrid的表头定义</param>
		<prop name="_TmplRow" type="string">JcGrid的表的主体模块定义</param>
		<prop name="CurrentCell" type="string"></param>
		<prop name="_CurCellHtml" type="string"></param>
		<prop name="CurrentRow" type="string"></param>
	</property>		
</doc>**/
function JcGrid(ele)
{	this.Type="jcgrid";
	this.ListData=null;
	this.ShowTitle=true;
	this.Border=true;
	this.ColDef=new Array();
	this._DefRow=null;
	this._TmplRow=null;
	this.CurrentCell=null;
	this._CurCellHtml="";
	this.CurrentRow=null;
	this.PopMenu=null;
	this.HideTitle=null;
	this.Init(ele);
	
}
JcGrid.prototype=new JcInput();

/**<doc type="protofunc" name="JcGrid.Init">
	<desc>JcGrid的构建器</desc>
	<input>
		<param name="ele" type="object">JcGrid对应的HTML元素</param>
	</input>	
</doc>**/
JcGrid.prototype.Init=function(ele)
{	if(!ele)ele=document.createElement("<span class='jcgrid' jctype='jcgrid'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;
	this.Css=ele.className;
	if(ele.getAttribute("ListData"))
	{	this.ListData = GetDsNode(ele.getAttribute("ListData"));
		if(!this.ListData){alert("Error!");};
	}else
		this.ListData = new DataList();
	if(ele.getAttribute("HideTitle")!=null)
	{
		this.HideTitle=true;
	}	
	this.SuperInit();		
	this._InitDefine();
	this.RenderObject();
	this.InitEvent();
	
	
	var menuDataStore="<DataStore Name='_Rds' Type='MyType'>";
	menuDataStore+="<Lists>";
	menuDataStore+="	<List Name='_Menu' Type='Menu'>";
	menuDataStore+="		<Row Type='Normal' Title='添加' ShortCut='Ctrl-A' Method='JcGrid.OnAdd'/>";
	menuDataStore+="		<Row Type='Normal' Title='复制' ShortCut='Ctrl-C' Method='JcGrid.OnCopy'/>";
	menuDataStore+="		<Row Type='Normal' Title='删除' ShortCut='Ctrl-D' Method='JcGrid.OnDelete'/>";
	menuDataStore+="	</List>";
	menuDataStore+="</Lists>";
	menuDataStore+="  </DataStore>";
	this.PopMenu=new JcPopMenu(new DataStore(menuDataStore),JcGrid.MenuEvent);
}

/**<doc type="protofunc" name="JcGrid.GetSelectedTrs">
	<desc>获取JcGrid对象中已选择的行元素数组</desc>
	<input>
		<param name="jcGridObject" type="object">传入的JcGrid对象</param>
	</input>
	<output type="Array">已选择的行元素数组</output>	
</doc>**/
JcGrid.GetSelectedTrs=function(jcGridObject)
{
	var trsArray=new Array();
	var trs=jcGridObject.HtmlEle.childNodes(0).childNodes(1).childNodes;
	for(var i=0;i<trs.length;i++)
	{
		if(trs.item(i).selected=="true")
		{
			trsArray[trsArray.length]=trs.item(i);
		}
	}
	return trsArray;
}

/**<doc type="protofunc" name="JcGrid.GetSelectedTrs">
	<desc>响应JcGrid的菜单事件</desc>
	<input>
		<param name="type" type="string">菜单命令(JcGrid.OnAdd/JcGrid.OnCopy/JcGrid.OnDelete)</param>
		<param name="parentObject" type="object">传入的JcGrid对象</param>
	</input>
</doc>**/
JcGrid.MenuEvent=function(type,parentObject)
{
	var trsArray=JcGrid.GetSelectedTrs(parentObject);
	switch(type)
	{
		case "JcGrid.OnAdd":
			var row = parentObject._TmplRow.cloneNode(true);
			//row.className=parentObject.SubCss("Row");
			row.state="origin"; //数据行处于原始数据状态
			parentObject.HtmlEle.childNodes(0).childNodes(1).appendChild(row);
		break;
		case "JcGrid.OnCopy":
			for(var i=0;i<trsArray.length;i++)
			{
				JcGrid.SetUnSelect(trsArray[i]);
				parentObject.HtmlEle.childNodes(0).childNodes(1).appendChild(trsArray[i].cloneNode(true));
			}		
		break;
		case "JcGrid.OnDelete":
			for(var i=0;i<trsArray.length;i++)
			{
				JcGrid.SetUnSelect(trsArray[i]);
				JcGrid.DeleteRow(trsArray[i]);
				
			}		
		break;				
	}
	parentObject.PopMenu.Hide("_Menu");	
}

JcGrid.DeleteRow=function(ele)
{
	var obj=GetParentJcElement(ele).Co;
	while(ele&&ele.tagName.toLowerCase()!="tr")
		ele=ele.parentNode;
	//ele.style.display="none";
	obj.ListData.Remove(ele.Record);
	obj.HtmlEle.childNodes(0).childNodes(1).removeChild(ele);
	
}

/**<doc type="protofunc" name="JcGrid.SetUnSelect">
	<desc>响应JcGrid的未选中事件</desc>
	<input>
		<param name="tr" type="object">未选中的行元素</param>
	</input>
</doc>**/
JcGrid.SetUnSelect=function(tr)
{
	var obj=GetParentJcElement(tr).Co;
	tr.className=obj.SubCss("Common");
	tr.selected="false";
}

/**<doc type="protofunc" name="JcGrid.SetSelect">
	<desc>响应JcGrid的选中事件</desc>
	<input>
		<param name="tr" type="object">选中的行元素</param>
	</input>
</doc>**/
JcGrid.SetSelect=function(tr)
{
	var obj=GetParentJcElement(tr).Co;
	tr.className=obj.SubCss("Select");
	tr.selected="true";
}

/**<doc type="protofunc" name="JcGrid.Validate">
	<desc>验证JcGrid的有效性</desc>
	<output type="object">ValidateResult对象</output>	
</doc>**/
JcGrid.prototype.Validate=function()
{
	var fullResult=new ValidateResult();
	var valstr=this.HtmlEle.getAttribute("ValString");
	if(valstr)
		fullResult.ValidateFormElement("",valstr)
	var ele=this.HtmlEle.all("EleValidate");
	if(!ele) return null;
	for(var i=0;i<ele.length;i++)
	{
		var value=this._GetColValue(ele[i].Name,ele[i].childNodes(0).value);
		var validateResult=new ValidateResult();
		if(ele[i].getAttribute("NotAllowEmpty")!=null)
			validateResult.ValidateNotAllowEmpty(value); 

		valstr=ele[i].getAttribute("ValString");
		if(valstr)
			validateResult.ValidateFormElement(value,valstr);
			
		if(!validateResult.Passed)	
		{
			ele[i].style.backgroundColor = ErrorBgColor;
			fullResult.Message+="\n            " + validateResult.GetErrMsg();
		}
	}
	if(fullResult.Message!="")
		fullResult.Passed=false;
	return fullResult;	
}

/**<doc type="protofunc" name="JcGrid._InitDefine">
	<desc>构建JcGrid的结构</desc>
</doc>**/
JcGrid.prototype._InitDefine=function()
{	var ele = this.HtmlEle;
	this._DefRow=ele.getElementsByTagName("tr")[0];
	var drow=this._DefRow;
	if(this.HideTitle)
		drow.style.display="none";
	var colnum=drow.childNodes.length;
	var trow = drow.cloneNode(false);
	trow.className=this.SubCss("Common");
	trow.style.display="block";
	for(var i=0;i<colnum;i++)
	{	var tcell=document.createElement("td");
		var cell=drow.childNodes[i];
		cell.className=this.SubCss("Title");
		if( cell.getAttribute("CellValign"))
			tcell.setAttribute("VALIGN", cell.getAttribute("CellValign"));
		if( cell.getAttribute("CellAlign"))
			tcell.setAttribute("ALIGN",cell.getAttribute("CellAlign"));
		if(cell.getAttribute("NotAllowEmpty")!=null)
		{
			tcell.style.backgroundColor=MustInputBgColor;
			tcell.NotAllowEmpty="";
		}
		tcell.setAttribute("PreBgColor",tcell.style.backgroundColor);
		if(cell.getAttribute("ValString"))
		{
			tcell.id="EleValidate";
			tcell.ValString=cell.getAttribute("ValString");
		}
						
		//tcell.style.cssText = GetAttr(cell,"CellStyle"," ")
		tcell.setAttribute("Name",cell.getAttribute("Name"));
		tcell.style.cursor="text";
		tcell.setAttribute("type","_jgcell");
		
		var defobj=this.ColDef[i]=this.ColDef[cell.getAttribute("Name")]=new Object();
		defobj["Name"]=GetAttr(cell,"Name","");
		defobj["_DefCell"]=cell; //保存定义的单元格
		
		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);
		
		trow.appendChild(tcell);
		//alert(defobj["_DefCell"].outerHTML);
		var type=defobj["_DefCell"].getAttribute("Type");
		if(type)
		{	
			if(type.toLowerCase()=="indicator")
			{
				tcell.innerHTML="<button class='" + this.SubCss("Button") + "' id='_indicator' type='_indicator' pos='body'></button>";
				cell.innerHTML="<button class='" + this.SubCss("HeadButton") + "' id='_indicator' type='_indicator' pos='header' title='添加'></button>";
			}
			else if(type.toLowerCase()=="function")
			{
				tcell.innerHTML="<img id='_deletor' type='_deletor' pos='body' onclick='JcGrid.DeleteRow(this)'  src='"+ECIDI.Util.Const.AppServer+"/images/jsctrl/delete.gif'>";
			}
			continue;
		}
		var ed=cell.getAttribute("Editor");
		if(!ed)ed="jctext";
		ed = ed.toLowerCase();
		var edobj=null,edele=null;
		switch(ed)
		{	case "jctext":
				tcell.innerHTML="<input type='text' nochange='true' style='background-color:transparent;width:100%;height:100%;border-width:0;padding-left:0;overflow:hidden;'>";
				break;
			case "jcselect":
				edobj = new JcSelect();
				edobj.HtmlEle.OptionList=defobj["Enum"];
				edobj.Init(edobj.HtmlEle);
				tcell.innerHTML="<input type='text' readonly nochange='false' style='background-color:transparent;width:100%;height:100%;border-width:0;padding-left:0;overflow:hidden;'>";
				//tcell.innerHTML="<input type='text' readonly onfocus='this.click();' nochange='false' style='background-color:transparent;width:100%;height:100%;border-width:0;padding-left:0;overflow:hidden;'>";
				break;
			case "jcdropdown":
				edobj = new JcDropDown();
				/*
				this.DropType="";//所弹出的关联实体类型：Calendar,List,Tree
				this.DataType="";//日期类型:Normal,Start,End
				this.RelateDateID="";
				this.DropUrl="";
				this.DropParam="";
				this.DropSize="width:auto;height:auto;";
				this.ReturnMode="single";//single /multi
				this.ReturnFields=""; //id1,id2,id3				
				*/
				//edobj.HtmlEle.OptionList=defobj["Enum"];
				//edobj.Init(edobj.HtmlEle);
				edobj.HtmlEle.style.width="100%";
				tcell.innerHTML="<input type='text' readonly nochange='false' style='background-color:transparent;width:100%;height:100%;border-width:0;padding-left:0;overflow:hidden;'>";
				//tcell.innerHTML="<input type='text' readonly onfocus='this.click();' nochange='false' style='background-color:transparent;width:100%;height:100%;border-width:0;padding-left:0;overflow:hidden;'>";
				break;
			case "jcpopup":
				edobj = new JcPopUp();
				//edobj.HtmlEle.OptionList=defobj["Enum"];
				//edobj.Init(edobj.HtmlEle);
				tcell.innerHTML="<input type='text' readonly nochange='false' style='background-color:transparent;width:100%;height:100%;border-width:0;padding-left:0;overflow:hidden;'>";
				//tcell.innerHTML="<input type='text' readonly onfocus='this.click();' nochange='false' style='background-color:transparent;width:100%;height:100%;border-width:0;padding-left:0;overflow:hidden;'>";
				break;
			case "jctextarea":
				edobj = new JcTextArea();
				edobj.HtmlEle.style.paddingLeft=0;
				tcell.innerHTML="<textarea  nochange='true' style='background-color:transparent;width:100%;height:100%;border-width:0;overflow-y:hidden;padding-left:0;'></textarea>";
				//tcell.innerHTML="<textarea  nochange='true' onfocus='this.click();' style='background-color:transparent;width:100%;height:100%;border-width:0;overflow-y:hidden;padding-left:0;'></textarea>";
				break;
		}
		if(edobj)
		{	edobj.HtmlEle.style.display="none";
			edobj.HtmlEle.id="_jcgrideditor";
			cell.appendChild(edobj.HtmlEle);
		}
	}
	this._TmplRow=trow;
}

/**<doc type="protofunc" name="JcGrid._GetOutput">
	<desc>设置某单元格内的显示格式</desc>
	<input>
		<param name="def" type="object">单元格的定义对象</param>
		<param name="item" type="DataItem">单元格内所设的DataItem</param>
	</input>
	<output type="string">单元格内的显示文本</output>	
</doc>**/
JcGrid.prototype._GetOutput=function(def,item)
{	var txt=(item.GetAttr(def["Name"])+"").filterNull();
	return this._GetColText(def["Name"],txt);
}

/**<doc type="protofunc" name="JcGrid.RenderObject">
	<desc>根据ListData绘制JcGrid的主体</desc>
</doc>**/
JcGrid.prototype.RenderObject=function()
{	
	if( this.ListData)
	{	
		var tbody = document.createElement("tbody"); 
		this.HtmlEle.childNodes[0].appendChild(tbody);
		var rowcount=this.ListData.GetItemCount();
		for(var i=0;i<rowcount;i++)
		{	if(this.Render=="client")
			{	var row = this._TmplRow.cloneNode(true);
				//row.className=this.SubCss("Row");
				row.state="origin"; //数据行处于原始数据状态
				var item = this.ListData.GetItem(i);
				row.Record=item;
				var colcount = this.ColDef.length;
				for(var j=0;j<colcount;j++)
				{	var def = this.ColDef[j];
					var type=def["_DefCell"].getAttribute("Type");
					if(!type||(type.toLowerCase()!="indicator"&&type.toLowerCase()!="function"))
					//if(def["Name"].toLowerCase()!="_indicator")
					{	
						row.childNodes[j].childNodes[0].value=this._GetOutput(def,item);
					}
				}
				tbody.appendChild(row);
			}
			tbody.childNodes[i].Record=this.ListData.GetItem(i);
		}
	}
}

/**<doc type="protofunc" name="JcGrid.InitEvent">
	<desc>初始化JcGrid的相关事件</desc>
</doc>**/
JcGrid.prototype.InitEvent=function()
{	var tbl=this.HtmlEle.childNodes[0];
	tbl.onclick=JcGrid.MouseClick;
	tbl.onkeydown=JcGrid.KeyDown;
	tbl.oncontextmenu = JcGrid.ContextMenu;
	tbl.ondeactivate=JcGrid.DeActivate;
}

/**<doc type="protofunc" name="JcGrid._GetColValue">
	<desc>获取某单元格所设的值</desc>
	<input>
		<param name="name" type="string">Enum单元格名称</param>
		<param name="text" type="string">单元格内的显示文本</param>
	</input>
	<output type="string">单元格所设的值</output>	
</doc>**/
JcGrid.prototype._GetColValue=function(name,text)
{	
	if(this.ColDef[name].DataType.toLowerCase() != "enum")
		return text;
	else
	{	var val= this.ColDef[name].EnumObject.GetValue(text);
		if(!val)return "";
		return val;
	}
}

/**<doc type="protofunc" name="JcGrid._GetColText">
	<desc>设置某单元格内的显示文本</desc>
	<input>
		<param name="name" type="string">单元格名称</param>
		<param name="value" type="string">单元格内所设的值</param>
	</input>
	<output type="string">单元格内的显示文本</output>		
</doc>**/
JcGrid.prototype._GetColText=function(name,value)
{	
	if(this.ColDef[name].DataType.toLowerCase() != "enum")
		return value;
	else
	{	var txt=this.ColDef[name].EnumObject.GetText(value);
		if(!txt)return "";
		return txt;
	}
}

/**<doc type="protofunc" name="JcGrid.RestoreCell">
	<desc>还原单元格的样式</desc>
</doc>**/
JcGrid.prototype.RestoreCell=function()
{	
	var td=this.CurrentCell;
	if(!td)
		return;
	prehtml = this._CurCellHtml;
	var name=td.getAttribute("Name");
	var edele = td.all("_jcgrideditor");
	if(!edele)//is jctext,jctextarea
	{	type = td.childNodes[0].getAttribute("type");
		if(type=="text"||type=="textarea")
			td.childNodes[0].select();
		return;
	}
	var tdval = edele.Co.GetValue();
	edele.style.display="none";
	this.ColDef[name]._DefCell.appendChild(edele);
	td.innerHTML = prehtml;
	td.childNodes[0].value=this._GetColText(td.getAttribute("Name"),tdval);
	//td.childNodes[0].onfocus=function(){this.click();};
	this.CurrentCell=null;
	this.CurrentHtml="";
}

/**<doc type="protofunc" name="JcGrid.StoreCell">
	<desc>设置单元格的样式</desc>
</doc>**/
JcGrid.prototype.StoreCell=function(td)
{	
	//if(td.NotAllowEmpty!=null)
	//	td.style.backgroundColor=MustInputBgColor;
	//else
	//	td.style.backgroundColor=NormalBgColor;	
	td.style.backgroundColor=td.PreBgColor;
	var defele=td.childNodes[0];
	if(defele.nochange=="true")
	{	type=defele.getAttribute("type");
		if(type=="text"||type=="textarea")
			defele.select();
		return;
	}
	JcGrid._StoreCellFlag=true;
	window.setTimeout("JcGrid._StoreCellFlag=false;",100);
	var tdtext = td.childNodes[0].value;
	var tdval = this._GetColValue(td.getAttribute("Name"),tdtext);
	this._CurCellHtml = td.innerHTML;
	var name=td.getAttribute("Name");
	var edele = this.ColDef[name]._DefCell.all("_jcgrideditor");
	if(edele)
	{	td.innerHTML="";
		edele.style.width = "100%";
		edele.style.display="";
		td.appendChild(edele);
		edele.Co.SetValue(tdval);
		if(edele.all("_text"))
		{	edele.all("_text").focus();
			edele.all("_text").select();
		}else
		{	edele.focus();
			edele.setActive();
		}
	}
}


/**<doc type="protofunc" name="JcGrid.ClearSelect">
	<desc>清除JcGrid的选中行</desc>
</doc>**/
JcGrid._StoreCellFlag=false;
JcGrid.prototype.ClearSelect=function()
{	var tbody = this.HtmlEle.childNodes[0].childNodes[1];
	if(!tbody)return;
	var rows = tbody.childNodes;
	var count = rows.length;
	for(var i=0;i<count;i++)
	{	if(rows[i].selected=="true")
		{	
			rows[i].style.backgroundColor=rows[i].PreBgColor;
			//rows[i].style.backgroundColor="white";
			rows[i].selected="false";
		}
	}
}

/**<doc type="protofunc" name="JcGrid.DeActivate">
	<desc>定义JcGrid的DeActivate事件</desc>
</doc>**/
JcGrid.DeActivate=function()
{	var ele=GetParentJcElement(event.srcElement);//get jcgrid object
	if(ele.Co.Type != "jcgrid")
		ele = GetParentJcElement(ele.parentNode);
	if(JcGrid._StoreCellFlag)return;
	if(document.activeElement)
	{	if(ele.contains(document.activeElement) )return;// sometime body is active element
		if(document.activeElement.Master)return;//如果活动元素是下拉iFRAME
	}
	ele.Co.RestoreCell();
	window.clearTimeout(JcGrid._CheckTimeout);
	ele.Co.ClearSelect();
	ele.Co.PopMenu.Hide("_Menu");
};

/**<doc type="protofunc" name="JcGrid.GetCell">
	<desc>通过指定规则获取指定td的相应单元格</desc>
	<input>
		<param name="td" type="object">指定的td元素</param>
		<param name="type" type="string">获取规则:next/pre/down/up</param>
	</input>	
</doc>**/
JcGrid.GetCell=function(td,type)
{	
	var tbody = td.parentNode.parentNode;
	var tcol = td.parentNode.childNodes.length;
	var trow = tbody.childNodes.length;
	var col = GetNodeIndex(td);
	var row = GetNodeIndex(td.parentNode);
	
	switch(type)
	{	case "next":
			col++;
			if(col>=tcol){	col=1;row++;}
			if(row>=trow){ row=trow-1;col=tcol-1;}
			break;
		case "pre":
			col--;
			if(col<0){	col=tcol-1;row--;}
			if(row<0){  row=0;col=1;}
			break;
		case "down":
			row--;
			if(row<0){	row=0;}
			break;
		case "up":
			row++;
			if(row>=trow){	row=trow-1;}
			break;
	}
	var cell = tbody.childNodes[row].childNodes[col];
	return cell;
}

/**<doc type="protofunc" name="JcGrid.KeyDown">
	<desc>定义JcGrid的KeyDown事件</desc>
</doc>**/
JcGrid.KeyDown=function()
{	
	var td=GetJcChildElement(event.srcElement,"_jgcell");
	if(!td)return;
	var kc=event.keyCode;
	var ctrl=event.ctrlKey;
	var shift=event.shiftKey;
	var ncell=null;
	if(kc==9 ||(kc==39 && ctrl))
		ncell=JcGrid.GetCell(td,"next");
	if((kc==37 && ctrl)||(kc==9 && shift))
		ncell=JcGrid.GetCell(td,"pre");
	if(kc==38 && ctrl)
		ncell=JcGrid.GetCell(td,"down");
	if(kc==40 && ctrl)
		ncell=JcGrid.GetCell(td,"up");
	if(ncell || kc==9)	
		event.returnValue=false;
	if(ncell)
		ncell.click();
}

/**<doc type="protofunc" name="JcGrid.MouseClick">
	<desc>定义JcGrid的MouseClick事件</desc>
</doc>**/
JcGrid.MouseClick=function()
{	
	var idc=GetJcChildElement(event.srcElement,"_indicator");
	if(idc&&idc.pos=="header")
	{
		var ele=GetParentJcElement(idc);
		JcGrid.MenuEvent("JcGrid.OnAdd",ele.Co);
		return false;
	}
	var td=GetJcChildElement(event.srcElement,"_jgcell");
	if(!td)return;
	var ele=GetParentJcElement(td);
	var obj=ele.Co;
	obj.PopMenu.Hide("_Menu");
	idc=GetJcChildElement(event.srcElement,"_indicator");
	if(idc)
	{	
		if(idc.pos=="body")
		{
			var tr = GetTableTr(idc);
			if(tr.selected=="true")
			{	
				JcGrid.SetUnSelect(tr);
			}else
			{	JcGrid.SetSelect(tr);
			}
		}
		else if(idc.pos=="header")
		{
			JcGrid.MenuEvent("JcGrid.OnAdd",obj);
		}	
		return;	
	}
	obj.ClearSelect();//清除当前所有的选择
	//alert("XX");
	if(obj.CurrentRow)
	{
		if(td.parentNode != obj.CurrentRow) //Dirty跟踪处理
			window.clearTimeout(JcGrid._CheckTimeout);
	}
	JcGrid.CheckDirty(td.parentNode);
	obj.CurrentRow = td.parentNode;
	
	if(obj.CurrentCell)
	{	if(obj.CurrentCell==td)return;
		obj.RestoreCell();
	}
	obj.StoreCell(td);	
	obj.CurrentCell=td;
}

/**<doc type="protofunc" name="JcGrid.ContextMenu">
	<desc>定义JcGrid的鼠标右键事件</desc>
</doc>**/
JcGrid.ContextMenu=function()
{	
	var ele=GetParentJcElement(event.srcElement);//get jcgrid object
	var obj=ele.Co;
	//var idc=GetJcChildElement(event.srcElement,"_indicator");
	//if(idc)
	//{	
		obj.PopMenu.Hide("_Menu");
		obj.PopMenu.Show("_Menu",window.event.x,window.event.y,obj);
		event.returnValue=false;
		return;	
	//}else
	//{	JcGrid.MouseClick();
	//}
 }

/**<doc type="protofunc" name="JcGrid.CheckDirty">
	<desc>检查JcGrid中的某一行是否Dirty</desc>
	<input>
		<param name="row" type="obj">要检查的行</param>
	</input>	
</doc>**/  
JcGrid._CheckTimeout=0;
JcGrid._CheckRow=null;
JcGrid.CheckDirty=function (row)
{	if (typeof(row)!="undefined")
	{	JcGrid._CheckRow = row;
		JcGrid._CheckTimeout = window.setTimeout(JcGrid.CheckDirty,200);
		return;
	}
	var state=JcGrid._CheckRow.getAttribute("state");
	if( typeof(state)!="undefined" && state!="origin")
	{	return;
	}
	var isdirty = JcGrid.IsRowDirty(JcGrid._CheckRow);
	if (isdirty)
		JcGrid.SetRowIsDirty(JcGrid._CheckRow);
	else
		JcGrid._CheckTimeout = window.setTimeout(JcGrid.CheckDirty,200);
}

/**<doc type="protofunc" name="JcGrid.IsRowDirty">
	<desc>判断JcGrid中的某一行状态是否为Dirty</desc>
	<input>
		<param name="row" type="obj">要判断的行</param>
	</input>	
</doc>**/ 
JcGrid.IsRowDirty=function (row)
{	var ele=GetParentJcElement(row);//get jcgrid object
	var obj=ele.Co;
	var rowvalue="";
	for(var i=0;i<row.cells.length;i++)
	{	var cell = row.cells[i];
		var name=cell.getAttribute("Name");
		if(!name||name.toLowerCase()=="_indicator")continue;//不是数据单元格
		var ele=cell.childNodes[0];
		if(ele.tagName.toLowerCase()=="input" )
			rowvalue+=obj._GetColValue(name,ele.value);
		else if(ele.getAttribute("jctype")!=null)
		{	rowvalue+=ele.Co.GetValue();
		}
	}	
	if(typeof(row.origin)=="undefined")
	{	row.origin = rowvalue;
		return false;
	}
	if(row.origin != rowvalue)
		return true;
	else 
		return false;
}

/**<doc type="protofunc" name="JcGrid.SetRowIsDirty">
	<desc>设置JcGrid中的某一行为Dirty(状态为N(new)/M(modify))</desc>
	<input>
		<param name="row" type="obj">要设置的行</param>
	</input>	
</doc>**/ 
JcGrid.SetRowIsDirty=function(row)
{	var idc = row.all("_indicator");
	if(!idc)return;
	if(!row.state)
		row.state = "new";
	if(row.state=="new")
		idc.innerHTML="N";
	if(row.state == "origin")
	{	idc.state == "modify";
		idc.innerHTML = "●";
	}	
	
}

/**<doc type="protofunc" name="JcGrid.GetValue">
	<desc>从JcGrid获取DataList的XML</desc>
	<input>
		<param name="dlname" type="string">获取的DataList的名称</param>
	</input>	
	<output type="string">获取的DataList的XML????</output>
</doc>**/ 
JcGrid.prototype.GetValue=function(dlname)
{	var tbody = this.HtmlEle.childNodes[0].childNodes[1];
	var rows = tbody.childNodes;
	var count = rows.length;
	var dl = new DataList();
	dl.SetName(this.HtmlEle.id);
	var flds="";
	for(var j=0;j<count;j++)
	{	var item = dl.NewItem();
		for(var i=0;i<rows[j].cells.length;i++)
		{	var cell = rows[j].cells[i];
			var name=cell.getAttribute("Name");
			if(!name||name.toLowerCase()=="_indicator")continue;//不是数据单元格
			var ele=cell.childNodes[0];
			if(ele.tagName.toLowerCase()=="input"||ele.tagName.toLowerCase()=="textarea" )
			{
				item.SetAttr(name,this._GetColValue(name,ele.value));
			}	
			else if(ele.getAttribute("jctype")!=null)
			{	
				
				item.SetAttr(name,ele.Co.GetValue());
			}
		}
	}
	for(var i=0;i<this._TmplRow.childNodes.length;i++)
	{	var cell = this._TmplRow.childNodes[i];
		var name=cell.getAttribute("Name");
		if(!name||name.toLowerCase()=="_indicator")continue;//不是数据单元格
		flds+=name+",";
	}
	if(flds.length>0)flds=flds.substr(0,flds.length-1);
	dl.SetAttr("Fields",flds);
	if(dlname)dl.SetName(dlname);
	return dl.ToString();
}

/**<doc type="protofunc" name="JcGrid.SetValue">
	<desc>设置JcGrid的值</desc>
	<input>
		<param name="value" type="string">待设置的DataList的XML</param>
	</input>
</doc>**/
JcGrid.prototype.SetValue=function(value)
{	
	var tbl = this.HtmlEle.childNodes[0];
	tbl.removeChild(tbl.childNodes[1]);
	this.ListData = new DataList(value);
	this.RenderObject();
}

/**<doc type="protofunc" name="JcGrid.SetDisabled">
	<desc>设置JcGrid是否禁止</desc>
	<input>
		<param name="st" type="boolean">是否禁止</param>
	</input>
</doc>**/
JcGrid.prototype.SetDisabled=function(st)
{	this.Disabled=st;
	this.HtmlEle.disabled=st;
	this.HtmlEle.all("_text").disabled=st;
	if(this.Disabled)
		this.HtmlEle.all("_text").style.backgroundColor=DisabledBgColor;
	else if(this.Readonly)
		this.HtmlEle.all("_text").style.backgroundColor=ReadonlyBgColor;
	else
		this.HtmlEle.all("_text").style.backgroundColor=NormalBgColor;
}

/**<doc type="protofunc" name="JcGrid.SetReadonly">
	<desc>设置JcGrid是否只读</desc>
	<input>
		<param name="st" type="boolean">是否只读</param>
	</input>
</doc>**/
JcGrid.prototype.SetReadonly=function(st)
{	this.Readonly=st;
	this.HtmlEle.readOnly=st;
	this.HtmlEle.all("_text").readOnly=st;
	this.HtmlEle.all("_btn").disabled=st;
	if(!this.Disabled && this.Readonly)
		this.HtmlEle.all("_text").style.backgroundColor=ReadonlyBgColor;
	else
		this.HtmlEle.all("_text").style.backgroundColor=NormalBgColor;
}
//
//--------------------------------JcGrid对象定义结束---------------------------------------------------
//







//
//--------------------------------JcPopUpEx对象定义开始 从JcInput继承----------------------------------------
//

/**<doc type="objdefine" name="JcPopUpEx">
	<desc>JcPopUpEx定义,由JcInput继承</desc>
	<property>
		<prop name="PopType" type="string">JcPopUpEx的弹出类型:Calendar/List/Tree/Url</param>
		<prop name="PopUrl" type="string">JcPopUpEx所弹出的关联URL</param>
		<prop name="PopParam" type="string">JcPopUpEx所弹出的关联参数</param>
		<prop name="PopStyle" type="string">JcPopUpEx的弹出样式,默认值为compact</param>
		<prop name="PopMode" type="string">JcPopUpEx的弹出模式,默认值为window(dialog/window)</param>
		<prop name="PopSize" type="string">JcPopUpEx的弹出尺寸大小</param>
		<prop name="ReturnMode" type="string">JcPopUpEx返回的是单值(single)还是多值(multi),默认值为single</param>
		<prop name="ReturnFields" type="string">JcPopUpEx返回的字段,以","分隔</param>
	</property>		
</doc>**/
function JcPopUpEx(ele)
{


	this.Type="jcpopupex";
	this.PopType="";//所弹出的关联实体类型：Calendar,List,Tree,Url
	this.PopUrl="";//所弹出的关联URL
	this.PopParam="";//所弹出的关联参数
	this.PopParam_First="";//First所弹出的关联参数
	this.System="System";
	this.OnPopBefore="";
	this.OnPopAfter="";
	this.PopStyle="compact"; //
	this.PopMode="window"; //dialog/window
	this.PopSize="";
	this.ReturnMode="single";
	this.ReturnParam="";    //返回的数据
	this.ReturnParam_First="";   // add by chenmin 20070724
	this.Init(ele);
}
JcPopUpEx.prototype=new JcInput();

/**<doc type="protofunc" name="JcPopUpEx.Init">
	<desc>JcPopUpEx的构建器</desc>
	<input>
		<param name="ele" type="object">JcPopUpEx对应的HTML元素</param>
	</input>	
</doc>**/
JcPopUpEx.prototype.Init=function(ele)
{	if(!ele)ele=document.createElement("<span class='jcpopupex' jctype='jcpopupex'>");
	this.HtmlEle = ele;
	this.HtmlEle.Co=this;
	
	if(ele.getAttribute("PopMode"))
		this.PopMode = ele.getAttribute("PopMode").toLowerCase();
		
	if(ele.getAttribute("PopStyle"))
		this.PopStyle = ele.getAttribute("PopStyle");
	else
	{ 
		if(this.PopMode=="window")
			this.PopStyle="compact";
		else(this.PopMode=="dialog")
			this.PopStyle="dialogHeight:400px;dialogWidth:400px;edge:Sunken;center:Yes;help:No;resizable:No;status:No;";	
	}
	
	if(ele.getAttribute("PopParam"))
		this.PopParam = ele.getAttribute("PopParam");
		
		// add by chenmin 20070724
	if(ele.getAttribute("PopParam_First"))
		this.PopParam_First = ele.getAttribute("PopParam_First");		
		
	if(ele.getAttribute("System"))
		this.System = ele.getAttribute("System");
		
	if(ele.getAttribute("ReturnMode"))
		this.ReturnMode =ele.getAttribute("ReturnMode").toLowerCase();
		
		
	if(ele.getAttribute("ReturnParam"))
		this.ReturnParam =ele.getAttribute("ReturnParam");
		
	// add by chenmin 20070724	
	if(ele.getAttribute("ReturnParam_First"))
		this.ReturnParam_First =ele.getAttribute("ReturnParam_First");
		
		
	if(ele.getAttribute("PopType"))
		this.PopType=ele.getAttribute("PopType");
	if(!this.PopType)this.PopType="List";

	if(ele.getAttribute("PopUrl"))
		this.PopUrl=ele.getAttribute("PopUrl");
		
	if(ele.getAttribute("OnPopBefore"))
		this.OnPopBefore=ele.getAttribute("OnPopBefore");
		
	if(ele.getAttribute("OnPopAfter"))
		this.OnPopAfter=ele.getAttribute("OnPopAfter");
		
	var lowerCasePopType=this.PopType.toLowerCase();
	switch(lowerCasePopType)
	{
		case "list":
			this.PopUrl = "http://srfile.ecidi.com/share/page/jclist.htm";
			this.PopUrl +="?CallElement="+this.HtmlEle.id+"&PopParam="+this.PopParam;//Page.List.Default
		break;
		case "url":
			if(this.PopUrl)
			{
				var prefix="";

				if(this.PopUrl.indexOf("?")>=0 )
					prefix="&";
				else
					prefix="?";
				if(this.OnPopAfter)	//如果设置了回调方法
					this.PopUrl +=prefix+"CallElementId="+this.HtmlEle.id+"&OnPopAfter="+this.OnPopAfter;//Page.List.Default
				else
				{
				
					this.PopUrl +=prefix+"CallElementId="+this.HtmlEle.id;//Page.List.Default
				}	
			}	
			else
			{
				alert("弹出框URL未设置!");
				return false;
			}		
		break;
	}
	this.SuperInit();
	this.RenderObject();
	this.InitEvent();	
	
}

/**<doc type="protofunc" name="JcPopUpEx.InitEvent">
	<desc>设置JcPopUpEx的绑定事件</desc>
</doc>**/
JcPopUpEx.prototype.InitEvent=function()
{	var ele=this.HtmlEle;
	ele.all("_btn").onclick=JcPopUpEx.BtnClick;
	if(!this.AllowEmpty)
	{	//this.HtmlEle.all("_text").style.backgroundColor=MustInputBgColor;
		this.HtmlEle.all("_text_First").style.backgroundColor=MustInputBgColor;
	}
}
JcPopUpEx.OnFocus=function()
{
	var ele=GetParentJcElement(event.srcElement);
	//ele.all("_text").style.backgroundColor=ele.Co.PreBgColor;	
	ele.all("_text_First").style.backgroundColor=ele.Co.PreBgColor;	
	
	ele.style.backgroundColor=ele.Co.PreBgColor;	
}

/**<doc type="protofunc" name="JcPopUpEx.RenderObject">
	<desc>绘制JcPopUpEx</desc>
</doc>**/
JcPopUpEx.prototype.RenderObject=function()
{	
	if(this.Render=="client")
	{	var elesrc = "<table cellspacing='0' cellpadding='0' border='0' style='height:20;width:100%'><tr>"+
			"<td><input id='_text_First'  readonly class='" + this.SubCss("Text") + "'  style='width:30%;background-color:#F0E68C'><input id='_text' readonly class='" + this.SubCss("Text") + "' style='width:70%'></td>"+
			"<td style='width:20;'>";
		var popType=this.PopType.toLowerCase();	
		//if(popType=="ftpfile"||popType=="ftpmultifile"||popType=="ftpfolderfile")	
		//	elesrc+="<button id='_btn' class='" + this.SubCss("UploadButton") + "' style='width:100%;height:21;'><img src='http://srfile.ecidi.com/share/image/jsctrl/uploadbtnpopup.gif'></button>";
		//else
			elesrc+="<button id='_btn' class='" + this.SubCss("Button") + "' style='width:100%;height:21;'><img src='"+ECIDI.Util.Const.AppServer+"/images/jsctrl/btnpopup.gif'></button>";
		elesrc+="</td></tr></table>";
		//alert(elesrc);
		this.HtmlEle.innerHTML= elesrc;
		this.HtmlEle.style.height=20;
	}
	
}


/**<doc type="protofunc" name="JcPopUpEx.BtnClick">
	<desc>定义JcPopUpEx的点击事件</desc>
</doc>**/
JcPopUpEx.BtnClick=function()
{	


	JcPopUpEx.OnFocus();
	var ele=GetParentJcElement(event.srcElement);
	var obj=ele.Co;

	var popParam="";

	if(obj.PopParam)
	{
		var sp=new StringParam(obj.PopParam);
		for(var i=0;i<sp.GetCount();i++)
		{
			popParam+=sp.Keys[i]+":";
			if(document.all(sp.Get(i)).Co)
			{
				popParam+=document.all(sp.Get(i)).Co.GetValue()+";";
			}	
			else
				popParam+=document.all(sp.Get(i)).value+";";	
		}
	}
	else if(obj.OnPopBefore)
	{
		popParam=eval(obj.OnPopBefore)();
	}	
	var popUrl=obj.PopUrl;

	var params = obj.PopUrl.split( "[" )
	var autoUrl = "";
	for ( var i = 1; i < params.length; i++ )
	{
		if ( document.all( params[i].split("]")[0] ).Co )
			autoUrl = obj.PopUrl.replace( "["+params[i].split("]")[0]+"]", document.all( params[i].split("]")[0] ).Co.GetValue() );
		else
			autoUrl = obj.PopUrl.replace( "["+params[i].split("]")[0]+"]", document.all( params[i].split("]")[0] ).value );
	}
	
	if ( autoUrl != "" )
	     popUrl = autoUrl;

	if(obj.PopUrl.indexOf("?")>0)
		popUrl+="&PopParam=" + popParam;
	else
		popUrl+="?PopParam=" + popParam;	


    // add by chenmin 20070724

	var popParam_First="";

	if(obj.PopParam_First)
	{
		var sp=new StringParam(obj.PopParam_First);
		for(var i=0;i<sp.GetCount();i++)
		{
			popParam_First+=sp.Keys[i]+":";
			if(document.all(sp.Get(i)).Co)
			{
				popParam_First+=document.all(sp.Get(i)).Co.GetValue()+";";
			}	
			else
				popParam_First+=document.all(sp.Get(i)).value+";";	
		}
	}
	


	if(obj.PopUrl.indexOf("?")>0)
		popUrl+="&PopParam_First=" + popParam_First;
	else
		popUrl+="?PopParam_First=" + popParam_First;
		
//======
		


	switch(obj.PopType.toLowerCase())
	{
		case "list":
			if(obj.PopMode.toLowerCase()=="window")
				window.open(popUrl,ele.id+"_win",CenterWin(obj.PopStyle));
			else
			{	window.showModalDialog(popUrl,window,CenterWin(obj.PopStyle,true));
			}
		break;
		default:
			if(obj.PopMode.toLowerCase()=="window")
			{
				window.open(popUrl,ele.id+"_win",CenterWin(obj.PopStyle));
			}	
			else
			{	
				window.showModalDialog(popUrl,window,CenterWin(obj.PopStyle,true));
			}
		break;		
	}		
}

/**<doc type="protofunc" name="JcPopUpEx.GetValue">
	<desc>取得JcPopUpEx的值</desc>
	<output type="string">JcPopUpEx的值</output>
</doc>**/
JcPopUpEx.prototype.GetValue=function()
{
	return this.HtmlEle.all("_text").value;
}


/**<doc type="protofunc" name="JcPopUpEx.GetValue">
	<desc>取得JcPopUpEx的值First</desc>
	<output type="string">JcPopUpEx的值</output>
</doc>**/
JcPopUpEx.prototype.GetValue_First=function()
{
	return this.HtmlEle.all("_text_First").value;
}


/**<doc type="protofunc" name="JcPopUpEx.SetValue">
	<desc>设置JcPopUpEx的值</desc>
	<input>
		<param name="value" type="string">待设置的值</param>
	</input>
</doc>**/
JcPopUpEx.prototype.SetValue=function(value)
{
	if(value == null) value = "";
	this.HtmlEle.all("_text").value=value;
}

/**<doc type="protofunc" name="JcPopUpEx.SetValue">
	<desc>设置JcPopUpEx的值First</desc>
	<input>
		<param name="value" type="string">待设置的值</param>
	</input>
</doc>**/
JcPopUpEx.prototype.SetValue_First=function(value)
{
	if(value == null) value = "";
	this.HtmlEle.all("_text_First").value=value;
}


/**<doc type="protofunc" name="JcPopUpEx.SetReturn">
	<desc>设置JcPopUpEx的返回值</desc>
	<input>
		<param name="rtnstr" type="string">JcPopUpEx的返回值</param>
	</input>	
</doc>**/
JcPopUpEx.prototype.SetReturn=function(rtnstr)
{	

	this.returnValue=true;
	this.ReturnString=rtnstr;
	try
	{
		eval(this.HtmlEle.getAttribute("onreturnbefore"));//this对象指向的是Jc对象
	}
	catch(e)
	{}
	
	if(this.returnValue)
	{	switch(this.ReturnMode.toLowerCase())
		{	
			case "single":
				switch(this.PopType.toLowerCase())
				{
					case "list":
						this.HtmlEle.all("_text").value = this.ReturnString;
					break;
				}		
			break;
			case "multi":
				var flds = this.ReturnParam.split(",");
				var sp = new StringParam(this.ReturnString);
				for(var i=0;i<flds.length;i++)
				{	if(sp[flds[i]])
						document.all(flds[i]).SetValue(sp[flds[i]]);
				}
			break;
			case "datalist":
			
			
				var sp=new StringParam(this.ReturnParam);
				var dataList=new DataList(rtnstr);
				var dataItems=dataList.GetItems();
				var fieldValues=new Array();
				for(var j=0;j<sp.GetCount();j++)
				{
					fieldValues[j]="";
				}			
				for(var i=0;i<dataItems.length;i++)
				{
					for(var j=0;j<sp.GetCount();j++)
					{
						fieldValues[j]+=dataItems[i].GetAttr(sp.Get(j))+","
					}
				}
				for(var j=0;j<sp.GetCount();j++)
				{
					if(fieldValues[j].substring(fieldValues[j].length-1,fieldValues[j].length)==",")
						fieldValues[j]=fieldValues[j].substring(0,fieldValues[j].length-1);
					var obj=document.all(sp.Keys[j]);
					if(obj.Co)
						obj.Co.SetValue(fieldValues[j]);
					else
						obj.value=fieldValues[j];
				}	
				
				
							
			break;
		}
		
	}
	
	try{	
		eval(this.HtmlEle.getAttribute("onreturnafter"));//this对象指向的是Jc对象
	}
	catch(e)
	{}
}


/**<doc type="protofunc" name="JcPopUpEx.SetReturn_First">
	<desc>设置JcPopUpEx的返回值</desc>
	<input>
		<param name="rtnstr" type="string">JcPopUpEx的返回值</param>
	</input>	
</doc>**/
JcPopUpEx.prototype.SetReturn_First=function(rtnstr)
{	

	this.returnValue=true;
	this.ReturnString=rtnstr;
	try
	{
		eval(this.HtmlEle.getAttribute("onreturnbefore"));//this对象指向的是Jc对象
	}
	catch(e)
	{}
	
	if(this.returnValue)
	{	switch(this.ReturnMode.toLowerCase())
		{	

			case "datalist":
			
			
				var sp=new StringParam(this.ReturnParam_First);
				var dataList=new DataList(rtnstr);
				var dataItems=dataList.GetItems();
				var fieldValues=new Array();
				for(var j=0;j<sp.GetCount();j++)
				{
					fieldValues[j]="";
				}			
				for(var i=0;i<dataItems.length;i++)
				{
					for(var j=0;j<sp.GetCount();j++)
					{
						fieldValues[j]+=dataItems[i].GetAttr(sp.Get(j))+","
					}
				}
				for(var j=0;j<sp.GetCount();j++)
				{
					if(fieldValues[j].substring(fieldValues[j].length-1,fieldValues[j].length)==",")
						fieldValues[j]=fieldValues[j].substring(0,fieldValues[j].length-1);
					var obj=document.all(sp.Keys[j]);
					if(obj.Co)
					  {
					    if (obj.Co.Type.toLowerCase()=="jcpopupex")
					  	  obj.Co.SetValue_First(fieldValues[j]);
					  	else
					  	  obj.Co.SetValue(fieldValues[j]);  
				    }
					else
						obj.value=fieldValues[j];
				}	
				
				
							
			break;
		}
		
	}
	
	try{	
		eval(this.HtmlEle.getAttribute("onreturnafter"));//this对象指向的是Jc对象
	}
	catch(e)
	{}
}


/**<doc type="protofunc" name="JcPopUpEx.SetDisabled">
	<desc>设置JcPopUpEx是否禁止</desc>
	<input>
		<param name="st" type="boolean">是否禁止</param>
	</input>
</doc>**/
JcPopUpEx.prototype.SetDisabled=function(st)
{	this.Disabled=st;
	this.HtmlEle.disabled=st;
	this.HtmlEle.all("_text").disabled=st;
	this.HtmlEle.all("_btn").disabled=st;
	if(this.Disabled)
	{
		this.HtmlEle.all("_text").style.backgroundColor=DisabledBgColor;
		this.HtmlEle.style.backgroundColor = DisabledBgColor;
	}	
	else if(this.Readonly)
	{
		this.HtmlEle.all("_text").style.backgroundColor=ReadonlyBgColor;
		this.HtmlEle.style.backgroundColor = ReadonlyBgColor;
	}	
	else
	{
		this.HtmlEle.all("_text").style.backgroundColor=NormalBgColor;
		this.HtmlEle.style.backgroundColor = NormalBgColor;
	}	
}

/**<doc type="protofunc" name="JcPopUpEx.SetReadonly">
	<desc>设置JcPopUpEx是否只读</desc>
	<input>
		<param name="st" type="boolean">是否只读</param>
	</input>
</doc>**/
JcPopUpEx.prototype.SetReadonly=function(st)
{	this.Readonly=st;
	this.HtmlEle.readOnly=st;
	this.HtmlEle.all("_text").readOnly=st;
	this.HtmlEle.all("_btn").disabled=st;
	if(!this.Disabled && this.Readonly)
	{
		this.HtmlEle.all("_text").style.backgroundColor=ReadonlyBgColor;
		this.HtmlEle.style.backgroundColor = ReadonlyBgColor;
	}	
	else
	{
		this.HtmlEle.all("_text").style.backgroundColor=NormalBgColor;
		this.HtmlEle.style.backgroundColor = NormalBgColor;
	}	
}

JcPopUpEx.prototype.Validate=function()
{	


	var value=this.GetValue()
	var value_First=this.GetValue_First()
	var validateResult=new ValidateResult();

	var valstr=this.HtmlEle.getAttribute("ValString");
	if(valstr)
		validateResult.ValidateFormElement(value,valstr);		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.all("_text").style.backgroundColor = ErrorBgColor;
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
		return validateResult;	
	}	
	

	/*	
	if(!this.AllowEmpty)
		validateResult.ValidateNotAllowEmpty(value); 
  */
		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.all("_text").style.backgroundColor = ErrorBgColor;
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
		return validateResult;
	}
		
	
	// add by chenmin 20070724 第一个人校验
	if(!this.AllowEmpty)
	validateResult.ValidateNotAllowEmpty(value_First); 

		
	if(!validateResult.Passed)	
	{
		this.HtmlEle.all("_text_First").style.backgroundColor = ErrorBgColor;
		this.HtmlEle.style.backgroundColor = ErrorBgColor;
		return validateResult;	
	}
	
	
	
	
	

	//ValString="DataType:String;Title:客户名称;Max:12;Min:5;RegExp:00000;"
}

//
//--------------------------------JcPopUpEx对象定义结束---------------------------------------------------
//








