//导入规则 e52731e59："co","pub","flow",
function GetRule(nid,e52731e59)
{
	if(em_usrrank<5) {
		alert("您的用户级别尚不足以使用该功能，请联系官网客服提升级别。");
		return;
	}
	if(!e52731e59)e52731e59='CO';	
	var curl="/mr_EximportRule.php?e1434c60d=1&gettype=post&e52731e59="+e52731e59+"&eb5707348=GetRule";
	var maininfo=makeformhtml(0,curl);
	$.poping({'width':'800px','height':'400px'},{},'导入配置',maininfo);
}
//type:0 导入规则  :1导出规则
function makeformhtml(type,curl,setstr){
	//alert(setstr);
	if(!setstr)setstr='';
	var tiptxt='',downfilestr='',maininfo='';
	if(type==0){
		actionurl=curl;
		//tiptxt='请在下面输入你要导入的文本配置或者上传配置文本文件';
		tiptxt='请在下面输入你要导入的配置文本';
		downfilestr='上传文件：<input type="file" name="ea40420c8">';
	}else {
		actionurl='';
		tiptxt='以下是检索到的节点配置文本，请复制保存以供下次使用。';
		//tiptxt='以下是检索到的节点配置文本，请复制保存或直接下载配置文本文件';
		downfilestr="配置文本附件：<a href='"+curl+"'><img src=\"images/gtk-edit.png\" alt=\"配置文本附件\" title=\"配置文本附件\"></a>";
	}

	maininfo+='<div id="div_dialogcontent">\
	<form id="eminerform" name="eminerform" method="post" action="'+actionurl+'" enctype="multipart/form-data" target="ajaxUpload">\
	<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DADADA">\
	<tbody><tr bgcolor="#DADADA">\
	<td colspan="2" background="images/wbg.gif" height="20"><font color="#666600"><b>'+tiptxt+'：</b></font></td>\
	</tr>\
	<tr bgcolor="#FFFFFF">\
	<td colspan="2" height="100">  <textarea name="notes" style="width:99%;height:200px">'+setstr+'</textarea> </td>\
	</tr>';
	/*
	maininfo+='<tr bgcolor="#FFFFFF">\
	<td colspan="2" height="20"> '+downfilestr+'</td>\
	</tr>';
	*/
	if(type==0)
	maininfo+='<tr>\
	<td colspan="2" bgcolor="#F9FCEF">\
	<table width="270" border="0" cellpadding="0" cellspacing="0">\
	<tbody><tr align="center" height="22">\
	<td width="90"><input name="imageField1" type="image" class="np" src="images/button_ok.gif" width="60" height="20" border="0" onclick="return Getruleconfirm(this)"></td>\
	<td width="90"><a href="#"><img class="np" src="images/button_reset.gif" width="60" height="20" border="0" onclick="this.form.reset();return false;"></a></td>\
	<td><a href="#"><img src="images/button_back.gif" width="60" height="20" border="0" onclick="$.unblockui();"></a></td>\
	</tr>\
	</tbody></table>\
	</td></tr>';


	maininfo+='</tbody></table></form>\
	<iframe id="ajaxUpload" name="ajaxUpload" style="width:0px;height:0px;display:none"></iframe></div>';
	return maininfo;
}



function Getruleconfirm(butt)
{
	var form=butt.form;
	form.notes.value=form.notes.value.trim();
	//form.ea40420c8.value=form.ea40420c8.value.trim();
	//if(form.notes.value && form.ea40420c8.value ) {alert("配置文本框和上传文件框不能同时有值");return false;}
	//if(!form.notes.value && !form.ea40420c8.value ) {alert("配置文本框和上传文件框二者之间必须有且仅有一个不能为空。");return false;}
	if(!form.notes.value ) {alert("配置文本框不能为空。");return false;}

	return true;

}
function ActRuleCallback(type,status,info,data,url){
	
	if(status=='success'){
		
		if(type==0){
		alert(info);
			window.location.reload();
		}else{
			var htmlstr=makeformhtml(1,url,data);
			$("#popmaininfo").html(htmlstr);
			alert(info);
		}
	}else{
		alert(info);
		if(type==1){$.unblockui();}
	}
}




//导出规则 e52731e59："co","pub","flow",
function ExportRule(nid,e52731e59)
{
	if(em_usrrank<5) {
		alert("您的用户级别尚不足以使用该功能，请联系官网客服提升级别。");
		return;
	}
	if(!nid) {nid=$("input.np:radio:checked").val();}  
	if(!nid){ alert("请选择一个节点！"); return;}
	if(!e52731e59)e52731e59='CO';	
	var ed946d2b0=$("tr[index='"+nid+"'] td.ed946d2b0").text();
	var curl="/mr_EximportRule.php?e1434c60d=1&gettype=post&e52731e59="+e52731e59+"&eb5707348=ExportRule&id="+nid;
	var now = (new Date()).getTime();
	
	
	$.poping({'width':'800px','height':'400px'},{},'导出配置--'+ed946d2b0,'<div id="div_dialogcontent"></div>');
	$.ajax({
		type: "POST",
		url: curl,
		dataType: "json",
		cache: false,
		success: function(data) {
			 if (data.status=="success"||data.status=="1") {
				$("#popmaininfo").html(makeformhtml(1,data.downurl,data.data));
			}else{
				if(data.info)$("#popmaininfo").html(data.info);
				else $("#popmaininfo").html('未成功导出配置数据，请检查配置');

				setTimeout( function() {$.unblockui();}, 2000);
			}
			
		},
		error: function(){
			
		}
	});	
}


