var nannot ;

function toggle(button, divid) {
  var div = document.getElementById(divid) ;
  
  var prevstyle = document.getElementById(divid).style.display ;
  var newstyle ;
  var butstyle ;
  if ( prevstyle == 'none' ) {
    newstyle = 'block' ;
    butstyle = 'solid red' ;
  } else {
    newstyle = 'none' ;
    butstyle = 'none' ;
  }
  for (i=1; i<nannot; i++ ) {
    var annot = 'a' + i ;
    var ctrl = 'b' + i ;
    try {
      document.getElementById(annot).style.display = 'none' ;
      document.getElementById(ctrl).style.border = 'none' ;
    } catch (ex) {
    }
  }
  div.style.display = newstyle ;
  button.style.border = butstyle ;
}
function CSSRule(ss,selector,styles){
  if (!ss) return false;
  if (ss.insertRule) return ss.insertRule(selector+' {'+styles+'}',ss.cssRules.length);
  if (ss.addRule){
    ss.addRule(selector,styles);
    return true;
  }
  return false;
}
function resize() {
  if ( ! document.width ) {
    return ;
  }
  var width = document.width - 280 ;
  var percent = (100*width) / document.width ;
  var style = 'width: '+percent + '%;' ;
  CSSRule(document.styleSheets[0], 'div.content', style) ;
}
function init() {
  var done = 0 ;
  for ( nannot=1; done == 0 ; nannot++ ) {
    try {
      var annot = 'a' + nannot ;
      document.getElementById(annot).style.display = 'none' ;
    } catch ( ex ) {
      done = 1 ;
    }
  }
  --nannot ;
  resize() ;
}
