var objAjax=new JAjax();

function backup(){//Main入口
	var nowPage=1;//当前页数
	var pageSize=13;//每页显示的数据量
	var pageCount=0;//数据总的条数
	var selArray=null;
	var mdbPath="";
	var pages=0;
	var saveDateArray=new Array();
	var saveFileArray=new Array();//文件名 + ZYDN.Sys.SysConst.c1 + 文件大小 + ZYDN.Sys.SysConst.c1 + 文件最后修改时间 + ZYDN.Sys.SysConst.c1 +文件路径+ ZYDN.Sys.SysConst.c2;
	var index=0;//当前备份的位置
	var editorID=0;//当前生成的数据编号
	var backUpLst=new Array();
	var hpModel=0;//还原模式0 全部还原 1 只还原比较旧的
}

backup.prototype.loadPage=function(){//页面加载的方法
	 writeFettleLeft("提示:选择数据包进行还原"); //状态栏提示
	 loadBodyclick();
	 var dt=new Date();		
	 var nowDateSystem=dt.toLocaleString();
	 var index=nowDateSystem.indexOf("月");
	 var indexD=nowDateSystem.indexOf("日");
	 $("selectTime").value=nowDateSystem.substring(0,4)+"-"+(nowDateSystem.substring(5,index)-1)+"-"+nowDateSystem.substring(index+1,indexD); 
	 this.nowPage=1;
	 this.pageSize=13;
	 this.loadBackUpDate();
}

backup.prototype.selDate=function(thisObj){//选择时间
	var d=openSelectDate("../../");
	if(d!="" & d!=null&typeof d!="undefined"){  
		if(thisObj.type=="button"){
			thisObj.previousSibling.value=d;
			this.nowPage=1;
			this.loadBackUpDate();
		}
	}
}

backup.prototype.hyBackUp=function(obj){//备份数据
	if(confirm("你确定要使用当前备份还原系统吗")){
		var cTable=$("runBackUpTitle");
		var backUpMessage=$("backUpMessage");
		var backUpLst=$("backUpLst");
		backUpMessage.style.display="block";
		backUpLst.style.display="none";
		var showBackUp=$("showBackUp");
		if(showBackUp.childNodes.length>0){
			showBackUp.firstChild.removeNode(true);
		}
		var tr=showBackUp.insertRow();
		var insertRowCell=tr.insertCell();
		insertRowCell.style.cssText="width:215px;height:30px;color:Red;"
		insertRowCell.appendChild(document.createTextNode("正在计算要还原的数据量,请稍等....."));
		setTimeout("bp.hyBackUpRun("+obj.id+")",2000);
	}
}

backup.prototype.hyBackUpRun=function(obj){//还原数据
	var cTable=$("runBackUpTitle");
	var backUpMessage=$("backUpMessage");
	var backUpLst=$("backUpLst");
	var showBackUp=$("showBackUp");
	//admin,395,365924KB,2010-8-1 0:11:11 adfasdfasd.mdb,../../upfile/back/sdf.mdb,224,268KB,1
	var nowGetBackUP=new Array();
	for(var i=0;i<this.saveDateArray.length;i++){
		if(this.saveDateArray[i][6]==obj){
			nowGetBackUP=this.saveDateArray[i];
			break;
		}
	}
	this.mdbPath=nowGetBackUP[5];
	var objResponse=new JHttpResponse();
	objResponse.write("mdbPath",nowGetBackUP[5]);
	objResponse.write("id",nowGetBackUP[6]);
	var overBackUP=document.getElementsByName("overBackUP");
	for(var op=0;op<overBackUP.length;op++){
	    if(overBackUP[i].checked){
	        this.hpModel=overBackUP[i].value;
	        break;
	    }
	}
	var out=objAjax.getText("post","index.aspx?type=readBackUpFiles",objResponse,null);
	//fileName,filePath,fileEditorDate,fileSize,fileKey
	if(out.indexOf(c1)>-1){
			out=out.split(c3);
			var outSplit=out[0].split(c2);
			for(var m=0;m<cTable.childNodes.length;m++){
				cTable.childNodes[m].removeNode(true);	
			}
			var t=new createOurTitle();
			t.add("文件名称","text-align:left;padding-left:5px;","150");
			t.add("文件大小","text-align:center","70");
			t.add("文件修改时间","text-align:center","130");
			t.add("还原进度","text-align:center","80");
			t.table=cTable;
			t.create();
			var tr=null;
			var index=0;
			this.backUpLst=new Array();
			for(var i=0;i<outSplit.length;i++){
				if(outSplit[i].indexOf(c1)>-1){
					var tSplit=outSplit[i].split(c1);
					tr=cTable.insertRow();
					tr.setAttribute("id","hk_"+index);
					var createTD=tr.insertCell();
					createTD.style.cssText="height:20px;width:150px;";	
					var txtContext=tSplit[0];
					if(txtContext.length>20){
						txtContext=txtContext.substring(0,20);
					}
					createTD.appendChild(document.createTextNode(txtContext));
					createTD=tr.insertCell();
					createTD.style.cssText="text-align:center;height:20px;color:#FF0000;width:70px;";	
					var fileZJ="0KB";
					try{
						if(parseInt(tSplit[3])>0){
							fileZJ=parseFloat(parseInt(tSplit[3])/1024).toFixed(1)+"KB";	
						}
					}catch(e){}
					createTD.appendChild(document.createTextNode(fileZJ));
					createTD=tr.insertCell();
					createTD.style.cssText="text-align:center;height:20px;width:130px;";
					createTD.appendChild(document.createTextNode(tSplit[2]));					
					createTD=tr.insertCell();
					createTD.style.cssText="text-align:center;color:#FF0000;height:20px;width:80px;";				
					createTD.appendChild(document.createTextNode("等待还原"));
					index=parseInt(index)+1;
					this.backUpLst.push(tSplit);
				}
			}
			this.index=0;
			$("nowBackUp").innerHTML="正在还原数据中......";
			if(showBackUp.childNodes.length>0){
				showBackUp.firstChild.removeNode(true);
			}
			var tr=showBackUp.insertRow();
			var insertRowCell=tr.insertCell();
			insertRowCell.className="styleCss";
			insertRowCell.innerHTML="当前总共需要还原"+this.backUpLst.length+"个文件";
			
			tr=showBackUp.insertRow();
			insertRowCell=tr.insertCell();
			insertRowCell.className="oneStyleCss";
			insertRowCell.setAttribute("id","showBackUpMsgRun")
			insertRowCell.innerHTML="当前准备还原"+this.backUpLst[0][0];	
			
			tr=showBackUp.insertRow();
			insertRowCell=tr.insertCell();
			insertRowCell.className="twoStyleCss";
			insertRowCell.setAttribute("id","showBackUpMsgRunJD");
			insertRowCell.innerHTML="<div class='runStyleCss'><div>";
			
			tr=showBackUp.insertRow();
			insertRowCell=tr.insertCell();
			insertRowCell.className="threeStyleCss";
			insertRowCell.setAttribute("id","showBackUpMsgRunError");
			insertRowCell.innerHTML="错误信息:<br>";
			setTimeout("bp.updateFileContent()",1000);
	}else{
		alert(out)	
	}
}

