var idString;
var optionLength;
var BUTTON_TAB_BLANK_HEIGHT = 69;
var group;
var userName;
var mainIpAddr;

function changeTreeHeight()
{
	$("#treeContent").css("height", function(index, value)
	{
		return (($("#mainContent").height() - BUTTON_TAB_BLANK_HEIGHT) + "px");
	});	
}

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

$(document).ready(function()
{
	var args = GetArgs();
	idString = args["ID"].split("_");
	group = args["group"];
	userName = args["userName"];
	mainIpAddr = args["mainIpAddr"];
	initFlag = args["init"];
	if(initFlag == 0)
	{
		if(language == CHINESE)
		{
			var breadCrumbText = encodeURIComponent("PSI/SI预览", "utf-8");
		}
		else
		{
			var breadCrumbText = encodeURIComponent("PSI/SI Preview", "utf-8");
		}
		$("#transferFrame").attr("src", "http://" + mainIpAddr + "/asp/transfer.asp?group=" + group + "&userName=" + userName +"&information=" + breadCrumbText);
	}
	changeTreeHeight();
	reloadTree();
	$("#psiType").val(parseInt(idString[5], 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], "_", idString[3], "_", idString[4], "_");
	var psiType = parseInt($("#psiType").val(), 10);
	self.location.replace("psi_preview" + pageLanguage[language] + "?ID=" + temp + psiType + "&mainIpAddr=" + mainIpAddr + "&group=" + group + "&userName=" + userName + "&init=1");
}