// Load a page as if a node on the tree was clicked (synchronize frames)
// (Highlights selection if highlight is available.)
function loadSynchPage(linkID) 
{
	//alert("loadSynchPage called with " + linkID);
	//alert("must synchronize page");
	var docObj;
	docObj = findObj(linkID);
	docObj.forceOpeningOfAncestorFolders();
	highlightObjLink(docObj);
	//clickOnLink(linkID,docObj.link,'_self');
} 

//this is not used anymore but left here for possible future usage
function getQueryString(index)
{
	//alert("getquerystring called with " + index);
	var paramExpressions;
	var param;
	var val;
	paramExpressions = window.location.search.substr(1).split("&");
	if (index < paramExpressions.length)
	{
		param = paramExpressions[index]; 
		if (param.length > 0) {
			return eval(unescape(param));
		}
	}
	return "";
}

function checkSynch(index)
{
	//alert("checksynch called with " + index);
	//var camefromTree = getQueryString(0);
	//alert("camefromTree is:" + camefromTree);
	//if(camefromTree != 1) loadSynchPage(index);
	//alert("current selected xid:" + currentNodeID());
	if(currentNodeID() != index) loadSynchPage(index);
}

function currentNodeID() {
   if (typeof lastClicked == "undefined" || lastClicked == null)
      return null;
   return lastClicked.xID;
}

// Open all folders
// May not work with very large trees (browser may time out)
// You may call this on a node other than the root, but it must be a folder
function expandTree(folderObj)
{
    var childObj;
    var i;

    //Open folder
    if (!folderObj.isOpen)
      clickOnNodeObj(folderObj)

    //Call this function for all folder children
    for (i=0 ; i < folderObj.nChildren; i++)  {
      childObj = folderObj.children[i]
      if (typeof childObj.setState != "undefined") {//is folder
        expandTree(childObj)
      }
    }
}

// Close all folders
function collapseTree()
{
	//hide all folders
	clickOnNodeObj(foldersTree)
	//restore first level
	clickOnNodeObj(foldersTree)
}

function submit(frm)
{
  frm.submit();
} 

function nothing()
{
  return false;
}

function op()
{
}

function smouse(img,s)
{
  //controls the search button's images
  if(s==0)
    //normal
    img.src = "images/sbutton.gif";
  else if(s==1)
    //mouse over
    img.src = "images/sbuttonover.gif";
  else if(s==2)
    //mouse down
    img.src = "images/sbuttonclk.gif";
}