var zTree;
//设置配置参数 和 方法
var setting =
{
	editable: false,//参数设置为true便可使用拖拽功能
	edit_renameBtn:false,
	edit_removeBtn:false,
	dragCopy: true,//拖拽功能为复制然后在目的菜单添加
	dragMove: false,//拖拽功能为先删除然后在目的菜单添加
	data: {
		key: {
			children: "nodes"
		},
		simpleData: {
			enable : false,
			idKey : "id",
			pIdKey : "pId",
			rootPId : null
		}
	},
	view: {
		showLine: true,
		showTitle:false,
		selectedMulti: false
	},
	callback: {
				beforeClick: zTreeBeforeClick,
				onClick: treeOnClick
			  }
};

var TREE_BLANK_HEIGHT = 66;
var IFRAME_BLANK_HEIGHT = 45;
var rightIframeHeight;
var id;
var muxServiceId;

function zTreeBeforeClick(treeId, treeNode, clickFlag)
{
	if(treeNode.level == 0)
	{
		return false;
	}
	else
	{
		return true;
	} 
};
function treeOnClick(event, treeId, treeNode) 
{
	self.frames[0].location.replace(treeNode.href);
}

function resizeHeight()
{
	GetMainContentHeight(BUTTON_TOP_MENU, NO_BUTTON_CHANGE);
	$(".mux_tree_content").css("height", function(index, value)
	{
		return ((parent.iframeHeight - TREE_BLANK_HEIGHT) + "px");
	});	
	rightIframeHeight = parent.iframeHeight - IFRAME_BLANK_HEIGHT;
	$(".iframe").css("height", function(index, value)
	{
		return (rightIframeHeight + "px");
	});	
}

window.onresize = function()
{
	resizeHeight();
}

$(document).ready(function()
{
	var args = GetArgs();
	id = args["ID"];
	slotNo = id.split("_")[0];
	portNo = id.split("_")[1];
	displayTopMenu();
	resizeHeight();	
	funcUpdateDisplay();
});

function displayTopMenu()
{
	if((portNo == 2) || (portNo == 3))
	{
		var curGbeEna = parent.selectNode.phyena;
		if(curGbeEna == INPUT)  //input
		{			
			$("#transmitMenu").css("display", "none");
			$("#arpMenu").css("display", "none");
			$("#backupMenu").css("display", "none");
		}
		else if(curGbeEna == OUTPUT)  //output
		{
			$("#receiveMenu").css("display", "none");
			$("#backupMenu").css("display", "none");
		}
		else if(curGbeEna == IN_AND_OUT)  //input and output
		{
			$("#backupMenu").css("display", "none");
		}
	}	
}

function funcUpdateDisplay()
{
	PageLoadStatus(true);
	
	zTree = $.fn.zTree.init($("#outputTree"), setting, zNodesOutPidRateTree);
	displayParam();
	
	PageLoadStatus(false);
}

function displayParam()
{
	var selectNode;
	
	if(zTree.getNodesByParam("level", "1").length == 0)
	{
		zTree.selectNode(zTree.getNodesByParam("level", "0")[0], false);
		selectNode = zTree.getNodesByParam("level", "0")[0];
	}
	else
	{
		zTree.selectNode(zTree.getNodesByParam("level", "1")[0], false);
		selectNode = zTree.getNodesByParam("level", "1")[0];
	}
	self.frames[0].location.replace(selectNode.href);
}