backup.prototype.updateFileContent=function(){
	if(this.index<this.backUpLst.length){
		if(this.mdbPath!=null&&this.mdbPath!=""){
			$("hk_"+this.index).childNodes[3].className="setTabThree";
			$("hk_"+this.index).childNodes[3].innerText="正在还原";
			if(parseInt(this.index)>15){
				$("backUpMessage").scrollTop=(backUpMessage.scrollHeight/parseInt(this.backUpLst.length))*(parseInt(this.index)-15);
			}
			var objResponse=new JHttpResponse();
			//fileName,filePath,fileEditorDate,fileSize,fileKey,id
			objResponse.write("mdbPath",this.mdbPath);	
			objResponse.write("fileName",this.backUpLst[this.index][0]);
			objResponse.write("filePath",this.backUpLst[this.index][1]);
			objResponse.write("fileEditorDate",this.backUpLst[this.index][2]);
			objResponse.write("fileKey",this.backUpLst[this.index][4]);
			objResponse.write("hpModel",this.hpModel);
			objResponse.write("id",this.backUpLst[this.index][5]);
			var out=objAjax.getText("post","index.aspx?type=upFileContent",objResponse,null);
			if(out.indexOf(c1)>-1){
				$("showBackUpMsgRun").innerHTML="完成"+this.index+"个文件还原,<br>文件名为"+this.backUpLst[this.index][0]+out.split(c1)[0];
				$("hk_"+this.index).childNodes[3].style.cssText="text-align:center;color:blue;height:20px;width:80px;";
				$("hk_"+this.index).childNodes[3].innerText=out.split(c1)[0];
				for(var i=0;i<$("hk_"+this.index).childNodes.length;i++){
						$("hk_"+this.index).childNodes[i].className="listBodyOptionOther";	
				}
				this.index=parseInt(this.index)+1;
				var persent=parseFloat(this.index/this.backUpLst.length*100).toFixed(1)+"%";
				if($("hk_"+this.index)){
					$("showBackUpMsgRunJD").firstChild.style.width=persent;
					$("showBackUpMsgRunJD").firstChild.innerText=this.index+"/"+this.backUpLst.length;	
					$("showBackUpMsgRun").innerHTML+="<br>正在还原"+this.backUpLst[this.index][0];
					for(var i=0;i<$("hk_"+this.index).childNodes.length;i++){
						$("hk_"+this.index).childNodes[i].className="listTitleOption_1Other";	
					}
					$("hk_"+this.index).childNodes[3].style.cssText='text-align:center;color:#000000;height:20px;width:80px;'
					$("hk_"+this.index).childNodes[3].innerText="还原中..";
				}
				setTimeout("bp.updateFileContent()",300);
			}else{
				$("showBackUpMsgRun").innerHTML="完成"+this.index+"个文件还原,<br>文件名为"+this.backUpLst[this.index][0]+out.split(c1)[0];
				$("hk_"+this.index).childNodes[3].style.cssText="text-align:center;color:blue;height:20px;width:80px;";
				$("hk_"+this.index).childNodes[3].innerText=out;
				for(var i=0;i<$("hk_"+this.index).childNodes.length;i++){
						$("hk_"+this.index).childNodes[i].className="listBodyOptionOther";	
				}
				this.index=parseInt(this.index)+1;
				var persent=parseFloat(this.index/this.backUpLst.length*100).toFixed(1)+"%";
				if($("hk_"+this.index)){
					$("showBackUpMsgRunJD").firstChild.style.width=persent;
					$("showBackUpMsgRunJD").firstChild.innerText=this.index+"/"+this.backUpLst.length;	
					$("showBackUpMsgRun").innerHTML+="<br>正在还原"+this.backUpLst[this.index][0];
					for(var i=0;i<$("hk_"+this.index).childNodes.length;i++){
						$("hk_"+this.index).childNodes[i].className="listTitleOption_1Other";	
					}
					$("hk_"+this.index).childNodes[3].style.cssText="text-align:center;color:#000000;height:20px;width:80px;";
					$("hk_"+this.index).childNodes[3].innerText="还原中..";
				}
				setTimeout("bp.updateFileContent()",300);
			}
		}
	}else{
		$("showBackUpMsgRunJD").firstChild.innerText=this.backUpLst.length+"/"+this.backUpLst.length;	
		$("showBackUpMsgRun").innerHTML+="<br>全部还原成功<input type='button' value='返回列表' onclick='bp.returnLoadDate()'/>";
	}
}

