﻿// JavaScript File: popup.js
// Usage: Controls showing/hiding of MoreInfo and BestPractices div elements

function togglePopup(imgButtonId, divId, offTooltipPrefix)
{      
    if (! (imgButtonId && divId)) return;    
       
    var divElmt = document.getElementById(divId);   
    if (! divElmt) return;

    var imgButtonElmt = document.getElementById(imgButtonId);   
    if (! imgButtonElmt) return;
    
    if (!offTooltipPrefix) offTooltipPrefix="";
    var img_off = "_off.jpg";
    var img_on  = "_on.jpg";
    
    if (imgButtonElmt.src.search(img_off) >= 0)
    {               
        imgButtonElmt.src = imgButtonElmt.src.replace(img_off, img_on); 
        imgButtonElmt.alt = offTooltipPrefix + " (" + imgButtonElmt.alt + ")";
        imgButtonElmt.title = imgButtonElmt.alt;
        divElmt.style.display = "block";
    }
    else
    {
        imgButtonElmt.src = imgButtonElmt.src.replace(img_on, img_off);  
        imgButtonElmt.alt = imgButtonElmt.alt.replace( (offTooltipPrefix + " ("),"");
        imgButtonElmt.alt = imgButtonElmt.alt.replace(")", "");  
        imgButtonElmt.title = imgButtonElmt.alt;
        divElmt.style.display = "none";       
    }     
}




