function doEnterprise(actionType, id, usertype, area) {
	var title = '';
	var categoryDisabled = false;
	var userTypeDisabled = true;
	var url = 'enterprises_update.action';
	var gridReflesh = false;
	var idReadOnly = true;
	if(actionType == 'updateInfo'){
		categoryDisabled = true;
		title = '企业信息维护';
	}
	if(actionType == 'register'){
		url = 'enterprises_register.action';
		title = '用户注册';
		idReadOnly = false;
		userTypeDisabled = false;
	}
	if(actionType == 'Operator'){
		title = '申报用户查看与审查';
		gridReflesh = true;
		userTypeDisabled = true;
	}
	if(actionType == 'administrator'){
		title = '申报用户查看与审查';
		gridReflesh = true;
		userTypeDisabled = false;
	}
	
	function field(name, fieldLabel, inputType) {
		return { fieldLabel: fieldLabel, inputType: inputType, name: name };
	}
	
	function twoColumnedPanel(leftColumnItems, rightColumnItems) {
		return {
			baseCls: 'x-plain',
			defaults: {
				baseCls: 'x-plain',
				//columnWidth: 0.5,
				defaults: { anchor: '94%'},
				layout: 'form'
			},
			items: [
				{ defaultType: 'textfield',	items: leftColumnItems, columnWidth: 0.5 },
				{ defaultType: 'textfield', items: rightColumnItems, columnWidth: 0.5 }
			],
			layout: 'column'
		};
	}
	function certainLengthTextField(name, fieldLabel, anchors, maxLength, allowBlank, enabled) {
		return new Ext.form.TextField({maxLength: maxLength, allowBlank: false||allowBlank, anchor: anchors, name: name, fieldLabel: fieldLabel ,disabled:false||enabled });
	};
	var utypeCombo = new Ext.form.ComboBox({
		mode: 'local',
		hiddenName:'utype',
		allowBlank: false,
		disabled: userTypeDisabled,
		valueField:'value',
		store: new Ext.data.SimpleStore({
//		data: [['个人','A'], ['企业','B'],['政府机关','C'],['事业单位','D'],['组织','E']],
		data: [['企业','B'],['政府机关','C'],['事业单位','D'],['组织','E']],
		fields: ['description','value' ]
		}),
		fieldLabel:'用户类型',
		displayField: 'description'
	});
	var categoryCombo = new Ext.form.ComboBox({
								id: 'theCategoryCombo',
								mode: 'local',
								hiddenName:'category',
								valueField:'value',
								disabled: categoryDisabled,
								store: new Ext.data.SimpleStore({
									data: [['　',''],['经认定过的软件企业',1], ['其他企业',2]],
									fields: ['description','value' ]
								}),
								fieldLabel:'企业性质',
								displayField: 'description'
							});
	var roomCombo = new Ext.form.ComboBox({
									mode: 'local',
									anchor: '95%',
									allowBlank: false,
									listWidth: 350,
									displayField: 'description',
									disabled: userTypeDisabled,
									hiddenName: 'room',
									store: new Ext.data.SimpleStore({
										data: [
										//下拉框的第二个值必须和window-operator.js对应的处室的值的字母相对应
										//如’无线电频率指配‘属于无线电管理处的，他的值A1 的第一个字母’A' 对应于window-operator.js中处室——无线电管理处的值是 ‘A’，第二个字母不要紧，只要不重复就可以了
//											['无线电频率指配','A1'], 
//											['研制、生产无线电发射设备时进行实效发射试验的审批','A2'], 
//											['无线电台（站）的设置及变更审批','A3'], 
//											['研制或生产无线电发射设备的型号','A4'], 
//											['无线电发射设备进关核准--进口申请','A5'], 
//											['无线电发射设备进关核准--进关申请','A6'], 
//											['无线电台（站）呼号审批','A7'],
//											['建立卫星通信网和设置卫星地球站审批','A8'],
//											['“三高”地点接纳设置无线寻呼发射基站的“三高”产权单位备案','A9'],
											
											['浙江省信息服务业发展专项资金项目','B1'],
											['软件产品登记','B2'],
											['软件企业认定','B3'],
											['软件企业年审','B4'],
											['软件企业更名','B5'],
											['软件产品更名','B6'],
											['软件产品延续','B7'],
											['浙江省信息服务业发展专项资金检查','B8'],
											['省电子信息产业发展专项申报','E1'],
											
											['计算机信息系统集成', 'C']
											],
										fields: ['description','value' ]
									}),
									valueField: 'value',
									fieldLabel: '申报类型'
								});
	var user_store = new Ext.data.Store({
		autoLoad: false,
		baseParams: { type: 'Enterprise' },
		reader: new Ext.data.JsonReader({ id: 'id', root: 'records' }, [ 'id', 'region' ]),
		url: 'users_list.action'
	});
	function setFieldDisabled(i){
		Ext.each(i, function(item, index) {
			if(Ext.getCmp(item)){
				Ext.getCmp(item).setDisabled(true);
			}
		});
	}
	function setFieldEnabled(i){
		Ext.each(i, function(item, index) {
			if(Ext.getCmp(item)){
				Ext.getCmp(item).setDisabled(false);
			} 
		});
	}
	
	function removeFields(i){
		Ext.each(i, function(item, index) {
			if(Ext.getCmp(item)){
				Ext.WindowMgr.getActive().items.get(0).form.remove(Ext.getCmp(item));
			} 
		});
	}
	
	function addFields(i){
		Ext.each(i, function(item, index) {
			if(Ext.getCmp(item)){
				Ext.WindowMgr.getActive().items.get(0).form.add(Ext.getCmp(item));
			} 
		});
	}
	function addFieldSet(name){
		if(Ext.getCmp(name)){
			Ext.WindowMgr.getActive().items.get(0).form.add(Ext.getCmp(name));
		} 
	}
	function removeFieldSet(name){ 
		if(Ext.getCmp(name)){
			Ext.WindowMgr.getActive().items.get(0).form.remove(Ext.getCmp(name));
		} 
	}
	function setFieldSetEnabled(name){
		if(Ext.getCmp(name)){
				Ext.getCmp(name).setDisabled(false);
		} 
	}
	function setFieldSetDisabled(name){
		if(Ext.getCmp(name)){
			Ext.getCmp(name).setDisabled(true);
		} 
	}
				var basicField = {
				    items: [
				    	new Ext.form.TextField({allowBlank: false, regex:/^[A-Za-z0-9_\-\u4e00-\u9fa5]{2,20}$/,regexText:'用户名为2-20位的字母、中文、数字、中划线、下划线或其组合',
								name: 'id', fieldLabel: '用户名', readOnly:idReadOnly, anchor:'47%'}),
						{
							baseCls: 'x-plain',
							defaults: {
								baseCls: 'x-plain',
								columnWidth: 0.5,
								defaults: { anchor: '94%'},
								layout: 'form'
							},
							items: [
								{ defaultType: 'textfield',	items: utypeCombo, columnWidth: 0.5 },
								{ defaultType: 'textfield', items: roomCombo, columnWidth: 0.5 }
							],
							layout: 'column'
						},
						{
							baseCls: 'x-plain',
							defaults: {
								baseCls: 'x-plain',
								columnWidth: 0.33,
								layout: 'form'
							},
							items: [{ 
								items: [
									new Ext.form.ComboBox({
									autoLoad: false,
									displayField: 'cityName',
									id: 'province',
									disabled: userTypeDisabled,
									allowBlank: false,
									store: Ext.StoreMgr.add('store-province', new Ext.data.Store({
										reader: new Ext.data.JsonReader({ id: 'id', root: 'areas' }, [ 'id','areaId','cityName' ]),
										url: 'areas_list.action'
									})),
									valueField: 'id',
									anchor: '93%',
									fieldLabel: '省  市'
								})],
								labelWidth: 75,
								columnWidth: 0.4
							},{
								 items: [
								 	new Ext.form.ComboBox({
									autoLoad: false,
									allowBlank: false,
									//emptyText:'请先选择省市',
									disabled: userTypeDisabled,
									displayField: 'cityName',
									id: 'area',
									store: Ext.StoreMgr.add('store-area', new Ext.data.Store({
										reader: new Ext.data.JsonReader({ id: 'id', root: 'citys' }, [ 'id','areaId','cityName' ]),
										url: 'cities_list.action'
									})),
									valueField: 'id',
									anchor: '89%',
									fieldLabel: '地  市' 
								})],
								columnWidth: 0.3
							},{
								 items: [
								 	new Ext.form.ComboBox({
									autoLoad: false,
									allowBlank: false,
									//emptyText:'请先选择地市',
									disabled: userTypeDisabled,
									displayField: 'cityName',
									hiddenName: 'region',
									id: 'city',
									store: Ext.StoreMgr.add('store-city', new Ext.data.Store({
										reader: new Ext.data.JsonReader({ id: 'id', root: 'citys' }, [ 'id','areaId','cityName' ]),
										url: 'cities_list.action'
									})),
									valueField: 'id',
									anchor: '89%',
									fieldLabel: '县区市' 
								})],
								columnWidth: 0.3
							}],
							labelWidth: 40,
							layout: 'column'
						}
					],
					title: '帐户信息',
					id: 'basicField'
				};
				var enterpriseField = {
				    items: [
				    	new Ext.form.TextField({maxLength: 50, allowBlank: false,anchor:'97%', name: 'name',readOnly: userTypeDisabled, fieldLabel: '单位名称', id:'enterpriseName'}),
						new Ext.form.TextField({maxLength: 50, allowBlank: false,anchor:'97%', name: 'address', fieldLabel: '单位地址',id:'enterpriseAddress'}),
						twoColumnedPanel(
							new Ext.form.TextField({allowBlank: true, anchor: '90%', name: 'code',readOnly: userTypeDisabled, fieldLabel: '组织机构代码',id:'enterpriseCode',regex:/^[A-Za-z0-9]{8}-[A-Za-z0-9]{1}$/,regexText:'组织机构代码为8位数字（或字母）+中划线+1位数字（或字母），且必须为半角符'}),
							categoryCombo
						),
						{	items: new Ext.form.TextField({
								maxLength: 150, anchor:'97%', name: 'codeReason', 
								fieldLabel: '无组织机构代码的原因',id:'enterpriseCodeReason', 
								allowBlank: false
							}),
							baseCls: 'x-plain',
							labelWidth: 124,
							layout: 'form'
						},
						twoColumnedPanel(
							[ new Ext.form.TextField({maxLength: 30, allowBlank: false, anchor: '90%', name: 'commercialId',readOnly: userTypeDisabled, fieldLabel: '工商注册号',
								 id: 'commercialId'}), 
							  new Ext.form.TextField({maxLength: 16, allowBlank: false, name: 'representitive', fieldLabel: '法定代表人',id:'representitive'}),	
								new Ext.form.TextField({maxLength: 25, allowBlank: false, anchor: '90%', minLength:6, id: 'enterprisePhone',
									name: 'phone', fieldLabel: '电  话', regex:/^\d+-?\d+$/, regexText: '电话号码只能是纯数字或数字-数字'}) ],
							[ new Ext.form.NumberField({maxLength: 6,minLength: 6,maxLengthText: '邮政编码为6位数字',maxLengthText:'邮政编码为6位数字', allowBlank: false, anchor: '90%', name: 'zip', fieldLabel: '邮政编码',id:'enterpriseZip'}),
								new Ext.form.TextField({maxLength: 16, allowBlank: false, name: 'contact', fieldLabel: '工作联系人',id:'enterpriseContact'}),
								new Ext.form.TextField({maxLength: 25, allowBlank: true, anchor: '90%', minLength:6, id: 'enterpriseFax',
									name: 'fax', fieldLabel: '传  真', regex:/^\d+-?\d+$/, regexText: '传真只能是纯数字或数字+中划线+数字'})
							]
						),
						twoColumnedPanel(
							new Ext.form.TextField({allowBlank: false, anchor: '90%',name: 'email',
								 vtype: 'email', fieldLabel: 'E-mail',maxLength: 40, id:'enterpriseEmail' }),
							new Ext.form.TextField({ name: 'url',   vtype: 'url'  , fieldLabel: '网  址',
								maxLength: 30, id:'enterpriseUrl' })
						),
						new Ext.form.TextArea({ anchor: '97% 30%', fieldLabel: '简介', name:'remark',maxLength:500, grow:true, preventScrollbars :true,allowBlank: false, id: 'enterpriseRemark'})
					], 
					title: '详细信息',
 					id: 'enterpriseField'
				};
				var personField = {
				    items: [
				    	twoColumnedPanel(
				    		new Ext.form.TextField({maxLength: 30, anchor:'97%', name: 'name', fieldLabel: '姓名', id:'personName',allowBlank: false}),
				    		new Ext.form.TextField({maxLength: 30, anchor: '90%', name: 'code', fieldLabel: '证件号码',id:'personCode',allowBlank: false})
				    	),
						twoColumnedPanel(
							new Ext.form.TextField({maxLength: 25, allowBlank: false, anchor: '90%', minLength:6, id:'personPhone',
									name: 'phone', fieldLabel: '电  话', regex:/^\d+-?\d+$/, regexText: '电话号码只能是纯数字或数字+中划线+数字'}),
							new Ext.form.TextField({allowBlank: false, anchor: '90%',name: 'email',
								 vtype: 'email', fieldLabel: 'E-mail',maxLength: 40, id:'personEmail' })
							
						),
						new Ext.form.TextField({maxLength: 50, allowBlank: false,anchor:'97%', name: 'address', fieldLabel: '通信地址', id:'personAddress'}),
						twoColumnedPanel(
							new Ext.form.NumberField({maxLength: 6,minLength: 6,maxLengthText: '邮政编码为6位数字',id:'personZip',
									mixLengthText:'邮政编码为6位数字', allowBlank: false, anchor: '90%', name: 'zip', fieldLabel: '邮政编码'}),
							new Ext.form.TextField({ name: 'url',   vtype: 'url'  , fieldLabel: '网  址',
								maxLength: 30, id:'personUrl' })
						),	
						new Ext.form.TextArea({ anchor: '97% 30%', fieldLabel: '备注', name:'remark',maxLength:500, grow:true, preventScrollbars :true, id:'personRemark'})
					],
					title: '详细信息', 
					id: 'personField'
				};
				Ext.getCmp('province').on('select', function(combo, record) {
					Ext.getCmp('area').clearValue();
					Ext.getCmp('city').clearValue();
					
					Ext.StoreMgr.get('store-area').baseParams = { areaId: record.get('id') };
					Ext.StoreMgr.get('store-area').load();
				});
				Ext.getCmp('area').on('select', function(combo, record) {
					Ext.getCmp('city').clearValue();
					
					Ext.StoreMgr.get('store-city').baseParams = { areaId: record.get('id') };
					Ext.StoreMgr.get('store-city').load();
				});
				if(Ext.getCmp('enterpriseCode')){
					Ext.getCmp('enterpriseCode').on('blur', function(){
						if(Ext.getCmp('enterpriseCode').getValue() == '' || Ext.getCmp('enterpriseCode').getValue() == null){
							Ext.getCmp('enterpriseCodeReason').setDisabled(false);
							Ext.getCmp('enterpriseCodeReason').allowBlank = false;
						} else {
							Ext.getCmp('enterpriseCodeReason').allowBlank = true;
							Ext.getCmp('enterpriseCodeReason').setValue();
							Ext.getCmp('enterpriseCodeReason').setDisabled(true);
						}
					});
				}
				
				var items = [];
	
		
	if(actionType == 'updateInfo' || actionType == 'Operator' || actionType == 'administrator') {
		if(usertype == 'A'){
			items = [basicField, personField];  
			setFieldDisabled(['enterpriseName','enterpriseAddress','enterpriseCode','commercialId','representitive','enterprisePhone','enterpriseContact','enterpriseUrl','enterpriseRemark','enterpriseEmail','enterpriseFax','enterpriseZip','category', 'enterpriseCodeReason']);
			if(Ext.getCmp('enterpriseField')){
				Ext.getCmp('enterpriseField').setVisible(false);
			}
		} else {
			items = [basicField, enterpriseField]; 
			setFieldDisabled(['personName','personAddress','personCode','personPhone','personZip','personUrl','personRemark','personEmail']);
			if(Ext.getCmp('personField')){
				Ext.getCmp('personField').setVisible(false);
			} 
		}
		if (!userTypeDisabled&&area) {   
			//地级市管理员
			setFieldDisabled(['province','area']);
		} else if (!userTypeDisabled&&!area){  
			//admin1不做操作
		} else if (userTypeDisabled&&area){ 
			//地市审核员
			setFieldDisabled(['province','area','city']);
		}
	} else {
		items = [basicField, enterpriseField, personField]; 
	}	
		
	if(actionType == 'register'){
		items.push({
				title:'安全信息',
				items:twoColumnedPanel(
					[new Ext.form.TextField({maxLength: 16, allowBlank: false, anchor: '90%', minLength:6,
						name: 'password', fieldLabel: '密  码', inputType:'password'})], 
					[new Ext.form.TextField({maxLength: 16, allowBlank: false, anchor: '90%',minLength:6, 
						name: 'confirm', fieldLabel: '确认密码', inputType:'password'})]
				)
			});
	}
	function pushCombobox(comboboxDisabled){
		items.push({
				items: [
					new Ext.form.ComboBox({
									allowBlank: true,
									mode: 'local',
									hiddenName:'enabled',
									valueField:'value',
									disabled: comboboxDisabled,
									store: new Ext.data.SimpleStore({
										data: [['通过',true], ['不通过',false] ],
										fields: ['description','value' ]
									}),
									fieldLabel:'<span style="color:red">审核结果</span>',
									listeners: {
										select: function(combo, record, index) {
											if (index==0) {
												Ext.getCmp('typeComb').allowBlank= false;
											} else {
												Ext.getCmp('typeComb').allowBlank= true;
											}
										}
									},
									displayField: 'description'
								}),
							new Ext.form.ComboBox({
									allowBlank: true,
									mode: 'local',
									hiddenName:'type',
									valueField:'value',
									id: 'typeComb',
									disabled: comboboxDisabled,
									store: new Ext.data.SimpleStore({
										data: [['　','null'], ['县级企业','B'], ['地级市企业','C'], ['省属企业','D'] ],
										fields: ['description','value' ]
									}),
									fieldLabel:'<span style="color:red">企业类型</span>',
									displayField: 'description'
								}),
							new Ext.form.ComboBox({
									allowBlank: true,
									mode: 'local',
									hiddenName:'provinceDepartment',
									valueField:'value',
									id: 'provinceDepartmentComb',
									disabled: comboboxDisabled,
									store: new Ext.data.SimpleStore({
										data: [['　','Z'],['科技厅','O'], ['教育厅','P'], ['经信委','B'], ['广电厅','Q'], ['发改委','R'], ['其他主管部门','S'] ],
										fields: ['description','value' ]
									}),
									fieldLabel:'<span style="color:red">主管部门</span>',
									displayField: 'description'
								})
						
					],
					title: '<span style="color:red">用户审核</span>'
			});
	};
	
	
	
	if(actionType == 'Operator' || actionType == 'administrator'){
			pushCombobox(false);
	}else if(actionType == 'updateInfo'){
			pushCombobox(true);
	}
	
	if(Ext.getCmp('typeComb')){
		Ext.getCmp('typeComb').on('select',function(combo, record){
			if(record.get('value')!= 'D'){
				Ext.getCmp('provinceDepartmentComb').clearValue();
				Ext.getCmp('provinceDepartmentComb').setDisabled(true);
			} else {
				Ext.getCmp('provinceDepartmentComb').setDisabled(false);
			}
		});
	}
	
	var entWindow = new Ext.Window({
		bbar: ['->', {
			handler:  function() {
						
						Ext.getCmp('saveButton').setDisabled(true);
						Ext.WindowMgr.getActive().items.first().getForm().submit({
							failure: function(form, action) {
								if(action.failureType == 'client' ){
									alert('输入项有误，请查看红色感叹号处！');
								} else if(action.failureType == 'server') {
									var application = action.result;
									if (null!=application.errors.name) {
										alert('单位名称已存在，说明你单位已注册过账户，不可重复注册，请向你单位内相关工作人员索取账户信息！');
									} else if (null!=application.errors.id){
										alert('用户名已存在，说明该用户名已被使用，不可重复注册，请改用其他用户名！');
									} else if (null!=application.errors.commercialId){
										alert('工商注册号已存在，说明你单位已注册过账户，不可重复注册，请向你单位内相关工作人员索取账户信息！');
									} else if (null!=application.errors.code){
										alert('组织机构代码已存在，说明你单位已注册过账户，不可重复注册，请向你单位内相关工作人员索取账户信息！');
									} else {
										alert('提交失败，请检查输入项格式是否正确！');
									}
								}
								Ext.getCmp('saveButton').setDisabled(false);
//								alert("提交失败，请检查输入项格式是否正确!");
							},
							success: function() {
								Ext.Msg.show({
									buttons: Ext.MessageBox.OK,
									fn: function(){ 
										Ext.WindowMgr.getActive().close();
										if(actionType == 'register') {
											window.open('/jihuo.html','', 'height=680,width=1000,left=0,top=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
										}
									},
									icon: Ext.MessageBox.INFO,
									msg: '操作成功',
									title: '信息'
								});
								
								if(gridReflesh){ 
									Ext.StoreMgr.get('store-enterprise').load();
								}
							},
							url: url
						});
				},text: '提交',
				id:'saveButton'
			},'-', {
			 handler: function(){ 
				Ext.WindowMgr.getActive().close();
			 }, text: '取消' 
			 }
			 ],
		height:560, 
		//autoHeight: true,
		autoScroll: true,
		items: new Ext.form.FormPanel({
			id: 'form',
			defaults: { labelWidth: 75 },
			defaultType: 'fieldset',
			items: items,
			listeners: {
			add: function(container, component) {
				this.doLayout();
				this.doLayout();
				Ext.each(component.findBy(function(component) { return component.isXType('field'); }), function(item) { container.form.add(item); });
			},
			remove: function(container, component) {
				Ext.each(component.findBy(function(component) { return component.isXType('field'); }), function(item) { container.form.remove(item); });
			}
		}
			
		}),
		maximizable: false,
		id: 'window-enterprise',
		title: title,
		width: 680
	});
	var i = 0;
	/*
	utypeCombo.on('select',function(combo, record) {
					if(record.get('value')== 'A') {
						if(i != 0){
							setFieldSetEnabled('personField');
							addFieldSet('personField');
						}
						setFieldSetDisabled('enterpriseField');
						removeFieldSet('enterpriseField');
						Ext.getCmp('enterpriseField').setVisible(false);
						Ext.getCmp('personField').setVisible(true);
					}else {
						if( i != 0){
							setFieldSetEnabled('enterpriseField');
							addFieldSet('enterpriseField');
						}
						setFieldSetDisabled('personField');
						removeFieldSet('personField');
						if(record.get('value')!= 'B') {
							Ext.getCmp('commercialId').setValue();
							setFieldDisabled(['commercialId']);
							removeFields(['commercialId']);
						}
						Ext.getCmp('personField').setVisible(false);
						Ext.getCmp('enterpriseField').setVisible(true);
					}
				i++;
				});
		*/
		utypeCombo.on('select',function(combo, record, index) {
//					if(index == 0) {
//						if(i != 0){
//							addFields(['personName','personAddress','personCode','personPhone','personUrl','personRemark','personEmail','personZip']);
//						}
//						setFieldEnabled(['personName','personAddress','personCode','personPhone','personUrl','personRemark','personEmail','personZip']);
//						setFieldDisabled(['enterpriseName','enterpriseAddress','enterpriseCode','commercialId','representitive','enterprisePhone','enterpriseContact','enterpriseUrl','enterpriseRemark','enterpriseEmail','enterpriseFax','enterpriseZip','category', 'enterpriseCodeReason']);
//						removeFields(['enterpriseName','enterpriseAddress','enterpriseCode','commercialId','representitive','enterprisePhone','enterpriseContact','enterpriseUrl','enterpriseRemark','enterpriseEmail','enterpriseFax','enterpriseZip','category', 'enterpriseCodeReason']);
//						if(Ext.getCmp('enterpriseField')){
//							Ext.getCmp('enterpriseField').setVisible(false);
//						}
//						if(Ext.getCmp('personField')){
//							Ext.getCmp('personField').setVisible(true);
//						}
//					}else {
						if( i != 0){
							addFields(['enterpriseName','enterpriseAddress','enterpriseCode','commercialId','representitive','enterprisePhone','enterpriseContact','enterpriseUrl','enterpriseRemark','enterpriseEmail','enterpriseFax','enterpriseZip','category', 'enterpriseCodeReason']);
						}
						setFieldEnabled(['enterpriseName','enterpriseAddress','enterpriseCode','commercialId','representitive','enterprisePhone','enterpriseContact','enterpriseUrl','enterpriseRemark','enterpriseEmail','enterpriseFax','enterpriseZip','category', 'enterpriseCodeReason']);
						setFieldDisabled(['personName','personAddress','personCode','personPhone','personUrl','personRemark','personEmail','personZip']);
						removeFields(['personName','personAddress','personCode','personPhone','personUrl','personRemark','personEmail','personZip']);
						if(index!= 0) {
							Ext.getCmp('commercialId').allowBlank = true;
							Ext.getCmp('representitive').allowBlank = true;
							Ext.getCmp('commercialId').setValue();
							Ext.getCmp('representitive').setValue();
							setFieldDisabled(['commercialId', 'representitive']);
							removeFields(['commercialId', 'representitive']);
						} else {
							Ext.getCmp('commercialId').allowBlank = false;
							Ext.getCmp('representitive').allowBlank = false;
						}
						if(Ext.getCmp('personField')){
							Ext.getCmp('personField').setVisible(false);
						}
						if(Ext.getCmp('enterpriseField')){
							Ext.getCmp('enterpriseField').setVisible(true);
						}
//					}
				i++;
				});
	if(id){
		entWindow.show(null,function(){
			doAction('load', 'post','users_view.action',function(form, action){
				if(Ext.getCmp('enterpriseCode')){
					Ext.getCmp('enterpriseCode').fireEvent('blur', Ext.getCmp('enterpriseCode'));
				}
				var theUtype = action.result.data.utype;
				var indexParam = theUtype == 'B' ? 0 : 1;
				//alert(indexParam);
				utypeCombo.fireEvent('select', utypeCombo, null, indexParam);
				Ext.StoreMgr.get('store-province').load({
					callback: function() {
						var id = action.result.data.region.areaId;
						var provinceId = '1111';
						Ext.Ajax.request({
							url: 'cities_view.action',
							params: {id: id},
							success: function(response, options){
								provinceId = Ext.decode(response.responseText).areaId;
								Ext.getCmp('province').setValue(provinceId);
								Ext.StoreMgr.get('store-area').baseParams = { areaId :provinceId };
								Ext.StoreMgr.get('store-area').load({
									callback: function() {
										Ext.getCmp('area').setValue(action.result.data.region.areaId);
										Ext.StoreMgr.get('store-city').baseParams = { areaId: action.result.data.region.areaId };
										Ext.StoreMgr.get('store-city').load({
											callback: function() {
												Ext.getCmp('city').setValue(action.result.data.region.id)
											}
										});
									}
								});
							}
						});
					}
				});
				
				
				var dtype = action.result.data.type && action.result.data.type.name ;
				Ext.WindowMgr.getActive().items.first().items.get(2).items.get(1).setValue(dtype);
				var provinceDepar = action.result.data.provinceDepartment ;
				if(provinceDepar == null || provinceDepar == 'undefined' || provinceDepar == 'null'){
					Ext.WindowMgr.getActive().items.first().items.get(2).items.get(2).setValue();
				}
				var categoryType = action.result.data.category;
				if(categoryType == null || categoryType == 'undefined' || categoryType == 'null'){
					categoryCombo.setValue();
				}
			}, {'id':id });
		});
	}else{
		entWindow.show();
		if(actionType == 'register'){	
		Ext.StoreMgr.get('store-province').load({
					callback: function() {
						Ext.getCmp('province').setValue('330000');
						Ext.StoreMgr.get('store-area').baseParams = { areaId: '330000' };
						Ext.StoreMgr.get('store-area').load();
					
						Ext.getCmp('area').on('select', function(combo, record) {
							Ext.getCmp('city').clearValue();
							
							Ext.StoreMgr.get('store-city').baseParams = { areaId: record.get('id') };
							Ext.StoreMgr.get('store-city').load();
						});
					}
				});
		Ext.getCmp('province').setValue('330000');
				if(Ext.getCmp('personField')){
					Ext.getCmp('personField').setVisible(false);
				}
				if(Ext.getCmp('enterpriseField')){
					Ext.getCmp('enterpriseField').setVisible(false);
				}
			}
	}
} 