backup.prototype.insertMDB=function(){//将备份文件插入数据库	
	if(this.index<this.saveFileArray.length){
		if(this.mdbPath!=null&&this.mdbPath!=""){
			var backUpMessage=$("backUpMessage");
			if(parseInt(this.index)>15){
				$("backUpMessage").scrollTop=(backUpMessage.scrollHeight/parseInt(this.saveFileArray.length))*(parseInt(this.index)-15);
			}
			var objResponse=new JHttpResponse();
			objResponse.write("mdbPath",this.mdbPath);	
			objResponse.write("fileName",this.saveFileArray[this.index][0]);
			objResponse.write("fileSize",this.saveFileArray[this.index][1]);
			objResponse.write("uateMDB",this.saveFileArray[this.index][2]);
			objResponse.write("filePath",this.saveFileArray[this.index][3]);
			var out=objAjax.getText("post","index.aspx?type=intFilesMDB",objResponse,null);
			if(out=="ok"){
				$("showBackUpMsgRun").innerHTML="完成"+this.index+"个文件备份,<br>文件名为<span style='color:#FF0000;'>"+this.saveFileArray[this.index][0]+"</span>备份成功";
				$("bk_"+this.index).childNodes[3].style.cssText='text-align:center;color:blue;height:20px;width:80px;';
				$("bk_"+this.index).childNodes[3].innerText="备份成功";
				for(var i=0;i<$("bk_"+this.index).childNodes.length;i++){
						$("bk_"+this.index).childNodes[i].className="listBodyOptionOther";	
				}
				this.index=parseInt(this.index)+1;
				var persent=parseFloat(this.index/this.saveFileArray.length*100).toFixed(1)+"%";
				if($("bk_"+this.index)){
					$("showBackUpMsgRunJD").firstChild.style.width=persent;
					$("showBackUpMsgRunJD").firstChild.innerText=this.index+"/"+this.saveFileArray.length;	
					$("showBackUpMsgRun").innerHTML+="<br>正在备份<span style='color:#FF0000;'>"+this.saveFileArray[this.index][0]+"</span>";
					for(var i=0;i<$("bk_"+this.index).childNodes.length;i++){
						$("bk_"+this.index).childNodes[i].className="listTitleOption_1Other";	
					}
					$("bk_"+this.index).childNodes[3].style.cssText='text-align:center;color:#000000;height:20px;width:80px;';
					$("bk_"+this.index).childNodes[3].innerText="备份中..";
				}
				setTimeout("bp.insertMDB()",300);
			}else{
				$("showBackUpMsgRun").innerText="文件名为<span style='color:#FF0000;'>"+this.saveFileArray[this.index][0]+"</span>备份失败";
				$("showBackUpMsgRunError").style.width="200px"
				$("showBackUpMsgRunError").innerHTML+=out;
				$("bk_"+this.index).childNodes[3].style.cssText='text-align:center;color:#FF0000;height:20px;width:80px;';
				$("bk_"+this.index).childNodes[3].innerText="备份失败";
				for(var i=0;i<$("bk_"+this.index).childNodes.length;i++){
						$("bk_"+this.index).childNodes[i].className="listBodyOptionOther";	
				}
				this.index=parseInt(this.index)+1;
				var persent=parseFloat(this.index/this.saveFileArray.length*100).toFixed(1)+"%";
				if($("bk_"+this.index)){
					$("showBackUpMsgRunJD").firstChild.style.width=persent;
					$("showBackUpMsgRunJD").firstChild.innerText=this.index+"/"+this.saveFileArray.length;	
					$("showBackUpMsgRun").innerHTML+="<br>正在备份<span style='color:#FF0000';>"+this.saveFileArray[this.index][0]+"</span>";
					for(var i=0;i<$("bk_"+this.index).childNodes.length;i++){
						$("bk_"+this.index).childNodes[i].className="listTitleOption_1Other";	
					}
					$("bk_"+this.index).childNodes[3].style.cssText='text-align:center;color:#000000;height:20px;width:80px;';
					$("bk_"+this.index).childNodes[3].innerText="备份中..";
				}
				setTimeout("bp.insertMDB()",300);
			}
		}
	}else{
		var objResponse=new JHttpResponse();
		objResponse.write("mdbPath",this.mdbPath);
		objResponse.write("editorID",this.editorID);
		var out=objAjax.getText("post","index.aspx?type=updateBackUP",objResponse,null);
		if(out=="1"){
			$("showBackUpMsgRun").innerHTML="数据备份完成,是否返回备份文件列表<br><input type='button' value='确定' onclick='bp.returnLoadDate()'/>";
		}else{
			$("showBackUpMsgRun").innerHTML="当前备份数据不完整,请查看错误信息,是否返回备份文件列表<br><input type='button' value='确定' onclick='bp.returnLoadDate()'/>'";
		}
		$("showBackUpMsgRunJD").firstChild.innerText=this.saveFileArray.length+"/"+this.saveFileArray.length;
	}
}

