function findMyLeftCoord(element)
    {
	/*
	DOM object element
	add up all the offsetLeft values for every element in the DOM chain that ends with the passed in element.
    the result should be the left pixel value of the passed in element.
	*/
    
    leftCoord = element.offsetLeft;
    if (element.offsetParent)   
        {
        leftCoord += findMyLeftCoord(element.offsetParent);
        }
    return leftCoord;
    }

function findMyTopCoord(element)
    {
	/*
	DOM object element
	add up all the offsetTop values for every element in the DOM chain that ends with the passed in element.
    the result should be the top pixel value of the passed in element.
	*/
    TopCoord = element.offsetTop;
    if (element.offsetParent)   
        {
        TopCoord += findMyTopCoord(element.offsetParent);
        }
	return TopCoord;
    }

function moveDiv(divName, pointOfReference, corner, leftOffset, topOffset)
    {    
    /*
	string DivName, DOM object element, string corner, int leftOffset, int topOffset.
    moves the layer DivName to the lower left-hand corner of the graphic element pointOfReference.
	
	corner refers to which corner of the pointOfReference object the div should be aligned to.
	
	Possible values for corner are: 
								'top left'
								'top right
								'top center'
								'bottom left'
								'bottom right'
								'bottom center'
								'middle center'
	Default is 'top left'.
	
	leftOffset and topOffset are values to add or subtract to the position of the point of reference, to 
	offset the div from the point of reference.
    */
	
	// get the coordinates for the pointOfReference.
    var newTop = findMyTopCoord(pointOfReference);
    var newLeft = findMyLeftCoord(pointOfReference);
	
	// add values necessary to position divName at the passed in corner of the pointOfReference.
	switch(corner)
		{
		case "top left":
			newTop = newTop;
			newLeft = newLeft;
			break;
		
		case "top right":
			newTop = newTop;
			newLeft += pointOfReference.clientWidth;
			break;
			
		case "top center":
			newTop = newTop
			newLeft += Math.ceil(pointOfReference.clientWidth / 2);
			break;
		
		case "bottom left":
			newTop += pointOfReference.clientHeight;
			newLeft = newLeft;
			break;
		
		case "bottom right":
			newTop += pointOfReference.clientHeight;
			newLeft += pointOfReference.clientWidth;
			break;
			
		case "bottom center":
			newTop += pointOfReference.clientHeight;
			newLeft += Math.ceil(pointOfReference.clientWidth / 2);
			break;
		
		case "middle center":
			newTop += Math.ceil(pointOfReference.clientHeight / 2);
			newLeft += Math.ceil(pointOfReference.clientWidth / 2);
		
		default:
			newTop = newTop;
			newLeft = newLeft;			
			break;
		}
	
	// add the offset values to the top and left coordinates.
	newTop += topOffset;
	newLeft += leftOffset;
    
	// move the div.
	eval ("document.all." + divName + ".style.top = " + newTop);
    eval ("document.all." + divName + ".style.left = " + newLeft);
    }
