
function showObjNear(showThisObj, nearThisObj, relPos){
    
    if( showThisObj != null && nearThisObj != null ){
        showThisObj.style.visibility='hidden';
        showThisObj.style.display='block';
	    // belowLeft
	    if( relPos == 'belowLeft' || relPos == '' || relPos == null || relPos == undefined){
        	showThisObj.style.left=getX(nearThisObj) - showThisObj.offsetWidth;
        	showThisObj.style.top=getY(nearThisObj);
        }
	    // belowRight
	    if( relPos == 'belowRight' ){
        	showThisObj.style.left=getX(nearThisObj) + nearThisObj.offsetWidth;
        	showThisObj.style.top=getY(nearThisObj);
	    }
	    // aboveLeft
	    if( relPos == 'aboveLeft' ){
        	showThisObj.style.left=getX(nearThisObj) - showThisObj.offsetWidth;
        	showThisObj.style.top=getY(nearThisObj) - nearThisObj.offsetHeight - showThisObj.offsetHeight;
	    }
	    // aboveRight
	    if( relPos == 'aboveRight' ){
        	showThisObj.style.left=getX(nearThisObj) + nearThisObj.offsetWidth;
        	showThisObj.style.top=getY(nearThisObj) - nearThisObj.offsetHeight - showThisObj.offsetHeight;
	    }
        hideSelects(showThisObj, true);
        showThisObj.style.visibility='visible';
    }
}//-- end function showObjAt


function showObjAt(showThisObj, X, Y){
    if( showThisObj != null ){
        showThisObj.style.visibility='hidden';
        showThisObj.style.display='block';
        showThisObj.style.left=X;
        showThisObj.style.top=Y;
        hideSelects(showThisObj, true);
        showThisObj.style.visibility='visible';
    }
}//-- end function showObjAt


function hideObj(obj){
    if( obj != null ){
        hideSelects(obj, false);
        obj.style.display='none';
    }
}//-- end function hideObj
                        
                                            
function hideSelects(obj, hide){
    var selects;
    var i;

    selects = document.getElementsByTagName("SELECT");
    if( !hide ){
        //make visible every select on the page
        if( selects != null ){
            for( i=0; i < selects.length; i++ ){
                if( isObscuring(obj, selects[i]) ){
                    selects[i].style.visibility = "visible";
                }
            }
        }
    } else { //hide
        //make hidden any selects that will be obscured by the obj
        if( selects != null ){  
            for( i=0; i < selects.length; i++ ){    
                if( isObscuring(obj, selects[i]) ){
                    selects[i].style.visibility = "hidden";
                }
            }
        }
    }
}//--end function hideSelects


function isObscuring(O1, O2){
    //is O1 obscuring O2?
    var obscured = false;
    var O1XL, O1XR, O1YU, O1YL, O2XL, O2XR, O2YU, O2YL;
    var iSmallestXR, iBiggestXL;
    var iSmallestYL, iBiggestYU;
    var Xoverlap = 0;
    var Yoverlap = 0;
    
    O1XL = getX(O1);
    O1XR = getX(O1) + O1.offsetWidth;
    O1YU = getY(O1) - O1.offsetHeight;
    O1YL = getY(O1);
    O2XL = getX(O2);
    O2XR = getX(O2) + O2.offsetWidth;
    O2YU = getY(O2) - O2.offsetHeight;
    O2YL = getY(O2);
    
    // set the vars we need to calculate the overlap area
    iSmallestXR = O1XR;
    if( O2XR < O1XR ){
        iSmallestXR = O2XR;
    }
    iBiggestXL = O1XL;
    if( O2XL > O1XL ){
        iBiggestXL = O2XL;
    }
    
    iSmallestYL = O1YL;
    if( O2YL < O1YL ){
        iSmallestYL = O2YL;
    }
    iBiggestYU = O1YU;
    if( O2YU > O1YU ){
        iBiggestYU = O2YU;
    }
    
    Xoverlap = iSmallestXR-iBiggestXL;
    Yoverlap = iSmallestYL-iBiggestYU;
    
    if( Xoverlap > 0 && Yoverlap > 0 ){
    	obscured = true;
    }
    
    return obscured;
}//--end function isObscuring


function getX(obj){
    // Returns the absolute left position of obj
    var pCountStr = "offsetParent";
    var pName = "";
    var total = obj.offsetLeft;
    
    while( pName != "BODY" ){
        total += eval("obj." + pCountStr + ".offsetLeft");  
        pName = eval("obj." + pCountStr + ".tagName");      
        pCountStr += ".offsetParent";
    }
    
    return total;
}//--end function getX
    
    
function getY(obj){
    // Returns the BOTTOM position of obj
    // NOT the top position like you'd expect!
    // This is generally more useful, and we don't want to rewrite isObscuring
    var pCountStr = "offsetParent";
    var pName = "";
    var total = obj.offsetTop + obj.offsetHeight;
    
    while( pName != "BODY" ){
        total += eval("obj." + pCountStr + ".offsetTop");
        pName = eval("obj." + pCountStr + ".tagName");      
        pCountStr += ".offsetParent";
    }
    
    return total;
}//--end function getY

