 function inputData(){
  		this.serverPath=null;
  		this.dataType="EXCEL";
  		this.dataName=null;
  		this.dataUser=null;
  		this.dataPass=null;
		this.tableName=null;
		this.outTabName=null;
		this.recordCount=null;
		this.rhisRecord=0;
		this.sDiv=null;
		this.outObj=null;
		this.inField=null;
		this.outField=null;
		this.setupName=null; //当前采用的配置名称
		this.menuid=null;
		this.NO=0;
		this.findType=0;
		
		var div=null;
		
		
		this.setDiv=function(){
			div=document.getElementsByName("step");
		}
  		
		
		this.step1start=function(){
			div[0].style.display="";  //开始第一步
			div[1].style.display="none";
			div[2].style.display="none";  
			div[3].style.display="none";  
			
		}
		
  		this.selectSource=function(thisObj){
			this.dataType=thisObj.value;
			switch  (this.dataType){
			   case "SQL":
				source[0].style.display="";
				source[1].style.display="none";
				source[2].style.display="none";
				source[3].style.display="none";
					break;
			   case "UPACCESS":
					source[0].style.display="none";
					source[1].style.display="none";
					source[2].style.display="none";
					source[3].style.display="";

				   break;
			   case "UPEXCEL":
					source[0].style.display="none";
					source[1].style.display="none";
					source[2].style.display="";
					source[3].style.display="none";
				   break;
			   default :
				source[1].style.display="";
				source[0].style.display="none";
				source[2].style.display="none";
				source[3].style.display="none";
				break;
			}
		}
  		
		this.step1=function(){
			switch  (this.dataType){
				case "SQL":
				if (form1.Server.value==""){
					 alert("请填写SQL服务器名")
					 return false	
				}
				if (form1.DataName.value==""){
					 alert("请填写SQL数据库名")
					 return false	
				}
				if (form1.userName.value==""){
					 alert("请填写SQL数据库用户名")
					 return false	
				}
				if (form1.userPass.value==""){
					 alert("请填写SQL数据库密码")
					 return false	
				}
				var objResponse=new JHttpResponse();
				objResponse.write("server",form1.Server.value);
				objResponse.write("DataName",form1.DataName.value);
				objResponse.write("userName",form1.userName.value);
				objResponse.write("userPass",form1.userPass.value);
			
				var out=objAjax.getText("post","inputData.aspx?type=testSQL",objResponse,null);
				
				if (out=="1"){
					this.step1ok();
				}else{
					 alert("无法正确连接SQL服务器"+erStr(out));
					 return false	;
				}
				
			case "UPACCESS":	
				var objResponse=new JHttpResponse();
				objResponse.write("fileType","ACCESS");
				var out=objAjax.getText("post","inputData.aspx?type=testFile",objResponse,null);
				//alert(out);
				if (out=="Err"){
					 alert("服务器上没有发现正确的EXCEL文件,请把EXCEL文件上传到 system/myweb/tempData/tempDB.mdb");
					return;
				}else{
					this.dataType="ACCESS";
					this.step1ok(out);
				}
				break;
				
			case "UPEXCEL":
				var objResponse=new JHttpResponse();
				objResponse.write("fileType","EXCEL");
				var out=objAjax.getText("post","inputData.aspx?type=testFile",objResponse,null);
				//alert(out);
				if (out=="Err"){
					 alert("服务器上没有发现正确的EXCEL文件,请把EXCEL文件上传到 system/myweb/tempData/tempDB.xls");
					return;
				}else{
					this.dataType="EXCEL";
					this.step1ok(out);
				}
				break;
			
			default :
				if (form1.UpFile.value==""){
					 alert("请选择要上传的数据文件");
					 return false	;
				}
				var fileName=form1.UpFile.value;
				fileName=fileName.split(".");
				fileName=fileName[fileName.length-1].toLowerCase();
			
				if (fileName=="xls"|fileName=="mdb"){
					if (fileName=="xls"&this.dataType=="ACCESS"){
						alert("数据文件和你选择的数据源不匹配");
						return false	;
					}
					if (fileName=="mdb"&this.dataType=="EXCEL"){
						alert("数据文件和你选择的数据源不匹配");
						return false	;
					}
					form1.submit();
				}else{
					alert(fileName+"格式的文件不能作为数据来源");
					return false	;
				}
			}
			//alert(out);
		}
  		
		this.step1ok=function(filePath){
		  if (this.dataType=="SQL"){
				this.serverPath=form1.Server.value;
				this.dataName=form1.DataName.value;
				this.dataUser=form1.userName.value;
				this.dataPass=form1.userPass.value;
			}else{
				this.serverPath=filePath;
			}
			//alert(this.serverPath);
			this.step2start();
		}
		
		
		this.step2start=function(){
			div[0].style.display="none";  //开始第二步
			div[1].style.display="";
			div[2].style.display="none";  
			div[3].style.display="none";  
			
			var objResponse=new JHttpResponse();
			objResponse.write("server",this.serverPath);
			objResponse.write("DataName",this.dataName);
			objResponse.write("userName",this.dataUser);
			objResponse.write("userPass",this.dataPass);
			objResponse.write("dbType",this.dataType);
			
			var objAjax=new JAjax();
			var out=objAjax.getText("post","inputData.aspx?type=SelectTable",objResponse,null);
			
				
			if (out=="0"){
				alert("程序运行发生错误,未能取出数据表");	
				return false	;
			}
			out=out.split(c1);
			var html="";
			for (var i=0;i<out.length-1;i++){
				if (i==0) {
					html=html+"<span style='width:120px'><input checked  onclick='input.tableName=this.value;' type='radio' id='R2' name='R2' value='"+out[i]+"'>"+out[i]+"</span>"
				}else{
					html=html+"<span style='width:120px'><input  onclick='input.tableName=this.value;' type='radio' id='R2' name='R2' value='"+out[i]+"'>"+out[i]+"</span>"
				}
			}
			this.tableName=out[0]
			$("tabList").innerHTML=html;
		}
		
		
		this.step2ok=function(){
			//alert(this.tableName);	
			this.step3start()
		
		}
		
			this.step3start=function(){
			div[0].style.display="none";  //开始第三步
			div[1].style.display="none";  
			div[2].style.display="";  
			div[3].style.display="none";
			
			
			//this.loadSelectINIname();
			var objResponse=new JHttpResponse();
			objResponse.write("server",this.serverPath);
			objResponse.write("DataName",this.dataName);
			objResponse.write("userName",this.dataUser);
			objResponse.write("userPass",this.dataPass);
			objResponse.write("dbType",this.dataType);
			objResponse.write("tableName",this.tableName);
			
			
			var out=objAjax.getText("post","inputData.aspx?type=setupFields",objResponse,null);
			if (out=="0"){
				alert("程序运行发生错误,无法和数据库连接");	
				return false	;
			}
			if (out=="Eof"){
				alert("来源表中没有数据, 无法完成数据导入工作");	
				return false	;
			}
			if (out.indexOf(c1)==-1){
				alert(erStr(out));	
				return false;
			}
			
			//alert (out)
			out= comminute(out,c1,c2)
			var bgcolor="efefef";
			inField.innerHTML="";
			outField.innerHTML="";
			for (var i=0;i<out.length-1;i++){
				if (bgcolor=="efefef"){
					bgcolor="cfcfcf";
				}else{
					bgcolor="efefef";
				}
				inField.innerHTML=inField.innerHTML+"<DIV style='background-color:#"+bgcolor+";color:#808080;overflow:hidden;width:250px;height:21px'><input readonly id='inFildList' type='text' title='"+out[i][0]+"' value='"+out[i][0]+"' style='width:100px;height:20px;'>"+out[i][1]+"</DIV>";
				outField.innerHTML=outField.innerHTML+"<DIV style='background-color:#"+bgcolor+";overflow:hidden;width:250px;height:21px'><input readonly onclick='input.seletctFieldType(this)' fdType='0' txtNum='"+i+"' id='outFieldList' type='text'  style='width:100px;height:20px;border:1px solid #7f9db9;' title='' ></DIV>"
			}
			
			objResponse.write("outTabName",this.outTabName);
			var out=objAjax.getText("post","inputData.aspx?type=readoutFields",objResponse,null);
			 //alert (out)
			out=comminute(out,c1,c2);
			var s="TabImage,缩略图|menu,所在栏目|Kind,前缀|TabKeys,关键字|Source,来源|SourceUrl,来源地址|signForUser,需签收用户"
			s=comminute(s,"|",",");
			for (var i=0;i<s.length;i++){
				//alert(out);
				out[out.length]=s[i];
			}
			
			
			
			
			var sObj=cObj(document.body,"div");
			sObj.style.cssText="display:none;border: 1px solid #808080; background-color: #BFDFFF;padding:3px;width:120px;height:auto;position:absolute;left:0px;top:0px;"
			for (var i=0;i<out.length;i++){
				if (out[i][0]!=""){
					//alert(out);
					var optDiv=cObj(sObj,"div");
					optDiv.innerText=out[i][1];
					optDiv.title=out[i][0];
					optDiv.style.cssText="height:20px;"
					optDiv.onmouseover=function(){
						this.style.cssText="padding-left:3px;height:20px;background-color:#c0c0ef;border-top: 1px solid #000080; border-bottom: 1px solid #000080;";
					}
					
					optDiv.onmouseout=function(){
						this.style.cssText="padding-left:3px;height:20px;background-color:#BFDFFF;";
					}
					
					optDiv.onclick=function(){
						if (input.outObj!=null){
							var outObjs=document.getElementsByName("outFieldList");
							var v=this.innerText+"|"+this.title;
							for (var i=0;i<outObjs.length;i++){
								if (outObjs[i].value==v){
									outObjs[i].value="";
								}
							}
							
							input.outObj.value=v;	
							input.sDiv.style.display="none";
						}
					}
				}
			}
			this.sDiv=sObj;
			this.readIniList();

		}
		
		this.step3ok=function(){
			var v=$("setupSave").value;
			if (v==""){
				alert("请设置把配置保存为什么名字");
				return;
			}
			var inField="";
			var outField="";
			var inObj=document.getElementsByName("inFildList");
			var outObj=document.getElementsByName("outFieldList");
			var x=0;
			for (var i=0;i<inObj.length;i++){
				inField=inField+inObj[i].value+c1;
				outField=outField+outObj[i].value+c1;
				if (outObj[i].value.indexOf("|content")!=-1 | outObj[i].value.indexOf("|title")!=-1){x++}
			}
			if (x<2){
				alert("必须设置内容和标题由哪个字段导入");
				return;
			}
			this.inField=inField;
			this.outField=outField;
			this.setupName=v; //当前采用的配置名称
			var objResponse=new JHttpResponse();
			objResponse.write("inField",inField);
			objResponse.write("outField",outField);
			objResponse.write("setupName",v);
			var out=objAjax.getText("post","inputData.aspx?type=saveIni",objResponse,null);
			
			if (out!=""){
				alert(erStr(out));
				return;
			}
			
			this.step4start();
		}
		
		this.step4start=function(){
			div[0].style.display="none";  //开始第四步
			div[1].style.display="none";  
			div[2].style.display="none";  
			div[3].style.display="";
			this.sDiv.style.display="none";
			$("button_end").style.display="none";
			this.NO=0;
			setTimeout("input.inputDataStart()",500)
		}
		
		
		this.readIniList=function(){  //读出配置列表
			var obj=$("selectINI");
			if (obj.options.length>1){
				return;
			}
			out=objAjax.getText("post","inputData.aspx?type=readIniName",null,null);
			out=comminute(out,c1,c2);
			for (var i=0;i<out.length-1;i++){
				var nObj=$c("option");
				nObj.text=out[i][0];
				nObj.value=out[i][0];
				obj.options.add(nObj);
			}
		}
		
		this.loadIni=function(v){
			if (v=="" | v==null){return;}
			var objResponse=new JHttpResponse();
			objResponse.write("iniName",v);
			out=objAjax.getText("post","inputData.aspx?type=readIni",objResponse,null);
			out=comminute(out,c1,c2);
			var inObj=document.getElementsByName("inFildList");
			var outObj=document.getElementsByName("outFieldList")
			for (var i=0;i<inObj.length;i++){
				if (inObj[i].value==out[i][0]){
					outObj[i].value=out[i][1]
				}else{
					alert("配置表结构和当前表结构不同,不能导入数据");
					return;
				}
			}
			$("setupSave").value=v;
		}
		
		
		this.delIni=function(){
			var v=$("selectINI").value;
			if (v==""){
				alert("请选择一个要删除的配置");
				return;
			}
			var objResponse=new JHttpResponse();
			objResponse.write("iniName",v);
			out=objAjax.getText("post","inputData.aspx?type=delIni",objResponse,null);
			if (out==""){
				$("setupSave").value="";
				var obj=$("selectINI");
		 		i=obj.selectedIndex;
				obj.options[i].removeNode(true);
			}else{
				alert(erStr(out));
			}
		}
		
		this.inputDataStart=function(){
			
			var objResponse=new JHttpResponse();
			objResponse.write("server",this.serverPath);
			objResponse.write("DataName",this.dataName);
			objResponse.write("userName",this.dataUser);
			objResponse.write("userPass",this.dataPass);
			objResponse.write("dbType",this.dataType);
			objResponse.write("outTabName",this.outTabName);
			objResponse.write("tableName",this.tableName);
			objResponse.write("inField",this.inField);
			objResponse.write("outField",this.outField);
			objResponse.write("menuid",this.menuid);
			objResponse.write("NO",this.NO);
			objResponse.write("findType",this.findType);
			
				//if (rCount>50){rCount=50}
				
				out=objAjax.getText("post","inputData.aspx?type=inputData",objResponse,null);
				//alert(out);
				if (out=="0"){
					alert("系统错误,无法连接来源数据");
					return false;
				}
				if (out=="2"){
					alert("系统错误,数据导入错误");
					return false;
				}
				if (out.indexOf(c1)==-1){
					alert(erStr(out));
					return false;
				}
				out=out.split(c1);
				if (isNaN(out[0])){
					alert("来源数据记录总数读取失败,请重试一次.");
					$("button_end").style.display="";
					return false;
				}
				rCount=parseInt(out[0]);
				inputWord.innerHTML="一共有"+rCount+"数据条需要导入, 已导入"+(this.NO+1)+"条   "+parseInt(((this.NO+1)/rCount)*100)+"%"
				this.NO++;
				if (this.NO>=rCount){
					alert("数据导入完成");
					//window.close();
					return false;
				}else{
					setTimeout("input.inputDataStart()",10)
				}
			 
		}
		
		
		this.seletctFieldType=function(thisObj){
			if (this.outObj!=null){
				this.outObj.style.border="1px solid #7f9db9";
			}
			this.sDiv.style.display="";
			this.outObj=thisObj;
			this.outObj.style.border="1px solid #0000FF";
			var x = getLeft(thisObj)+104;
			var y = getTop(thisObj);
			var h=Element.getHeight(step[2]);
			var h1=Element.getHeight(this.sDiv);
			if (y+h1>h){y=h-h1;}
			this.sDiv.style.left=x;
			this.sDiv.style.top=y;
		}
		
		this.setFindType=function(){
			var obj=$("findType");
			if (obj.checked=true){
				this.findType=1;
			}else{
				this.findType=0;
			}
			
		}
		

  
 }