backup.prototype.returnLoadDate=function(){
		$("nowBackUp").innerHTML="<input type=\"button\" value=\"备份当前系统\" onclick=\"bp.bfBackUp()\" style=\"width:90px\"/>&nbsp;&nbsp;<input type=\"button\" value=\"ftp上传还原\" onclick=\"bp.ftpBackUp()\" style=\"width:90px\"/>";
		var backUpMessage=$("backUpMessage");
		var backUpLst=$("backUpLst");
		backUpMessage.style.display="none";
		backUpLst.style.display="block";
		this.nowPage=1;
		this.loadBackUpDate();
}

backup.prototype.ftpBackUp=function(){
	//var nowGetBackUP=new Array();//填充数组
	var out=objAjax.getText("post","index.aspx?type=readBackUP",null,null);
	if(out.indexOf(c1)>-1){
		var nowGetBackUP=new Array();
		var cTable=$("runBackUpTitle");
		var backUpMessage=$("backUpMessage");
		var backUpLst=$("backUpLst");
		var showBackUp=$("showBackUp");
		backUpMessage.style.display="block";
		backUpLst.style.display="none";
		this.mdbPath="../../upfile/tempData/zydn_backup.mdb";
		//fileName,filePath,fileEditorDate,fileSize,fileKey
			var outSplit=out.split(c2);
			for(var m=0;m<cTable.childNodes.length;m++){
				cTable.childNodes[m].removeNode(true);	
			}
			var t=new createOurTitle();
			t.add("文件名称","text-align:left;padding-left:5px;","150");
			t.add("文件大小","text-align:center","70");
			t.add("文件修改时间","text-align:center","130");
			t.add("还原进度","text-align:center","80");
			t.table=cTable;
			t.create();
			var tr=null;
			var index=0;
			this.backUpLst=new Array();
			for(var i=0;i<outSplit.length;i++){
				if(outSplit[i].indexOf(c1)>-1){
					var tSplit=outSplit[i].split(c1);
					tr=cTable.insertRow();
					tr.setAttribute("id","hk_"+index);
					var createTD=tr.insertCell();
					createTD.style.cssText="height:20px;width:150px;";	
					var txtContext=tSplit[0];
					if(txtContext.length>20){
						txtContext=txtContext.substring(0,20);
					}
					createTD.appendChild(document.createTextNode(txtContext));
					createTD=tr.insertCell();
					createTD.style.cssText="text-align:center;height:20px;color:#FF0000;width:70px;";	
					var fileZJ="0KB";
					try{
						if(parseInt(tSplit[3])>0){
							fileZJ=parseFloat(parseInt(tSplit[3])/1024).toFixed(1)+"KB";	
						}
					}catch(e){}
					createTD.appendChild(document.createTextNode(fileZJ));
					
					createTD=tr.insertCell();
					createTD.style.cssText="text-align:center;height:20px;width:130px;";
					createTD.appendChild(document.createTextNode(tSplit[2]));					
					createTD=tr.insertCell();
					createTD.style.cssText="text-align:center;color:#FF0000;height:20px;width:80px;";				
					createTD.appendChild(document.createTextNode("等待还原"));
					index=parseInt(index)+1;
					this.backUpLst.push(tSplit);
				}
			}
			this.index=0;
			$("nowBackUp").innerHTML="正在还原ftp上传备份数据中......";
			if(showBackUp.childNodes.length>0){
				showBackUp.firstChild.removeNode(true);
			}
			var tr=showBackUp.insertRow();
			var insertRowCell=tr.insertCell();
			insertRowCell.className="styleCss";
			insertRowCell.innerHTML="当前总共需要还原"+this.backUpLst.length+"个文件";
			
			tr=showBackUp.insertRow();
			insertRowCell=tr.insertCell();
			insertRowCell.className="oneStyleCss";
			insertRowCell.setAttribute("id","showBackUpMsgRun")
			insertRowCell.innerHTML="当前准备还原"+this.backUpLst[0][0];	
			
			tr=showBackUp.insertRow();
			insertRowCell=tr.insertCell();
			insertRowCell.className="twoStyleCss";
			insertRowCell.setAttribute("id","showBackUpMsgRunJD");
			insertRowCell.innerHTML="<div class='runStyleCss'><div>";
			
			tr=showBackUp.insertRow();
			insertRowCell=tr.insertCell();
			insertRowCell.className="threeStyleCss";
			insertRowCell.setAttribute("id","showBackUpMsgRunError");
			insertRowCell.innerHTML="错误信息:<br>";
			setTimeout("bp.updateFileContent()",1000);
	}else{
		alert(out);	
	}
}

