/**
* getToc function:
* The getToc function builds the link of the folders levels in the TOC.
* The getToc parameters :
* 	@param nodeId - the id of the TOC node
*	@param level  - how many levels of descendants to open
*	@param first  - the position (1,2,3, ...) of the first visible child
*	@param mode   - direction of retrieving descendants (prev siblings or next siblings
*
* the function creates the request URL and sends it.
* The URL is of the form: GetTocDescendants.do?nodeId&level&[first | last]
* if neither first nor last is provided then we will retrieve 'next' siblings starting from the 1st child
*/

function getToc(nodeId,level,position,mode)
{
	var props = new Object();

	props.nodeId=nodeId;
	props.maxChildrenInLevel=100;

	if (level!='')
	{
		props.level=level ;
	}

	if(mode == "next")
	{
		props.first=position;
	}
	else if(mode == "previous")
	{
		props.last=position;
	}

	URLUtil.openLinkUnified("GetTocDescendants.do", props);
}



/**
* getDoc function:
* The getDoc function builds the link of the documents in the TOC.
* The getToc parameters :
* 	@param documentId - id of the document we want to show
*
* GetDocument.do?doc=documentId
**/


function getDoc(documentId, tocNodeId)
{
	//var gotoURL = "GetDocument.do?doc="+escape(documentId );

	// set the parameters for the request
	var props = new Object();

	props.nodeId=tocNodeId;
	props.docId=documentId;
	props.locSource="input";
	var nodeId = documentId.substring(documentId.indexOf("docID=")+6,documentId.indexOf(")")+1);
	props.docLoc="$REP_ROOT$"+nodeId;

	URLUtil.openLinkUnified("GetDocument.do", props);
}


function openShortcut(nodeId,type)
{
	var props = new Object();

	props.targetId=nodeId;
	props.type=type;

	URLUtil.openLinkUnified("OpenShortcut.do", props);
}

// Add message to TOCFolders
//
function addMessage(a_nodeId,a_parentId,a_title)
{
/*
	if(event.button==2)
	{
		alert("add message to: "+a_title);
		document.location = "AddTOCThread.do?parentId="+escape(a_parentId)+"&nodeId="+escape(a_nodeId)+"&targetType=TOC&title="+a_title;
	}
*/
}








