 var _formkey = 0
 var _formmode = 1
 var _formvalue = ""
 var _indexLetter = 'A'
 var _accountsCount = 0
 var _accountsTotal = 0
 var _emailIndex = 7 // data column containing emails
 var _emailMax = 100 // Email copy's max, and below this, 'All' is the default tab instead of 'A'
 
 var _columnMenu = '<option selected>any item</option>'
 for (i = 0; i < _column.length; i++) _columnMenu += '<option>' + _column[i] + '</option>'
 var _iconColumn = _column.length // where to find icon index
 var _useColumn = _iconColumn + 1 // where to find use flag (1=use, 0=skip)

 function handleError(){return true;}
 window.onerror = handleError;
 
 function bodyOnLoad()
 {
  javascript:window.history.forward()
  if (_account.length < _emailMax) _indexLetter = '['
  showTable(_indexLetter)
 }
 window.onload = bodyOnLoad;

 // ref: http://www.pbdr.com/jscript/trimstr.htm
 function TrimString(sInString)
 {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
 }

 function showTable()
 {
  document.getElementById('directory-working').innerHTML = 'working...'

  // mark matching accounts
  _accountsCount = 0
  _accountsTotal = 0
  for (i = 0; i < _account.length; i++)
  {
   var _showFlag = 0 // assume not to be shown
   if ((_formvalue == '') && (_formmode != 5)) 
    _showFlag = 1 // no filter applied
   else for (j = 0; j < _iconColumn && _showFlag == 0; j++)
   {
    if (_formkey != 0 && (_formkey - 1) != j) continue
    if ((_showFlag == 0) && (_formmode == 0 || _formmode == 1)) // starts with
      if (_account[i][j].toLowerCase().indexOf(_formvalue) == 0) _showFlag = 1
    if ((_showFlag == 0) && (_formmode == 0 || _formmode == 2)) // contains
      if (_account[i][j].toLowerCase().indexOf(_formvalue) >= 0) _showFlag = 1
    if ((_showFlag == 0) && (_formmode == 0 || _formmode == 3)) // ends with
    {
      var _index = _account[i][j].toLowerCase().lastIndexOf(_formvalue)
      if (_index >= 0 && (_index + _formvalue.length == _account[i][j].length)) _showFlag = 1
    }
    if ((_showFlag == 0) && (_formmode == 0 || _formmode == 4)) // equals 
      if (_account[i][j].toLowerCase() == _formvalue) _showFlag = 1
    if ((_showFlag == 0) && (_formmode == 5)) // exists 
      if (_account[i][j].toLowerCase() != '') _showFlag = 1
   }

   _account[i][_useColumn] = _showFlag
   _accountsCount += _showFlag
   _accountsTotal++
  }

  if (arguments[0] != null) _indexLetter = arguments[0]
  href = new Array(27)
  for (i = 0; i < 27; i++) href[i]='javascript:void(showTable(\'' + String.fromCharCode(i + 65) + '\'))'
  _indexLetter = a2zHeader(_indexLetter, 'directory-tabs', _account, href)

  // add the codes
  _tbl = document.getElementById('directory-content')
  while(_tbl.hasChildNodes()) _tbl.removeChild(_tbl.childNodes.item(0))
  _tbody = document.createElement('TBODY')
  _tbl.appendChild(_tbody)

  n = 0 // column index
  for (i = 0; i < _account.length; i++)
  {
   if (_account[i][_useColumn] == 0) continue

   code = _account[i][0]
   firstLetter = code.substring(0,1).toUpperCase()
   if ((_indexLetter != '[') && (firstLetter != _indexLetter)) continue;
   
   if ((++n % _nCols) == 1)
   {
    _row = document.createElement('TR')
    _tbody.appendChild(_row)
    _row.className= 'tabbedpane'
   }

   // the sequence number
   _cell = document.createElement('TD')
   _row.appendChild(_cell)
   _cell.className = 'tabbedpane'
   _cell.className = 'index-right'
   _cell.vAlign = 'top'
   _cell.appendChild(document.createTextNode('' + n))

   // the icon
   _cell = document.createElement('TD')
   _row.appendChild(_cell)
   _img = document.createElement('IMG')
   _cell.appendChild(_img)
   //_img.src = '/commoncontent/directory-listing/images/' + _iconImages[_account[i][_iconColumn]]
   _img.src = '/commoncontent/directory-listing/images/blank.gif'
   _img.border = 0

   // the code as hyperlink
   _cell = document.createElement('TD')
   _row.appendChild(_cell)
   _cell.className = 'index-left'
   _cell.vAlign = 'top'

   _anchor = document.createElement('A')
   _anchor.href = 'javascript:editResult(' + i + ')'
   _anchor.title = 'click for contact information'
   _anchor.appendChild(document.createTextNode(code))
   _cell.appendChild(_anchor)
  }

  // fill in the last row
  n = n % _nCols
  if (n > 0) for (; n < _nCols; n++)
  {
   _cell = document.createElement('TD')
   _row.appendChild(_cell)
   _cell.colSpan = '3'
   _cell.className = 'index-left'
   _img = document.createElement('IMG')
   _cell.appendChild(_img)
   _img.src = '/commoncontent/directory-listing/images/blank.gif'
   _img.height = 1
   _img.width = 50
   _img.border = 0
  }

  if (_accountsCount == 0) // no match found
  {
   _row = document.createElement('TR')
   _tbody.appendChild(_row)
   _row.className= 'tabbedpane'

   _cell = document.createElement('TD')
   _row.appendChild(_cell)
   //_cell.className = 'tabbedpane'
   _cell.className = 'index-center'
   _cell.appendChild(document.createTextNode('Sorry, no match found...'))
  }

  document.getElementById('directory-working').innerHTML = ''
  document.getElementById('formvalue').focus()
 }

 function notesCopy() // put's emails in paste buffer
 {  
  if (_accountsCount == _accountsTotal)
  {
   alert('Use the email copy to put the emails of listed persons into your "paste buffer" so that you can paste them into the TO, CC, or BCC of an email message.\nA filter has to be applied in order to use this feature.')
   return
  }

  if (_accountsCount > _emailMax)
  {
   alert('Sorry, this feature will not work if the number of listed persons is over ' + _emailMax)
   return
  }

  var _buf = ''
  var _count = 0

  // mark matching accounts
  for (i = 0; i < _account.length; i++)
  {
   if (_account[i][_emailIndex] == '') continue
   var _showFlag = 0 // assume not to be shown
   if ((_formvalue == '') && (_formmode != 5)) 
    _showFlag = 1 // no filter applied
   else for (j = 0; j < _iconColumn && _showFlag == 0; j++)
   {
    if (_formkey != 0 && (_formkey - 1) != j) continue
    if ((_showFlag == 0) && (_formmode == 0 || _formmode == 1)) // starts with
      if (_account[i][j].toLowerCase().indexOf(_formvalue) == 0) _showFlag = 1
    if ((_showFlag == 0) && (_formmode == 0 || _formmode == 2)) // contains
      if (_account[i][j].toLowerCase().indexOf(_formvalue) >= 0) _showFlag = 1
    if ((_showFlag == 0) && (_formmode == 0 || _formmode == 3)) // ends with
    {
      var _index = _account[i][j].toLowerCase().lastIndexOf(_formvalue)
      if (_index >= 0 && (_index + _formvalue.length == _account[i][j].length)) _showFlag = 1
    }
    if ((_showFlag == 0) && (_formmode == 0 || _formmode == 4)) // equals 
      if (_account[i][j].toLowerCase() == _formvalue) _showFlag = 1
    if ((_showFlag == 0) && (_formmode == 5)) // exists 
      if (_account[i][j].toLowerCase() != '') _showFlag = 1
   }
   if (_showFlag == 0) continue
   if (_buf != '') _buf += "; " 
   _buf += _account[i][_emailIndex] // email
   _count++
  }

  var flashcopier = 'flashcopier';
  if(!document.getElementById(flashcopier))
  {
   var divholder = document.createElement('div');
   divholder.id = flashcopier;
   document.body.appendChild(divholder);
  }
  document.getElementById(flashcopier).innerHTML = '';
  var divinfo = '<embed src="/commoncontent/directory-listing/js/_clipboard.swf" FlashVars="clipboard='+encodeURIComponent(_buf)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
  document.getElementById(flashcopier).innerHTML = divinfo;

  alert('You may now paste ' + _count + ' email address(es) into the TO, CC, or BCC of an email message.')
 } 

 function editResult()
 {
  // build window contents
  var _i = arguments[0]
  var _buf = "<table width='95%'>"
  for (i = 2; i < _iconColumn; i++)
  {
   _buf += "<tr><td align='right' valign='top'>" + _column[i]
   _buf += ":</td><td><tt>&nbsp;</tt></td><td align='left' valign='top'><b>"

   // check for email (7) or bio page (11)
   if (_account[_i][i] == "") _buf += "&nbsp;"
   else if (i == 7) _buf += "<a href='mailto:" + _account[_i][i] + "'>" + _account[_i][i] + "</a>"
   else if (i == 11) _buf += "<a href='/biopage/" + _account[_i][i] + "'>http://www.dvc.edu/biopage/" + _account[_i][i] + "/</a>"
   else _buf += _account[_i][i]

   _buf += "</b></td></tr>"
  }
  _buf += "</table><br/>"
  _caption = "<center>" + _account[_i][0] + "</center>"

  // display window -- requires <div id='overDiv' style='position:absolute; visibility:hidden; z-index:1000;'></div>
  overlib(_buf, AUTOSTATUSCAP, STICKY, CLOSECLICK, CENTERPOPUP, CLOSETEXT, 'x',
  TEXTFONTCLASS, "popupCKnox", CAPTIONFONTCLASS, "captionCKnox", CLOSEFONTCLASS, "captionCKnox",
  BGCOLOR, "#007550", FGCOLOR, "#ECE8B5", TEXTCOLOR, "#000000", BORDER, 3, 
  CAPTION, _caption, WIDTH, 400)
 }

 function saveAndExit()
 {
  cClick()
 }

 function setFilter()
 {
  _formkey = document.getElementById('formkey').selectedIndex
  _formmode = document.getElementById('formmode').selectedIndex
  _formvalue = TrimString(document.getElementById('formvalue').value).toLowerCase()
  showTable()
  if (_accountsCount <= 60) showTable(String.fromCharCode(91))
 }
 
 function clearFilter()
 {
  if (_accountsCount != _accountsTotal)
  {
   document.getElementById('formkey').selectedIndex = _formkey = 0
   document.getElementById('formmode').selectedIndex = _formmode = 1
   document.getElementById('formvalue').value = _formvalue = ""
   showTable()
 }}

 function keySelected()
 {
  if (document.getElementById('formkey').selectedIndex == 12)
   document.getElementById('formmode').selectedIndex = 5
  else if (document.getElementById('formkey').selectedIndex != 0 && document.getElementById('formmode').selectedIndex == 0)
   document.getElementById('formmode').selectedIndex = 2
 } 

 function modeSelected()
 {
  if (document.getElementById('formmode').selectedIndex == 0 && document.getElementById('formkey').selectedIndex != 0)
   document.getElementById('formkey').selectedIndex = 0 
 } 











































