var ttime = new String("@5pm");
var to    = "to:";
var hrf   = self.location.href;
var pref  = hrf.substr(0, 7) == 'file://' 
              ? hrf.substr( 0, hrf.indexOf('dev')+3 )  // for testing
              : '';

// if page is being load in a top level window, and search != dotop redirect to Frames.htm
// contents.htm reads the query string and loads the correct page into the main frame
if (top == self && location.search != "?dotop")
  { top.location = pref + "/Frames.htm?main-src=" + top.location.pathname + top.location.hash; }

top.document.title = document.title;

function setstt(txt) { status = txt; return true }

function magen(n1, n2, a1, a2) {
  if (!a2) a2 = "net";
  return "mail" + to + n1 + n2 + ttime.charAt(0) + a1 + a2;
}

// start slide show
var imgn, indx = {}, imgs = [], cpns = [], imar = [], imgsrc = '', imwd = 768, imght = 576;
var wghpsimv, swin, svrun, notrn;
function openim(im, r) {
  imgn = indx[im];
  wghpsimv = 1;
  par = parent || self;
  svrun = r;
  swin = par.swin;
  if (!swin || swin.closed) par.swin = swin = window.open(pref + '/imview.htm', '_blank',
    'width=852,height=684,location=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=no');
  else swin.opit(self);
}

function setst() { window.status = "click to enlarge image"; return true; }
function srtsh() { window.status = "start slide show"; return true; }
function blkst() { window.status = ""; return true; }

function set_status(tid) {
  myp = document.links;
  for (i=0; i<myp.length; i++) {
    myl = myp[i].getElementsByTagName("img");
    if ( myl.length == 1 && myp[i].href.substr(0,17) == "javascript:openim" ) {
      myp[i].onmouseover = setst;
      myp[i].onmouseout = blkst;
  } }

  if (!tid) tid = "sldshw";
  myi = document.getElementById(tid);
  if (myi) { myi.onmouseover = srtsh;
             myi.onmouseout = blkst;
} }

// use page title to generate banner text
var hps = 'Hardy Plant Society';
var wg  = 'Worcestershire Group';
var bant = 0;
var banf = top.banner;
if (banf) bant = banf.document.getElementById('tbox');
if (bant) {
  var newt = document.title;
  if ( newt.match(hps + ', ' + wg) && newt.length > (hps + wg).length + 10 ) {
//    newt = newt.replace(hps, 'HPS');
    newt = newt.replace(hps  + ', ', '');
    newt = newt.replace(/Group,?\s+(-\s+)?/, 'Group<br>');
    newt = newt.replace(/ /g, '&nbsp;');
    bant.innerHTML = newt; }
  else bant.innerHTML = wg.replace(/ /g, '<br />');
//  else bant.innerHTML = hps.replace(/ /g, '&nbsp;') + '<br>' + wg.replace(/ /g, '&nbsp;');
// else bant.innerHTML = wg.replace(/ /g, '&nbsp;');
}

