/**
 * Rivet Software Inc.
 *
 * @copyright Copyright � 2006-2007 Rivet Software, Inc. All rights reserved.
 *
 */

function setContentHeight(){
	var baseMargin = 125;
	var minTabHeight = 30;

	var tabs = $('tabs');
	var tabHeight = Math.max( minTabHeight, tabs.offsetHeight );

	var margin = baseMargin + tabHeight;
	setObjectHeight( 'yui-content', (-margin) );
	
	setReportHeight();
}

function setReportHeight(){
	var reports = getElementsByClassName( 'ReportWrapper', null, 'div' );
	var tabContainer = $( 'yui-content' );

	var height = 0;
	var width  = 0;
	for( var i = 0; i < reports.length; i++ )
	{
		if( reports[ i ].parentNode &&
			reports[ i ].parentNode.parentNode &&
			reports[ i ].parentNode.parentNode.style &&
			reports[ i ].parentNode.parentNode.style.display == 'block' )
		{
			var prev = reports[ i ].previousSibling;
			do
			{
				if( prev.offsetHeight > 0 )
					height += prev.offsetHeight;
			}while( prev = prev.previousSibling )
			
			reports[ i ].style.width  = reports[ i ].parentNode.parentNode.parentNode.offsetWidth - 8 +'px';
			reports[ i ].style.height = ( tabContainer.offsetHeight - height - 17 ) +'px';
			break;
		}
	}
}

/**
 * Allows a screen object (div, iframe, etc.) to be sized based on the
 * viewable screen height. This version applies to an id.
 * 
 * Attach to the body 'onload' and 'onresize' events 
 * 
 * @param {Object} objId
 * @param {Object} adjustment in pixels (usually negative)
 */
function setObjectHeight(objId, adjustment) {
    
    var objEl = document.getElementById(objId);

    if(objEl) {
        objEl.style.height = "auto"; // Helps resize (for some) if new doc shorter than previous
        var h = getWindowSize();
        var new_h = (h + adjustment);
        objEl.style.height = new_h + "px";
		
		return new_h;
    }
}

function showHide( obj, self ){
	var domObj = obj;
	while( !domObj.tagName )
	{
		domObj = domObj.nextSibling;
	}
	
	if (domObj.style.display == 'none') {
		domObj.style.display = 'block';
		self.firstChild.nodeValue = '-';
	}else{
		domObj.style.display = 'none';
		self.firstChild.nodeValue = '+';
	}
}

/**
 * Returns the true viewable height of the current window
 */
function getWindowSize() {
    
    var myHeight = 0;

    if(typeof(window.innerWidth) == 'number') {
        // Non-IE
        myHeight = window.innerHeight;
    } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        // IE 6+ in 'standards compliant mode'
        myHeight = document.documentElement.clientHeight;
    } else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
        // IE 4 compatible
        myHeight = document.body.clientHeight;
    }
    //alert('Height = '+myHeight); // Echo window height setting - for debug

    return myHeight;
}

/** $Author:$ * $Date:$ * $Rev:$ **/