/*POWER BY BDX-CS*/
/*E-Mail:csgmy@163.com*/
/*	杭州巴达星			*/
/*	BDX-CS-Prototype	*/
//类主体
function CS(){}
Number.prototype.NaN=function(_num){return isNaN(this)?_num:this;}
String.prototype.Trim=function(){return this.replace(/(^\s*)|(\s*$)/g,'');}
String.prototype.Format=function(){
	var _str=this;
	for(var i=0;i<arguments.length;i++){
		var _reg=new RegExp('{['+i+']}','g');
		_str=_str.replace(_reg,arguments[i]);
	}
	return _str;
}
var ie=(navigator.userAgent.indexOf('MSIE')!=-1);
$=function(_id){return document.getElementById(_id);}
$$=function(_name){return document.getElementsByName(_name);}
$t=function(_tag,_parent){return _parent.getElementsByTagName(_tag);}
$c=function(_tag){return document.createElement(_tag);}
$x=function(_xml,_name,_value){
	var _element=_xml.createElement(_name);
	var _node=_xml.createTextNode('#text');
	_node.nodeValue=_value;
	_element.appendChild(_node);
	return _element;
}
$pc=function(_obj,_parent){
	while(_obj.tagName!='BODY'&&_obj.tagName!='HTML'&&_obj!=_parent){
		_obj=_obj.parentElement||_obj.parentNode;
		if(_obj==_parent){return true;}
	}
	return false;
}
$n=function(_name,_parent){
	var _eles=$$(_name);
	for(var i=0;i<_eles.length;i++){
		if($pc(_eles[i],_parent)){return _eles[i];}
	}
	return null;
}
$p=function(_tag,_child){
	var _obj=_child.parentElement||_child.parentNode;
	while(_obj.tagName!=_tag){
		_obj=_obj.parentElement||_obj.parentNode;
		if(_obj.tagName=='BODY'||_obj.tagName=='HTML'){return null;}
	}
	return _obj;
}
//XML兼容
if(!ie){
	XMLDocument.prototype.selectNodes=function(cXPathString,xNode){
		if(!xNode){xNode=this;}
		var oNSResolver=this.createNSResolver(this.documentElement)
		var aItems=this.evaluate(cXPathString,xNode,oNSResolver,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
		var aResult=[];
		for(var i=0;i<aItems.snapshotLength;i++){aResult[i]=aItems.snapshotItem(i);}
		return aResult;
	}
	Element.prototype.selectNodes=function(cXPathString){
		if(this.ownerDocument.selectNodes){return this.ownerDocument.selectNodes(cXPathString,this);}
		else{throw '只支持XML';}
	}
	XMLDocument.prototype.selectSingleNode=function(cXPathString,xNode){
		if(!xNode){xNode=this;}
		var xItems=this.selectNodes(cXPathString,xNode);
		if(xItems.length>0){return xItems[0];}else{return null;}
	}
	Element.prototype.selectSingleNode=function(cXPathString){
		if(this.ownerDocument.selectSingleNode){return this.ownerDocument.selectSingleNode(cXPathString,this);}
		else{throw '只支持XML';}
	}
	XMLDocument.prototype.transformNode=function(xslUri){
		var xslt=new XSLTProcessor();
		xslt.importStylesheet(xslUri);
		return xslt.transformToFragment(this,document);
	}
}
//------------------------------地址栏----------------------------//
//Script匹配
CS.MATCH_SCRIPT=/<script language="javascript" type="text\/javascript">([\s\S]+)<\/script>/i
//地址匹配
CS.MATCH_URI=/(http:\/\/){0,1}([^\?#]{0,})\/((\w+).(\w+)){0,1}(\?|#){0,1}(.*)/i;
//参数匹配
CS.MATCH_QUERY=/([\?#&]{0,1})(\w+)=([^&#]*)/g;
//路径解析
CS.URI_PATH=function(_uri,_abs){
	if(_uri==null){_uri=window.location.href;}
	if(_abs==null){_abs=true;}
	var _host=window.location.host;
	var _regUri=new RegExp('^(http:\/\/'+_host+'){1,1}\/(.*)','i');
	if(!_abs){return _uri.replace(_regUri,'/$2');}
	if(_uri.match(_regUri)==null){
		if(_uri.charAt(0)!='/'){_uri='/'+_uri;}
		_uri='http://'+_host+_uri;
	}
	return _uri;
}
//路径目录
CS.URI_DIR=function(_uri,_abs){
	if(_uri==null){_uri=window.location.href;}
	_uri=CS.URI_PATH(_uri,_abs);
	return _uri.replace(CS.MATCH_URI,'$1$2/');
}
//------------------------------样式------------------------------//
//页面位置
CS.STYLE_POSITION=function(_obj){
	var _l=0;
	var _t=0;
	while(_obj.offsetParent)
	{
		_l+=_obj.offsetLeft+(_obj.currentStyle?(parseInt(_obj.currentStyle.borderLeftWidth)).NaN(0):0);
		_t+=_obj.offsetTop+(_obj.currentStyle?(parseInt(_obj.currentStyle.borderTopWidth)).NaN(0):0);
		_obj=_obj.offsetParent;
	}
	_l+=_obj.offsetLeft+(_obj.currentStyle?(parseInt(_obj.currentStyle.borderLeftWidth)).NaN(0):0);
	_t+=_obj.offsetTop+(_obj.currentStyle?(parseInt(_obj.currentStyle.borderTopWidth)).NaN(0):0);
	return{x:_l,y:_t}
}
//当前样式
CS.STYLE_CURRENT=function(_obj){
	if(_obj.currentStyle){return _obj.currentStyle;}
	else{return document.defaultView.getComputedStyle(_obj, null);}
}
//显示大小
CS.STYLE_SIZE=function(_obj){
	var _w=parseInt(_obj.offsetWidth).NaN(0);
	var _h=parseInt(_obj.offsetHeight).NaN(0);
	if(!ie){
		_w=_w-(parseInt(CS.STYLE_CURRENT(_obj).borderLeftWidth).NaN(0)+parseInt(CS.STYLE_CURRENT(_obj).borderRightWidth).NaN(0));
		_h=_h-(parseInt(CS.STYLE_CURRENT(_obj).borderTopWidth).NaN(0)+parseInt(CS.STYLE_CURRENT(_obj).borderBottomWidth).NaN(0));
	}
	return{w:_w,h:_h}
}
//屏幕尺寸
CS.STYLE_SIZE_WINDOW=function(){
	var _w=(window.innerWidth)?window.innerWidth:(document.documentElement&&document.documentElement.clientWidth)?document.documentElement.clientWidth:document.body.offsetWidth;
	var _h=(window.innerHeight)?window.innerHeight:(document.documentElement&&document.documentElement.clientHeight)?document.documentElement.clientHeight:document.body.offsetHeight;
	if(!ie&&document.body.scrollHeight>_h){_w-=20;}
	return {w:_w,h:_h};
}
//------------------------------日期------------------------------//
//转换为日期
String.prototype.ParseToDate=function(){
	var _date=this.Trim();
	if(_date==''){return new Date();}
	var _format=_date.replace(/[\d]{4,4}[\-/]{1}[\d]{1,2}[\-/]{1}[\d]{1,2}/g,'');
	if(_format!=''){return false;}
	var _group=new Date(_date.replace(/[-/]/g,'/'));
	var _arr=_date.split(/[-/]/);
	if(_arr[0]!=_group.getFullYear()||_arr[1]!=_group.getMonth()+1||_arr[2]!=_group.getDate()){return false;}
	return _group;
}
//格式化输出
Date.prototype.Format=function(_str){
	var _week=['日','一','二','三','四','五','六'];
	
	_str=_str.replace(/yyyy|YYYY/,this.getFullYear());
	_str=_str.replace(/yy|YY/,(this.getYear()%100)>9?(this.getYear()%100).toString():'0'+(this.getYear()%100));
	
	_str=_str.replace(/MM/,this.getMonth()>8?this.getMonth()+1:'0'+(this.getMonth()+1));
	_str=_str.replace(/M/g,this.getMonth()+1);
	
	_str=_str.replace(/w|W/g,_week[this.getDay()]);
	
	_str=_str.replace(/dd|DD/,this.getDate()>9?this.getDate().toString():'0'+this.getDate());
	_str=_str.replace(/d|D/g,this.getDate());
	
	_str=_str.replace(/hh|HH/,this.getHours()>9?this.getHours().toString():'0'+this.getHours());
	_str=_str.replace(/h|H/g,this.getHours());
	_str=_str.replace(/mm/,this.getMinutes()>9?this.getMinutes().toString():'0'+this.getMinutes());
	_str=_str.replace(/m/g,this.getMinutes());
	
	_str=_str.replace(/ss|SS/,this.getSeconds()>9?this.getSeconds().toString():'0'+this.getSeconds());
	_str=_str.replace(/s|S/g,this.getSeconds());
	
	return _str;
}
//日期叠加
Date.prototype.DateAdd=function(_int,_num){
	switch(_int){
		case 's':return new Date(Date.parse(this) + (1000 * _num));
		case 'n':return new Date(Date.parse(this) + (60000 * _num));
		case 'h':return new Date(Date.parse(this) + (3600000 * _num));
		case 'd':return new Date(Date.parse(this) + (86400000 * _num));
		case 'w':return new Date(Date.parse(this) + ((86400000 * 7) * _num));
		case 'q':return new Date(this.getFullYear(), (this.getMonth()) + _num*3, this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds());
		case 'm':return new Date(this.getFullYear(), (this.getMonth()) + _num, this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds());
		case 'y':return new Date((this.getFullYear() + _num), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds());
	} 
}
//日期差值
Date.prototype.DateDiff=function(_int,_date){
	if(typeof(_date)=='string'){_date=_date.PareseToDate();}
	switch(_int){
		case 's' :return parseInt((_date - this) / 1000);
		case 'n' :return parseInt((_date - this) / 60000);
		case 'h' :return parseInt((_date - this) / 3600000);
		case 'd' :return parseInt((_date - this) / 86400000);
		case 'w' :return parseInt((_date - this) / (86400000 * 7));
		case 'm' :return (_date.getMonth()+1)+((_date.getFullYear()-this.getFullYear())*12) - (this.getMonth()+1);
		case 'y' :return _date.getFullYear()-this.getFullYear();
	}
}
//闰年判断
Date.prototype.isLeapYear=function(){
	return (0==this.getYear()%4&&((this.getYear()%100!=0)||(this.getYear()%400==0)));
}
//月第一天
Date.prototype.FirstDayOfDate=function(){
	var _yyyy=this.getFullYear();
	var _mm=this.getMonth()+1;
	var _date=_yyyy+'-'+_mm+'-1'
	return _date.ParseToDate();
}
//月天数
Date.prototype.MaxDayOfDate=function(){
	var _dtf=this.FirstDayOfDate();
	var _dte=_dtf.DateAdd('m',1);
	var _num=_dtf.DateDiff('d',_dte);
	return _num;
}
//月周数
Date.prototype.MaxWeekOfDate=function(){
	var _days=this.FirstDayOfDate().getDay()+this.MaxDayOfDate();
	var _weeks=_days%7;
	if(_weeks>0){
		_days+=7-_weeks;
	}
	return _days/7;
}
//------------------------------常用操作---------------------------//
//GUID
CS.GUID=function(){
	var _hex=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'];
	var _guid='';
	for(var i=0;i<32;i++){
		if(i==8||i==12||i==16||i==20){_guid+='-';}
		_guid+=_hex[Math.floor(Math.random()*16)];
	}
	return _guid;
}
//组件调用
CS.OBJECT_CREATE=function(){
	var _ver=false;
	if(!_ver){
		for(var i=0;i<arguments.length;i++)
		{
			try{
				new ActiveXObject(arguments[i]);
				_ver=arguments[i];break;
			}
			catch(exc){;}
		}
	}
	return _ver?new ActiveXObject(_ver):null;
}
//注册事件
CS.EVENT_ATTACH=function(_obj,_action,_arg){
	if(ie){
		_obj.attachEvent('on'+_action,_arg);
	}else{
		_obj.addEventListener(_action,_arg,false);
	}
}
//注销事件
CS.EVENT_DELETE=function(_obj,_action,_arg){
	if(ie){
		_obj.detachEvent('on'+_action,_arg);
	}else{
		_obj.removeEventListener(_action,_arg,false);
	}
}
//------------------------------数据请求---------------------------//
//AJAX对象
CS.AJAX_OBJ=function(){
	if(typeof(ActiveXObject)!='undefined'){
		return CS.OBJECT_CREATE('MSXML2.XmlHttp.5.0',
								'MSXML2.XmlHttp.4.0',
								'MSXML2.XmlHttp.3.0',
								'MSXML2.XmlHttp.2.6',
								'MSXML2.XmlHttp');
	}
	else if(typeof(XMLHttpRequest)!='undefined'){return new XMLHttpRequest();}
	else{throw new Error('你的浏览器不支持XMLHTTP');}
}
//Get请求
CS.AJAX_GET=function(_path,_temp){
	if(_temp==null){_temp=false;}
	if(_path==null){_path='';}
	if(_path.Trim()==''){return null;}
	var _xml=CS.AJAX_OBJ();
	try{
		_xml.open('GET',_path,false);
		_xml.setRequestHeader('Content-Type','text/xml');
		_xml.send(null);
		return _temp?_xml.responseText:_xml.responseXML;
	}catch(err){return null;}
}
//XML加载
CS.XML_LOAD=function(_path,_temp){
	if(_temp==null){_temp=true;}
	if(_path==null){_path='';}
	if(_path.Trim()==''){return null;}
	if(typeof(ActiveXObject)!='undefined'){
		var _xml=CS.OBJECT_CREATE('Msxml2.DOMDocument.5.0',
								 'Msxml2.DOMDocument.4.0',
								 'Msxml2.DOMDocument.3.0',
								 'Msxml2.DOMDocument.2.6',
								 'Msxml2.DOMDocument');
		_xml.async=false;
		if(_temp){_xml.load(_path);}
		else{_xml.loadXML(_path);}
		return _xml;
	}else{return _temp?CS.AJAX_GET(_path):null;}
}
//------------------------------常用操作---------------------------//
CS.FORM_EXC=[];
CS.FORM_EXC['image']=true;
CS.FORM_EXC['file']=true;
CS.FORM_EXC['button']=true;
CS.FORM_EXC['reset']=true;
CS.FORM_EXC['submit']=true;
//表单数据采集
CS.FORM_COLLECTION=function(_form){
	var _has=[];
	
	var _inputs=$t('input',_form);
	for(var i=0;i<_inputs.length;i++){
		if(typeof(CS.FORM_EXC[_inputs[i].type.toLowerCase()])!='undefined'){continue;}
		if(_inputs[i].type.toLowerCase()=='radio'||_inputs[i].type.toLowerCase()=='checkbox'){
			if(_inputs[i].checked){
				if(typeof(_has[_inputs[i].name])!='undefined'){_has[_inputs[i].name]+=',';}
				else{_has[_inputs[i].name]='';}
				_has[_inputs[i].name]+=_inputs[i].value;
			}
		}else{
			if(typeof(_has[_inputs[i].name])!='undefined'){_has[_inputs[i].name]+=',';}
			else{_has[_inputs[i].name]='';}
			_has[_inputs[i].name]+=_inputs[i].value;
		}
	}
	_inputs=null;
	
	var _selects=$t('select',_form);
	for(var i=0;i<_selects.length;i++){
		if(typeof(_has[_selects[i].name])!='undefined'){_has[_selects[i].name]+=',';}
		else{_has[_selects[i].name]='';}
		_has[_selects[i].name]+=_selects[i][_selects[i].selectedIndex].value;
	}
	_selects=null;
	
	var _textareas=$t('textarea',_form);
	for(var i=0;i<_textareas.length;i++){
		if(typeof(_has[_textareas[i].name])!='undefined'){_has[_textareas[i].name]+=',';}
		else{_has[_textareas[i].name]='';}
		_has[_textareas[i].name]+=_textareas[i].value;
	}
	_textareas=null;
	
	return _has;
}
//表单重构
CS.FORM_RELOAD=function(_obj){
	if(_obj==null){_obj=document;}
	var _forms=$t('FORM',_obj);
	for(var i=0;i<_forms.length;i++){
		if(_forms[i].enctype!="multipart/form-data"){
			_forms[i].onsubmit=function(){return false;}
		}
	}
}
/*==================*/
/*		CS.Page		*/
/*==================*/
//页对象
CS.PAGE_HAS=[];
CS.PAGE_INTERVAL='200';
CS.PATH_COMMAND='/command.axd';
CS.PATH_LOADING='/loading.html';
//参数替换 
CS.PAGE_QUERY_REPLACE=function(_param,_value,_uri,_quote){
	_param=_param.toLowerCase();
	if(_quote==null){_quote='#';}
	if(_uri==null){_uri=window.location.href;}
	try{_value=encodeURIComponent(_value);}
	catch(exc){_value=null;}
	
	var _reg=new RegExp('([\?#&]{0,1})'+_param+'=([^&#]*)','g');
	if(_value==null){_uri=_uri.replace(_reg,'');}
	else{
		if(_uri.match(_reg)==null){_uri+=_quote+_param+'='+_value;}
		else{_uri=_uri.replace(_reg,'$1'+_param+'='+_value);}
	}
	return _uri;
}
/*数据页面类*/
CS.Page=function(_uri){
	if(_uri==null){_uri=window.location.href;}
	var _path=CS.URI_DIR(_uri,false);
	var _arr=_uri.match(CS.MATCH_URI);
	if(_arr==null){alert('页面装载错误！');return;}
	
	CS.PAGE_HAS['PAGE']=this;
	this.render_obj=null;
	this.render_index=0;
	this.render_id=null;
	this.uri=_uri;
	//参数
	this.query_str=_arr[7];
	this.query_arr=new Array();
	this.query_has=[];
	this.QueryInit();
	//数据
	if(_arr[3]==null){_arr[3]='';}
	var _page=_arr[3]==''?'index':_arr[4];
	this.data_path='/App_Config/Config'+_path+_page+'.xml';
	this.ui_path='/App_Config/UI'+_path;
	this.config=CS.XML_LOAD(this.data_path);
	if(this.config==null){alert('未发现数据源：'+this.data_path);return;}
	if(this.config.documentElement==null){alert('数据源格式错误：'+this.data_path);return;}
	this.loading=CS.AJAX_GET(CS.PATH_LOADING,true);
	this.data_arr=new Array();
	this.data_has=[];
	var _objects=this.config.documentElement.selectNodes('DataObject');
	for(var i=0;i<_objects.length;i++){
		var _key=_objects[i].getAttribute('ID').toUpperCase();
		this.data_arr.push(_key);
		this.data_has[_key]=new CS.DataObject(this.ui_path,_objects[i]);
	}
}
/*参数解析*/
CS.Page.prototype.QueryInit=function(){
	var _has=this.query_str.match(CS.MATCH_QUERY);
	if(_has!=null){
		for(var i=0;i<_has.length;i++){
			var _query=_has[i].split('=');
			var _param=_query[0].replace('#','').toUpperCase();
			this.query_arr.push(_param);
			this.query_has[_param]=decodeURIComponent(_query[1]);
		}
	}
}
/*参数重载*/
CS.Page.prototype.QueryReload=function(_uri){
	if(_uri!=null){this.uri=_uri;}
	var _arr=this.uri.match(CS.MATCH_PAGE);
	if(_arr==null){alert('页面装载错误！');return;}
	else{
		this.query_str=_arr[8];
		this.query_arr=new Array();
		this.query_has=[];
		this.QueryInit();
	}
}
/*参数替换*/
CS.Page.prototype.QueryReplace=function(_param,_value,_flush){
	if(_flush==null){_flush=true;}
	if(_flush){this.query_has[_param.toUpperCase()]=_value;}
	this.uri=CS.PAGE_QUERY_REPLACE(_param.toUpperCase(),_value,this.uri);
	return this.uri;
}
/*参数清除*/
CS.Page.prototype.QueryClear=function(_flush){
	if(_flush==null){_flush=true;}
	if(_flush){
		this.query_arr=new Array();
		this.query_has=[];
	}
	this.uri=this.uri.replace(CS.MATCH_URI,'$1$2/$3');
	return this.uri;
}
/*顺序输出*/
CS.Page.prototype.Render=function(_arr,_arg,_guid){
	if(_guid==null){_guid=CS.GUID();}
	if(this.render_id==null){this.render_id=_guid;}
	if(this.render_id!=_guid){return;}
	if(_arg==null){_arg=true;}
	if(_arg){
		if(typeof(CS.PAGE_HAS['RENDER'])=='function'){CS.PAGE_HAS['RENDER']();}
	}
	if(_arr==null){_arr=this.data_arr;}

	if(this.render_obj!=null){clearTimeout(this.render_obj);}
	if(this.render_index==_arr.length){
		_arr=null;
		this.render_index=0;
		this.render_id=null;
		CS.FORM_RELOAD();
		return;
	}
	var _key=_arr[this.render_index];
	if(this.data_has[_key].output_status){
		if(this.data_has[_key].status==0){this.data_has[_key].Execute();}
		else{
			if(this.data_has[_key].status==4){this.data_has[_key].status=0;this.render_index+=1;}
		}
	}else{this.render_index+=1;}
	var _this=this;
	this.render_obj=setTimeout(function(){_this.Render(_arr,false,_guid);},parseInt(CS.PAGE_INTERVAL));
}
/*==================*/
/*	CS.DataObject	*/
/*==================*/
//数据翻页
CS.DATA_PAGE_CHANGE=function(_key,_index,_param){
	_key=_key.toUpperCase();
	if(_param!=null){window.location.href=CS.PAGE_HAS['PAGE'].QueryReplace(_param,_index);}
	var _obj=CS.PAGE_HAS['PAGE'].data_has[_key];
	_obj.method_has[_obj.output_method].ConfigUpdate('page_index',_index);
	CS.PAGE_HAS['PAGE'].data_has[_key].Execute();
}
//模板切换
CS.DATA_TEMPLATE_CHANGE=function(_key,_temp,_flush,_method){
	if(_flush==null){_flush=true;}
	_key=_key.toUpperCase();
	_temp=_temp.toLowerCase();
	var _obj=CS.PAGE_HAS['PAGE'].data_has[_key];
	if(ie){
		var _xslt=CS.AJAX_GET(_obj.xsl_path,true);
		_xslt=_xslt.replace(/<xsl:template name="(\w+)" match="([\/\w]+)">/g,'<xsl:template name="$1" match="/none">');
		_xslt=_xslt.replace('<xsl:template name="'+_temp+'" match="/none">','<xsl:template name="'+_temp+'" match="/">');
		_obj.data_xsl=CS.XML_LOAD(_xslt,false);
	}else{
		var _selected=_obj.data_xsl.documentElement.selectSingleNode('//xsl:template[@name="'+_temp+'"]');
		var _temps=_obj.data_xsl.documentElement.selectNodes('//xsl:template');
		if(_selected==null){_temp=_temps[0].getAttribute('name').toLowerCase();}
		for(var i=0;i<_temps.length;i++){
			var _root=_temps[i].getAttribute('name').toLowerCase()==_temp?'/':'/none';
			_temps[i].setAttribute('match',_root);
		}
	}
	if(_flush){_obj.Execute(_method);}
}
//编辑索引
CS.DATA_EDIT_CHANGE=function(_key,_index){
	if(CS.PAGE_HAS['PAGE'].data_has[_key].data_xml==null){alert('数据源错误');return;}
	CS.PAGE_HAS['PAGE'].data_has[_key].data_xml.documentElement.setAttribute('EditIndex',_index);
	CS.PAGE_HAS['PAGE'].data_has[_key].TransForm();
}
//列表更新
CS.DATA_UPDATE=function(_key,_method,_index,_msg,_status){
	var _form=$(CS.PAGE_HAS['PAGE'].data_has[_key].panel.id+'_'+_index);
	if(_form!=null){
		CS.DATA_EXECUTE(_key,_method,_form,_msg,_status);
	}
}
//执行方法
CS.DATA_EXECUTE=function(_key,_method,_form,_msg,_status,_debug){
	if(_msg!=null){
		var _confirm=confirm(_msg);
		if(!_confirm){return;}
	}
	var _dataform=new CS.DataForm(_key,_method,_form,_status,_debug);
	_dataform.Dispose=function(){
		_dataform=null;
	}
	_dataform.Submit(_debug);
}
/*数据表单对象*/
CS.DataForm=function(_key,_method,_form,_status,_debug){
	if(_status==null){_status=true;}
	this.key=_key.toUpperCase();
	this.method=_method.toUpperCase();
	this.form=_form;
	this.upload_forms=$t('FORM',_form);
	this.upload_objs=new Array();
	for(var i=0;i<this.upload_forms.length;i++){
		if(CS.PAGE_HAS[this.upload_forms[i].id]!=null){
			this.upload_objs.push(this.upload_forms[i]);
		}
	}
	this.upload_index=0;
	this.upload_status=_status;
	
	if(!this.upload_status){
		this.upload_index=this.upload_objs.length;
		this.upload_status=true;
		return;
	}
	
	if(this.upload_objs.length>this.upload_index){
		for(var i=0;i<this.upload_objs.length;i++){
			var _obj=CS.PAGE_HAS[this.upload_objs[i].id];
			if(!_obj.Upload()){
				this.upload_status=false;break;
			}
		}
		if(this.upload_status){
			for(var i=0;i<this.upload_objs.length;i++){
				var _this=this;
				CS.PAGE_HAS[this.upload_objs[i].id].UploadStatusChange=function(){
					if(this.status==4){
						_this.upload_index=i+1;
						_this.Submit(_debug);
					}else{
						if(this.status==2||this.status==3){_this.Dispose();}
					}
				}
			}
		}
	}
}
/*数据表单提交*/
CS.DataForm.prototype.Submit=function(_debug){
	if(this.upload_index<this.upload_objs.length&&this.upload_status){
		this.upload_objs[this.upload_index].submit();
		CS.PAGE_HAS[this.upload_objs[this.upload_index].id].Progress();
	}else{
		if(this.upload_status){
			var _has=CS.FORM_COLLECTION(this.form);
			var _config=CS.PAGE_HAS['PAGE'].data_has[this.key].method_has[this.method];
			for(var i=0;i<_config.query_arr.length;i++){
				if(typeof(_has[_config.query_arr[i]])!='undefined'){
					_config.query_has[_config.query_arr[i]]=_has[_config.query_arr[i]];
				}else{
					_config.query_has[_config.query_arr[i]]=null;
				}
			}
			CS.PAGE_HAS['PAGE'].data_has[this.key].Execute(this.method,_debug);
		}
		this.Dispose();
	}
}
/*数据表单注销*/
CS.DataForm.prototype.Dispose=function(){}
/*数据对象*/
CS.DataObject=function(_ui,_node){
	this.key=_node.getAttribute('ID').toUpperCase();
	this.config=_node;
	this.panel=$(_node.getAttribute('Panel'));
	this.status=0;
	
	this.obj=null;
	this.xml_msg=null;
	
	this.xsl_path=_ui+_node.getAttribute('UI')+'.xsl';
	this.data_xsl=CS.XML_LOAD(this.xsl_path);
	this.data_xml=null;

	this.output_status=false;
	if(this.panel!=null&&_node.getAttribute('Output')!='false'){
		this.output_status=true;
	}
	this.output_method=_node.getAttribute('Default')==null?'SELECT':_node.getAttribute('Default').toUpperCase();
	
	this.method_has=[];
	for(var i=0;i<_node.childNodes.length;i++){
		var _method=_node.childNodes[i];
		if(_method.nodeName!='#text'){
			this.method_has[_method.nodeName.toUpperCase()]=new CS.DataConfig(_method);
		}
	}
}
/*数据请求*/
CS.DataObject.prototype.Post=function(_query,_status){
	if($('DEBUG')!=null){
		$('DEBUG').innerHTML=_query;
		var _confirm=confirm('继续？');
		if(!_confirm){return;}
	}
	
	if(_status==null){_status=true;}
	
	this.obj=CS.AJAX_OBJ();
	this.obj.open('POST',CS.PATH_COMMAND,_status);
	this.obj.setRequestHeader('Content-Type','application/x-www-form-urlencoded;');
	this.obj.send(_query);
	
	var _this=this;
	this.obj.onreadystatechange=function(){
		if(_this.obj!=null){
			_this.status=_this.obj.readyState;
			if(_this.obj.readyState==4){
				try{
					if(_this.obj.status==200){_this.TransForm();}
					else{
						alert('发生错误：'+_this.obj.status);
						_this.obj=null;
					}
				}catch(exc){}
			}else{
				try{_this.panel.innerHTML=CS.PAGE_HAS['PAGE'].loading;}catch(exc){}
			}
		}
	}
	
	if(!_status){this.TransForm();}
}
/*数据解析*/
CS.DataObject.prototype.TransForm=function(){
	this.xml_msg=this.obj==null?null:this.obj.responseXML;
	this.obj=null;
	
	var _flush=false;
	if(this.xml_msg!=null){
		if(this.xml_msg.documentElement.nodeName!='DocumentElement'){
			var _msg=null;
			if(this.xml_msg.documentElement.selectSingleNode('//Content')!=null){
				_msg=this.xml_msg.documentElement.selectSingleNode('//Content').childNodes[0].nodeValue;
			}
			var _linknode=this.xml_msg.documentElement.selectSingleNode('//Link');
			var _link=_linknode==null?window.location.href:_linknode.childNodes[0].nodeValue;
			var _intr=this.xml_msg.documentElement.nodeName.toUpperCase();
			if(_intr!='AUTHORITY'&&_msg!=null){alert(_msg);}
			switch(_intr){
				case 'RELOAD':_flush=true;break;
				case 'CALLBACK':this.xml_msg=null;this.CallBack();return;
				case 'MESSAGE':this.xml_msg=null;return;
				case 'AUTHORITY':
					/*var _login=new CS.DialogFrame(_link);
					CS.PAGE_HAS['AUTHORITY']=_login;
					this.xml_msg=null;*/
					this.xml_msg=null;window.location.href=_link;
					return;
				case 'REURL':this.xml_msg=null;window.location.href=_link;return;
				default:_flush=false;break;
			}
		}else{
			this.data_xml=this.xml_msg;
			this.data_xml.documentElement.setAttribute('EditIndex','0');
			this.PreRender();
		}
	}
	this.xml_msg=null;

	if(_flush){
		try{this.Execute();}catch(exc){}
	}else{
		if(this.output_status){
			if(this.data_xsl==null){alert('数据装载错误'+this.xsl_path);return;}
			if(this.panel==null){alert(this.key+'无法定位输出容器');return;}
			if(this.data_xml!=null){
				try{
					var _html=this.data_xml.transformNode(this.data_xsl);
					this.panel.innerHTML='';
					if(ie){
						try{this.panel.innerHTML=_html;}
						catch(exc){alert(this.key+':请检查页面代码\r\n'+_html);return;}
						try{
							var _script=_html.match(CS.MATCH_SCRIPT);
							if(_script!=null){
								var _script_element=document.createElement('script');
								_script_element.text=_script[1];
								this.panel.insertAdjacentElement('beforeEnd',_script_element);
							}
						}catch(exc){}
					}else{
						this.panel.appendChild(_html);
					}
					this.Formated();
				}catch(exc){alert('转换出错'+exc.message);return;}
			}
		}
	}
}
/*执行查询*/
CS.DataObject.prototype.Execute=function(_method,_status,_debug){
	if(_method==null){_method=this.output_method;}
	if(_debug==null){_debug=false;}
	try{
		var _query=this.method_has[_method].ConfigInit();
		if(_debug){alert(_query);}
		if(_query.match(/[\u4e00-\u9fa5]/g)!=null){alert(_query);this.status=4;}
		else{this.Post(_query,_status);}
	}catch(exc){
		alert('未发现方法：'+this.key+'.'+_method);
	}
}
/*关联方法*/
CS.DataObject.prototype.CallBack=function(){}
CS.DataObject.prototype.PreRender=function(){}
CS.DataObject.prototype.Formated=function(){}
/*==================*/
/*	CS.DataConfig	*/
/*==================*/
/*配置对象*/
CS.DataConfig=function(_node){
	if(_node==null){alert('错误的配置类');return;}
	this.config=_node;
	this.key=_node.getAttribute('Method').toUpperCase();
	this.query_has=[];
	this.query_reg=[];
	this.query_msg=[];
	this.query_arr=new Array();
	for(var i=0;i<this.config.childNodes.length;i++){
		var _param=this.config.childNodes[i];
		if(_param.nodeName!='#text'){
			this.query_arr.push(_param.nodeName);
			this.query_reg[_param.nodeName]=null;
			if(_param.selectSingleNode('reg')==null){
				this.query_has[_param.nodeName]=_param.childNodes.length>0?_param.childNodes[0].nodeValue:'';
			}else{
				this.query_has[_param.nodeName]=_param.selectSingleNode('value').childNodes.length>0?_param.selectSingleNode('value').childNodes[0].nodeValue:'';
				this.query_reg[_param.nodeName]=_param.selectSingleNode('reg').childNodes.length>0?new RegExp(_param.selectSingleNode('reg').childNodes[0].nodeValue):null;
				this.query_msg[_param.nodeName]=_param.selectSingleNode('msg').childNodes.length>0?_param.selectSingleNode('msg').childNodes[0].nodeValue:'';
			}
		}
		_param=null;
	}
}
/*配置数据*/
CS.DataConfig.prototype.ConfigInit=function(){
	var _query='';
	var _exc='';
	var _flag=false;
	for(var i=0;i<this.query_arr.length;i++){
		if(this.query_has[this.query_arr[i]]==null){continue;}
		if(this.query_reg[this.query_arr[i]]!=null){
			if(this.query_has[this.query_arr[i]].match(this.query_reg[this.query_arr[i]])==null){
				_flag=true;
				_exc+=this.query_msg[this.query_arr[i]]+';';
			}
		}
		_query+='&'+this.query_arr[i]+'='+encodeURIComponent(this.query_has[this.query_arr[i]]);
	}
	return _flag?'发生错误：'+_exc:'APPKEY='+this.key+_query;
}
/*更新配置*/
CS.DataConfig.prototype.ConfigUpdate=function(_param,_value){
	//if(this.query_has[_param]==null){alert('错误的参数名');return;}
	this.query_has[_param]=_value;
}
/*==================*/
/*	CS.DialogFrame	*/
/*==================*/
//异步卸载
CS.DialogDispose=function(_key){
	CS.PAGE_HAS[_key].Dispose();
}
//对话框
CS.DialogFrame=function(_arg){
	this.frame=$c('iframe');
	this.dialog=$c('div');
	this.frame.setAttribute('style','-moz-opacity:0.9;opacity:0.9;');
	with(this.frame){
		frameborder='0';
		scrolling='no';
		allowtransparency='true';
		style.position='absolute';
		style.zIndex=996;
		style.top='0px';
		style.left='0px';
		style.filter='alpha(opacity=80)';
	}
	this.dialog.setAttribute('style','-moz-opacity:0.9;opacity:0.9;');
	with(this.dialog.style){
		background='#999';
		position='absolute';
		zIndex=997;
		top='0px';
		left='0px';
		filter='alpha(opacity=80)';
	}
	document.body.appendChild(this.frame);
	document.body.appendChild(this.dialog);
	this.Resize();
	var _this=this;
	this.arg_resize=function(){_this.Resize();}
	CS.EVENT_ATTACH(window,'scroll',this.arg_resize);
	CS.EVENT_ATTACH(window,'resize',this.arg_resize);
	this.dialog_show=_arg;
	if(typeof(_arg)=='function'){
		_arg(_this);
	}
}
//窗体调整
CS.DialogFrame.prototype.Resize=function(){
	var _win=CS.STYLE_SIZE_WINDOW();
	with(this.frame.style){
		width=_win.w+'px';
		height=_win.h+'px';
		display='block';
	}
	with(this.dialog.style){
		width=_win.w+'px';
		height=_win.h+'px';
		paddingTop=window.document.documentElement.scrollTop+'px';
		display='block';
	}
}
//卸载对象
CS.DialogFrame.prototype.Dispose=function(){
	CS.EVENT_DELETE(window,'scroll',this.arg_resize);
	CS.EVENT_DELETE(window,'resize',this.arg_resize);
	document.body.removeChild(this.frame);
	document.body.removeChild(this.dialog);
}