backup.prototype.bfBackUp=function(){//备份数据
	if(confirm("你确定要备份当前的系统吗")){
		var cTable=$("runBackUpTitle");
		var backUpMessage=$("backUpMessage");
		var backUpLst=$("backUpLst");
		backUpMessage.style.display="block";
		backUpLst.style.display="none";
		var showBackUp=$("showBackUp");
		if(showBackUp.childNodes.length>0){
			showBackUp.firstChild.removeNode(true);
		}
		var tr=showBackUp.insertRow();
		var insertRowCell=tr.insertCell();
		insertRowCell.style.cssText="width:215px;height:30px;color:Red;"
		insertRowCell.appendChild(document.createTextNode("正在计算要备份的数据量,请稍等....."));
		setTimeout("bp.bfBackUpRun()",2000);
	}
}

backup.prototype.bfBackUpRun=function(){//备份数据
		var cTable=$("runBackUpTitle");
		var backUpMessage=$("backUpMessage");
		var backUpLst=$("backUpLst");
		var showBackUp=$("showBackUp");
		var out=objAjax.getText("post","index.aspx?type=backupWeb",null,null);
		if(out.indexOf(c2)>-1){
			out=out.split(c3);
			this.mdbPath=out[1];
			this.editorID=out[2];
			var outSplit=out[0].split(c2);
			for(var m=0;m<cTable.childNodes.length;m++){
				cTable.childNodes[m].removeNode(true);	
			}
			var t=new createOurTitle();
			t.add("文件名称","text-align:left;padding-left:5px;","150");
			t.add("文件大小","text-align:center","70");
			t.add("文件修改时间","text-align:center","130");
			t.add("备份进度","text-align:center","80");
			t.table=cTable;
			t.create();
			var tr=null;
			this.saveFileArray=new Array();
			var index=0;
			for(var i=0;i<outSplit.length;i++){
				if(outSplit[i].indexOf(c1)>-1){
					var tSplit=outSplit[i].split(c1);
					tr=cTable.insertRow();
					tr.setAttribute("id","bk_"+index);
					var createTD=tr.insertCell();
					createTD.style.cssText="height:20px;width:150px;";	
					var txtContext=tSplit[0];
					if(txtContext.length>20){
						txtContext=txtContext.substring(0,20);
					}
					createTD.appendChild(document.createTextNode(txtContext));
					createTD=tr.insertCell();
					createTD.style.cssText="text-align:center;height:20px;color:#FF0000;width:70px;";
					var fileSize="0KB";
					try{
						fileSize=parseFloat(tSplit[1]/1024).toFixed(1)+"KB";
					}catch(e){}
					createTD.appendChild(document.createTextNode(fileSize));
					
					createTD=tr.insertCell();
					createTD.style.cssText="text-align:center;height:20px;width:130px;";				
					createTD.appendChild(document.createTextNode(tSplit[2]));
					
					createTD=tr.insertCell();
					createTD.style.cssText="text-align:center;color:#FF0000;height:20px;width:80px;";				
					createTD.appendChild(document.createTextNode("等待备份"));
					this.saveFileArray.push(tSplit);
					index=parseInt(index)+1;
				}
			}
			this.index=0;
			$("nowBackUp").innerHTML="正在备份数据中......";
			if(showBackUp.childNodes.length>0){
				showBackUp.firstChild.removeNode(true);
			}
			var tr=showBackUp.insertRow();
			var insertRowCell=tr.insertCell();
			insertRowCell.className="styleCss";
			insertRowCell.innerHTML="当前总共需要备份"+this.saveFileArray.length+"个文件";
			
			tr=showBackUp.insertRow();
			insertRowCell=tr.insertCell();
			insertRowCell.className="oneStyleCss"
			insertRowCell.setAttribute("id","showBackUpMsgRun")
			insertRowCell.innerHTML="当前准备备份"+this.saveFileArray[0][0];	
			
			tr=showBackUp.insertRow();
			insertRowCell=tr.insertCell();
			insertRowCell.className="twoStyleCss";
			insertRowCell.setAttribute("id","showBackUpMsgRunJD");
			insertRowCell.innerHTML="<div class='runStyleCss'><div>";
			
			tr=showBackUp.insertRow();
			insertRowCell=tr.insertCell();
			insertRowCell.className="threeStyleCss"
			insertRowCell.setAttribute("id","showBackUpMsgRunError");
			insertRowCell.innerHTML="错误信息:<br>";
			setTimeout("bp.insertMDB()",1000);
		}
}

