// Testing for different Browser methods, the actual browser is 
// prolly not as important as the methods it uses to retrieve
// and set elements etc. 

// All the browsers that support document.all (not just IE)
isDocAll = (document.all ? true : false);

// All the browser that supprt getElementBy Id
isDOM = (document.getElementById ? true : false);

// get the true offset of anything on NS4, IE4/5 & NS6, even if it's in a table!
function getAbsX( elt ){
	return (elt.x) ? elt.x : getAbsPos( elt, "Left" );
}

function getAbsY( elt ){
	return (elt.y) ? elt.y : getAbsPos( elt, "Top" );
}

function getAbsPos( elt, which ){
	iPos = 0;

	while (elt != null) {
		iPos += elt["offset" + which];
		elt = elt.offsetParent;
	}
	
	return iPos;
}

function getDivStyle( divName ){
	var style;

	if( isDOM ){
		style = document.getElementById(divName).style; 
	}else{
		style = isDocAll ? document.all[divName].style : document.layers[divName]; 
	}
	
	return style;
}

function hideElement( divName ){
	getDivStyle(divName).visibility = 'hidden';
}

// annoying detail: IE and NS6 store elt.top and elt.left as strings.
function moveBy( elt, deltaX, deltaY ) {
	elt.left = parseInt(elt.left) + deltaX;
	elt.top = parseInt(elt.top) + deltaY;
}

function toggleVisible(divName) {
	divstyle = getDivStyle(divName);
	positionAllMenus();

	if( divstyle.visibility == 'visible' || divstyle.visibility == 'show' ){
		divstyle.visibility = 'hidden';
	}else{
		fixPosition(divName);
		divstyle.visibility = 'visible';
	}
	var setTimeoutText = "hideElement('" + divName + "')";	
	setTimeout( setTimeoutText, 5000 );
}

function setPosition( elt, positionername, isPlacedUnder ){
	var positioner;

	if( isDocAll ){
		positioner = document.all[positionername];
	}else{
		if( isDOM ){
			positioner = document.getElementById(positionername);
		} else {
			// not IE, not DOM (probably NS4)
			// if the positioner is inside a netscape4 layer this will *not* find it.
			// I should write a finder function which will recurse through all layers
			// until it finds the named image...
			positioner = document.images[positionername];
		}
	}
	
	elt.left = getAbsX(positioner) - 1;
	elt.top = getAbsY(positioner) + (isPlacedUnder ? positioner.height - 1 : 24);
}

<!--
// fixPosition() attaches the element named eltname
// to an image named eltname+'Pos'
//
function fixPosition( divName ) {
	// hint: try setting isPlacedUnder to false
	isPlacedUnder = false;
	
	if (isPlacedUnder) {
		setPosition( getDivStyle( divName ), divName + 'Button', true);
	} else {
		setPosition( getDivStyle( divName ), divName + 'Button' )
	}
}

// fixPositions() puts everything in the correct position, you can call it from onresize in the body tag
// and this will fix the positions after a resize.

function positionAllMenus(){
	// put a reference to the name of the menu minus the 'MenuDropdown' bit to the elements you want to position.
	menusArray = new Array( 'Home', 'Tools');
	
	for( i=0 ; i < menusArray.length; i++ ){
		hideElement( 'MenuDropdown' + menusArray[i] );
		fixPosition( 'MenuDropdown' + menusArray[i] );
	}
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadimages() {
	if (document.images) {
		preloadFlag = true;
	}
}
