var syncStatusEn = ["Unlock", "Lock"];
var syncStatusCn = ["未锁定", "锁定"];
var syncStatus = [syncStatusEn, syncStatusCn];

var objIdArray = ["syncStatus", "totalRate", "effectivRate", "signalStrength", "signalQuality", "channelInfo"];
var ROW_NUM = 6;
var CHANNEL_INFO = 5;
var channelInfo = [];
var SIGN = ",";

window.onresize = function()
{
	GetMainContentHeight(BUTTON_TOP_MENU, NO_BUTTON_CHANGE);
}

$(document).ready(function()
{
	var args = GetArgs();
	slotNo = parseInt(args["slotNo"], 10);
	portNo = parseInt(args["portNo"], 10);
	GetMainContentHeight(BUTTON_TOP_MENU, NO_BUTTON_CHANGE);
	funcUpdateDisplay();
});

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

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

	xmlHttp.open("GET", "/goform/formEMR30?type=" + PORT_MONITOR + "&cmd=" + GET + "&language=" + language + "&slotNo=" + slotNo + "&portNo=" + portNo + "&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);
				for(var i = 0; i < ROW_NUM; i++)
				{
					if(i == 0)
					{
						$("#" + objIdArray[i]).html(syncStatus[language][data[i]]);
					}
					else if(i== CHANNEL_INFO)
					{
						channelInfo = data[CHANNEL_INFO].split(SIGN);						
						displayChannelInfo();
					}
					else
					{
						$("#" + objIdArray[i]).html(data[i]);
					}
				}
				refreshFlag = true;
			}
		}
	}
	xmlHttp.send(null);
}

function displayChannelInfo()
{
	$("#channelInfo").empty();
	var length = channelInfo.length;
	for(var i = 0; i < length; i++)
	{
		$("#channelInfo").append("<span id='channelInfo" + i + "'></span><br>");
		$("#channelInfo" + i).html(channelInfo[i]);
	}
}