backup.prototype.delBackUp=function(obj){//删除备份
	if(confirm("确实要删除备份数据吗?")){
		var path="";
		var index=0;
		for(var i=0;i<this.saveDateArray.length;i++){
			if(this.saveDateArray[i][6]==obj.id){
				path=this.saveDateArray[i][5];
				index=i;
				break;
			}
		}
		var objResponse=new JHttpResponse();
		objResponse.write("id",obj.id);	
		objResponse.write("path",path);	
		var out=objAjax.getText("post","index.aspx?type=DlBackUp",objResponse,null);
		if(out=="ok"){
			$(obj.id).removeNode(true);			
			if($("showBackUp").childNodes.length>0){
				$("showBackUp").firstChild.removeNode(true);
			}
			this.saveDateArray.splice(index,1);
		}else{
			alert(out);	
		}
		if(this.saveDateArray.length==0){
			if(parseInt(this.nowPage)>1){
				this.nowPage=parseInt(this.nowPage)-1;
				this.loadBackUpDate();
			}
		}
	}
}

backup.prototype.updownDate=function(obj){//下载备份
	var objResponse=new JHttpResponse();
	objResponse.write("mdbPath",obj.id);	
	var out=objAjax.getText("post","index.aspx?type=downLoad",objResponse,null);
	if(out.indexOf("rar")>-1){
		$("updown").href=out
		$("updown").click();
	}else{
		alert(out);	
	}	
}

backup.prototype.clickCheck=function(){//显示全部
	this.nowPage=1;
	this.loadBackUpDate();
}

