var winPopup=null;
// varargs: args should be the event object, followed by a comma-separated list of associations for that area
function infoPopup(e, assoc)
{
  if(winPopup) winPopup.close();  //if user left popup open, start fresh to prevent size & position issues
  if (arguments.length < 2 || typeof e.screenX == "undefined") {return false;} // invalid argument
  var locX=e.screenX;
  var locY=e.screenY; 
  var winProp="width=300,height=100,left=" + locX + ",top=" + locY + ",resizable=yes,scrollbars=yes";
  winPopup=window.open("about:blank", "info", winProp); //winPopup.focus(); unnecessary on newly opened
  winPopup.document.write
    ("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'\
     'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\
      <html lang='en'><head><title>Local Associations</title>\
      <style type='text/css'>a:visited{color:#691136;}a:link{color:#16628F;}\
      a:focus{color:#0000ff;}a:hover{color:#0000ff;}a:active{color:#0000ff;}</style></head>\
      <body style='font-family: Verdana, \"DejaVu Sans\", Tahoma, Arial, Helvetica, sans-serif;margin:0;\
      ;'>\
      <div id='locals' style='font-size:65%; margin:0; padding:0px;'>");
  for (var i=1; i<arguments.length; i++)
  {
    var h=arguments[i].slice(0,1);            //first item in array becomes the header text
    var str=arguments[i].slice(1).toString(); //rest become normal text
    winPopup.document.write
    ("<h2 style='color:#FFFFFF; background-color:#073D5D; padding: 2px 2px 1px 3px; margin:0 0 2px 0;font-size: 100%;'>",h,"</h2><div style='padding-left: 2px; padding-bottom: .75em; '>", str, "</div>");
  }
  winPopup.document.write("</div></body></html>");
  winPopup.document.close();
  var localsDiv=winPopup.document.getElementById("locals");
  var rect=localsDiv.getBoundingClientRect(); 
  var newHeight=100;
  if (typeof winPopup.outerHeight != 'undefined')  //using if(winPopup.outerHeight) generates an error
    {
      var chromeHeight=winPopup.outerHeight-100;
      newHeight=rect.bottom  + chromeHeight;    
    }
  else    //100px should be enough for chrome height if browser (IE) won't give its window size; if not, scrollbar appears
    {newHeight=rect.bottom + 100;}
  if(newHeight>screen.availHeight) newHeight=screen.availHeight;  // make sure popup fits onscreen
  var newY=screen.availHeight-locY-newHeight; 
  if(locY + newY < 0) newY=-locY;           // never put popup top above top of screen      
  if(newY < 0) {winPopup.moveBy(0,newY)}    // move popup up on screen, if needed; never need to move down
  winPopup.resizeTo(300, newHeight);
  return false;      
}  


