function hideInfoBox(divID) {
    objDiv=document.getElementById(divID);    
    objDiv.style.display="none";    
}

function showInfoBox(divID, hrefID, setWidth){
    var collDiv=document.getElementsByTagName("DIV"); 
    var strID=new String(); 
    
    for (i=0; i < collDiv.length; i++) {        
        if (typeof collDiv[i].id != "undefined") {
            strID=collDiv[i].id; 
        }
        else {
            strID=""; 
        }       
        if ((strID.indexOf("ans") != -1) && (typeof collDiv[i].style.display != "undefined") && (collDiv[i].style.display == "block")) {
            collDiv[i].style.display="none";
        } 
    }
    thelink=document.getElementById(hrefID);
    popupBox=document.getElementById(divID); 
    
    if(setWidth){
     popupBox.style.width=setWidth+'px';
    }
    else {
     popupBox.style.width='210px';
    }
    
    var IE=document.all?true:false;
    var fireFoxAdj=0;
    if(!IE){ fireFoxAdj=5; }
    
    if(popupBox.style.display == "block"){
        popupBox.style.display="none";
    }
    else {
        popupBox.style.display="block";
    
        var popup_wdth=popupBox.clientWidth;
        var popup_ht=popupBox.clientHeight;

        var linkPos=new Object(); 
        linkPos=getElementPosition(hrefID);
        
        var link_tp=linkPos.top;
        var link_lft=linkPos.left;
        var link_wdth=thelink.offsetWidth;
        
        var setLeft=link_lft + link_wdth + 20;

        var body_wdth=document.body.clientWidth;
        var body_ht=document.body.clientHeight;
        
		if(((setLeft + popup_wdth > body_wdth) && (link_lft - popup_wdth > 100))
				|| ((setLeft + popup_wdth > 1220) && (body_wdth > 1200 && body_wdth <= 1400)) 
				|| ((setLeft + popup_wdth > 1320) && (body_wdth > 1400 && body_wdth <= 1600)) 
				|| ((setLeft + popup_wdth > 1400) && (body_wdth > 1600)))
		{  
			setLeft=link_lft - popup_wdth;
        }

        var halfHeight=popup_ht/2;
        var halfHeight=Math.round(halfHeight);
        
        var setTop=link_tp - halfHeight;
        if ((setTop + popup_ht) > body_ht){
                setTop=link_tp - popup_ht + 10;
                pointVert='down'; 
        }
        if (setTop < 205) {
            setTop=205; 
            link_tp=305;      
        }       
        
        popupBox.style.left=setLeft+'px';
        popupBox.style.top=setTop+'px';
    }
}
function getElementPosition(elemID) {
	
   var offsetTrail=document.getElementById(elemID);
   var offsetLeft=0;
   var offsetTop=0;
 
   while (offsetTrail) {
       offsetLeft += offsetTrail.offsetLeft;
       offsetTop += offsetTrail.offsetTop;
       offsetTrail=offsetTrail.offsetParent;
   }
   
   if (navigator.userAgent.indexOf("Mac") != -1 && 
       typeof document.body.leftMargin != "undefined") {
       offsetLeft += document.body.leftMargin;
       offsetTop += document.body.topMargin;
   }
   return {left:offsetLeft, top:offsetTop};
}