backup.prototype.loadBackUpDate=function(){//载入备份数据列表	
	var cTable=$("bodyDiv");
	var divPages=$("divPages");
	var selectTime=$("selectTime");
	var showBackUp=$("showBackUp");
	if(showBackUp.childNodes.length>0){
		showBackUp.firstChild.removeNode(true);
	}
	if(selectTime.value==""&&selectTime.value==null){
		return;	
	}
	var isShow=1;//不显示
	if(selectTime.nextSibling.nextSibling.checked){
		isShow=0;//显示全部	
	}
	var objResponse=new JHttpResponse();
	objResponse.write("nowPage",this.nowPage);	
    objResponse.write("pageSize",this.pageSize);
	objResponse.write("selTime",selectTime.value);
	objResponse.write("isShow",isShow);	
	var out=objAjax.getText("post","index.aspx?type=readBackUpDate",objResponse,null);
	if(out.indexOf(c3)>-1){
		this.saveDateArray=new Array();
		out=out.split(c3);
		this.pageCount=out[1];//总页数
		var saveDateArrayVar=out[0].split(c2);
		if(cTable.childNodes.length>0){
			cTable.firstChild.removeNode(true);
		}
		divPages.innerHTML="";		
		var t=new createOurTitle();
		t.add("备份包名称","text-align:left;padding-left:10px;","150");
		t.add("大小","text-align:center","40");
		t.add("文件数","text-align:center","50");
		t.add("备份时间","text-align:center","130");
		t.add("备份人","text-align:center","60");
		t.table=cTable;
		t.create();
		var tr=null;
		for(var i=0;i<saveDateArrayVar.length;i++){
				tr=cTable.insertRow();
				var tSplit=saveDateArrayVar[i].split(c1);
				tr.setAttribute("id",tSplit[6]);
				var createTD=tr.insertCell();
				//bcakUserName,backFileNum,backFileSize,backCreateDate,backFileName,backFilePath,id				
				createTD.style.cssText="text-align:left;padding-left:2px;height:23px;width:150px;";	
				createTD.appendChild(document.createTextNode(tSplit[4]));
				
				createTD=tr.insertCell();
				createTD.style.cssText="text-align:center;height:23px;width:40px;";
				createTD.appendChild(document.createTextNode(tSplit[2]));
				
				createTD=tr.insertCell();
				createTD.style.cssText="text-align:center;;height:23px;width:50px;";				
				createTD.appendChild(document.createTextNode(tSplit[1]));
				
				createTD=tr.insertCell();
				createTD.style.cssText="text-align:center;color:#FF0000;;height:23px;width:130px;";				
				createTD.appendChild(document.createTextNode(tSplit[3]));

				createTD=tr.insertCell();
				createTD.style.cssText="text-align:center;height:23px;width:60px;";				
				createTD.appendChild(document.createTextNode(tSplit[0]));

				tr.onmouseover=function(){
					for(var i=0;i<this.childNodes.length;i++){
						this.childNodes[i].className="listTitleOption_1Other";	
					}
				}
				tr.onmouseout=function(){
				  var isBool=false;
				  if(bp.selArray!=null){
						if(bp.selArray==this){
							isBool=true;
						}
				   }
				   if(isBool==false){
						for(var i=0;i<this.childNodes.length;i++){
							this.childNodes[i].className="listBodyOptionOther";	
						}
					}
				}
				tr.onclick=function(){
					if(bp.selArray){
						for(var i=0;i<bp.selArray.childNodes.length;i++){
								bp.selArray.childNodes[i].className="listBodyOptionOther";	
						}
					}
					bp.selArray=this;
					var tr=null;
					for(var j=0;j<bp.saveDateArray.length;j++){
						if(bp.saveDateArray[j][6]==this.id){
							if(showBackUp.childNodes.length>0){
								showBackUp.firstChild.removeNode(true);
							}
    						tr=showBackUp.insertRow();
							var insertRowCell=tr.insertCell();
							insertRowCell.className="leftBackCssTitle";
							insertRowCell.appendChild(document.createTextNode("标题"));
							insertRowCell=tr.insertCell();
							insertRowCell.className="rightBackCssTitle";
							insertRowCell.appendChild(document.createTextNode("详细"));

							tr=showBackUp.insertRow();
							insertRowCell=tr.insertCell();
							insertRowCell.className="leftBackCss";
							insertRowCell.appendChild(document.createTextNode("备份人:"));
							insertRowCell=tr.insertCell();
							insertRowCell.className="rightBackCss";
							insertRowCell.appendChild(document.createTextNode(bp.saveDateArray[j][0]));							
							
							tr=showBackUp.insertRow();
							insertRowCell=tr.insertCell();
							insertRowCell.className="leftBackCss";
							insertRowCell.appendChild(document.createTextNode("备份时间:"));
							insertRowCell=tr.insertCell();
							insertRowCell.className="rightBackCss";
							insertRowCell.appendChild(document.createTextNode(bp.saveDateArray[j][3]));
							
							tr=showBackUp.insertRow();
							insertRowCell=tr.insertCell();
							insertRowCell.className="leftBackCss";
							insertRowCell.appendChild(document.createTextNode("备份名称:"));
							insertRowCell=tr.insertCell();
							insertRowCell.className="rightBackCss";
							insertRowCell.appendChild(document.createTextNode(bp.saveDateArray[j][4]));
							
							tr=showBackUp.insertRow();
							insertRowCell=tr.insertCell();
							insertRowCell.className="leftBackCss";
							insertRowCell.appendChild(document.createTextNode("备份文件数:"));
							insertRowCell=tr.insertCell();
							insertRowCell.className="rightBackCss";
							insertRowCell.appendChild(document.createTextNode(bp.saveDateArray[j][1]+"个文件"));
							
							tr=showBackUp.insertRow();
							insertRowCell=tr.insertCell();
							insertRowCell.className="leftBackCss";
							insertRowCell.appendChild(document.createTextNode("备份大小:"));
							insertRowCell=tr.insertCell();
							insertRowCell.className="rightBackCss";
							var isHave=" ";
							if(bp.saveDateArray[j][7]!="undefined"&&bp.saveDateArray[j][7]!=""&&bp.saveDateArray[j][7]!=null){
								isHave=bp.saveDateArray[j][7]
							}
							insertRowCell.appendChild(document.createTextNode(isHave));
							
							tr=showBackUp.insertRow();
							insertRowCell=tr.insertCell();
							insertRowCell.className="leftBackCss";
							insertRowCell.appendChild(document.createTextNode("备份完成度:"));
							insertRowCell=tr.insertCell();
							insertRowCell.className="rightBackCss";
							var isHave="非常好";
							if(bp.saveDateArray[j][8]!="1"){
								isHave="没有完全备份";
							}
							insertRowCell.appendChild(document.createTextNode(isHave));
							
							tr=showBackUp.insertRow();
							insertRowCell=tr.insertCell();
							insertRowCell.className="leftBackCss";
							insertRowCell.appendChild(document.createTextNode("还原模式:"));
							insertRowCell=tr.insertCell();
							insertRowCell.className="rightBackCss";
							insertRowCell.innerHTML="<input type='radio' id='R0-1' name='overBackUP' value='0' checked><lable for='R0-2'>全部还原</lable><br><input type='radio' name='overBackUP' value='1' id='R0-2'><lable for='R0-1'>只还原比备份旧的数据</lable>";
							tr=showBackUp.insertRow();
							insertRowCell=tr.insertCell();							
							insertRowCell.className="leftBackCss";
							insertRowCell.appendChild(document.createTextNode("备份操作:"));
							insertRowCell=tr.insertCell();
							insertRowCell.setAttribute("id","hpBackUpRun");
							insertRowCell.className="rightBackCss";
							var cElement=document.createElement("input");
							cElement.setAttribute("type","button");
							cElement.setAttribute("value","还原");
							cElement.setAttribute("title","还原");
							cElement.style.cssText="width:40px;cursor:hand;"
							cElement.setAttribute("id",bp.saveDateArray[j][6]);
							cElement.onclick=function(){
								bp.hyBackUp(this)	
							}
							insertRowCell.appendChild(cElement);
							cElement=document.createElement("span");
							cElement.style.cssText='width:5px;';
							cElement.innerHTML="&nbsp;";
							insertRowCell.appendChild(cElement);
							cElement=document.createElement("input");
							cElement.setAttribute("type","button");
							cElement.setAttribute("value","删除");
							cElement.setAttribute("title","删除");
							cElement.setAttribute("id",bp.saveDateArray[j][6]);
							cElement.style.cssText="width:40px;cursor:hand;"
							cElement.onclick=function(){
								bp.delBackUp(this)	
							}
							insertRowCell.appendChild(cElement);
							cElement=document.createElement("span");
							cElement.style.cssText='width:5px;';
							cElement.innerHTML="&nbsp;";
							insertRowCell.appendChild(cElement);
							cElement=document.createElement("input");
							cElement.setAttribute("type","button");
							cElement.setAttribute("value","下载");
							cElement.setAttribute("title","下载");
							cElement.setAttribute("id",bp.saveDateArray[j][5]);
							cElement.style.cssText="width:40px;cursor:hand;"
							cElement.onclick=function(){
								bp.updownDate(this)	
							}
							insertRowCell.appendChild(cElement);
						}
					}
				}
				this.saveDateArray.push(tSplit);
		}
		//分页写入开始
		var pagesGet=parseInt(this.pageCount/this.pageSize);
		if(this.pageCount%this.pageSize>0){
			pagesGet=pagesGet+1;	
		}
		this.pages=pagesGet;
		divPages.appendChild(document.createTextNode("一共有"+this.pageCount+"条,分"+this.pages+"页,第"+this.nowPage+"页"));
		
		var cPage=document.createElement("span");
		cPage.setAttribute("title","首  页");
		cPage.style.cssText="padding-left:10px;cursor:hand;";
		cPage.innerHTML="首  页";	
		if(this.pages>1&&this.nowPage>1){
		   cPage.onclick=function(){
			   bp.nowPage=1;
			   bp.loadBackUpDate();
		   }
		}else{
			cPage.style.cssText="padding-left:10px;color:#C0C0C0;";
		}
		divPages.appendChild(cPage);
		
		cPage=document.createElement("span");
		cPage.setAttribute("title","下一页");
		cPage.style.cssText="padding-left:10px;cursor:hand;";
		cPage.innerHTML="下一页";
		if(this.pages>1&&this.nowPage<this.pages){
		   cPage.onclick=function(){
			   bp.nowPage=parseInt(bp.nowPage)+1;
			   bp.loadBackUpDate();
		   }
		}else{
			cPage.style.cssText="padding-left:10px;color:#C0C0C0;";
		}
		divPages.appendChild(cPage);
		
		cPage=document.createElement("span");
		cPage.setAttribute("title","上一页");
		cPage.style.cssText="padding-left:10px;cursor:hand;";
		cPage.innerHTML="上一页";
		if(this.pages>1&&this.nowPage>1){
		   cPage.onclick=function(){
			   bp.nowPage=parseInt(bp.nowPage)-1;
			   bp.loadBackUpDate();
		   }
		}else{
			cPage.style.cssText="padding-left:10px;color:#C0C0C0;";
		}
		divPages.appendChild(cPage)
		
		cPage=document.createElement("span");
		cPage.setAttribute("title","尾  页");
		cPage.style.cssText="padding-left:10px;cursor:hand;";
		cPage.innerHTML="尾  页";
		if(this.pages>1&&this.nowPage<this.pages){
		   cPage.onclick=function(){
			   bp.nowPage=pages;
			   bp.loadBackUpDate();
		   }
		}else{
			cPage.style.cssText="padding-left:10px;color:#C0C0C0;";
		}
		divPages.appendChild(cPage)
		var runTime=document.createElement("span");
		runTime.style.cssText="color:#FF0000;padding-left:25px;"
		runTime.innerHTML="运行时间"+out[2]+"ms";
		divPages.appendChild(runTime);
		
	}else{
		if(cTable.childNodes.length>0){
			cTable.firstChild.removeNode(true);
		}
		divPages.innerHTML="<p style='color:#FF0000;'>从"+$("selectTime").value+"到现在没有相应的信息</p>";		
	}
}