var ap = null;

function setClass( obj, className )
{
	obj.className = className;
}

function setActivePage( pid ) {
	hiliteMenu( document.getElementById( pid ) );
	ap = document.getElementById( pid );
}
	

function hiliteMenu( obj ) {
	if ( obj != ap ) {
		setClass( obj, "menuSelected" );
	}
}
	
function loliteMenu( obj ) {
	if ( obj != ap ) {
		setClass( obj, "menu" );
	}
}

function getAbsoluteLeft(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oLeft = o.offsetLeft            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent left position
		o = oParent
	}
	// Return left postion
	return oLeft
}

function getAbsoluteTop(objectId) {
	// Get an object left position from the upper left viewport corner
	// Tested with relative and nested objects
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get left position from the parent object
	while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent    // Get parent object reference
		oTop += oParent.offsetTop // Add parent left position
		o = oParent
	}
	// Return left postion
	return oTop
}

function positionMenu( menu, posElement ) {
	m = MM_findObj( menu );
	p = MM_findObj( posElement );
	
	if ( m==null || p == null ) { return; }
	
	m.style.left = getAbsoluteLeft(posElement);
	m.style.top = getAbsoluteTop(posElement)+17;
}

function showProps( obj ) {
	for (prop in obj ) {
		document.write( "obj["+prop+"] = "+obj[prop]+"\n" );
	}
}

