//  sub-window code for presenting example documents - version date Dec 2003
//  Some example links: <a href="yo.html" onclick="return openSubWin(this.href)">link</a> 
//  <a href="some.html" onclick="return openSubWin(this.href, 'win2', null, null, 800, 600, 'resizable')">link</a>
function openSubWin(url, nm, x, y, w, h, atts) {
  nm = nm || "subwindow";
  atts = atts || "resizable,scrollbars";
  w = w || 1000; h = h || 1000;
  x = (typeof x=="number")? x: window.opera? 100: Math.round( (screen.availWidth - w)/2 );
  y = (typeof y=="number")? y: window.opera? 20: Math.round( (screen.availHeight - h)/2 );
  atts += ',width='+w+',height='+h+',left='+x+',top='+y;
  var win = window.open(url, nm, atts); 
  if (win) {
    if (!win.closed) { win.resizeTo(w,h); win.moveTo(x,y); win.focus(); return false; }
  } 
  return true;
}

// attach title to links that open sub-windows
function setSubWinTitle() {
  var lnks, att;
  if ( document.getElementsByTagName ) lnks = document.getElementsByTagName("A");
  if ( lnks && lnks[0].getAttribute ) {
    for (var i=0; lnks[i]; i++) {
      if ( ( att = lnks[i].getAttribute("onclick") )  && att.toString().indexOf("openSubWin") != -1 ) 
        lnks[i].setAttribute("title", "opens sub-window");
    }
  }
}