var idString;
var optionLength;
var BUTTON_TAB_BLANK_HEIGHT = 69;
var DVB = 0;

function changeTreeHeight()
{
	GetMainContentHeight(BUTTON_TOP_NO_MENU, NO_BUTTON_CHANGE);
	$("#treeContent").css("height", function(index, value)
	{
		return ((parent.iframeHeight - BUTTON_TAB_BLANK_HEIGHT) + "px");
	});	
}

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

$(document).ready(function()
{
	var args = GetArgs();
	idString = args["ID"].split("_");
	changeTreeHeight();
	optionLength = $("#psiType").find("option").length;
	if(parseInt(work_mode, 10) == DVB)
	{
		if(optionLength == 3)
		{
			$("#psiType").append("<option value='2'>SDTa</option>");
			$("#psiType").append("<option value='3'>SDTo</option>");
			$("#psiType").append("<option value='4'>NITa</option>");
			$("#psiType").append("<option value='5'>NITo</option>")
			$("#psiType").append("<option value='6'>BAT</option>");
		}
	}
	reloadTree();
	$("#psiType").val(parseInt(idString[3], 10));
});

var zTree;
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,
					showIcon:false,
					selectedMulti: false
				},
		callback:{
					 beforeClick: zTreeBeforeClick
				 }
	};
	
function zTreeBeforeClick(treeId, treeNode) 
{
	return false;
}

function reloadTree() 
{
	zTree = $.fn.zTree.init($("#treeDemo"), setting, PSINodes);
}

function changePsiType()
{
	var temp = idString[0].concat("_", idString[1], "_", idString[2], "_");
	var psiType = parseInt($("#psiType").val(), 10);
	self.location.replace("psi_preview" + pageLanguage[language] + "?ID=" + temp + psiType);
}