var rowNum;
var rowIdArray = ["pidValue", "pidType", "pidBitrate"];
var COL_NUM = 3;
var id;
var udpPortNo;
var serviceId;

window.onresize = function()
{
	$("#mainContent").css("height", function(index, value)
	{
		return ((parent.rightIframeHeight - 30) + "px");
	});
}

$(document).ready(function()
{
	var args = GetArgs();
	id = args["ID"];
	slotNo = id.split("_")[0];
	portNo = id.split("_")[1];
	udpPortNo = id.split("_")[2];
	serviceId = id.split("_")[3];
	
	pageApply();
	$("#mainContent").css("height", function(index, value)
	{
		return ((parent.rightIframeHeight - 30) + "px");
	});
	funcUpdateDisplay();
	setInterval("displayParam();", 10000);
});

function funcUpdateDisplay() 
{	 
	DisableButton("refreshBtn");
	PageLoadStatus(true);
	
	displayParam();
	
	ResetColor();
	EnableButton("refreshBtn");
	PageLoadStatus(false);
}

function displayParam()
{
	var data;
	var response;
	var length;
	var xmlHttp = GetHTTPObject();
	var infoData;

	xmlHttp.open("GET", "/goform/formEMR30?type=" + GBE_OUT_PID_DETAIL + "&cmd=" + GET + "&slotNo=" + slotNo + "&portNo=" + portNo + "&udpPortNo=" + udpPortNo + "&serviceId=" + serviceId + "&language=" + language 
		+ "&slotNo=" + slotNo + "&ran=" + Math.random(), true);
	xmlHttp.onreadystatechange = function()
	{
		if((xmlHttp.readyState == 4) && (xmlHttp.status == 200))
		{
			response = AjaxStrDeal(xmlHttp.responseText);
			if(response != "")
			{
				data = response.split(FIRST_DELIMITER);
				length = data.length;
				rowNum = length - 1; //主控那边为了提高效率，最后有一个拼接符
				DrawTableRow("dataTable", "dataRow", "CaseRow", rowNum);
				if(rowNum != 0)
				{
					updateTableData(data);
				}
				refreshFlag = true;
			}
		}
	}
	xmlHttp.send(null);
}

function updateTableData(data)
{
	var rowData;
	var index;
	
	for(var i = 0; i < rowNum; i++)
	{
		index = i + 1;
		rowData = data[i].split(SECOND_DELIMITER);
		for(var j = 0; j < COL_NUM; j++)
		{
			$("#" + rowIdArray[j] + index).html(rowData[j]);
		}
	}
}

function pageApply()
{
	var data;
	var response;
	var xmlHttp = GetHTTPObject();	
	
	data = "type=" + GBE_OUT_PID_DETAIL + "&cmd=" + SET + "&id=" + id + "&language=" + language + "&slotNo=" + slotNo + "&portNo=" + portNo + "&udpPortNo=" + udpPortNo + "&serviceId=" + serviceId + "&setString=";
	
	xmlHttp.open("POST", "/goform/formEMR30", true)
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", data.length);

	xmlHttp.onreadystatechange = function()
	{
		if((xmlHttp.readyState == 4) && (xmlHttp.status == 200))
		{
			//不做任何处理
		}
	}
	xmlHttp.send(data);
}
