function blueMenu(menuNumber)
{
	var LabelID = 'myLabel' + menuNumber ;
	getStyleObject(LabelID).color="#000000" ;
	var LabelID = 'myTD' + menuNumber ;
	getStyleObject(LabelID).backgroundImage='url(/images/buttona.png)' ;
}

function resetMenu(menuNumber)
{
	var LabelID = 'myLabel' + menuNumber ;
	getStyleObject(LabelID).color="#5871F0" ;
	var LabelID = 'myTD' + menuNumber ;
	getStyleObject(LabelID).backgroundImage='url(/images/button.png)' ;
}	

function menuOver(myThis)
{
	myThis.style.backgroundColor="#ffffff" ;
}

function menuOut(myThis)
{
	myThis.style.backgroundColor="#EBEEFD" ;
}

function showMenu(menuNumber, eventObj) 
{
	var MenuID = 'myMenu' + menuNumber ;
	var ButtonID = 'myButton' + menuNumber ;
	var menux, menuy ;
    
	hideAllMenus();
	eventObj.cancelBubble = true;
	
	var button = document.getElementById(ButtonID) ;
	menux = findPosX(button) ;
	menuy = findPosY(button) + 30 ;
	if(changeObjectVisibility(MenuID, 'visible', menux, menuy)) 
    {
		return true;
    } 
    else 
    {
		return false;
    }
}

function hideMenu(menuNumber, eventObj) 
{
	var MenuID = 'myMenu' + menuNumber ;
	
	eventObj.cancelBubble = true;
    if(changeObjectVisibility(MenuID, 'hidden', 0, 0)) 
    {
		return true;
    } 
    else 
    {
		return false;
    }
}

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else {
	return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility, xpos, ypos) 
{
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) 
    {
	    //styleObject.top = ypos ;
	    //styleObject.left = xpos ;
		styleObject.visibility = newVisibility;
		return true;
    } 
    else 
    {
		//we couldn't find the object, so we can't change its visibility
		return false;
    }
} // changeObjectVisibility

function findXY($obj, $dad)
{
	var $curtop = 0;
	var $curleft = 0;
	if ($obj.offsetParent)
	{
		$curtop = $obj.offsetTop ;
		$curleft = $obj.offsetLeft ;
		while (($obj = $obj.offsetParent) && ($obj != $dad))
		{
			$curtop += $obj.offsetTop ;
			$curleft += $obj.offsetLeft ;
		}
	}
	return [$curtop, $curleft];
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function MyMailTo(who)
{
	newwho = "" ;
	for (i=who.length-1; i>=0; i--)
	{
		newwho += who.substr(i,1) ;
	}
	mail = "mailto:" + newwho ;
	mail = mail.replace(/=/, "@") ;
	mail = mail.replace(/~/g, ".") ;
	document.location=mail ;        
}

function adjustHeight() 
{
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var fixupy = (ns)? -30:-30 ;
	var fixupx = (ns)? 10:10 ;
	var fixupt = (ns)? 2:2 ;

    // Calculate the height of the header.
    var headerHeight = 0;
    var header = document.getElementById("divHeader");

    if (header != null) 
    {
        headerHeight = header.offsetHeight;
    }

    // Calculate the height of the footer section.
    var footerHeight = 0;
    var footer = document.getElementById("divFooter");
    if (footer != null) 
    {
        footerHeight = footer.offsetHeight;
		var footerTop = document.body.clientHeight - footerHeight;
        footer.style.top = footerTop;
    }
    
    // Calculate the height of application components that are always visible.
    var applicationHeight = headerHeight + footerHeight;

    // Target height for the remainder of the screen is the browser height
    // minus the height of the fixed components.
    var targetHeight = document.body.clientHeight - applicationHeight;
    var targetWidth = document.body.clientWidth ;
    //alert ("{" + document.body.clientHeight + "} {" + document.body.clientWidth + "}") ;
    // Adjust the height of the scrollable segment.
    var scroller = document.getElementById("divScroll");
    if (scroller != null) {
        //targetHeight -= 30;
   	    // Check for a table div
    	var divColumns = document.getElementById("divColumns");
    	var divRows = document.getElementById("divRows");
    	var divBody = document.getElementById("divBody");
    	if ((divColumns != null) && 
    		(divRows != null) && 
    		(divBody != null))
    	{	
        	scroller.style.overflow="hidden" ; // Added for preview mode
	    	var tableOuter = document.getElementById("tableOuter");

	    	var tableTop = tableOuter.offsetTop ;
	    	var tableLeft = tableOuter.offsetLeft + 10 ;
	    	var rowsWidth = divRows.offsetWidth ;

	    	divColumns.style.width = targetWidth - tableLeft  - rowsWidth - 20 ;
    		divBody.style.width = targetWidth - tableLeft - rowsWidth ;
    		// Check if the horizontal scrollbar is visible
    		var hs = (document.getElementById('divBody').scrollWidth > document.getElementById('divBody').clientWidth) ;
    		divRows.style.height = targetHeight - tableTop - 20 - ((hs)?17:0) ;
    		divBody.style.height = targetHeight - tableTop - 20  ;
    		
        	targetWidth -= fixupt ;
		}
		else
		{
	        targetHeight -= 30;
        	scroller.style.overflow="auto" ;
    	}
    	targetHeight -= fixupy ;
    	targetWidth -= fixupx ;
        scroller.style.height = targetHeight;
        scroller.style.width = targetWidth;
        scroller.style.top = headerHeight;
        scroller.style.left = 10;

        // there is a problem with both IE and FF when 
        // looking for an anchor in a scrollable DIV.
        // This onload/onresize code should sort it
        
        // Look at URL and extract anchor if any
	 	var url = new String (document.location) ;
	 	var parts = url.split("#") ;
	 	if (parts.length > 1)
	 	{
	 		var anchor = document.getElementById(parts[1]) ;
		 	if (anchor != null)
	 		{
		 		var off = anchor.offsetTop ;
		 		scroller.scrollTop = off ;
	 		}
		} 	
 	}
}    


