/*******************************************************************************
** FILE : siteTree.js
********************************************************************************
** client side object that create the menus,site map and pointer
** *****************************************************************************
** created by	: ilan mazuz and yossi aharoni
** created on	: 10-10-2001
** scepia ltd.
*******************************************************************************
* Contents:
* - siteTree()		: the object itself
	pointer			= pointer();//pointer(projector) function
	positionMenus	= position();//position menu function
*
*******************************************************************************
* PARAMETERS 
*	IN	: 
		meny parameters that was writen to the page after the siteTree created
		in the pageHead file(p_head.asp)
*	OUT: 
*		functions
*******************************************************************************/

///////////////////////////////////////////////////////////////////////////////
// main object
function createSiteTree(){
	/*
	try{
		this.siteTree	= new ActiveXObject("Msxml2.DOMDocument.3.0");
		this.siteTree.load(xmlFile);
	}
	catch(e){}
	*/
		
	this.pointer			= pointer;//pointer(projector) function
	this.positionMenus	= position;//position menu function
		
}

////////////////////////////////////////////////////////////
// create a Pointer , hirarch links from the current place-
// up to the main folder + link to home page
function pointer(){
	return "";
	var lclStr		= "<table border=0 cellpadding=2 cellspacing=2 width='100%'><tr>";
	var strPointer	= "";
	var curFiNode	= this.siteTree.documentElement.selectSingleNode("//folder[@id=" + sitepi + "]");
	var arrPointer = [];
	var url = pagePath + "?pi="
	//loop back to the root of the xml and colacte the captions
	var parentNode = curFiNode.parentNode;
	while (!isnull(parentNode) && parentNode.nodeName=="folder"){
		strPointer	= ""
			+ "<td nowrap>" 
				+ "<a href='" + url + parentNode.getAttribute("id") + "'>"
					+ parentNode.getAttribute("name") 
				+ "</a>"
				+ " > " 
			+ "</td>"
		arrPointer[arrPointer.length] = strPointer
		parentNode	= parentNode.parentNode;
	}
	arrPointer.reverse();
	for(var i = 0; i < arrPointer.length; i++){
		lclStr += arrPointer[i]
	}
	//add the current page name 
	lclStr += ""
		+ "<td nowrap>" 
			+ curFiNode.getAttribute("name") 
		+ "</td>";
	lclStr += "<td width='100%'></td></tr></table>";
	document.write(lclStr);
}

////////////////////////////////////////////////////////////
//position the upper bar Menu divs to the parent location
function position(){
	var theLeft		= 0;
	var theTop		= 0;
	var divId		= 0;
	var divBorder	= 0;
	var barWidth	= 0;
	var menuWidth	= 0;

	var barHeight	= document.getElementById('uBar').style.height;
	barHeight		= Number(barHeight.substring(0,barHeight.indexOf("p")));

	var barBorder	= document.getElementById('uBar').style.borderWidth;
	barBorder		= Number(barBorder.substring(0,barBorder.indexOf("p"))) * 2;

	barHeight +=  barBorder;
	
	var container = document.getElementsByTagName('uBarMenuDiv');
		
	for(var i=0;i< container.length;i++){
		divId		= container[i].id
			
		divBorder= document.getElementById("bar" + divId).style.borderWidth;
		divBorder= Number(divBorder.substring(0,divBorder.indexOf("p"))) -2;

		barWidth	= document.getElementById("bar" + divId).offsetWidth;
		menuWidth= document.getElementById("menu"+divId).style.width
		menuWidth= Number(menuWidth.substring(0,menuWidth.indexOf("p")));
		
		//change the div's minimum width to the parent menu
		if(barWidth > menuWidth && menuWidth>0){
			menuWidth = barWidth + 1;
			document.getElementById("menu"+divId).style.width = menuWidth;
			//document.getElementById("menu"+divId).style.setAttribute("width",menuWidth + "px");
		}

		//alert(barWidth + "\n" + menuWidth)
		theLeft	= (document.getElementById('uBar').offsetLeft * 1) + (document.getElementById("bar" + divId).offsetLeft * 1);
		theTop	= (document.getElementById('uBar').offsetTop * 1)	+ barHeight + divBorder + 2 ;

		//position them
		if (dir.toUpperCase() == "LTR"){
			document.getElementById("menu"+divId).style.left = theLeft - 1;
		}
		else{
			var widthOffset = theLeft - menuWidth + barWidth + 1;
			document.getElementById("menu"+divId).style.left = widthOffset;
		}
		document.getElementById("menu"+divId).style.top = theTop;
		//alert(document.getElementById("menu"+divId).id)
	}
	_menusCreated = true;

}

var siteTree = new createSiteTree();

///////////////////////////////////////////////////////////////////
// go 2 home page func
function goHome(){window.navigate(homePath);}

///////////////////////////////////////////////////////////////////
// open/close tr functions-for the site map xsl
function openTr(){document.write("<tr>");}
function closeTr(){document.write("</tr>");}
