function updateOutput(index, type)
{
	var slotUpdate;
	if(type == ADD)
	{
		slotUpdate= document.getElementById("AddDstSlotNo");
	}
	else if(type == EDIT)
	{
		slotUpdate = document.getElementById("dstslotnum" + index);
	}
	else if(type == MODIFY)
	{
		slotUpdate= document.getElementById("modifyDstSlotNo");
	}
	slotUpdate.options.length=0;	
	if((Outputcardnum == 0)&&("0"==gbemulti_outport_exist))
	{
		var newitem = new Option("无","15");         
		slotUpdate.options.add(newitem);
	}
	for(i = 0; i < Outputcardnum; i++)
	{
		if(slotno != Outputcardid[i])
		{
			var newitem = new Option("卡"+Outputcardid[i]+"-"+Outputcardname_zh[i],Outputcardid[i]-1);         
	   		slotUpdate.options.add(newitem);
		}    
	}
	if("1" == gbemulti_outport_exist)
	{
		var newitem = new Option("主千兆卡","6");         
		slotUpdate.options.add(newitem);  
	}
	if(type != EDIT)
	{
		changePortList(MODAL_INDEX, type);
	}
}

function changePortList(index, type)
{
	var curSlotNo;
	var portUpdate;
	if(type == ADD)
	{
		curSlotNo = parseInt($("#AddDstSlotNo").val(), 10);
		portUpdate = document.getElementById("AddDstPortNo");
	}
	else if(type == EDIT)
	{
		curSlotNo = parseInt($("#dstslotnum" + index).val(), 10);
		portUpdate = document.getElementById("dstportnum" + index);
	}
	else if(type == MODIFY)
	{
		curSlotNo = parseInt($("#modifyDstSlotNo").val(), 10);
		portUpdate = document.getElementById("modifyDstPort");
	}	
	portUpdate.options.length=0;
	if(curSlotNo ==15)
	{
		var newitem = new Option("无",15);         
		portUpdate.options.add(newitem);
	}
	else if(curSlotNo == 6)
	{
		for(j = 0; j < gbeoutportno.length; j++)
		{
			if(gbeoutportno[j] > 255)
			{
				var newitem = new Option("网口2端口"+(gbeoutportno[j]-255),gbeoutportno[j]);         
				portUpdate.options.add(newitem);  
			}
			else
			{
				var newitem = new Option("网口1端口"+(gbeoutportno[j]+1),gbeoutportno[j]);         
				portUpdate.options.add(newitem);  
			}
		}
	}
	else
	{
		for(j = 0; j < Outputportnum[curSlotNo]; j++)
		{
			var portno = eval("outportno_"+curSlotNo+"["+j+"]");
			var newitem = new Option("端口"+(portno+1),portno);      
			portUpdate.options.add(newitem);  
		}
	}
}

function addsubmitcheck()
{	
	var returnnum;	
	patten = /^\d+$/;
	if(!patten.test($("#AddNum").val()))
	{
		alert("<添加个数>必须为十进制数!");
		$("#AddNum").focus();
		return; 
	}
	var tempnum = parseInt($("#AddNum").val(),10);
	if(TotalNum == 256)
	{
		alert("已有256条配置信息，不能再添加新的信息！");
		$("#AddNum").focus();
		return;
	}
	else
	{
		if((tempnum < 1)||(tempnum > 256 - TotalNum))
		{
			alert("<添加个数>必须在1和" + (256 - TotalNum) +"之间!");
			$("#AddNum").focus();
			return;
		}
	}
	returnnum=ValidateNum($("#AddTsId"),"ID","<传送流ID>");
	if(returnnum == false)
	{
		return;
	}
	returnnum=ValidateNum($("#AddServiceId"),"PROGIDENTIFIER","<节目号>");
	if(returnnum == false)
	{
		return;
	}	
	returnnum=ValidateNum($("#AddNetid"),"ID","<网络ID>");
	if(returnnum == false)
	{
		return;
	}
	returnnum=ValidateNum($("#AddFileName"),"NAME","<文件名>");
	if(returnnum == false)
	{
		return;
	}
	CreateHiddenFormElem("paramform","Operation",1);
	CreateHiddenFormElem("paramform","CurSlot",slotno);
	$("#addsubmitbtn").attr("disabled",true);
	$("#paramform").submit(); 
	setTimeout("self.location.reload(true)",1000);
}
function submitcheck()
{	
	var returnnum;
	for(i=0;i<CurPageRowNum;i++)
	{		
		returnnum=ValidateNum($("#tsid"+(i+1)),"ID","<传送流ID>");
		if(returnnum == false)
		{
			return;
		}
		returnnum=ValidateNum($("#serviceid"+(i+1)),"PROGIDENTIFIER","<节目号>");
		if(returnnum == false)
		{
			return;
		}
		returnnum=ValidateNum($("#netid"+(i+1)),"ID","<网络ID>");
		if(returnnum == false)
		{
			return;
		}
		returnnum=ValidateNum($("#filename"+(i+1)),"NAME","<文件名>");
		if(returnnum == false)
		{
			return;
		}
	}
	$("#Subbtn").attr("disabled",true);
	CreateHiddenFormElem("myform","Operation",2);
	CreateHiddenFormElem("myform","CurSlot",slotno);
	CreateHiddenFormElem("myform","CurRow",parent.CurrentRow);
	$("#myform").submit(); 
	setTimeout("self.location.reload(true)",1000);
}