var operateEdit1 = "<img src='../../style/img/xiugai.png' title='Modify'  onClick='edittsinfo(GetRow(event,0))'>&nbsp;";
var operateDel1  = "<img src='../../style/img/shanchu1.png' title='Delete'  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 = "Are you sure to delete stream " + (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 = "Are you sure to delete current descriptor?";
		if(window.confirm(confirm_prompt))
		{
			submitcheck();
		}
	}
	else
	{
		$("#Tsid").val(rightclick_node[0].getParentNode().STREAM);
		$("#OperateType").val("3");
		var confirm_prompt = "Are you sure to delete current descriptor?";
		if(window.confirm(confirm_prompt))
		{
			submitcheck();//Delete Element descriptor(second)
		}	
	}	
}
//main page form submit
function submitcheck(Type)
{	
	if(submitcnt != 0)
	{
		return;
	}
	var returnnum;
	var tempid = $("#Curid").val();
	returnnum=ValidateParam($("#Network_Id"),"VALI_INTEGER",0,65535,"<Network ID>",2);
	if(returnnum==false)
	{
		return;
	}
	if(parseInt($("#Network_Id").val(),10)!=parseInt(network_id,10))
	{
		for(i=0; i<psinum; i++)
		{
			if((PsiType[i] == "NITa")&&(parseInt(Id_Ext[i],10) == parseInt($("#Network_Id").val(),10)))
			{
				alert("Already exists the Nit(Current) table which has the same Network ID!");
				return false;
			}
			if((PsiType[i] == "NITo")&&(parseInt(Id_Ext[i],10) == parseInt($("#Network_Id").val(),10)))
			{
				alert("Already exists the Nit(Other) table which has the same Network ID!");
				return false;
			}
		}
	}
	returnnum=ValidateParam($("#Version_Num"),"VALI_INTEGER",0,31,"<Version Num>",2);
	if(returnnum==false)
	{
		return;
	}
	switch(Type)
	{
		case "ts_info":
			returnnum=ValidateParam($("#Stream_Id"),"VALI_INTEGER",0,65535,"<Stream ID>",2);
			if(returnnum==false)
			{
				return;
			}
			returnnum=ValidateParam($("#Ornet_Id"),"VALI_INTEGER",0,65535,"<Original Network ID>",2);
			if(returnnum==false)
			{
				return;
			}
			if($("#Stream_operatetype").val() == "1")//add
			{
				for(i=0;i<stream_num;i++)
				{
					if((parseInt($("#Stream_Id").val(),10)==stream_id[i])&&(parseInt($("#Ornet_Id").val(),10)==ornet_id[i]))
					{
						alert("Already exists the same Stream ID and Network ID!");
						return false;
					}
				}
			}
			else if($("#Stream_operatetype").val() == "2")//modify
			{
				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]))
						{
							alert("Already exists the same Stream ID and Network 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/nitoedit.asp?PSIID="+ newPsiId +"'",1000);
}