var operateEdit1 = "<img src='../../style/img/xiugai.png' title='修改'  onClick='editesinfo(GetRow(event,0))'>&nbsp;";
var operateDel1  = "<img src='../../style/img/shanchu1.png' title='删除'  onClick='delesinfo(GetRow(event,0))'>";
function delesinfo(index)
{
	var id = parseInt(index,10)-1;	
	$("#OperateType").val("1");
	$("#Es_OperateType").val("3");
	$("#Es_Pos").val(id);
	var confirm_prompt = "确定要删除 " + element_PID[id] + " ?";
	if(window.confirm(confirm_prompt))
	{
		$("#myform").submit();
		setTimeout("self.location.reload(true)",1000);
	}	
}
//form 提交
function submitcheck(Type)
{
	if(submitcnt != 0 )
	{
		return;
	}
	var returnnum;
    var paramentnum=0;
	var cnt=0;
	var tempid = $("#Curid").val();
	returnnum=ValidateParam($("#Version_Num"),"VALI_INTEGER",0,31,"<版本号>",1);
	if(returnnum==false)
	{
		return;
	}
	switch(Type)
	{
		case "ES":
			returnnum=ValidateParam($("#Es_Type"),"VALI_INTEGER",0,255,"<单元类型>",1);
			if(returnnum==false)
			{
				return;
			}
			returnnum=ValidateParam($("#Es_Pid"),"VALI_COM_DATA",32,8190,"<单元 PID>",1);
			if(returnnum==false)
			{
				return;
			}
			if(($("#Es_OperateType").val() ==1)||(($("#Es_OperateType").val() ==2)&&(parseInt($("#Es_Pid").val()) != parseInt(element_PID[tempid]))))//新添加了或者Modify了PID
			{
				for(i=0;i<elementnum;i++)
				{	
					if(parseInt($("#Es_Pid").val()) == parseInt(element_PID[i]))
					{
						alert("单元 PID已经存在!");
						return false;
					}
				}
			}
			CreateHiddenFormElem("Es_Type", $("#Es_Type").val());
			CreateHiddenFormElem("Es_Pid", $("#Es_Pid").val());
			break;
		case "Apply":
			$("#Apply_Enable").val("1");
			break;
	}
	$("#myform").submit();
	submitcnt++;
	setTimeout("self.location.reload(true)",1000);	
}
function deletedesc()//Delete descriptor
{	
	var rightclick_node = zTree.getSelectedNodes();
	$("#Pos").val(rightclick_node[0].POS);
	if(rightclick_node[0].level==2)//Delete Program descriptor
	{
		$("#OperateType").val("2");
		var confirm_prompt = "确定要删除当前描述符?";
		if(window.confirm(confirm_prompt))
		{
			submitcheck();
		}
	}
	else
	{
		$("#OperateType").val("3");
		var confirm_prompt = "确定要删除当前描述符?";
		if(window.confirm(confirm_prompt))
		{
			submitcheck();//Delete Element descriptor(second)
		}	
	}	
}