	//***************************************************************************************************************
	//
	//		file: jfunctions.js
	//		desc: various functions for creating custom layout
	//
	//***************************************************************************************************************
	
//this function makes two columns of elements the same height 
//by adding height to the last element of the shorter column

function equalHeights(leftArray,rightArray){
	
	//add pixels in left column
		var nLeftHeight = getColumnHeight( leftArray );
	
	//add pixels in right column
		var nRightHeight = getColumnHeight( rightArray );

	//increase last element in column by difference
	if( nLeftHeight > nRightHeight ){
		var element = document.getElementById(rightArray[rightArray.length-1]);
			//subtract out the border size
		var nLastRightHeight = element.offsetHeight - bordersAndPaddingHeight( element );
		element.style.height= ( nLastRightHeight + nLeftHeight - nRightHeight ) + "px";
		}
	else if ( nLeftHeight < nRightHeight ){
		var element = document.getElementById(leftArray[leftArray.length-1]);
			//subtract out the border size
		var nLastLeftHeight = element.offsetHeight - bordersAndPaddingHeight( element );
		element.style.height = (nLastLeftHeight + nRightHeight-nLeftHeight)+"px";
		}
	else {}; //do nothing
	
}

//this function is for making two elements the size of the larger element, such as the parent container
//of a child element. Its just a simplied calling of the equalHeights()
function setEqualHeightById( element1, element2){
	var leftArray = new Array(1);
	var rightArray = new Array(1);
	leftArray[0] = element1;
	rightArray[0] = element2;
	equalHeights( leftArray,rightArray );
}

//this function adds the top and bottom borders and padding in a div
function bordersAndPaddingHeight ( element ){
		var nBorderTop = Number(retrieveComputedStyle(element, "borderTopWidth").replace("px",""));
		var nBorderBottom = Number(retrieveComputedStyle(element, "borderBottomWidth").replace("px",""));
		var nPaddingTop = Number(retrieveComputedStyle(element, "paddingTop").replace("px",""));
		var nPaddingBottom = Number(retrieveComputedStyle(element, "paddingBottom").replace("px",""));

		var nHeight = nBorderTop + nBorderBottom + nPaddingTop + nPaddingBottom;
		return nHeight;
}

// Retrievea default style in the currentstyle is undefined
function retrieveComputedStyle(element, styleProperty)
{
		var computedStyle = null;

		if (typeof element.currentStyle != "undefined")
		{
			computedStyle = element.currentStyle;
		}
		else
		{
			computedStyle = document.defaultView.getComputedStyle(element, null);
		}
		return computedStyle[styleProperty];
}

//this function adds the heights of divs in an array
//including all margins, top and bottom
function getColumnHeight( array ){
	var totalHeight = 0;
	for(var i=0; i<array.length; i++) {
		var element = document.getElementById(array[i]);
		var nMarginTop = Number(retrieveComputedStyle(element, "marginTop").replace("px",""));
		var nMarginBottom = Number(retrieveComputedStyle(element, "marginBottom").replace("px",""));
		if( isNaN(nMarginTop))
		{
			nMarginTop = 0;
		}
		if( isNaN(nMarginBottom))
		{
			nMarginBottom = 0;
		}
		
		//element.style.height="auto";
		totalHeight = totalHeight + element.offsetHeight+
			nMarginTop +
			nMarginBottom;
		}
	return totalHeight;
}


// Opens a panel in the Tree display
function openTreePanelContent( panelId){
	var element = document.getElementById(panelId);
	if(element != null)
		element.style.display = "block";
	
}

