var operateEdit1 = "<img src='../../style/img/xiugai.png' title='修改'  onClick='edittsinfo(GetRow(event,0))'>&nbsp;";
var operateDel1  = "<img src='../../style/img/shanchu1.png' title='删除'  onClick='deltsinfo(GetRow(event,0))'>";
//删除流信息
function deltsinfo(index)
{
	var id = parseInt(index,10)-1;	
	$("#OperateType").val("2");
	$("#Stream_operatetype").val("3");
	$("#Stream_Pos").val(stream_index[id]);	
	var confirm_prompt = "确定要删除描述符 " + (parseInt(stream_index[id],10)+1) + " 吗？";
	if(window.confirm(confirm_prompt))
	{
		$("#myform").submit();
		setTimeout("self.location.reload(true)",1000);
	}	
}
//删除流描述符信息
function deltsdesc()
{
	var rightclick_node = zTree.getSelectedNodes();
	$("#Pos").val(rightclick_node[0].POS);
	
	if(rightclick_node[0].level==2)//Delete Program descriptor
	{
		$("#OperateType").val("1");
		var confirm_prompt = "确定要删除当前描述符?";
		if(window.confirm(confirm_prompt))
		{
			submitcheck();
		}
	}
	else
	{
		$("#Tsid").val(rightclick_node[0].getParentNode().STREAM);
		$("#OperateType").val("3");
		var confirm_prompt = "确定要删除当前描述符?";
		if(window.confirm(confirm_prompt))
		{
			submitcheck();//Delete Element descriptor(second)
		}	
	}	
}
//主页面表单提交
function submitcheck(Type)
{	
	if(submitcnt != 0)
	{
		return;
	}
	var returnnum;
    var paramentnum=0;
	var cnt=0;
	var tempid = $("#Curid").val();
	returnnum=ValidateParam($("#Network_Id"),"VALI_INTEGER",0,65535,"<网络ID>",1);
	if(returnnum==false)
	{
		return;
	}
	if(parseInt($("#Network_Id").val(),10)!=parseInt(network_id,10))//修改了网络ID
	{
		for(i=0; i<psinum; i++)
		{
			if((PsiType[i] == "NITa")&&(parseInt(Id_Ext[i],10) == parseInt($("#Network_Id").val(),10)))
			{
				alert("已存在相同网络ID的NIT当前表！");
				return false;
			}
			if((PsiType[i] == "NITo")&&(parseInt(Id_Ext[i],10) == parseInt($("#Network_Id").val(),10)))
			{
				alert("已存在相同网络ID的NIT其他表！");
				return false;
			}
		}
	}
	returnnum=ValidateParam($("#Version_Num"),"VALI_INTEGER",0,31,"<版本号>",1);
	if(returnnum==false)
	{
		return;
	}
	switch(Type)
	{
		case "ts_info":
			returnnum=ValidateParam($("#Stream_Id"),"VALI_INTEGER",0,65535,"<流ID>",1);
			if(returnnum==false)
			{
				return;
			}
			returnnum=ValidateParam($("#Ornet_Id"),"VALI_INTEGER",0,65535,"<原始网络ID>",1);
			if(returnnum==false)
			{
				return;
			}
			if($("#Stream_operatetype").val() == "1")//添加信息
			{
				for(i=0;i<stream_num;i++)
				{
					if((parseInt($("#Stream_Id").val(),10)==stream_id[i])&&(parseInt($("#Ornet_Id").val(),10)==ornet_id[i]))//同时存在相同的流ID和网络ID
					{
						alert("已存在相同的流ID和网络ID!");
						return false;
					}
				}
			}
			else if($("#Stream_operatetype").val() == "2")//修改信息
			{
				for(i=0;i<stream_num;i++)
				{
					if((parseInt($("#Stream_Id").val(),10)!=stream_id[tempid])||(parseInt($("#Ornet_Id").val(),10)!=ornet_id[tempid]))//发生了改变才判断
					{
						if((parseInt($("#Stream_Id").val(),10)==stream_id[i])&&(parseInt($("#Ornet_Id").val(),10)==ornet_id[i]))//同时存在相同的流ID和网络ID
						{
							alert("已存在相同的流ID和网络ID!");
							return false;
						}
					}
				}
			}
			CreateHiddenFormElem("Stream_Id", $("#Stream_Id").val());
			CreateHiddenFormElem("Ornet_Id", $("#Ornet_Id").val());
			break;		
		case "Apply":
			$("#Apply_Enable").val("1");
			break;
	}
	$("#myform").submit();
	submitcnt++;
	var tableId = parseInt($("#Network_Id").val(), 10);
	var psiIdArray = [string[0], string[1], string[2], tableId, string[4]];
	newPsiId = psiIdArray.join("_");
	setTimeout("top.mainFrame.location.href = '../desc/nitcedit.asp?PSIID="+ newPsiId +"'",1000);
}
function GetDescInfo()
{
	var psitype=$("#PsiType").val();
	var symbol = "_"
	var edittype = $("#Desc_OperateType").val();
	var curdesctag = $("#cur_desc_tag").val();
	var curdesctype = psitype.concat(symbol,edittype,symbol,curdesctag);
	var DESC_ID=$("#CurDescId").val();
	
	var xmlhttp = getHTTPObject();
	var getParams = "desc_type="+curdesctype+"&desc_id="+DESC_ID+"";
	
	xmlhttp.open("POST", "/goform/mcuGetDescInfo", true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", getParams.length);
	xmlhttp.onreadystatechange = function()
	{
		if(xmlhttp.readyState == 4)
		{
			if((xmlhttp.status>=200&&xmlhttp.status<300)||xmlhttp.status==304)
			{
				var response = xmlhttp.responseText.slice(7, -8);
				var response_array = response.split("&");
				Assignment(1,response_array);
			}
			else
			{
				alert("请求未成功:"+xmlhttp.status);
			}
		}
	}
	xmlhttp.send(getParams);
	return true;
}