var version = "3.2"              // CUSTOMIZE
var thisFileName = "survey.js";    // CUSTOMIZE

// Changes:
//  3.1/2 20040302 Put in a generic To address for group emails.
//  3.0   20040109 Allow 4th arg in leftnav[] in entity.js to be rollover (title attr); add melink into css for current bleed leftnav
//  2.9   20031220 Allow alias (3rd arg in leftnav[] in entity.js & var page_alias in sub\index.html) to bleed current page into left nav
//  2.8   20031116 Take out explicit references to static email addresses to foil scum-sucking spammer crawlers.
//  2.7   20030930 tablewidthst attribute on data tables when grouping is in affect.
//  2.6   20030508 Pad column 1 for clip row.
//  2.5   20030507 Pointer to html character guidance in record details popup.
//  2.4a  20030407 Add a <a> link in writePix.
//  2.4   20030329 Add writePix()
//  2.3a  20030326 Add db_file and DeleteThisRecord fields to FormMail's sort array.  - NO NO NO
//  2.29  20030324 Explicit reference to redirect file in recordForm() for local hosting via serve.bat;
//                  Disable submit button on details panel if local copy.
//  2.28  20030321 Add setMailHelp() and consolidate copyrightLine.  Add tableSearch fcn.  (see charis roster.data)
//  2.27  20030320 Add forceMultiLine and associated fcnality.
//  2.26  20030318 Add replaceablePix
//  2.25  20030317 Add surveyPix array options to insertTable() for top and bottom images.
//                  Fix okToNavto switch setting.
//  2.24  20030313 Here's an idea: if we show and allow selection of any column how about we actually SHOW it!
//  2.23  20030312 Show all columns in manual column select pull-down.
//  2.22  20030311 Drop alert about cookie switches changing.
//  2.21  20030306 Special treatment of <a >val</a> in showTab()
//  2.2   20030305 Add DeleteThisRecord checkbox to update form.  Also updated FormMailJS.pl.
//  2.14  20030227 Allow "y" in tableHTML in addition to "yes".  Added cm to copy email addresses.
//  2.13  20030226 Defeat submit on recordForm if local filesystem version.
//  2.12  20030225 Make default copyright year the modify date of file.
//  2.11  20030220 Debug grouping default val (-1, not 0 which is same as null)
//  2.10  20030219 Add Grouping.
//  2.06  20030213 Add selectColumns as a possible call to insertTable to enable pre-defined Default view.
//  2.05  20030129 No, add additional possible SubmitterURL field for data files that don't include Submitter field.
//  2.04  20030129 Allow email address of submitter to begin "http://".  May be implications later
//                  if we start validating against private list of known/trusted users.
//  2.03  20030128 Minor changes for distribution of generic
//  2.02  20030126 Allow tableType to be MULTI indicating multiple select (if also a select).
//  2.01  20021219 Add insertCharts()
//  1.98k 20021218 Cosmetic, valign sort buttons, less cellspacing.  Added editorEmail for *.data files.
//  1.98j 20021217 Add tableHTML to enable <> characters (and ") in a field.
//  1.98i 20021210 variablize tb_lnwidth instead of hard-coding 150; better column/sort buttons; tableView's.
//  1.98h 20021210 variablize tb_bgnormal/left, remove some css vars with backrounds hardcoded: leftSel, leftNonSel, leftnav, bodyarea, wholepage
//  1.98g 20021209 Add descriptions to categorical field pull-downs in add/change pop-up (tableSelects[])
//  1.98f 20021205 Add TD_n ids to all records, global search in url, =searchst for non-wildcard, popHelp()
//  1.98d 20021119 Add (all) fields search option (default)
//  1.98c 20021119 Break column help "?" to save horizontal space, allow tableDef and tableStyle to not be defined.
//  1.97  20021116 Add "Plain Table" link and associated showTab()

// To Do:
// 20030329 Propogate tableType into bubblesort.
// 20021219 Warning: NS 7 does split() differently; if no preceding/trailing, does not add array elements!


// Some of the left nav scrolling functions here are based on original material by:
//  Eddie Traversa (psych3@primus.com.au), Web Site:  http://dhtmlnirvana.com/
//   (Used with permission)
// That and many other javascript scripts are available for free online at:
//   The JavaScript Source!! http://javascript.internet.com
// A routine for finding things on the screen provided by:
//   Matt Kruse <matt@mattkruse.com>
//   http://www.mattkruse.com/
//
// All the other content in this file is:
//
//    (c) 2002 J.F. Kelley, all rights reserved
//

// We expect that calling html file also included a local entity.js with these definitions:
if ("undefined" == typeof hostEntity)  var hostEntity  = "JFK";
if ("undefined" == typeof keyCol)      var keyCol      = 0;
if ("undefined" == typeof copyRight1)  var copyRight1  = "J.F.";
if ("undefined" == typeof copyRight2)  var copyRight2  = "Kelley";
if ("undefined" == typeof leftnav)     var leftnav     = [["index.html","Home"]];
if ("undefined" == typeof footerLinks) var footerLinks = ['<a href="index.html">Home</a>'];
if ("undefined" == typeof tb_bgnormal) var tb_bgnormal = "bgnormal.gif";
if ("undefined" == typeof tb_bgleft)   var tb_bgleft   = "bgleft.gif";
if ("undefined" == typeof tb_lnwidth)  var tb_lnwidth  = "150";
var jfatsg='@'
if ("undefined" == typeof editorEmail) var editorEmail = "badaddress"+jfatsg+"wellhost.com";

// Optional variables that could be in data file (not sure about sequence, but this shouldn't hurt either way).
if ("undefined" == typeof forceMultiLine) var forceMultiLine = false; // 20030320
if ("undefined" == typeof tableClippable) var tableClippable = false; // 20030320


var hostSubject = hostEntity+"Web: Survey";

var page_name = getPageName();


var switchVars = ["enableNavTo","okToFloat","usersEmail","usersURL"];
var switchVals = [false        ,false      ,"",""];
var switchType = ["BOOLEAN"    ,"BOOLEAN"  ,"EMAIL","Website"];
var switchSay = new Array()
switchSay["enableNavTo"]='Programmed links for some versions of IE so that when you click the link, that window comes to the top.';
switchSay["okToFloat"]  ='Experimental floating left nav bar, as you scroll down a long page, it creeps along.'
switchSay["usersEmail"] ='Your email address for forms you may submit later.';
switchSay["usersURL"] ='Your contact http://url for forms you may submit later.';
var currentView = "Default";
var currentSortCol = -1;

procSwitches();

var searchval = "";
var searchvar = "";

var blockingcol = -1;
var twistedblock = new Array();

var viewableColNums = '';
var displayedRows = new Array();

var isDefaultView=false; // whether defined explictly in data file.
var isAllView=false;

var useImages = new Array()

var clipTable = false;
var allowFloat = false;
var oPopup = null;
var phelp = new Array()
var shelp = new Array()
var navWindow = "";

var lastPopHelp = "";

var logStat = '';
var meModified = new Date(document.lastModified);

var copyrightLine  = '<font size="-2"><a style="color:black;text-decoration:none" href="JavaScript: popSettings()">&copy;</a>';
    copyrightLine += '<a style="color:black;text-decoration:none" href="JavaScript: seeLog()">'+meModified.getFullYear()+',</a>';
    copyrightLine += '<a style="color:black;text-decoration:none" href="JavaScript:showHTML()">'+copyRight1+'</a> /';
    copyrightLine += '<a style="color:black;text-decoration:none" href="JavaScript:reportFullCookie()">'+copyRight2+'</a></font>';

var timeoutDelay = 50;     //- How long (milliseconds) For each loop on dependant loading
var timeoutMax   = 10;     //- How long (seconds) to wait before giving up on a file.
var leftNavX     = 0;
var flyr = "";


var gotop = "";
var startTopPos = 0;

var nullArray = new Array();

var jsDataFile=''

var leftPre = new Array();  // for inserting indented sub-heads later
var leftPost = new Array();

var tableStyleOriginal = new Array();
var tableContent = '';
var tablesToLoad = new Array();
var tabContents = new Object();
var datArray = new Array();
var arrayLength = 0;
var webcol=-1;
var namecol=-1;
if ("undefined" == typeof webcolname) var webcolname='WEBSITE' // collapse columns webcolname & namecolname into an anchor tag
if ("undefined" == typeof namecolname) var namecolname='NAME'
// var myPage="";
var popper = "";
var windowContents="nil";
var myVars = '';
var myTypes = '';

var lastsortcol = -1;
var compareColType = ""
var compareColDir = "FWD"

var navdiv = "";
var footdiv= "";
window.onerror = null;
var navTop = 100;
var slideTime = 1200;

var lockedSeq = new Array();

// Various indicators of browser version for various generations of functions...
//var isNS6 = (!document.all && document.getElementById);
var isNS6 = ((document.all && document.getElementById) ? false : true);
var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);

var isNS6m = isNS6;
var isIE4m = (document.all ? true : false);
var isNS4m = (document.layers ? true : false);

var isNS  = false;
var isIE  = false;
var isIE5 = false;
var isNS5 = false;

var browserVersionNote = "";
var browserName=navigator.appName
var browserVersion=navigator.appVersion

var ib = browserVersion.indexOf(" ",0)
if (-1<ib) {
  browserVersionNote = browserVersion.substring(1+ib,browserVersion.length)
  browserVersion=browserVersion.substring(0,ib)
  }
browserVersion=new Number(browserVersion);

if (browserName == "Netscape") {
  isNS=true;
  if (browserVersion >= 5.0) { isNS5=true; }
  }
else if (browserName == "Microsoft Internet Explorer") {
  isIE=true;
  var ibb=navigator.appVersion.indexOf("MSIE ",0)
  if (-1<ibb) {
    browserVersion=navigator.appVersion
    browserVersion=new Number(browserVersion.substring(5+ibb,browserVersion.indexOf(";",5+ibb)))
    }
  if (browserVersion >= 5.0) { isIE5=true; }
  }

var page_name = getPageName()

var cookieLastSeen=getCookie(page_name);
if (cookieLastSeen == null) {
  cookieLastSeen="10/08/1951 00:00:00"
  }
var pageLastSeen = new Date(cookieLastSeen);
setCookie(page_name,pageLastSeen,offsetDays(364))

if ((okToFloat) && (("undefined" != typeof document.getElementById("floatLayer")) || ("undefined" != typeof floatLayer)) ) {
  allowFloat = true;
  }
else allowFloat = false;

//- Fcn: buildLeftNav
// Globals: page_name (from getPageName())
function buildLeftNav() {

// <!--   <div id="floatLayer" style="position: absolute; height:300px; width:150px; left:0px; top:100px; z-index:100"> -->
// top requires customization and MIGHT not be required

  var stx = '<table width="'+tb_lnwidth+'" cellpadding=0 cellspacing=0 border=0 style="background-image: url('+tb_bgleft+')">\n';

  stx += '<tr><td width="3"></td><td><img src="clear_dot.gif" height="10px"></td></tr>';
  leftPre.push(stx)
  var lnk = "";
  var sty = "";
  var curdone=false;
  for (var i=0;i<leftnav.length;i++) {
    var pg = leftnav[i][0]
    var ti = leftnav[i][1]
    if (leftnav[i][2]) var ta = leftnav[i][2]
    else var ta = 'matchnot'

    if (leftnav[i][3]) var metitle=' title="'+leftnav[i][3]+'" '; /* 20040109 */
    else var metitle='';

    if (leftnav[i][4]) var meattribs = leftnav[i][4]
    else meattribs = ''

    if ((ta == '') || ("undefined" == typeof page_alias)) page_alias='notmatch'
    if ((page_name == pg) || (ta == page_alias)) {
      mesty=' style="background-image: url('+tb_bgnormal+'); background-color:#DDDDDD;"'
      mecl='melink'
      }
    else {
      mesty=' '
      mecl='llink'
      }
    sty  = '<tr'+mesty+'><td'+mesty+' width="3">&nbsp;</td><td'+mesty+' width="100%">'
    sty += '<a class="'+mecl+'" href="'+pg+'" ' + metitle + ' ' + meattribs + '>'+ti+'</a></td></tr>\n';

    if (curdone) {
      leftPost.push(sty)
      }
    else {
      if (page_name == pg) {
        curdone=true;
        }
      leftPre.push(sty)
      }
    stx += sty;
    }
  sty  = '<tr><td colspan=2>&nbsp;</td></tr>'
  sty += '<tr><td width="3">&nbsp;</td><td id=TOPTD><a class=llink href="#TOP">Top of Page</td></tr>' // tr and td had class=leftNonSel, a nop
  sty += "</table>";

  leftPost.push(sty)
  stx += sty;

  navdiv=stx;
  }

// E.g. <script language="JavaScript" type="text/javaScript">buildFooter();document.write(footdiv);</script>
function buildFooter() {
  footdiv="";
  footdiv += '   <center><font size="-1">';
  footdiv += '    &#91; <a href="Javascript: window.scrollTo(0,0)">Top</a>';
  for (var i = 0;i<footerLinks.length;i++) {
    footdiv += '    &#124; '+footerLinks[i];
    }
  footdiv += '    &#124; <a href="http://wellhost.com/contactcharis.html?subject='+hostEntity+'Web: ">Contact Charis</a>';
  footdiv += '    &#93;</font>';

  footdiv += '<br />'+copyrightLine;
//footdiv += '    <br /><font size="-2"><a style="color:black;text-decoration:none" href="JavaScript: popSettings()">&copy;</a>';
//footdiv += '           <a style="color:black;text-decoration:none" href="JavaScript: seeLog()">'+meModified.getFullYear()+',</a>';
//footdiv += '           <a style="color:black;text-decoration:none" href="JavaScript:showHTML()">'+copyRight1+'</a> /';
//footdiv += '           <a style="color:black;text-decoration:none" href="JavaScript:reportFullCookie()">'+copyRight2+'</a></font>';

  footdiv += '    <br /><font size="-2"><script Language="JavaScript" type="text/javaScript">show_visits()</script></font>';
//footdiv += '    <br /><img src="clear_dot.gif" width=500 height=1 />'
  footdiv += '    <span id=utilSpan style="position:absolute;visibility:hidden"></span>'
  footdiv += '    </center>';
  }

function scrollMe () {
  if ("undefined" != typeof document.body.scrollTop) {
    now=new Number(document.body.scrollTop)
    gotop=document.getElementById("TOPTD")
    if (now>0) {
      gotop.style.display=""
      gotop.style.visibility="visible"
      }
    else {
      gotop.style.display="none"
      gotop.style.visibility="hidden"
      }
    }
  }

function closePopup () {
//  popper.close();
  location.reload(true);
  }

//- Fcn: initialize 1.0
// Globals: page_name (from getPageName())
function initialize (htmlfile) {
  if (document.title) { document.title=hostEntity+" - Version "+version+", updated: "+meModified }
  if (page_name == "endsurvey.html") {
    opener.closePopup();
//    setTimeout("window.close()";2000);
    }
  if ((allowFloat) && ("undefined" != typeof document.getElementById("floatLayer")) && ("undefined" != typeof floatLayer)) {
    setupFloatLayer();
    }
  if ("yes" == getCookie("scrollBottom")) {
    scrollToBottom()
    deleteCookie("scrollBottom")
    }
  }

function scrollToBottom () {
  if (document.layers) var bottom = window.document.height;
  else if (document.all) var bottom = document.body.scrollHeight;
  else if (document.getElementById) var bottom = window.document.height;
  window.scrollTo(0, bottom);
  }

function scrollToTop () {
  window.scrollTo(0, 0);
  }

function setupFloatLayer () {
  flyr=document.getElementById("floatLayer")
  flyr.style.position='absolute';
  navTop=getAnchorPosition("floatLayer").y+5;
  startTopPos=getAnchorPosition("TOP");
//alert(startTopPos)
  flyr.style.top=navTop;
  window.onscroll=scrollMe
  gotop=document.getElementById("TOPTD")
  scrollMe()
  if(isNS6m||isNS4m) {
    pageWidth = innerWidth;
    pageHeight = innerHeight;
    layerSetup();
    floatObject();
    }
  else if(isIE4m) {
    pageWidth = document.body.clientWidth;
    pageHeight = document.body.clientHeight;
    layerSetup();
    floatObject();
    }
  }

function insertCharts (mychartfile) {
  var n=0;
  var maxn = 0;
  var startleft=leftPre.length;
  for (var i=0;i<bodyText.length;i++) {
    var stline=bodyText[i];
    if ('<h1' == stline.substring(0,3)) maxn++;
    }
  stout='<table border="0" width="100%" bgcolor="#FFFFFF">'
debug1=0
  for (var i=0;i<bodyText.length;i++) {
    var stline=bodyText[i];
    if ('<h1' == stline.substring(0,3)) {
      if (n>0) stout+='</td></tr><tr><td colspan=2><hr size=28 style="color:#DDDDDD" /></td></tr>'
      stout += '<tr><td><img src="clear_dot.gif" width="1" height="800" /></td>';
      stout += '<td valign="top" width="100%" style="font-size:200%">\n';
      var sst=' '+stline+' '
      var hd=sst.split(/<h1>|<\/h1>/)
//if (debug1 < 3) {debug1++;alert(hd.length+' ='+hd+'=');}
      n++;
      stout += reformHead(n,hd[1],maxn)+'\n';
      }
    else stout += stline+'\n';
    }
  n++;
  stout+='</td></tr></table>\n';
  if (leftPre.length>startleft) {
    stx=''
    for (var i=0;i<leftPre.length;i++) {
      stx += leftPre[i];
      }
    for (var i=0;i<leftPost.length;i++) {
      stx += leftPost[i];
      }
    navdiv=stx;
    var flobj=getRef("floatLayer")
    if(flobj) { flobj.innerHTML = navdiv; }
    }
  document.write(stout)
  }

function reformHead (n,tstring,maxn) {
  if (n<=1) pst=' style="visibility:hidden" '
  else pst=''
  if (n == maxn) nst=' style="visibility:hidden" '
  else nst=''
  var stx=''
  var pn=n-1;
  var nn=n+1;
  var nstring = new String(tstring);
  if ((nstring != '') && (-1 < nstring.indexOf(':',0))) {
    var tind=nstring.indexOf(':',0);
    var ti=nstring.substring(0,tind);
    leftPre.push('<tr><td width="3">&nbsp;</td><td width="100%">---<a class="llink" href="#H1_'+n+'">'+ti+'</a><td></tr>\n');
    }
  stx += '<a name="H1_'+n+'" /><p><table width="100%" style="page-break-before:always">';
//stx += '<tr><td colspan=2 valign=top><hr size=8></td></tr>\n';
  stx += '<tr><td style="font-size:250%" valign=top>'+tstring+'</td>\n'
  stx += '<td style="font-size:12;vertical-align:top" width="100" align=right>\n'
  stx += '[ <a href="#TOP">top</a>\n'
  stx += '| <a href="#H1_'+pn+'"><span '+pst+'>prev</span></a>\n'
  stx += '| <a href="#H1_'+nn+'"><span '+nst+'>next</span></a>\n'
  stx += ' ]'
  stx += '<br>Slide '+n+'</br>'
  stx += '</td></tr></table>\n'
  stx += '<hr width="95%" />\n'
  return stx;
  }

function insertTable (myjsfile,imageStem) {
  if (!myjsfile) {
    alert("No js file specified in html insertTable() call");
    }
  parseSearch();
  if ("yes" == getCookie("cleanSlate")) {
    deleteCookie("cleanSlate")
    searchval='';
    searchvar='';
    document.location.href=page_name
    }
  jsDataFile=myjsfile;
  isDefaultView=false;
  isAllView=false;

  if (imageStem) {
    if (("undefined" != typeof surveyPix) && ("undefined" != typeof surveyPix[imageStem])) {
      useImages = surveyPix[imageStem];
      }
    }

  if ("undefined" == typeof tableView) tableView = new Array()

  if ("undefined" == typeof tableSearch) tableSearch = new Array()

  if (("undefined" == typeof tableStyle) || (0 == tableStyle.length)) {
    tableStyle=new Array()
    tableStyle[0]=new Array()
    for (var j=0;j<tableHdr[0].length;j++) {
      tableStyle[0][j]=''
      }
    }

  if (0 < tableView.length) {
    for (var i=0;i<tableView.length;i++) {
      if (tableView[i][0] == 'Default') isDefaultView=true;
      else if (tableView[i][0] == 'All') isAllView=true;
      }
    }

  if ((!isDefaultView) | (!isAllView)) {
    var arow=new Array()
    var drow=new Array()
    for (var j=0;j<tableHdr[0].length;j++) {
      arow.push(tableHdr[0][j])
      if (tableStyle[0][j] != 'display:none') drow.push(tableHdr[0][j])
      }
    if (!isDefaultView) tableView.push(['Default',drow]);
    if (!isAllView) tableView.push(['All',arow]);
    }
  if (isDefaultView) selectColumns('','','','!Default',true)
  else writeTable();
  }

function insertPix (myjsfile) {
  if (!myjsfile) {
    alert("No js file specified in html insertTable() call");
    }
  parseSearch();
  if ("yes" == getCookie("cleanSlate")) {
    deleteCookie("cleanSlate")
    searchval='';
    searchvar='';
    document.location.href=page_name
    }
  jsDataFile=myjsfile;
  isDefaultView=false;
  isAllView=false;

  if ("undefined" == typeof tableView) tableView = new Array()

  if ("undefined" == typeof tableSearch) tableSearch = new Array()

  if (("undefined" == typeof tableStyle) || (0 == tableStyle.length)) {
    tableStyle=new Array()
    tableStyle[0]=new Array()
    for (var j=0;j<tableHdr[0].length;j++) {
      tableStyle[0][j]=''
      }
    }

  if (0 < tableView.length) {
    for (var i=0;i<tableView.length;i++) {
      if (tableView[i][0] == 'Default') isDefaultView=true;
      else if (tableView[i][0] == 'All') isAllView=true;
      }
    }

  writePix();
  }

function insertTableOLD(tableSpan,textfile) {
//document.write('<script language="JavaScript" src="practice.js" type="text/JavaScript" />')
  if (isIE5) {
    document.write("<iframe id=tabFile src='"+textfile+".txt' style='display:none;visibility:hidden'></iframe>");
    tablesToLoad.push([tableSpan,textfile]);
    }
  else {
    var ilyr=locateObject("linkLayer")
    ilyr.src='db_'+textfile+'.html';
//  var stx = "<p>Note: if you use <a href='http://microsoft.com/ie'>Internet Explorer</a>, you'll get a more interactive table here.";
//  stx +=    "<p><div><ilayer src='db_"+textfile+".html' bgcolor='#FFFFDD'></ilayer></div>";
//    document.write("stxxxxxxxxxxxxxx");
    }
  }


function layerObject(id,left) {
  if (isNS6m) {
    this.obj = document.getElementById(id).style;
    this.obj.left = left;
    return this.obj;
    }
  else if(isIE4m) {
    this.obj = document.all[id].style;
    this.obj.left = left;
    return this.obj;
    }
  else if(isNS4m) {
    this.obj = document.layers[id];
    this.obj.left = left;
    return this.obj;
    }
  }

function layerSetup() {
//floatLyr = new layerObject('floatLayer', pageWidth * .5);
  floatLyr = new layerObject('floatLayer', leftNavX)
  window.setInterval("main()", 10)
  }

function floatObject() {
  if (isNS4m || isNS6m) {
    findHt = window.innerHeight;
    }
  else if(isIE4m) {
    findHt = document.body.clientHeight;
    }
  }

function main() {
  if (isNS4m) {
    this.currentY = document.layers["floatLayer"].top;
    this.scrollTop = window.pageYOffset;
    mainTrigger();
    }
  else if(isNS6m) {
    this.currentY = parseInt(document.getElementById('floatLayer').style.top);
    this.scrollTop = scrollY;
    mainTrigger();
    }
  else if(isIE4m) {
    this.currentY = floatLayer.style.pixelTop;
    this.scrollTop = document.body.scrollTop;
    mainTrigger();
    }
  }

function mainTrigger() {
  var newTargetY = this.scrollTop + this.navTop;
  if ( this.currentY != newTargetY ) {
    if ( newTargetY != this.targetY ) {
      this.targetY = newTargetY;
      floatStart();
      }
    animator();
    }
  }

function floatStart() {
  var now = new Date();
  this.A = this.targetY - this.currentY;
  this.B = Math.PI / ( 2 * this.slideTime );
  this.C = now.getTime();
  if (Math.abs(this.A) > this.findHt) {
    this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt;
    this.A = this.A > 0 ? this.findHt : -this.findHt;
    }
  else {
    this.D = this.currentY;
    }
  }

function animator() {
  var now = new Date();
  var newY = this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D;
  newY = Math.round(newY);
  if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) {
    if ( isIE4m )document.all.floatLayer.style.pixelTop = newY;
    if ( isNS4m )document.layers["floatLayer"].top = newY;
    if ( isNS6m )document.getElementById('floatLayer').style.top = newY + "px";
    }
  }


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//- Fcn: showTab 1.1
// Globals:
function showTab (clipOnly) {
  var stx='';
  var sty='';
  for (var jcol=0;jcol<viewableColNums.length;jcol++) {
    i=viewableColNums[jcol];
    if (jcol > 0) {
      stx += '\t';
      sty += '\t';
      }
    stx += tableHdr[0][i];
    sty += tableHdr[0][i];
    }
  stx += '\x0D\x0A';
  sty += '\x0D\x0A';

  for (var i=0;i<displayedRows.length;i++) {
    if (i > 0) {
      stx += '\x0D\x0A';
      sty += '\x0D\x0A';
      }
    for (var jcol=0;jcol<viewableColNums.length;jcol++) {
      j=viewableColNums[jcol];
      val = tableRow[i][j];
      if (jcol > 0) {
        stx += '\t';
        sty += '\t';
        }
      if ('<a ' == val.substring(0,3)) {
        val=val.split('>')[1]
        val=val.split('<')[0]
        }
      stx += val;
      val = val.replace(/<br \/>|\n|\r|\r\n|\n\r/g,"&lt;b /&gt;");
      sty += val;
      }
    }

  if ((isIE) || (isNS5)) {
    var cvinst='\nGo to Excel and click the upper-left cell and do Edit->Paste Special->text.';
    if (clipOnly) {
      var onlyst=' (only)';
      var ccinst=''
      }
    else {
      var onlyst= '';
      var ccinst='\nPlace cursor in window, hit Ctrl+a then Ctrl+c to place on clipboard.';
      }
    if (window.clipboardData) {
      window.clipboardData.setData('Text',stx);
      var clipst='The tab-delimited table is'+onlyst+' on your clipboard.';
      var alsost=' also';
      var ccinst='';
      }
    else {
      var alsost='';
      var clipst='Your browser does not support automatic copying to the clipboard.'
      }

    var winst='\nThe tab-delimited table is'+alsost+' going to come up in another window.';
    var wordst='\nThe MS Word Mailing Label Wizard can use this excel file; note that some fields may have different names.'
    alert(clipst+winst+ccinst+cvinst+wordst);
    if (!clipOnly) {
      windowContents  = '<html>';
//      windowContents += '<head><script language="Javascript" src="survey.js" type="text/javascript"></script></head>';
      windowContents += '<body id=mainBody>';
      windowContents += '<pre>'+sty+'</pre>';
//    windowContents += stx;
//    windowContents += '<br /><a href="Javascript: showHTML(true)">showHTML</a>';
      windowContents += '</body></html>';
      ht=-50+ new Number(screen.height)
      wd = -50 + new Number(screen.width);
      popper=window.open("blank.html","","toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width="+wd+",height="+ht+",resizable=yes,top=0,left=0")
      }
    }
  else alert("showTab() only works with IE and NS 5.0+")
  }

function OBSOLETEshowTab (clipOnly) {
  var stx='';
  var sty='';
  for (var i=0;i<tableHdr[0].length;i++) {
    if (i > 0) {
      stx += '\t';
      sty += '\t';
      }
    stx += tableHdr[0][i];
    sty += tableHdr[0][i];
    }
  stx += '\x0D\x0A';
  sty += '\x0D\x0A';

  for (var i=0;i<tableRow.length;i++) {
    if (i > 0) {
      stx += '\x0D\x0A';
      sty += '\x0D\x0A';
      }
    for (var j=0;j<tableRow[i].length;j++) {
      val = tableRow[i][j];
      if (j > 0) {
        stx += '\t';
        sty += '\t';
        }
      stx += val;
      val = val.replace(/<br \/>|\n|\r|\r\n|\n\r/g,"&lt;b /&gt;");
      sty += val;
      }
    }

  if ((isIE) || (isNS5)) {
    var cvinst='\nGo to Excel and click the upper-left cell and do Edit->Paste Special->text.';
    if (clipOnly) {
      var onlyst=' (only)';
      var ccinst=''
      }
    else {
      var onlyst= '';
      var ccinst='\nPlace cursor in window, hit Ctrl+a then Ctrl+c to place on clipboard.';
      }
    if (window.clipboardData) {
      window.clipboardData.setData('Text',stx);
      var clipst='The tab-delimited table is'+onlyst+' on your clipboard.';
      var alsost=' also';
      var ccinst='';
      }
    else {
      var alsost='';
      var clipst='Your browser does not support automatic copying to the clipboard.'
      }

    var winst='\nThe tab-delimited table is'+alsost+' going to come up in another window.';
    var wordst='\nThe MS Word Mailing Label Wizard can use this excel file; note that some fields may have different names.'
    alert(clipst+winst+ccinst+cvinst+wordst);
    if (!clipOnly) {
      windowContents  = '<html>';
//      windowContents += '<head><script language="Javascript" src="survey.js" type="text/javascript"></script></head>';
      windowContents += '<body id=mainBody>';
      windowContents += '<pre>'+sty+'</pre>';
//    windowContents += stx;
//    windowContents += '<br /><a href="Javascript: showHTML(true)">showHTML</a>';
      windowContents += '</body></html>';
      ht=-50+ new Number(screen.height)
      wd = -50 + new Number(screen.width);
      popper=window.open("blank.html","","toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width="+wd+",height="+ht+",resizable=yes,top=0,left=0")
      }
    }
  else alert("showTab() only works with IE and NS 5.0+")
  }

//- Fcn: showHTML 1.1
// Globals: id=mainBody (in html body tag), isIE, isNS5
function showHTML (clipOnly) {
  if ((isIE) || (isNS5)) {
//    var stx = document.getElementById("mainBody")
    var stx = getRef("mainBody")
    if (stx.outerHTML) {
      var sty=stx.outerHTML
      outst=' "outer"';
      }
    else {
      var sty=stx.innerHTML
      outst='';
      }
    if (window.clipboardData) {
      window.clipboardData.setData('Text',sty);
      if (clipOnly) onlyst=' (only)';
      else onlyst= '';
      window.status= 'The'+outst+' html source is'+onlyst+' on your clipboard';
      }
//    document.write("<HTML><xmp>"+sty+"</xmp></HTML>")
    if (!clipOnly) {
      windowContents = '<html><body id=mainBody><xmp>'+sty+'</xmp><a href="Javascript: showHTML(true)">showHTML</a></body></html>';
      ht= -50 + new Number(screen.height)
//    wd = -50 + new Number(screen.width);
      wd=700;
      popper=window.open("blank.html","","toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width="+wd+",height="+ht+",resizable=yes,top=0,left=0")
      }
    }
  else alert("showHTML() only works with IE and NS 5.0+")
  }

function getRef(id) {
 if (isDOM) return document.getElementById(id);
 if (isIE4) return document.all[id];
 if (isNS4) return document.layers[id];
 }
function getSty(id) {
 return (isNS4 ? getRef(id) : getRef(id).style);
 }

function PROPOSEDgetRef(id) {
 if (document.getElementById) return document.getElementById(id);
 else if (document.all) return document.all[id];
 else if (document.layers) return document.layers[id];
 else return ''
 }

function PROPOSEDgetSty(id) {
 if (document.layers) return getRef(id);
 else return getRef(id).style;
 }

//- Fcn: parseSearch 1.1
function PROPOSEDparseSearch () {
  uargs=location.search.substring(1,location.search.length);
  if (-1 < uargs.indexOf('\\')) uargs=uargs.replace(/\\/gi,'/')
  if (-1 < uargs.indexOf('\%26',0)) {
    argArray=uargs.split("\%26")
    }
  else argArray=uargs.split("&");
  for (var i=0;i<argArray.length;i++) {
    thisst=argArray[i];
    thisArgset = thisst.split('=');
    if (thisArgset[1]) eval(thisArgset[0]+'="'+thisArgset[1]+'"')
    }
  }


function goTo(pagename) {
  if ((-1 < pagename.selectedIndex) && (pagename.options[pagename.selectedIndex].value != 'nil')) {
    val = pagename.options[pagename.selectedIndex].value;
    if (val!="NoValue") {
      pagename.selectedIndex=0;
      location.href=val;
      return true;
      }
    }
  }

function lTrim (myString) {
  return myString.replace( /^\s*/, "" );
  }

function rTrim (myString) {
  return myString.replace( /\s*$/, "" );
  }

function trim (myString) {
  return rTrim(lTrim(myString));
  }

function validateInt(myNumber) {
  if (myNumber.length == 0) { return false; }
  for (var i=0;i < myNumber.length;i++) {
    var mychar=myNumber.substring(i,i+1);
//alert(mychar)
    if ((mychar < '0') || (mychar > '9')) { return false; }
    }
  return true;
//For no leading zeros:  return (("" + parseInt(myNumber)) == myNumber);
  }


function validateNumber(myNumber) {
  if (myNumber.length == 0) { return false; }
  for (var i=0;i < myNumber.length;i++) {
    var mychar=myNumber.substring(i,i+1);
    if ((mychar != ".") && (mychar != "-") && (mychar != "+") && ((mychar < '0') || (mychar > '9'))) { return false; }
    }
  var pos1=myNumber.indexOf(".",0);
//  alert(myNumber+"/"+pos1+"/"+myNumber.indexOf(".",pos1))
  if ((pos1 != -1) && (-1 != myNumber.indexOf(".",pos1))) return false;
  return true;
  }

function checkURL (myURL) {
  if (myURL == "") return '';
  if (myURL.substring(0,7) != 'http://') return 'URL does not begin http://...';
  if (-1 < myURL.indexOf(' ',0)) return 'URL has spaces in it.';
  return '';
  }

function checkEmails (myEmails) {
  var allEmails = myEmails.split(',')
  for (var i=0;i<allEmails.length;i++) {
    var retval=checkEmail(trim(allEmails[i]))
    if (retval != "") return retval
    }
  return "";
  }

function checkEmail (myEmail) {
  validchars  = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM?";  // allow ? even though not valid.
  for(i=0; i < myEmail.length ;i++){
    if(validchars.indexOf(myEmail.charAt(i))<0){
      return 'Email address "'+myEmail+'" has invalid characters.';
      }
    }
  var at="@"
  var dot="."
  var lat=myEmail.indexOf(at)
  var lstr=myEmail.length
  var ldot=myEmail.indexOf(dot)
  if (myEmail.indexOf(at,(lat+1)) != -1 || myEmail.indexOf(at)==-1 || myEmail.indexOf(at)==0 || myEmail.indexOf(at)==lstr) {
    return 'Email address "'+myEmail+'" is invalid (see the @ sign).';
    }
  if (myEmail.indexOf(dot)==-1 || myEmail.indexOf(dot)==0 || myEmail.indexOf(dot)==lstr){
    return 'Email address "'+myEmail+'" is invalid (something about the placement of the dots).';
    }
  if (myEmail.indexOf(dot,(lat+2)) == -1 || myEmail.substring(lat-1,lat)==dot || myEmail.substring(lat+1,lat+2)==dot){
    return 'Email address "'+myEmail+'" is invalid (something about the @ and the dots).';
    }
  if (myEmail.indexOf(" ")!=-1){
    return 'Email address "'+myEmail+'" is invalid (no spaces allowed).';
    }
  return "";
  }

function checkEmailBroken2 (myEmail) {
  validchars = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

  for(i=0; i < myEmail.length ;i++){
    if(validchars.indexOf(myEmail.charAt(i))<0){
      return "The email address your entered: "+myEmail+" has invalid character(s).";
      }
    }
 if (document.images) {
    re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
    re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
    if (!myEmail.match(re) && myEmail.match(re_two)) {
      return "The email address you entered: "+myEmail+" doesn't look right.";
      }
    }
  }

function checkEmailBroken (strng) {
  var error="";
  if (strng == "") {
    error = "You didn't enter an email address.\n";
    }
  var emailFilter=/^.+@.+\..{2,3}$/;
  if (!(emailFilter.test(strng))) {
    error = "Please enter a valid email address.\n";
    }
  else {
//  var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
    var illegalChars= /[\(\)\<\>\;\:\\\"\[\]]/
    if (strng.match(illegalChars)) {
      error = "The email address contains illegal characters.\n";
      }
    }
  return error;
  }

function toggleRecordDeleted (formname) {
  var inform=getRef(formname);
  var oldval=inform.DeleteThisRecord.value;
  if (oldval == "YES") {
    var newval="no";
    var bg="#FFFFFF";
    var alstring="This record is no longer marked for deletion.";
    inform.SubmitButton.value=" Submit Changes ";
    inform.SubmitButton.style.color="#000000";
    }
  else {
    var newval="YES";
    var bg="#FFCCCC";
    var alstring="This record will be deleted when you click Submit.";
    inform.SubmitButton.value=" Delete Record ";
    inform.SubmitButton.style.color="#FF0000";
    }
  inform.DeleteThisRecord.value=newval;

  if (document.all || document.getElementById) {  // IE or NS6+ only
    if (("undefined" == typeof inform) || (inform == "")) {
      inform=document.getElementById('mainForm');
      checkonly=true;
      }
    for (i = 0; i < inform.length; i++) {
      var tempobj = inform.elements[i];
      otype=tempobj.type.toLowerCase();
      if (document.all || document.getElementByID) {
        // change the color of text field back to normal if checkonly
        if (otype != "submit" && otype != "reset" && otype != "button") {
          val=tempobj.value;
          if (-1 == val.indexOf("??",0)) { tempobj.style.background = bg; }
          else {
            tempobj.style.background = "#EEEE99";
            }
          }
        }
      }
    }
  window.status=alstring;
  }

function validPixForm (myform) {
  if (myform.uploadfile.value == "") {
    alert("You must Browse or otherwise specify a local file to upload")
    return false;
    }
  tryfn=myform.newfilename.value
  if (tryfn == "") {
    alert("You must specify a new filename");
    return false;
    }
  if ((-1 != tryfn.indexOf('\\')) || (-1 != tryfn.indexOf('\/')) ) {
    alert("You must not specify a path with the new filename")
    return false;
    }
  return true;
  }

//- Fcn: validForm
//-   ALWAYS for a pop-up daughter window (see references to opener. below)
function validForm(inform,myTableHdr,myTableType,myTableReq,myTableForm,myTableStyle) {
  checkonly=false;
  though="";
  if (document.all || document.getElementById) {  // IE or NS6+ only
    if (("undefined" == typeof inform) || (inform == "")) {
      inform=document.getElementById('mainForm');
      checkonly=true;
      }
    for (i = 0; i < inform.length; i++) {
      var tempobj = inform.elements[i];
      otype=tempobj.type.toLowerCase();
      if (otype == "submit" || otype == "reset") tempobj.disabled = true;
      else {
        if (!checkonly) {tempobj.disabled=false;} // allow uneditable values to be passed
        else if (document.all || document.getElementByID) {
          // change the color of text field back to normal if checkonly
          if (otype != "submit" && otype != "reset" && otype != "button") {
            val=tempobj.value;
            if (-1 == val.indexOf("??",0)) { tempobj.style.background = "white"; }
            else {
              tempobj.style.background = "#EEEE99";
              though=" (though some fields still have ?? in them)"
              }
            }
          }
        }

      }
    }

  if (("undefined" == typeof inform) || (inform == "")) {
    alert("Sorry, your browser will not support form validation until you click Submit");
    return false;
    }

//var tryemail = inform.EMAIL.value;
  var errSt="";
  var toploc = ""
  var switchto = "";

  for (var i=0;i<myTableHdr[0].length;i++) {
    var hdr = myTableHdr[0][i];
    if (myTableReq)   var req   = myTableReq[0][i];   else var req  ='';
    if (myTableType)  var type  = myTableType[0][i];  else var type ='';
    if (myTableForm)  var edit  = myTableForm[0][i];  else var edit ='';
    if (myTableStyle) var style = myTableStyle[0][i]; else var style='';
    if ("undefined" == typeof inform[hdr]) {
      alert("Program error, missing field: "+hdr)
      return false;
      }
    if ("undefined" != typeof inform[hdr].value) val=inform[hdr].value;else val='';
// alert("hdr:"+hdr+", val:"+val+", edit:"+edit+", style:"+style)
    if ('MULTI' == type) {
      if (!inform[hdr].multiple) {
        alert('Field '+hdr+' is supposed to be multiple-select; please notify the webmaster!')
        }
      val='';
      for (var imf=0;imf<inform[hdr].length;imf++) {
        if (inform[hdr][imf].selected) {
          if (val != '') val += ',';
          val += inform[hdr][imf].value;
          }
        }
      }
    if ((req=="y") && (("undefined" == typeof inform[hdr].value) || (trim(inform[hdr].value) == ""))) {
      errSt += "* Required value "+hdr+" not entered.\n"
      if (switchto == "") { switchto = inform[hdr]; }
      if (document.all || document.getElementByID) { inform[hdr].style.background = "yellow"; }
      }
    else if (("undefined" != typeof inform[hdr].value) && (edit != "ro") && ((edit == "edit") || (style != "display:none")) && ("" != inform[hdr].value)) {
      var val = inform[hdr].value;
      if ((hdr != "EMAIL") && (type == "EMAIL")) {  // do hdr EMAIL later, separately
        val=trim(val);
        inform[hdr].value=val;
        temperr=checkEmails(val);
        if (temperr != "") {
          errSt += "* "+temperr+"\n";
          if (switchto == "") { switchto = inform[hdr]; }
          if (document.all || document.getElementByID) { inform[hdr].style.background = "yellow"; }
          }
        else if (hdr == "usersEmail") {
          opener.usersEmail=val;
          opener.procSwitches(true);
          }
        else if (hdr == "usersURL") {
          opener.usersURL=val;
          opener.procSwitches(true);
          }
        }
      else if ((type == "W") && (!validateInt(val))) {
        errSt += "* Non-integer ("+val+") entered for "+hdr+".\n";
        if (switchto == "") { switchto = inform[hdr]; }
        if (document.all || document.getElementByID) { inform[hdr].style.background = "yellow"; }
        }
      else if ((type == "N") && (!validateNumber(val))) {
        errSt += "* Non-numeric ("+val+") entered for "+hdr+".\n";
        if (switchto == "") { switchto = inform[hdr]; }
        if (document.all || document.getElementByID) { inform[hdr].style.background = "yellow"; }
        }
      }
    }

  if ("undefined" != typeof inform["EMAIL"]) {  // special, might exist apart from table
    tryemail=trim(inform["EMAIL"].value);
    inform["EMAIL"].value=tryemail;
    if (tryemail == "") {
      errSt += "* Required Email  not entered.\n"
      if (switchto == "") { switchto = inform["EMAIL"]; }
      if (document.all || document.getElementByID) { inform["EMAIL"].style.background = "yellow"; }
      }
    else {
      temperr=checkEmail(inform["EMAIL"].value);
      if (temperr != "") {
        errSt += "* "+temperr+"\n";
        if (switchto == "") { switchto = inform["EMAIL"]; }
        if (document.all || document.getElementByID) { inform["EMAIL"].style.background = "yellow"; }
        }
      else {
        opener.usersEmail=tryemail;
        opener.procSwitches(true);
        }
      }
    }

  if ("undefined" != typeof inform["SubmitterURL"]) {
    tryurl=trim(inform["SubmitterURL"].value);
    if (tryurl == 'http://') tryurl=''; // 20030324
    inform["SubmitterURL"].value=tryurl;
    temperr=checkURL(tryurl);
    if (temperr != "") {
      errSt += "* "+temperr+"\n";
      if (switchto == "") { switchto = inform["SubmitterURL"]; }
      if (document.all || document.getElementByID) { inform["SubmitterURL"].style.background = "yellow"; }
      }
    else {
      opener.usersURL=tryurl;
      opener.procSwitches(true);
      }
    }

  if (errSt != "") {
    alert("Error(s) in Form:\n"+errSt)
    if (toploc != "") location.href=toploc
    else if (switchto != "") switchto.focus()
    for (i = 0; i < inform.length; i++) {
      var tempobj = inform.elements[i];
      if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset") tempobj.disabled = false;
      }
    return false;
    }
  else {
    if (checkonly) {alert("Your form looks good"+though+"!");}
    for (i = 0; i < inform.length; i++) {
      var tempobj = inform.elements[i];
      if (tempobj.type.toLowerCase() == "submit" || tempobj.type.toLowerCase() == "reset") tempobj.disabled = false;
      }
    return true;
    }
  }


//- Function: "onConditionExecute()"
//-   Wait till a test comes back "true" and execute an arbitrary command
//-   Use "lockedSeq" to register our place in line to access that object.
function onConditionExecute (testname,cmdString) {
    var args=onConditionExecute.arguments;
    var isit=true;
    var passargs=''
    for (var i=2;i<args.length;i++) {
      passargs += ',"'+args[i]+'"'
      eval ("var isthis = ("+args[i]+")")
      if (!isthis) {
        isit=false;
        break;
        }
      }
    if (isit == false) {
      if ((typeof lockedSeq[testname] == "undefined") || (lockedSeq[testname] == null)) {
        lockedSeq[testname] = 0;
        }
      else {
        lockedSeq[testname]++;
        }
      if (lockedSeq[testname]*timeoutDelay/1000 > timeoutMax) {
        window.status=("oce[1] "+testname+" onConditionExecute Error: timeout occured waiting for truth of "+testname);
        lockedSeq[testname] = null;
        }
      else {
        var doit='onConditionExecute("'+testname+'","'+cmdString+'"'+passargs+')';
        setTimeout(doit,timeoutDelay);
        }
      }
    else {
      lockedSeq[testname] = null;
      window.status="oce[0]";
      eval(cmdString);
      }
    }

//- Fcn: show_visits 1.4
// Globals: page_name (from earlier invocation of getPageName()), getCookie(), setCookie()
function show_visits(page_cookie) {
  if (!page_cookie) {
    page_cookie=page_name
    }
  var cookie_date=new Date(document.lastModified);
  var expdate = new Date();
  expdate.setTime(expdate.getTime()+(364*24*60*60*1000));
  document.write("<Font color=0000FF>" + "Page "+page_cookie+" last updated: "+ document.lastModified);
  if (!(cookie_date == getCookie(page_cookie))){
    setCookie(page_cookie,cookie_date,expdate);
    document.write(" (<font color='red'>Changed</font> since your last visit)");
    }
  else {
    document.write(" (Unchanged since your last visit)");
    }
  document.write("</font>");
  }


//- Fcn: tagNew 1.3
// E.g.: <script language="JavaScript" type="text/javascript">tagNew("10/11/2002","new11.gif")</script>
// Global: pageLastSeen
function tagNew(datest,tryimg) {
  var tagdate = new Date(datest);
//alert(pageLastSeen+"/"+tagdate)
  if (tagdate > pageLastSeen) {
    if (("undefined" == typeof tryimg) || (tryimg=="")) {
      document.write("<font color=FFFF00><b>New</b></font>");
      }
    else {
      document.write("<img src='"+tryimg+"' alt='Item Modified: "+tagdate+", your last visit: "+cookieLastSeen+"' />")
      }
    }
  }

//- Fcn: getPageName 1.2
// Globals: (none, returns what will become page_name at top)
function getPageName () {
  var page_n=location.href
  var i=page_n.indexOf("?",0)
  if (-1 < i) {
    page_n=page_n.substring(0,i)
    }
  var ip=page_n.indexOf("#",0)
  if (-1 < ip) {
     page_n=page_n.substring(0,ip)
     }
  var i=page_n.indexOf("/",0)
  while (i > -1) {
    page_n=page_n.substring(1+i,page_n.length)
    i=page_n.indexOf("/",0)
    }
  if (page_n == "") { page_n = "index.html" };
  return page_n;
  }


//- Fcn: parseSearch 1.0
function parseSearch () {
  uargs=location.search.substring(1,location.search.length);
  if (-1 < uargs.indexOf('\%26',0)) {
    argArray=uargs.split("\%26")
    }
  else argArray=uargs.split("&");
  for (var i=0;i<argArray.length;i++) {
    thisst=argArray[i];
    thisArgset = thisst.split('=');
    if (thisArgset[1]) eval(thisArgset[0]+'="'+thisArgset[1]+'"')
    }
  }

function locateObject(n, d) { //v3.0
   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=locateObject(n,d.layers[i].document); return x;
 }

function loadSource(id,nestref,url) {
 if (ns4) {
  var lyr = (nestref)? eval('document.'+nestref+'.document.'+id) : document.layers[id]
  lyr.load(url,lyr.clip.width)
 }
 else if (ie4) {
  parent.bufferFrame.document.location = url
 }
}
function loadSourceFinish(id) {
 if (ie4) document.all[id].innerHTML = parent.bufferFrame.document.body.innerHTML
}

function food () {
  alert(document.layers["tabFileZ"])
  }

function searchBox (isReset) {
  searchcol=-1;
  searchname="";
  if ("undefined" == typeof tabform) { tabform=getRef("tabform"); }
  searchcol=tabform.ssel.value
//for (var i=0;i<tabform.ssel.length;i++) {
//  logIt("<br>"+i+": "+tabform.ssel[i].checked)
//  if (tabform.ssel[i].checked == true) {
//    searchcol=i
//    }
//  }
  var searchst = tabform.searchInput.value;
  if ((searchst != "") && (searchcol==-1)) {
//    alert("no column selected")
//  searchname="(all)" // not necessary?  might be retiring searchcolname arg?
    searchcol=9999;
    }
  tabform.searchInput.value='';
  tabform.searchInput.focus();
  writeTable(searchst,searchcol,searchname,true)
  }

function defaultArrays() {
  if ("undefined" == typeof tableSort) {
    tableSort=new Array()
    tableSort[0]=new Array()
    for (var j=0;j<tableHdr[0].length;j++) {
      tableSort[0][j]='FWD'
      }
    }

  if ("undefined" == typeof tableType) {
    tableType=new Array()
    tableType[0]=new Array()
    for (var j=0;j<tableHdr[0].length;j++) {
      tableType[0][j]=''
      }
    }

  if ("undefined" == typeof tableHTML) {
    tableHTML=new Array()
    tableHTML[0]=new Array()
    for (var j=0;j<tableHdr[0].length;j++) {
      tableHTML[0][j]=''
      }
    }
  if ("undefined" == typeof tableFcn) {
    tableFcn=new Array()
    tableFcn[0]=new Array()
    for (var j=0;j<tableHdr[0].length;j++) {
      tableFcn[0][j]=''
      }
    }

  if ("undefined" == typeof tableMultiCol) {
    tableMultiCol=new Array()
    tableMultiCol[0]=new Array()
    for (var j=0;j<tableHdr[0].length;j++) {
      tableMultiCol[0][j]=false;
      }
    }

  if ("undefined" == typeof tableSelects) {
    tableSelects=new Array()
    }
  }

function clipForm () {
  if(window.clipboardData) {
    var stx="Directory:  xxx\n";
    inform=document.getElementById("mainForm");
      for (i = 0; i < inform.length; i++) {
        var tempobj = inform.elements[i];
        if (("checkbox" == tempobj.type) && (tempobj.checked == true)) {
          stx += tempobj.id+"\n";
          }
        else if ("checkbox" != tempobj.type) {
          stx += tempobj.id+": "+tempobj.value+"\n";
          }
        }
    window.clipboardData.setData("Text",stx);
    }
  else {alert("Your browser (unlike IE 5+) does not support the clipboard")  }
  return false;
  }

function writePix (doReplace,doScrollTop) {
  defaultArrays();
  stx = ''

//tableHdr.push(["N","FilePath","Filename","Description","FileDate","Type","XSize","YSize","FileSize","Colors","Submitter","ModDate"]);
//                0   1          2          3             4          5      6       7       8          9        10          11
  var ind=new Array()
  for (var i=0;i<tableRow.length;i++) {
    var fn=tableRow[i][2];
    var fp=tableRow[i][1];
    if (fp == '') var div='';
    else var div='\\';
    var fd   =tableRow[i][3];
    var fdate=tableRow[i][4];
    var xp   =tableRow[i][6];
    var yp   =tableRow[i][7];
    var sz   =tableRow[i][8];
    var co   =tableRow[i][9];
    stx += '  <span style="height:240px;width:208px">\n'
    stx += '   <table border="1" cellpadding="2" cellspacing="0" height="100%" width="100%">\n'
    stx += '    <tr>\n'
    stx += '     <td height="100%" align=left valign="top">\n'
    stx += '      <table border="0" cellpadding="0" cellspacing="0" height="100%">\n'
    stx += '       <tr>\n'
    stx += '        <td valign=top>\n'
    stx += '        <font size="-1"><input type=checkbox id="c_showimg.html?'+fp+div+fn;
    stx += '|%3Cfont%20size%3D%22+1%22%3E%3Cb%3E'+fn+'%3C/b%3E%3C/font%3E%3Cbr%20/%3E%20';
    stx += fd.replace(/ /gi,'%20')+'%3Cbr%20/%3E%20%3Cfont%20size%3D%22-2%22%3E%7B';
    stx += xp+'x'+yp+'%20'+co+'%20'+sz+'K%7D%3C/font%3E%3Cbr%20/%3E%20"'
    stx += ' /> <a href="'+fn+'">'+fn+'</a></font><br />\n'
    stx += '         <center>\n'
    stx += '          <a href="showimg.html?'+fp+div+fn;
    stx += '|%3Cfont%20size%3D%22+1%22%3E%3Cb%3E'+fn+'%3C/b%3E%3C/font%3E%3Cbr%20/%3E%20';
    stx += fd.replace(/ /gi,'%20')+'%3Cbr%20/%3E%20%3Cfont%20size%3D%22-2%22%3E%7B';
    stx += xp+'x'+yp+'%20'+co+'%20'+sz+'K%7D%3C/font%3E%3Cbr%20/%3E%20"'
    stx += ' target="_NEWWIN">\n'
    stx += '           <img border="0" src="'+fp+div+'CRUMBS200x200/'+fn+'" />\n'
    stx += '           </a>\n'
    stx += '          </center>\n'
    stx += '         <font size="-2">{'+xp+'x'+yp+' '+co+' '+sz+'K}';
    stx += '          </font><br /> </td></tr>\n'
    stx += '        <tr><td valign="bottom" height="100%">\n'
    stx += '         </td>\n'
    stx += '        </tr>\n'
    stx += '       </table>\n'
    stx += '      </td>\n'
    stx += '     </tr>\n'
    stx += '    </table>\n'
    stx += '   </span>\n'
    }
  stx += ' </form>\n'
  var rxgt = new RegExp("&gt;",'ig')
  var rxlt = new RegExp("&lt;",'ig')
  stx=stx.replace(rxgt,">")
  stx=stx.replace(rxlt,"<")
  tableContent=stx;
//window.clipboardData.setData('Text',tableContent);window.status=tableContent.length+' bytes of data placed on clipboard';
  if (doReplace) {
    if ((document.getElementById) && (document.getElementById("linkTable").innerHTML)) {
      document.getElementById("linkTable").innerHTML = tableContent; // won't work in old netscape.
      }
    else alert('Sorry, your browser does not support something called "innerHTML".\nTry upgrading your Internet Explorer or Netscape.');
    }
  if (doScrollTop) { scrollToTop(); }
  }

function writeTable (searchst,searchcol,searchcolname,doReplace,doScrollTop) {
//alert(searchvar+"="+searchval)
//alert('2: '+searchvar+'='+searchval)
// alert(searchst+"/"+searchcolname+"/"+searchcol+"/"+searchvar+"/"+searchval)
  if (("undefined" == typeof searchst) || (searchst=="")) {
    if (searchval != "") {
      searchst=unescape(searchval);
      if (-1 < searchst.indexOf("\%")) searchst=unescape(searchst)
//alert(searchst+"//"+searchval+"//"+unescape(searchval))
      searchval="";
      }
    else searchst="";
    }
  if (searchst != "") {
    var rxsearch = new RegExp(searchst,'i')
    }

  if (("undefined" == typeof searchcolname) || (searchcolname == "")) {
    if (searchvar != "") {
      searchcolname=searchvar
      searchvar="";
      }
    else {
      searchcolname="";
      }
    }

  if (("undefined" == typeof searchcol) || (searchcol == "")) {
    searchcol=-1;
    }


  var rxweb=new RegExp(webcolname,'i')
  var rxname=new RegExp(namecolname,'i')
  var namecol=-1;
  var webcol=-1;

  var numshown=0;

//Unnecessary, see insertTable() above
//  if (("undefined" == typeof tableStyle) || (0 == tableStyle.length)) {
//    tableStyle=new Array()
//    tableStyle[0]=new Array()
//    for (var j=0;j<tableHdr[0].length;j++) {
//      tableStyle[0][j]=''
//      }
//    }

  if (tableStyleOriginal=='') {
    tableStyleOriginal = new Array()
    tableStyleOriginal.push(new cloneObject(tableStyle[0]));
    }

  defaultArrays();

  emailCols=new Array()
  for (var j=0;j<tableHdr[0].length;j++) {
    emailCols[j]=''
    }

//Unnecessary, see insertTable above
//  if ("undefined" == typeof tableView) {
//    tableView=new Array();
//    }

  viewableColNums=new Array();
  for (var i=0;i<tableView.length;i++) {
    if (tableView[i][0] == currentView) {
      for (var j=0;j<tableView[i][1].length;j++) {
        for (var k=0;k<tableHdr[0].length;k++) {
          if ((k != blockingcol) && (tableHdr[0][k] == tableView[i][1][j])) { // 20030219 array combined columns
            viewableColNums.push(k);
            }
          }
        }
      }
    }
  numcols=viewableColNums.length

  for (var j=0;j<tableHdr[0].length;j++) { // 20030219 update to viewableColNums?
    if (tableStyle[0][j] != 'display:none') {
      if (tableHdr[0][j].match(rxweb)) {
        webcol=j;
        }
      else if (tableHdr[0][j].match(rxname)) {
        namecol=j;
        }
//alert("searchcolname: "+searchcolname.toLowerCase()+", this: "+tableHdr[0][j].toLowerCase())
      if (("undefined" != typeof searchcolname) && (searchcolname != "") && (tableHdr[0][j].toLowerCase() == searchcolname.toLowerCase())) {
        searchcol=j;
        }
      }
    }

  if ((namecol != -1) && (webcol != -1)) var docollapse=true;
  else var docollapse=false;

//alert("Searching for "+searchst+" in col "+searchcol+", named "+searchcolname)

  var sth="<tr>"
  var sts='<select name=ssel>'
  sts += '<option value="9999">(all fields)</option>'

//st1='<th align=left class=colhead><a style="text-decoration:none" href="JavaScript: bubbleSort2D(tableRow,';
//st2=',\''+searchst+'\','+searchcol+',\''+searchcolname+'\')">';
//et='</a></th>';
//st0='<th align=left><input width="100%" type=button value="';
//st1='<th align=left><input width="100%" type=button value="';
//st2='" onclick="bubbleSort2D(tableRow,';
//st3=',\''+searchst+'\','+searchcol+',\''+searchcolname+'\')" '
//st4=' /></th>';
//  et='</th>';

  var showingcol = new Array();
//* * * * Column/Sort Buttons (sth) and selector for search fields (sts)  * * *
//  for (var j=0;j<tableHdr[0].length;j++) {
  for (var jcol=0;jcol<viewableColNums.length;jcol++) {
    j=viewableColNums[jcol];
    showingcol[j] = true;
    if (tableStyle[0][j] != 'display:none') { // 20030219 Unnec?
      var thdr=tableHdr[0][j];
      if ((!docollapse) || (!thdr.match(rxweb))) {
        if (j == currentSortCol) { var whatset='inset' }
        else var whatset = 'outset'
        sth += '<td align=center valign=top style="padding:1" id=col_'+thdr.replace(/ /gi,"_")+'>';
        sth += '<span style="width:100%;background-color:#FFFFFF;border:2px '+whatset+'">'
        sth += '<a style="width:100%;text-decoration:none;font-size:90%;font-weight:bold;color:#000000" '
        sth += ' href="Javascript: bubbleSort2D(tableRow,'+j+',\''+searchst+'\','+searchcol+',\''+searchcolname+'\')">'+thdr+'</a></span>';

        sth += '<br><a href="JavaScript: popColumnHelp(\'col_'+thdr.replace(/ /gi,"_")+'\',\''+thdr+'\')" style="color:green;text-decoration:none;font-size:70%" title="See a popup describing this column">?</a>';
        if (j != keyCol) {
          sth += ' <a href="JavaScript: setGroupColumn('+j+',\''+searchst+'\','+searchcol+',\''+searchcolname+'\',\'\')" style="color:green;text-decoration:none;font-size:70%" title="Group table according to the unique values in this column">g</a>';
          if (window.clipboardData) {
            sth += ' <a href="JavaScript: clipColumn('+j+')" style="color:green;text-decoration:none;font-size:70%" title="Put all values in this column on clipboard for pasting into a document">c</a>';
            sth += ' <a href="JavaScript: clipEmailColumn('+j+')" style="color:green;text-decoration:none;font-size:70%" title="Put emails in this column on clipboard for your email program">cm</a>';
            }
          }
        sth += '</br></td>'
        if (j == searchcol) opsel=' selected ';
        else opsel='';
        sts += '<option value="'+j+'" '+opsel+' >'+tableHdr[0][j]+'</option>'
        }
      }
    }

  sth += "</tr>";
  sts += "</select>";

  var maxKeyVal = 0;
  var padLength = 0;


//  var numcols=0;
  var regbl = new RegExp(" ",'ig');
  var imatch=true;
  var wholerecord='';
//  var colcounted=false;
  var didemails=false;
  var didalert='';
  var stblocks = new Array();
  var displayedBlocks = new Array();
  var stblockhead= new Array();
  var isopenblock = new Array();
  var blockcol=0;
  var blockval="*";
  var thisblockhead=''
  var strows=''
  var numinblock=0;

  doblocks=new Array()


  if (blockingcol != -1) {
    var blockfound = new Array()
    var thisval=''
    for (var i=0;i<tableRow.length;i++) {
      thisval=tableRow[i][blockingcol];
      if (blockfound[thisval] != 1) {
        doblocks.push([blockingcol,thisval]);
        blockfound[thisval]=1;
        }
      }
    tableDefString=tableDef[tableHdr[0][blockingcol]];
//    alert(iblock+"/"+doblocks[iblock]+'/'+blockcol+': '+tableHdr[0][blockcol])
    if (tableDefString) {
      var thdr=tableHdr[0][blockingcol];
      tableDefString=' <font size="-1">(<a href="JavaScript: popColNameHelp(\'BLHDR\',\''+thdr+'\')" style="color:green;text-decoration:none;">?</a>)</font>';
      }
    else tableDefString='';
    var sttwist='<tr><td colspan="'+viewableColNums.length+'" style="background-color:#999999" id=BLHDR>';
    sttwist += 'Grouped by column <b>'+tableHdr[0][blockingcol]+'</b>'+tableDefString+', <font size="-1">('+doblocks.length+' unique values found)</font>&nbsp;&nbsp;'
    sttwist += '&nbsp;&nbsp;<a style="text-decoration:none;color:#009900;font-size:120%;font-weight:bold" href="JavaScript: twistallOpen(\''+searchst+'\','+searchcol+',\''+searchcolname+'\',\'\')">++</a>';
    sttwist += '&nbsp;&nbsp;<a style="text-decoration:none;color:#990000;font-size:120%;font-weight:bold" href="JavaScript: twistallClosed(\''+searchst+'\','+searchcol+',\''+searchcolname+'\',\'\')">--</a>';
    sttwist += '&nbsp;&nbsp;<font size="-1"><a href="JavaScript: setGroupColumn(\'\',\''+searchst+'\','+searchcol+',\''+searchcolname+'\',\'\')">ungroup</a></font>'
    sttwist += '</td></tr>'
    tablewidthst=' width="100%" ';
    }
  else {
    doblocks.push([0,"*"])
    sttwist='';
    tablewidthst=''
    }
  compareColType="TEXT";
  compareColDir="FWD";
  compareColNum=1;
  doblocks.sort(compareCols);

//if (("undefined" != typeof tableClippable) && tableClippable) doclip=true; // 20030320
  if (tableClippable) doclip=true; // 20030320
  else doclip=false;

  displayedRows = new Array();

  for (var iblock=0;iblock<doblocks.length;iblock++){
    tempRowArray = new Array();
    numinblock=0;
    blockcol=doblocks[iblock][0];
    blockval=doblocks[iblock][1];
    if (blockval != '*') {
      useblockval=blockval;
      if (twistedblock[iblock] == 1) {
        thistwist='<a href="JavaScript: twistClosed('+iblock+',\''+searchst+'\','+searchcol+',\''+searchcolname+'\',\'\')" style="text-decoration:none;color:#990000;font-size:120%">-</a>'
        isopenblock[iblock]=0;
        }
      else {
        thistwist='<a href="JavaScript: twistOpen('+iblock+',\''+searchst+'\','+searchcol+',\''+searchcolname+'\',\'\')" style="text-decoration:none;color:#009900;font-size:120%">+</a>'
//        blockval=-868686;
        isopenblock[iblock]=-868686;
        }
      thisblockhead='<tr><td id=BLOCK_'+iblock+' style="background-color:#999999;color:#550000" colspan="';
      thisblockhead += viewableColNums.length+'"><b>'+thistwist+'&nbsp;&nbsp;'+tableHdr[0][blockcol]+': '+useblockval;
      thisblockhead += '</b> <font size="-2">';
      thisblockhead += '<a href="JavaScript: setGroupColumn(\'\',\''+searchst+'\','+searchcol+',\''+searchcolname+'\',\'\')">ungroup</a>&nbsp;&nbsp;'
      }
    else thisblockhead=''
    strows=''
    for (var i=0;i<tableRow.length;i++) {
      if (tableRow.length > 200) window.status='Processing record '+i+' of '+tableRow.length;
      maxKeyVal = Math.max(tableRow[i][keyCol],maxKeyVal);
      padLength = Math.max(tableRow[i][keyCol].length,padLength);
      if (searchst == "") matchme=true;
      else if (searchcol < 0) matchme=true;
      else if (searchcol == 9999) {
        wholerecord=''
        for (var j=0;j<tableRow[i].length;j++) {
          wholerecord += ' '+tableRow[i][j]
          }
        if (wholerecord.match(rxsearch)) matchme=true;
        else matchme=false;
        }
      else if ('=' == searchst.substring(0,1)) {
  //      alert(searchst.substring(1).toLowerCase()+"//"+tableRow[i][searchcol].toLowerCase())
        if (searchst.substring(1).toLowerCase() == tableRow[i][searchcol].toLowerCase()) matchme=true;
        else matchme=false;
        }
      else if (!tableRow[i][searchcol].match(rxsearch)) matchme=false;
      else matchme=true;
      if (matchme) {
        if (blockval == "*") {
          numinblock++;
          }
        else {
          if (tableRow[i][blockcol] != blockval) matchme=false;
          else numinblock++;
          }
        }
      if (matchme) {
        numshown++;
        strows += '<tr>'
        var tempRow = new Array(tableRow[i].length)
        for (var jcol=0;jcol<viewableColNums.length;jcol++) {
          j=viewableColNums[jcol];
          var colpad=''
          if (doclip) {
            if (jcol==0) {
              clipatt=' onclick="clipRow('+i+')" ';
              colpad='<span style="color:green;font-size:60%;cursor:hand" title="Put this row on the clipboard so you can use Clone link to create a new record like it">&nbsp;c</span>'
              }
            else {
              clipatt=' onclick="clipCell('+i+','+j+')" ';
              }
            }
          else clipatt='';
          if (("undefined" != typeof tableLocal) && (tableLocal[0][j] == "y")) { tableRow[i][j]="" }
          var val = tableRow[i][j];
          tempRow[j]=val;
          if (val.replace(regbl,"") == "") val='&nbsp;'
          if (tableStyle[0][j] != 'display:none') { // unnec?  20030219
            mestyle=tableStyle[0][j];
            if (-1<val.indexOf("??",0)) { mestyle += 'background-color:#FFFF99'; }
            if (mestyle != '') mestyle=' style="'+mestyle+'" '
            st='<td valign=top id=TD_'+tableRow[i][keyCol]+' class=record'+mestyle+clipatt+'>' /* 20021205 */
            et='</td>'
            if ((docollapse) && (j==namecol) ) {
              if (enableNavTo) {
                st = st+'<a href="JavaScript: navTo(\''+tableRow[i][webcol]+'\')">'
                }
              else {
                st += '<a href="'+tableRow[i][webcol]+'" target="_OTHER">';
                }
              et='</a>'+et
              }
            else if (tableFcn[0][j] != "") {
              st = st+'<a href="JavaScript: '+tableFcn[0][j]+'('+i+')" title="Click here to open up this record for viewing or editing">'
              et='</a>'+colpad+et
              }
            else if ((tableType[0][j] == 'EMAIL') && (val != '&nbsp;') && (-1 == val.indexOf("??",0))) {
              didemails=true;
              if (emailCols[j] != '') emailCols[j] += ','
              emailCols[j] += val;
              st += '<a href="mailto:'+val+'?subject='+hostEntity+'WebMail: ">'
              et = '</a>'+et
              }
            else if ((tableType[0][j] == 'URL') && (val != '&nbsp;') && (val != "") && ('http://' == val.substring(0,7)) && (-1 == val.indexOf("??",0))) {
              if (enableNavTo) {
                st = st+'<a href="JavaScript: navTo(\''+val+'\')">'
                }
              else {
                st += '<a href="'+val+'" target="_OTHER">';
                }
              et='</a>'+et
              }

            if ((!docollapse) || (j != webcol)) {
              if ((tableHTML[0][j] == "yes") || (tableHTML[0][j] == "y")) {
                val=val.replace(/&#060;/g,"<");
                val=val.replace(/&#062;/g,">");
                val=val.replace(/&quot;/g,'"');
                }
              if ((tableType[0][j] == "BULLET") && (val != "&nbsp;")) {
                val="&bull; "+val.replace(/<br \/>/g,"<br \/>&bull; ")
                }
              if ((-1 < val.indexOf('\n',0)) || (-1 < val.indexOf('<br',0)) || (val.length > 60)) {
                tableMultiCol[0][j]=true;
                }
              strows += st+val+et
//              if (!colcounted) { numcols++; }
              }
            }
          }
        tempRowArray.push(tempRow)
//        colcounted=true;
        strows += '</tr>'
        }
      }

    if (thisblockhead != '') thisblockhead += '&nbsp;&nbsp;('+numinblock+')</font></td></tr>';
    stblockhead.push(thisblockhead)
    stblocks.push(strows);
    displayedBlocks.push(tempRowArray)
    }

  stx = ''
  if (0<useImages.length) {
    stx += '<img src="'+useImages[0][0]+'" /><br />'+useImages[0][1]+' (<a href="Javascript: replacePix(\''+useImages[0][0]+'\')">'+useImages[0][0]+'</a>)';
    }

  stx += '<form id=tabform action="#" onsubmit="searchBox()" ><table border="1" cellspacing="0" cellpadding="0" bgcolor="#EEEEEE" '+tablewidthst+'>'

  stv=''
  if (0 < tableView.length) {

    tempView = new Array();

//    if (!isDefaultView) tempView.push('Default');
    tempView.push('Default');
    for (var i=0;i<tableView.length;i++) {
      if ((tableView[i][0] != 'Default') && (tableView[i][0] != 'All')) {
        tempView.push(tableView[i][0]);
        }
      }
    if (!isAllView) tempView.push('All');

    stv += '<tr><td colspan='+numcols+' BGCOLOR="#CCCCCC" style="padding:2"><font size="-1">Column view: '
    for (var i=0;i<tempView.length;i++) {
      var thisv=tempView[i];
      if (thisv == currentView) {
        stv += '&nbsp;&nbsp; <span style="text-decoration:none;color:#0000AA;border:2px inset" >&nbsp; '+thisv+' &nbsp;</span>&nbsp; ';
        }
      else {
        stv += '&nbsp;&nbsp; <a style="text-decoration:none;color:#0000CC;border:2px outset" href="Javascript: selectColumns(\''+searchst+'\','+searchcol+',\''+searchcolname+'\',\'!'+thisv+'\')">&nbsp; '+thisv+' &nbsp;</a>&nbsp; ';
        }
      }
    stv += ' &nbsp;&nbsp;(*)</font></td></tr>'
    stx += stv;
    }

  if (0 < tableSearch.length) {
    var tempSearch = new Array();for (var i=0;i<tableSearch.length;i++) tempSearch.push(tableSearch[i])
    tempSearch.push(["All","",""]);
    stts = '<tr><td colspan='+numcols+' BGCOLOR="#CCCCCC" style="padding:2"><font size="-1">Special Search: '
    for (var i=0;i<tempSearch.length;i++) {
      tscol=9999;
      for (var j=0;j<tableHdr[0].length;j++) {
        if (tableHdr[0][j] == tempSearch[i][1]) tscol=j;
        }
      if ((searchst == tempSearch[i][2]) && (tscol == searchcol)) {
        stts += '<b style="color:blue">'+tempSearch[i][0]+'</b>&nbsp'
        }
      else {
        stts += ' <a style="color:#0000CC" ';
        stts += ' href="Javascript: writeTable(\''+tempSearch[i][2]+'\',\''+tscol+'\',\'\',true)">';
//      stts += ' href="Javascript: writeTable(\''+tempSearch[i][2]+'\',\''+tscol+'\',\'\',true);window.status=\'Did a Search for '+tempSearch[i][2]+' in column '+tempSearch[i][1]+'\'">';
        stts += tempSearch[i][0]+'</a>&nbsp; ';
        }
      }
    stts+='</td></tr>';
    stx += stts;
    }


  var clearstring='';
  if (isDOM) {
    stx += "<tr><td colspan="+numcols+"><table width='100%' border=0 cellpadding=0 cellspacing=0><tr>";
    if (numshown != tableRow.length) {
      clearstring = numshown+' of '+tableRow.length+' records showing - <a href="javascript:writeTable(\'\',\'\',\'\',true)">Reset Search Results</a>';
      }
    if (clearstring != "") {
      stx += "<td align=left bgcolor='#CCCCCC'><font size='-1'>"+clearstring+" &nbsp;&nbsp;</font></td>";
      }
    stx += '<td align=right bgcolor="#CCCCCC"><font size="-1">Search for: <input id=searchInput type=text size=26 value="'+searchst+'"></input> in:'
    stx += sts;
    stx += "&nbsp;<input id=searchButton type=submit value=' Go  '></input></font></td></tr></table></td></tr>"
    }
  else stx = '<br />(Note: You will get more functionality with this table if you use a new version of <a href="http://microsoft.com/ie">Internet Explorer</a>)'+stx

//  stx += sth;

  nullArray = [pad(maxKeyVal+1,padLength),""];
  for (var i=0;i<tableHdr[0].length-2;i++) {
    nullArray.push("");
    }

//var stnew=''
//for (var i=0;i<numcols-2;i++) {
//  stnew += '<td>&nbsp;</td>'
//  }
//stnew += '</tr>';
  if (doclip) {
    clonetag='&nbsp;&nbsp;(<a href="JavaScript: recordForm(\'\',true,true)" title="Click here after clicking on the green clip icon next to a record number to create a new record like that one">clone from clipboard</a>)'
    }
  else clonetag=''
  var stadd = '<tr><td valign=top class=record colspan="'+numcols+'"><a href="JavaScript: recordForm(\'\',true)">'+pad(maxKeyVal+1,padLength)+'</a> <a href="JavaScript: recordForm(\'\',true)">(Add new)</a>'+clonetag+'</td></tr>'

  stx += sttwist;

  for (var i=0;i<stblocks.length;i++) {
    stx += stblockhead[i];
    if (isopenblock[i] != -868686) {
      stx += sth;
      if (i == 0) stx += stadd;
      stx += stblocks[i]+stadd;
      for (var j=0;j<displayedBlocks[i].length;j++) {
        displayedRows.push(displayedBlocks[i][j]);
        }
      }
    }

//stx +=  '<tr><td valign=top class=record colspan="'+numcols+'"><a href="JavaScript: recordForm(\'\',true)">'+pad(maxKeyVal+1,padLength)+'</a> <a href="JavaScript: recordForm(\'\',true)">(Add new)</a></td></tr>'

  if (clearstring != "") {
      stx += "<tr><td width='100%' colspan="+numcols+" align=left bgcolor='#CCCCCC'><font size='-1'>"+clearstring+" &nbsp;&nbsp;</font></td></tr>";
      }
  if (stv != "") {
    stx += stv;
    }
  stx += '</table>'
  if (didemails) {
    lastjcol=-1;
    if (clearstring != '') var stm='<br />';
    else var stm='';
    stm += 'Group EMail everyone listed in column: [ ';
    emdid=false;
    for (var j=0;j<emailCols.length;j++) {
      if (emailCols[j] != '') {
        if (emdid) {
          stm += ' | ';
          }
        emdid=true;
//        stm += '<a href="mailto:?bcc='+emailCols[j]+'&subject='+hostEntity+'WebGroupMail: ">'+tableHdr[0][j]+'</a>';
        stm += '<a href="JavaScript: clipEmailColumn('+j+',\'true\')" >'+tableHdr[0][j]+'</a>';
        if (lastjcol == -1) lastjcol=j;
        else lastjcol='';
        }
      }
    stm+=' ] <font size="-1">(Didn\'t work? Click <a href="JavaScript: setMailHelp('+lastjcol+')">here</a>)</font>';
    stx += stm;
    }
  stx += '</form>'
  stx += '<form action="" onsubmit="selectColumns(\''+searchst+'\','+searchcol+',\''+searchcolname+'\',\'\')">'
  stcs='<select name=colselect id=colselect multiple size=3>'

  for (var j=0;j<tableHdr[0].length;j++) { // 20030219
//for (var jcol=0;jcol<viewableColNums.length;jcol++) {
//  j=viewableColNums[jcol];
//  if ((!docollapse) || (!tableHdr[0][j].match(rxweb))) {
//  if (tableStyle[0][j] != 'display:none') issel='selected'
    if ((showingcol[j]) && (tableStyle[0][j] != 'display:none')) issel='selected'
    else issel=''
    stcs += '<option value="'+j+'" '+issel+'>'+tableHdr[0][j]+'</option>'
//    }
    }

  stcs += '</select>'
  stx += '<table border=0 bgcolor="#DDDDDD"><tr>'
  stx += '<td valign=middle>'+stcs+'</td>'
  stx += '<td valign=middle>(*) You can also select specifically which columns to display.'
  stx += '<br><input type=submit value=" Show " /></br></td>'
//  stx += '<td valign=middle>(*) You can also select specifically which columns to display.</td>'
//  stx += '<td valign=middle>'+stcs+'</td>'
//stx += '<td valign=middle><input type=submit value=" Show " onclick="selectColumns(\''+searchst+'\','+searchcol+',\''+searchcolname+'\',\'\')" /></td>'
//stx += '<td valign=middle> <input type=button value=" Default " onclick="selectColumns(\''+searchst+'\','+searchcol+',\''+searchcolname+'\',\'@reset\')" /></td>'
//stx += '<td valign=middle> <input type=button value=" All " onclick="selectColumns(\''+searchst+'\','+searchcol+',\''+searchcolname+'\',\'@all\')" /></td>'
  stx += '</tr></table>'
  stx += '</form>'
  stx += '<br />Notes: Cells with "??" in them are yellow and need attention.<p />&nbsp;'

  for (var i=1;i<useImages.length;i++) {
    stx += '<img src="'+useImages[i][0]+'" /><br />'+useImages[i][1]+' ('+useImages[i][0]+')<p />&nbsp;'
    }


  var rxgt = new RegExp("&gt;",'ig')
  var rxlt = new RegExp("&lt;",'ig')
  stx=stx.replace(rxgt,">")
  stx=stx.replace(rxlt,"<")
  tableContent=stx;
  if (clipTable) window.clipboardData.setData('Text',tableContent);window.status=tableContent.length+' bytes of data placed on clipboard';
  if (doReplace) {
    if ((document.getElementById) && (document.getElementById("linkTable").innerHTML)) {
      document.getElementById("linkTable").innerHTML = tableContent; // won't work in old netscape.
      }
    else alert('Sorry, your browser does not support something called "innerHTML".\nTry upgrading your Internet Explorer or Netscape.');
    }
  if (doScrollTop) { scrollToTop(); }
  }

function clipColumn (j) {
  if (window.clipboardData) {
    var stx=''
    var cnt=0
    for (var i=0;i<displayedRows.length;i++) {
      if (displayedRows[i][j] != '') {
        stx += displayedRows[i][j]+'\n'
        cnt++;
        }
      }
    window.clipboardData.setData('Text',stx);
    window.status="Placed "+cnt+" entries from column "+j+" on clipboard"
    }
  else alert("Sorry, Your browser does not support clipboard operations.  (Windows Internet Explorer does.)");
  }

function clipEmailColumn (j,isSend) {
  var stx=''
  var cnt=0
  var didThis = new Array()
//alert(displayedRows.length)
  for (var i=0;i<displayedRows.length;i++) {
    var meval=trim(displayedRows[i][j]);
    if (("undefined" == typeof didThis[meval]) && (meval != '') && (-1 < meval.indexOf('@')) ) {
      didThis[meval]=true;
      if (stx != '') stx += ','
      stx += meval
      cnt++;
      }
    }
  if (isSend) {
//  parent.location.href="mailto:?bcc="+stx+"&subject="+hostEntity+"WebGroupMail: "
    parent.location.href="mailto:?to=\""+hostEntity+"%20Group\"%20%3Cgengroup@wellhost.com%3E&bcc="+stx+"&subject="+hostEntity+"WebGroupMail:%20"
    }
  else {
    if (window.clipboardData) {
      window.clipboardData.setData('Text',stx);
      window.status="Placed "+cnt+" email unique email addressess from column "+j+" on clipboard"
      }
    else alert("Sorry, Your browser does not support clipboard operations.  (Windows Internet Explorer does.)");
    }
  }

function clipRow (i) {
  if (window.clipboardData) {
    stx=''
    for (var j=0;j<tableHdr[0].length;j++) {
      stx += tableHdr[0][j]+'='+tableRow[i][j]+'\n'
      }
    window.clipboardData.setData('Text',stx);
    window.status="Placed record "+i+" on windows clipboard"
    }
  else alert("Sorry, Your browser does not support clipboard operations.  (Windows Internet Explorer does.)");
  }

function clipCell (i,j) {
  if (window.clipboardData) {
    stx=tableRow[i][j].replace(/<br \/>/g,"\n");
    window.clipboardData.setData('Text',stx);
    window.status="Placed record "+i+", cell "+j+" on windows clipboard"
    }
  else alert("Sorry, Your browser does not support clipboard operations.  (Windows Internet Explorer does.)");
  }

function navTo (url) {
  if (("undefined" != typeof navWindow.location) && (navWindow !="")) { navWindow.location=url; }
  else {
    navWindow = window.open(url,"");
    }
  setTimeout("navWindow.focus()",100);
  }

function selectColumns (searchst,searchcol,searchcolname,view,noReplace) {
  blockingcol=-1;
  twistedblock=new Array();
  if (noReplace) doReplace=false;
  else doReplace=true;
  if ((!document.getElementById) || (!document.getElementById("linkTable").innerHTML)) {
    alert('Sorry, your browser does not support something called "innerHTML".\nView Selection is not available.\nTry upgrading your Internet Explorer or Netscape!');
    return;
    }
//if (((!isDefaultView) && (view == '!Default')) || (view == '@reset')) {
//  currentView='Default'
//  tableStyle = new Array();
//  tableStyle.push(tableStyleOriginal[0]);
//  searchst='';
//  }
//else if (((!isAllView) && (view == '!All')) || (view == '@all')) {
//  currentView='All'
//  tableStyle = new Array();
//  searchst = '';
//  }
//else if ("!" == view.substring(0,1)) {
  if ("!" == view.substring(0,1)) {
    var tview=view.substring(1);
    currentView = tview;
    tableStyle = new Array();
    tableStyle[0] = new Array();
    var matched=''
    for (var i=0;i<tableHdr[0].length;i++) { // 20030219 unnec?
      matched=false;
      for (var j=0;j<tableView.length;j++) {
        if (tview == tableView[j][0]) {
          for (var k=0;k<tableView[j][1].length;k++) {
            if (tableHdr[0][i] == tableView[j][1][k]) {
              matched=true;
              }
            }
          }
        }
      if (matched) {
        tableStyle[0].push('');
        }
      else {
        tableStyle[0].push('display:none');
        }
      }
    }
  else {
    var cs = document.getElementById("colselect");
    for (i = 0;i<cs.length;i++) {
      if (cs[i].selected) {
        if (tableStyle[0][i] == 'display:none') tableStyle[0][i] = "";
        var found = false;
        for (var iv=0;iv<viewableColNums.length;iv++) {  // 20030313
          if (i == viewableColNums[iv]) {
            found=true;
            }
          }
        if (!found) { // 20030312 but, always adds at the end, but views can be arbitrary order anyway.
          for (var itv=0;itv<tableView.length;itv++) {
            if (tableView[itv][0] == currentView) {
              tableView[itv][1].push(tableHdr[0][i])
              }
            }
          }
        }
      else tableStyle[0][i]='display:none';
      }
    }
//writeTable(searchst,searchcol,searchcolname,true,true);
  writeTable(searchst,searchcol,searchcolname,doReplace);
  }

function setGroupColumn (gcol,searchst,searchcol,searchcolname) {
  twistedblock = new Array();
  if (gcol=='') gcol=-1;
  blockingcol=gcol;
//writeTable(searchst,searchcol,searchcolname,true);
  writeTable('','','',true);
  }

function twistOpen (iblock,searchst,searchcol,searchcolname) {
  twistedblock[iblock] = 1;
  writeTable(searchst,searchcol,searchcolname,true);
  }

function twistClosed (iblock,searchst,searchcol,searchcolname) {
  twistedblock[iblock] = 0;
  writeTable(searchst,searchcol,searchcolname,true);
  }

function twistallClosed (searchst,searchcol,searchcolname) {
  twistedblock = new Array();
  writeTable(searchst,searchcol,searchcolname,true);
  }

function twistallOpen (searchst,searchcol,searchcolname) {
  twistedblock = new Array();
  for (var iblock=0;iblock<doblocks.length;iblock++) {
    twistedblock[iblock] = 1;
    }
  writeTable(searchst,searchcol,searchcolname,true);
  }

function cloneObject(what) {
  for (i in what) {
    this[i] = what[i];
    }
  }

function setMailHelp (colnum) {
  stx = '';
  stx +='<html>\n<head>\n';
  stx +='<script language="JavaScript" src="'+thisFileName+'" type="text/javaScript"></script>\n';
  stx +='</head>\n<body id=mainBody style="background-image: url('+tb_bgnormal+'); background-position: center center; background-attachment: fixed; font-family:Arial, sans-serif">\n';
  stx +='<table cellpadding="5" bgcolor="#D4D0C8" width="90%"><tr><td>';
  stx +='<font size="+2">Default Mail Client not Installed?</font><br />';

  stx +='If you click the "Group Email" link and get a message like "Default email client not properly installed", you may want\n';
  stx +='to check that and fix it.<p />In Windows, you click Start->Settings->ControlPanel->Internet Options.  Then select the Programs\n';
  stx +='tab and select something like Outlook Express for the "E-mail" pull-down.\n';
  stx +='There is a step-by-step explanation of this kindly provided on the\n<br />&nbsp;&nbsp;&nbsp;';
  stx +='<a href="http://support.earthlink.net/mu/1/psc/img/walkthroughs/windows_9x_nt/browsers/ie_5.0/3017.psc.html" target="_blank">Earthlink Support Site</a>.\n';

  stx +='<p />Another option (if you are using Internet Explorer): look for the little green "cm" link at the top of the Email\n';
  stx +='column and click it.  This will place all the email addresses on your clipboard so you can paste them (ctrl+v) into the To: field\n';
  stx +='(or, <b>preferably, the bcc: field!</b>) in your email program.\n';

  if ((window.clipboardData) && (colnum)) {
    stx +='<p />For your convenience, you can try that by clicking here:\n';
    stx += ' <a href="JavaScript: opener.clipEmailColumn('+colnum+')" style="color:green;text-decoration:none"><b>cm</b></a>';
    stx += ' and going to your email and doing a paste.';
    }
  else stx += '<p />(Unfortunately your browser doesn\'t appear to support clipboard actions -- sorry!)'

  stx +='<p />&nbsp;'
  stx +='&nbsp;&nbsp;<input type=button value=" Close Window " onclick="window.close()" />\n';
  stx +='</td></tr></table>';

  stx +='<br /><font size="-1">'+copyrightLine;
//stx +='<br /><font size="-1">&copy; '+meModified.getFullYear()+', J<a style="color:black;text-decoration:none" href="JavaScript: seeLog()">F</a><a style="color:black;text-decoration:none" href="JavaScript:showHTML()">K</a> / IBM</font>\n';

  stx +='<span id=utilSpan style="position:absolute;visibility:hidden"></span>';
  stx +='</body></html>';
//  ht=new Number(screen.height);
//  ht=ht - 60;
  ht=500;
  windowContents=stx;
  popper=window.open("blank.html","","toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width=700,height="+ht+",resizable=yes,top=0,left=0");
  }

function replacePix (filename) {
  stx = '';
  stx +='<html>\n<head>\n';
  stx +='<script language="JavaScript" src="'+thisFileName+'" type="text/javaScript"></script>\n';
  stx +='</head>\n<body id=mainBody style="background-image: url('+tb_bgnormal+'); background-position: center center; background-attachment: fixed; font-family:Arial, sans-serif">\n';
  stx +='<font size="+2">Main Image</font> ('+filename+')';
  stx +='<img src="'+filename+'" />'
  if (replaceablePix) {
    stx +='<form id=mainForm onSubmit="return validPixForm(this)" action="cgi-bin/simpleupload.pl" method="POST"  enctype="multipart/form-data">\n';
    stx +='<input type="hidden" name="redirect" value="../endsurvey.html" />'
    stx +='<input type="hidden" name="newfilename" value="'+filename+'" />'
    stx +='Upload file (to replace '+filename+'):';
    stx +='<br /><input type="file" name="uploadfile" size="60" maxlength="80" />'
    stx +='<br />Allow overwrite?'
    stx +='<input type=radio name="allowoverwrite" value="yes">Yes</input>&nbsp;&nbsp;<input type=radio name="allowoverwrite" value="no" checked>No</input>'
    stx +='<br /><input type="Submit" value="Upload" />'
    }
  else {
    stx +='<form id=mainForm onSubmit="opener.deleteCookie(\'scrollBottom\');window.close" ACTION = "#">\n';
    }
  stx += '&nbsp;&nbsp;<input type=button value=" Cancel/Close " onclick="opener.deleteCookie(\'scrollBottom\');window.close()" />\n'
  stx += '</form>\n'

  stx += '<br /><font size="-1">'+copyrightLine;
//stx += '<br /><font size="-1">&copy; '+meModified.getFullYear()+', J<a style="color:black;text-decoration:none" href="JavaScript: seeLog()">F</a><a style="color:black;text-decoration:none" href="JavaScript:showHTML()">K</a> / IBM</font>\n'

  stx += '<span id=utilSpan style="position:absolute;visibility:hidden"></span>'
  stx += '</body></html>';
  ht=new Number(screen.height)
  ht=ht - 60;
  windowContents=stx;
  popper=window.open("blank.html","","toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width=700,height="+ht+",resizable=yes,top=0,left=0")
  }

function recordForm(i,isBlank,isClone) {
  var mypagename=getPageName()
  var mypath = location.href.substring(0,location.href.indexOf(mypagename,0))
  var myredirect=mypath+'endsurvey.html'; // was ../endsurvey.html
  var cloneVal = new Array()
  if (isClone) {
    var starr=window.clipboardData.getData('Text').split("\n");
    for (var i=0;i<starr.length;i++) {
      var cpos=starr[i].indexOf('=',0)
      var att=starr[i].substring(0,cpos)
      var val=starr[i].substring(1+cpos)
      cloneVal[att]=val;
      }
    }
  var hideMe = new Array()
  var isdisabled = '';
  var meselect = '';
  var legend ='';
  var stx ='';
  var val ='';
  var sth='';
  setPhelp()
  var rpl = new RegExp("<br>|<br />|<br/>",'ig');
  stx +='<html>\n<head>\n';
//  stx +='<script language="JavaScript" src="entity.js" type="text/javaScript"></script>\n';
//  stx +='<script language="JavaScript" src="'+jsDataFile+'" type="text/javaScript"></script>\n';
  stx +='<script language="JavaScript" src="'+thisFileName+'" type="text/javaScript"></script>\n';
  stx +='</head>\n<body id=mainBody style="background-image: url('+tb_bgnormal+'); background-position: center center; background-attachment: fixed; font-family:Arial, sans-serif">\n';
  stx +="<h2>Record Details</h2><p />\n";
  stx +='<form id=mainForm onSubmit="return validForm(this,opener.tableHdr,opener.tableType,opener.tableReq,opener.tableForm,opener.tableStyle)" ACTION = "cgi-bin/FormMailJS.pl" METHOD = "POST">\n';
  var jfatsg='@'
  stx +='<input type=hidden name="recipient" value="surveyforms'+jfatsg+'wellhost.com" />\n';
  stx +='<input type=hidden name="subject" value="'+hostSubject+'" />\n';
  stx +='<input type=hidden name="db_file" value="../'+jsDataFile+'" />\n';
  stx +='<input type=hidden name="DeleteThisRecord" value="no" />\n';
  stx +='<input type=hidden name="redirect" value="'+myredirect+'" />\n';  // CUSTOMIZE -- make sure this file exists.
  stx +='<input type=hidden name="background" value="../'+tb_bgnormal+'" />\n';
  stx +='<input type=hidden name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT" />\n';
  stx +='<input type=hidden name="print_config" value="EMAIL" />\n';
  stx +='<input type=hidden name="print_blank_fields" value="1" />\n';
  stx +='<input type=hidden name="required" value="EMAIL" />\n';
  stx +='<input type=hidden name="keyval" value="'+tableHdr[0][keyCol]+'" />\n';

  var sthide = '';
  if ("undefined" != typeof tableHiddens) {
    for (var j=0;j<tableHiddens.length;j++) {
      stx +='<input type=hidden name="'+tableHiddens[j][0]+'" value="'+tableHiddens[j][1]+'" />\n';
      }
    }

// NOTE: SORT MUST BE IN SAME ORDER AS IN TABLE!!  See FormMailJS.pl

  var stsort='<input type=hidden name="sort" value="order:';
  stx += '<table border="1" bgcolor="#EEEEEE" style="font-size:80%">';
  var tind=0;
  var isContactURL=false;
  for (var j=0;j<tableHdr[0].length;j++) {
    var suppressMe=false;
    hdr = tableHdr[0][j];
    if ((j>0) && (isClone)) {
      val=cloneVal[hdr]
      }
    else if (isBlank) {
      val = nullArray[j];
      }
    else { val = tableRow[i][j]; }
    val=val.replace(rpl,'\n')

    if (j>0) stsort+=",";
    stsort += hdr;

    if ("undefined" != typeof tableForm) { var edit=tableForm[0][j]; }
    else var edit = ""

//  if ((edit != "edit") && ( ((!i) && (j == keyCol)) || (tableStyle[0][j] == 'display:none') || (edit == "ro")) ) isdisabled='disabled'
    if ((edit != "edit") && ( ((!i) && (j == keyCol))                                         || (edit == "ro")) ) isdisabled='disabled'
    else isdisabled=''

    mestyle=''

    if (hdr == 'Submitter') { // CUSTOMIZE special meaning of tag Submitter; it is same as EMAIL (but prettier)
      isdisabled='disabled';
      legend='Previous Submitter EMail';
      mestyle=" style='background-color:#CCCCCC' "
      }
    else if (hdr == 'SubmitterURL') { // CUSTOMIZE special meaning of tag Submitter; it is same as EMAIL (but prettier)
      isContactURL=true;
      suppressMe=true;
      }
    else if (hdr == 'ModDate') {
      isdisabled='disabled';
      legend='Previous Mod Date';
      mestyle=" style='background-color:#CCCCCC' "
      }
    else legend=hdr;

    if (isdisabled == '') { legend = '<b>'+legend+'</b>'; }

    if (phelp[hdr] != "") {
      legend = '<table border=0 width="100%" cellpadding=0 cellspacing=0><tr><td>'+legend+'</td>'
      legend += '<td align="right" id="fld_'+hdr+'">&nbsp;&nbsp;<a href="JavaScript: popFieldHelp(\'fld_'+hdr+'\',\''+hdr+'\',\'phelp\')" style="color:green;text-decoration:none" tabindex="-1"><b>?</b></a></td></tr></table>';
      }

    if ((edit == "hide") && (0 == usersEmail.indexOf('jfkelley')) ) {
      sthide += '<input type=hidden name="'+hdr+'" value="'+val+'" />\n';
      }
    else if (!suppressMe) {

      if (usersEmail == editorEmail) {
        if (edit == "hide")         { mestyle= " style='background-color:#99FF99' ";isdisabled=''; }
        else if (isdisabled != '')  { mestyle= " style='background-color:#FF9999' ";isdisabled=''; }
        }
      else {
        if (-1<val.indexOf("??",0)) { mestyle = " style='background-color:#FFFF99' "; }
        }

//    if ((edit == "hide") && (usersEmail == "////jeff's email was here/////")) { mestyle= " style='background-color:#99FF99' "; isdisabled=''; }
//    else if ((isdisabled != '') && (usersEmail == "////jeff's email was here////")) { mestyle= " style='background-color:FF9999' ";isdisabled=''; }
//    else if (-1<val.indexOf("??",0)) { mestyle = " style='background-color:#FFFF99' "; }
//    else mestyle=''

      stx += '<tr><td valign=top '+mestyle+'>'+legend+'</td>\n'
      stx += '<td valign=top '+mestyle+'>'

      tind++;
      if (tableSelects[hdr]) {
        if (tableType[0][j] == 'MULTI') {
          stmult=' multiple size=3 ';
          var checkarray="y";
          var checkvarray = val.split(',')
          var checkval = new Array()
          for (icv=0;icv<checkvarray.length;icv++) {
            if (checkvarray[icv] != "") {
              checkval[checkvarray[icv]]="y";
//alert("checkval["+checkvarray[icv]+"] = "+checkval[checkvarray[icv]])
              }
            }
          }
        else {
          stmult=' ';
          var checkarray="n";
          }
        stx += '<select name="'+hdr+'" '+stmult+' tabindex="'+tind+'">\n'
        for (var k=0;k<tableSelects[hdr].length;k++) {
          if ((tableSelects[hdr][k][1]) && (1<tableSelects[hdr][k][1].length)) { // NS and IE are different about array lengths.  sigh.
            meselect=tableSelects[hdr][k][0];
            meselsay=meselect+": "+tableSelects[hdr][k][1];
            }
          else {
            meselect=tableSelects[hdr][k];
            meselsay=meselect;
            }
          stx += '<option value="'+meselect+'" ';
          if (((checkarray=="y") && (checkval[meselect]=="y")) || ((checkarray != "y") && (meselect==val))) { stx += ' selected '; }
          stx += '>'+meselsay+'</option>\n';
          }
        stx += '</select>\n'
        }
      else if ((tableMultiCol[0][j]) || (-1 < val.indexOf('\n',0)) || (val.length > 60)) {
        stx += '<textarea '+isdisabled+' name="'+hdr+'" rows=4 cols="60" tabindex="'+tind+'">'+val+'</textarea>\n'
        }
      else {
        if (forceMultiLine) stx += '<textarea '+isdisabled+' name="'+hdr+'" rows=1 cols="60" tabindex="'+tind+'">'+val+'</textarea>\n'
        else stx += '<input '+isdisabled+' name="'+hdr+'" size="60" value="'+val+'" tabindex="'+tind+'" />\n'
        }
      stx += '</td></tr>'

      if ((tableType[0][j] == 'EMAIL') && (val != '')) {
        stx += '<tr><td '+mestyle+'><font size="-1">(email link):</font></td><td '+mestyle+'><font size="-1">&nbsp;<a href="mailto:'+val+'?subject='+hostEntity+'WebMail: ">'+val+'</a></font></td></tr>'
        }
      }
    }
  stx += '<tr><td style="background-color:#CCCCCC" colspan="2">&nbsp;</td></tr>\n'
  tind++;
  stx += '<tr><td>Your Email please:</td><td><input name="EMAIL" size="60" value="'+usersEmail+'" tabindex="'+tind+'" /></td></tr>\n'
  if (isContactURL) {
    if (usersURL == "") {
      var tryurl="http://";
      }
    else {
      var tryurl=usersURL;
      }
    stx += '<tr><td>Contact http:// URL?</td><td><input name="SubmitterURL" size="60" value="'+tryurl+'" tabindex="'+tind+'" /></td></tr>\n'
    }
  stx += '</table>\n'
  stx += sthide;
  stx += stsort+'" />\n'

  if ('file:' == location.href.substring(0,5)) {
    stx += '<input type=button disabled name=SubmitButton value=" Submit Changes "  onclick="alert(\'Unable to submit changes since you are looking at local (not web) version of this page\')" />\n'
    var stindis='<br /><font size="-1">(Submit button is disabled because you\'re looking at a local version, not an interactive/web version of this page)</font>\n'
    }
  else {
    stx += '<input type=submit name=SubmitButton value=" Submit Changes "  />\n'
    var stindis=''
    }

  stx += '&nbsp;&nbsp;<input type=button value=" Validate Form " onclick="validForm(\'\',opener.tableHdr,opener.tableType,opener.tableReq,opener.tableForm,opener.tableStyle)" />\n'
  stx += '&nbsp;&nbsp;<input type=button value=" Cancel/Close " onclick="opener.deleteCookie(\'scrollBottom\');window.close()" />\n'
  stx += stindis
  stx += '</form>\n'

//  stx += '(* Some fields here are not editable because there were not displayed on Parent page.)\n'
  stx += '<br />(To Delete this record, click here before submitting: ';
  stx += '<input type=checkbox onclick="toggleRecordDeleted(\'mainForm\')" /> Delete This Record)'
  stx += '<br /><font size="-1">(For help entering special characters click: <a href="http://wellhost.com/htmlcharacters.html" target="_new">voil&#224;</a>.)</font>'

  stx += '<br /><font size="-1">'+copyrightLine;
//stx += '<br /><font size="-1">&copy; '+meModified.getFullYear()+', J<a style="color:black;text-decoration:none" href="JavaScript: seeLog()">F</a><a style="color:black;text-decoration:none" href="JavaScript:showHTML()">K</a> / IBM</font>\n'

  stx += '<span id=utilSpan style="position:absolute;visibility:hidden"></span>'
  stx += '</body></html>';
  ht=new Number(screen.height)
  ht=ht - 50;
  windowContents=stx;
  df=jsDataFile.split('.')
  blankfile=df[0]+'_form.html'
  popper=window.open(blankfile,"","toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width=700,height="+ht+",resizable=yes,top=0,left=0")
//  popper.document.write(stx)
  setCookie("scrollBottom","yes",offsetDays(1))
  setCookie("cleanSlate","yes",offsetDays(1))
  }

//- Fcn: popSettings 1.1
//-   Globals: myVars[], myTypes[], switchVars[], switchTypes[], utilSpan, thisFileName, windowContents
//-   Includes: [this file], entity.js, bgnormal.gif,
//-   Requires: validForm(), procPopSettings(), popFieldHelp(), deleteCookie(), setCookie(), seeLog(), showHTML()
function popSettings(isBlank) {
  var stx ='';
  var sth='';
  myVars = new Array()
  myTypes = new Array()
  var tempv=new Array()
  var tempt=new Array()
  for (var i=0;i<switchVars.length;i++) {
    tempv.push(switchVars[i]);
    tempt.push(switchType[i]);
    }
  myVars.push(tempv);
  myTypes.push(tempt);
  setShelp();
  stx +='<html>\n<head>\n';
  stx +='<script language="JavaScript" src="entity.js" type="text/javaScript"></script>\n';
  stx +='<script language="JavaScript" src="'+thisFileName+'" type="text/javaScript"></script>\n';
  stx +='</head>\n<body id=mainBody style="background-image: url('+tb_bgnormal+'); background-position: center center; background-attachment: fixed; font-family:Arial;">\n';
  stx +="<h2>Settings</h2><p />\n";
  stx +='<form id=mainForm onSubmit="procPopSettings(this,opener.myVars,opener.myTypes)" ACTION = "">\n';
  stx += '<table border="1" bgcolor="#EEEEEE">';
  tind=0;
  for (var i=0;i<switchVars.length;i++) {
    hdr    =switchVars[i];
    medef  =switchVals[i];
    metype =switchType[i];
    val    =eval(switchVars[i]);
    mehlp  =switchSay[hdr];

    if (mehlp != "") {
      legend = '<table border=0 width="100%" cellpadding=0 cellspacing=0><tr><td>'+hdr+'</td>'
      legend += '<td align="right" id="fld_'+hdr+'">&nbsp;&nbsp;<a href="JavaScript: popFieldHelp(\'fld_'+hdr+'\',\''+hdr+'\',\'shelp\')" style="color:green;text-decoration:none" tabindex="-1"><b>?</b></a></td></tr></table>';
      }
    else legend=hdr;

    stx += '<tr><td valign=top>'+legend+'</td>\n'
    stx += '<td valign=top>'

    tind++;
    if (metype.toLowerCase() == "boolean") {
      if ((val == "true") || (val == true)) isselected=' checked ';
      else isselected = '';
      stx += '<input type=checkbox name="'+hdr+'" tabindex="'+tind+'"'+isselected+' /> '
      }
    else {
      stx += '<input name="'+hdr+'" size="60" value="'+val+'" tabindex="'+tind+'" />\n'
      }
    stx += '</td></tr>'
    }
  stx += '<tr><td style="background-color:#CCCCCC" colspan="2">&nbsp;</td></tr>\n'
  stx += '</table>\n'
  stx += '<input type=submit value=" Submit " />\n'
  stx += '&nbsp;&nbsp;<input type=button value=" Validate Form " onclick="validForm(\'\',opener.myVars,opener.myTypes)" />\n'
  stx += '&nbsp;&nbsp;<input type=button value=" Cancel/Close " onclick="opener.deleteCookie(\'scrollBottom\');window.close()" />\n'
  stx += '&nbsp;&nbsp;<input type=button value=" Show Cookie " onclick="opener.reportFullCookie()" />\n'
  stx += '</form>\n'
//  stx += '(* Some fields here are not editable because there were not displayed on Parent page.)\n'
  stx += '<br />(To delete a record, make the first word in title: DELETED )\n'

  stx += '<br /><font size="-1">'+copyrightLine;
//stx += '<br /><font size="-1">&copy; 2002, I<a style="color:black;text-decoration:none" href="JavaScript: seeLog()">B</a>'
//stx += '<a style="color:black;text-decoration:none" href="JavaScript:showHTML()">M</a></font>\n'

  stx += '<span id=utilSpan style="position:absolute;visibility:hidden"></span>'
  stx += '</body></html>';
  ht=new Number(screen.height)
  ht=ht - 60;
  windowContents=stx;
  popper=window.open("blank.html","","toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width=700,height="+ht+",resizable=yes,top=0,left=0")
//  popper.document.write(stx)
  setCookie("scrollBottom","yes",offsetDays(1))
  }

function procPopSettings(inform,meHdr,meType) {
  if (!validForm(inform,meHdr,meType)) return false;
  for (var i=0;i<meHdr[0].length;i++) {
    hdr=meHdr[0][i];
    if (meType[0][i].toLowerCase() == "boolean") {
      if (hdr == 'okToFloat') {
        if ((inform[hdr].checked) && ((opener.okToFloat == "false") || (!opener.okToFloat))) {
          if (("undefined" != typeof document.getElementById("floatLayer")) || ("undefined" != typeof floatLayer)) {
            opener.okToFloat  = true;
            opener.allowFloat = true;
            opener.procSwitches(true);
            opener.location.reload(true);
            }
          else {
            alert("Unable to enable floating/scrolling left nav with your browser; try IE 6+");
            }
          }
        else if ((!inform[hdr].checked) && ((opener.okToFloat == "true") || (opener.okToFloat))) {
          opener.okToFloat = false;
          opener.allowFloat=false;
          opener.procSwitches(true);
          opener.location.reload(true)
//          alert("Floating left nav will stop when you refresh the main page");
          }
        }
      else {
        setter='opener.'+hdr+'='+inform[hdr].checked; // 20030317
        eval(setter);
        opener.procSwitches(true);
        }
      }
    else {
      setter='opener.'+hdr+'="'+inform[hdr].value+'"';
      eval(setter);
//    opener.procSwitches(true);  // this fails for some reason only on web; also seems to be redundant?
      }
    }
  window.close()
  }

function popColumnHide () {
  if (oPopup) {
    if (window.createPopup) { oPopup.hide() }
    else {
      if ((oPopup) && (!oPopup.closed)) oPopup.close();
      }
    }
  }

function setPhelp () {
  for (var i=0;i<tableHdr[0].length;i++) {
    me=tableHdr[0][i];
    if (("undefined" != typeof tableDef) && ("undefined" != typeof tableDef[me])) { sth=tableDef[me]; }
    else { sth=""; }
    if (("undefined" != typeof tableType) && ("undefined" != typeof tableType[0][i]) && (sth != "")) {
      ttype=tableType[0][i];
      if (ttype.toLowerCase() == "w") sth += " - Datatype: Whole Number"
      else if (ttype.toLowerCase() == "n") sth += " - Datatype: Number"
      else if (ttype.toLowerCase() == "boolean") sth += " - Datatype: On or Off"
      else if (ttype.toLowerCase() == "email") sth += " - Datatype: Email Address"
      else if (ttype.toLowerCase() == "url") sth += " - Datatype: URL (http://xyz)"
      }
    phelp[me]=sth;
    }
  }

function setShelp () {
  for (var i=0;i<switchVars.length;i++) {
    me=switchVars[i];
    if ("undefined" != typeof switchSay[me]) { sth=switchSay[me]; }
    else { sth=""; }
    if (("undefined" != typeof switchType[i]) && (sth != "")) {
      ttype=switchType[i];
      if (ttype.toLowerCase() == "w") sth += " - Datatype: Whole Number"
      else if (ttype.toLowerCase() == "n") sth += " - Datatype: Number"
      else if (ttype.toLowerCase() == "boolean") sth += " - Datatype: On or Off"
      else if (ttype.toLowerCase() == "email") sth += " - Datatype: Email Address"
      else if (ttype.toLowerCase() == "url") sth += " - Datatype: URL (http://xyz)"
      }
    shelp[me]=sth;
    }
  }

function popColumnHelp (objname,hdr) {
  setPhelp();
  refObj=getRef(objname);
  text=phelp[hdr]+", click to sort up & dn.";
  text='<table border=1><tr><td>'+text+'</td></tr></table>'
  popup(refObj,text)
  }

function popColNameHelp (objname,hdr) {
  setPhelp();
  refObj=getRef(objname);
  text=hdr+'='+phelp[hdr];
  text='<table border=1><tr><td>'+text+'</td></tr></table>'
  popup(refObj,text)
  }


function popFieldHelp (objname,hdr,helpObjName) {
  refObj=getRef(objname)
  text=opener[helpObjName][hdr];
  text='<table border=1><tr><td>'+text+'</td></tr></table>'
  popup(refObj,text)
  }

function popHelp (refObj,text) {
  text='<table border=1><tr><td>'+unescape(text)+'</td></tr></table>'
  popup(refObj,text)
  }


//- Fcn: popup (IE only...probably)
// Global: utilSpan
function popup (refObj,text,color,border) {
  if (!color) color="#FFFF00";
  if (window.createPopup) {
//  reportProperties(oPopup);
    uspan=getRef("utilSpan");
    uspan.innerHTML = text;
    var w=uspan.clientWidth;
    var h=uspan.clientHeight;
    oPopup = window.createPopup();
    var oPopupBody = oPopup.document.body;
    oPopupBody.innerHTML = text;
    oPopupBody.style.backgroundColor = color;
    if (border) oPopupBody.style.border = border // e.g., "1 solid black";
    else oPopupBody.style.border = "0"
    oPopupBody.style.fontSize = "90%"; // why doesn't this work (penetrate table?)
    oPopupBody.style.fontFamily = "Arial,MS Sans Serif";
  //oPopupBody.style.paddingLeft = "5px";
  //oPopupBody.style.paddingLeft = "5px";

  //oPopup.show(20,0,310,300, refObj);
  //  uspan.style.visibility="visible";
  //  uspan.style.visibility="hidden";
  //  oPopupBody.innerHTML = h+"  "+text
  //  h=h*1.15 // why this unfortunate necessity?
  //  h=Math.floor(h)
    var hd=0-h;
// alert(uspan.clientWidth)
    oPopup.show(10,hd,w,h, refObj); // was 29, -24
    }
  else {
//  alert(w+"/"+h+"/"+text);
    if ((oPopup) && (!oPopup.closed)) oPopup.close();
    windowContents=text+'<p /><a href="JavaScript: window.close()">Close this window</a>'
    wleft=550;
    ww=250;
    wh=200;
    oPopup=window.open("blank.html","","toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,top=0,width="+ww+",height="+wh+",left="+wleft)
    }
  }

function pad(number,length) {
    var str = '' + number;
    while (str.length < length)
        str = '0' + str;
    return str;
}

function compareCols(a, b) {
  var atemp=a[compareColNum].toLowerCase();
  var btemp=b[compareColNum].toLowerCase();

  if (compareColType == 'NUM') {
    atemp=new Number(atemp)
    btemp=new Number(btemp)
    }
  else if (compareColType == 'MONEY') {
    var origatemp=atemp
    atemp=atemp.replace(sortRegExp,'')
    if ('$'==atemp.substr(0,1)) atemp=atemp.substr(1,atemp.length)
//logIt(origatemp+" -> "+atemp)
    btemp=btemp.replace(sortRegExp,'')
    if ('$'==btemp.substr(0,1)) btemp=btemp.substr(1,btemp.length)
    atemp=new Number(atemp)
    btemp=new Number(btemp)
    }

  if ((atemp ==  "") || (atemp == " ") || (atemp=="&nbsp;")) atemp="z"; // was penultimate char: FE
  else if (compareColType=='BINARY') atemp=' ';

  if ((btemp ==  "") || (btemp == " ") || (btemp=="&nbsp;")) btemp="z"; // was penultimate char: FE
  else if (compareColType=='BINARY') btemp=' ';


  if (compareColDir == "REV") {
    if (atemp > btemp) {
      return -1;
      }
    if (atemp < btemp) {
      return 1;
      }
    }
  else {
    if (atemp < btemp) {
      return -1;
      }
    if (atemp > btemp) {
      return 1;
      }
    }

  return 0;
  }

function bubbleSort2D(arrayName,c,searchst,searchcol,searchcolname) {
  if ((!document.getElementById) || (!document.getElementById("linkTable").innerHTML)) {
    alert('Sorry, your browser does not support something called "innerHTML".\nSorting is not available.\nTry upgrading your Internet Explorer or Netscape!');
    return;
    }
  currentSortCol=c;
  dir = tableSort[0][c];
  if (dir == "") dir="FWD";
  sortArray(arrayName,c,dir)
  writeTable('','','',true)
  }

function sortArray(myArray,c,dir) {
  var odir=dir;
  if (dir == null) dir="FWD"
  if (dir.substr(0,1) == 'N') {
    dir=dir.substr(1,dir.length)
    compareColType='NUM'
    }
  else if (dir.substr(0,1) == 'D') {
    dir=dir.substr(1,dir.length)
    compareColType='DATE'
// not implemented yet, like string, the default.
// Note: if implemented, should allow for timestamp after date! and must be sensitive to global statment of preferred date format.
    }
  else if (dir.substr(0,1) == 'B') {
    dir=dir.substr(1,dir.length)
    compareColType='BINARY'
    }
  else if (dir.substr(0,1) == 'M') {
    dir=dir.substr(1,dir.length)
    compareColType='MONEY'
    }
  else compareColType="STRING"

  if (lastsortcol == c) {
    if (dir=="FWD") dir="REV"
    else dir="FWD"
    }
  compareColDir  =dir
  compareColNum = c

//logIt("sort: odir:"+odir+", c:"+c+", dir:"+dir+", type:"+compareColType)

  myArray=myArray.sort(compareCols)

  if (dir=="FWD") lastSortColDir = [c-1,'up']
  else lastSortColDir = [c-1,'dn']
//alert(lastSortColDir)

  if (lastsortcol == c) lastsortcol = -1;
  else lastsortcol = c;
  sortArrayDone=true;
  }

function findPosX(obj)
{
 var curleft = 0;
 if (obj.offsetParent)
 {
  while (obj.offsetParent)
  {
   curleft += obj.offsetLeft
   obj = obj.offsetParent;
  }
 }
 else if (obj.x)
  curleft += obj.x;
 return curleft;
}

function findPosY(obj)
{
 var curtop = 0;
 if (obj.offsetParent)
 {
  while (obj.offsetParent)
  {
   curtop += obj.offsetTop
   obj = obj.offsetParent;
  }
 }
 else if (obj.y)
  curtop += obj.y;
 return curtop;
}



/*
AnchorPosition.js
Author: Matt Kruse
Last modified: 10/11/02

DESCRIPTION: These functions find the position of an <A> tag in a document,
so other elements can be positioned relative to it.

COMPATABILITY: Netscape 4.x,6.x,Mozilla, IE 5.x,6.x on Windows. Some small
positioning errors - usually with Window positioning - occur on the
Macintosh platform.

FUNCTIONS:
getAnchorPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor. Position is relative to the PAGE.

getAnchorWindowPosition(anchorname)
  Returns an Object() having .x and .y properties of the pixel coordinates
  of the upper-left corner of the anchor, relative to the WHOLE SCREEN.

NOTES:

1) For popping up separate browser windows, use getAnchorWindowPosition.
   Otherwise, use getAnchorPosition

2) Your anchor tag MUST contain both NAME and ID attributes which are the
   same. For example:
   <A NAME="test" ID="test"> </A>

3) There must be at least a space between <A> </A> for IE5.5 to see the
   anchor tag correctly. Do not do <A></A> with no space.
*/

// getAnchorPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the page.
// JEFF SAYS: Appears to work with DIV's too!
function getAnchorPosition(anchorname) {
 // This function will return an Object with x and y properties
 var useWindow=false;
 var coordinates=new Object();
 var x=0,y=0;
 // Browser capability sniffing
 var use_gebi=false, use_css=false, use_layers=false;
 if (document.getElementById) { use_gebi=true; }
 else if (document.all) { use_css=true; }
 else if (document.layers) { use_layers=true; }
 // Logic to find position
  if (use_gebi && document.all) {
  x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
  y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
  }
 else if (use_gebi) {
  var o=document.getElementById(anchorname);
  x=AnchorPosition_getPageOffsetLeft(o);
  y=AnchorPosition_getPageOffsetTop(o);
  }
  else if (use_css) {
  x=AnchorPosition_getPageOffsetLeft(document.all[anchorname]);
  y=AnchorPosition_getPageOffsetTop(document.all[anchorname]);
  }
 else if (use_layers) {
  var found=0;
  for (var i=0; i<document.anchors.length; i++) {
   if (document.anchors[i].name==anchorname) { found=1; break; }
   }
  if (found==0) {
   coordinates.x=0; coordinates.y=0; return coordinates;
   }
  x=document.anchors[i].x;
  y=document.anchors[i].y;
  }
 else {
  coordinates.x=0; coordinates.y=0; return coordinates;
  }
 coordinates.x=x;
 coordinates.y=y;
 return coordinates;
 }

// getAnchorWindowPosition(anchorname)
//   This function returns an object having .x and .y properties which are the coordinates
//   of the named anchor, relative to the window
function getAnchorWindowPosition(anchorname) {
 var coordinates=getAnchorPosition(anchorname);
 var x=0;
 var y=0;
 if (document.getElementById) {
  if (isNaN(window.screenX)) {
   x=coordinates.x-document.body.scrollLeft+window.screenLeft;
   y=coordinates.y-document.body.scrollTop+window.screenTop;
   }
  else {
   x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
   y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
   }
  }
 else if (document.all) {
  x=coordinates.x-document.body.scrollLeft+window.screenLeft;
  y=coordinates.y-document.body.scrollTop+window.screenTop;
  }
 else if (document.layers) {
  x=coordinates.x+window.screenX+(window.outerWidth-window.innerWidth)-window.pageXOffset;
  y=coordinates.y+window.screenY+(window.outerHeight-24-window.innerHeight)-window.pageYOffset;
  }
 coordinates.x=x;
 coordinates.y=y;
 return coordinates;
 }

// Functions for IE to get position of an object
function AnchorPosition_getPageOffsetLeft (el) {
 var ol=el.offsetLeft;
 while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
 return ol;
 }
function AnchorPosition_getWindowOffsetLeft (el) {
 return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
 }
function AnchorPosition_getPageOffsetTop (el) {
 var ot=el.offsetTop;
 while((el=el.offsetParent) != null) { ot += el.offsetTop; }
 return ot;
 }
function AnchorPosition_getWindowOffsetTop (el) {
 return AnchorPosition_getPageOffsetTop(el)-document.body.scrollTop;
 }


//- v v v v v v v Function Suite: COOKIES AND OPTIONS v v v v v v v v v v

//- Fcn: procSwitches 1.1
//-   Either reads or writes cookie with switches listed in "switches"
//-   Gobals: switchVars[], switchVals[]
//-   Requires: compareArrays(), setCookie(), getCookie(), offsetDays()
function procSwitches (isset) {
  if ("undefined" == typeof isset) isset=false;
  if (switchVars.length != switchVals.length) {
    alert("Program error, mismatch in settings switch variables and values, please notify webmaster.");
    }
  else {
    if (isset) {
      var newvals=new Array()
      for (var i=0;i<switchVars.length;i++) {
        newvals.push(eval(switchVars[i]));
        }
      }
    else var newvals=switchVals;

    var cvars=getCookie("switchVars")
    if ((cvars != null) && (cvars != "")) {
      var swvars=cvars.split(',');
      }
    else {
      var swvars=switchVars;
      cvars='';
      isset=true;
      }

    var cvals=getCookie("switchVals")
    if ((isset) || (cvals == null)) {
      var swvals=newvals;
      }
    else {
      var swvals=cvals.split(',');
      }
    isequal = compareArrays(swvars,switchVars);
    if ((cvars!='') && (!isequal)) {

// 20030311
//    alert("Option switches have changed from what is in your cookie -- resetting switches:\nOld: "+cvars+"\nNew: "+switchVars);

      swvals=switchVals;
      swvars=switchVars;
      }
    setCookie("switchVars",swvars,offsetDays(364))
    setCookie("switchVals",swvals,offsetDays(364))
    var re = new RegExp('boolean','i');
    for (var i=0;i<swvars.length;i++) {
      swvar=swvars[i]
      swval=swvals[i]
      if ((switchType[i].toLowerCase() != "boolean") && ((swval == "") || ("string" == typeof swval))) {
        var stset=swvar+'="'+swval+'"';
        }
      else {
        var stset=swvar+'='+swval;
        }
      eval(stset);
      }
    }
  }

function compareArrays(arr1,arr2) {
  if (arr1.length != arr2.length) return false;
  for (var i=0;i<arr1.length;i++) {
    if (arr1[i] != arr2[i]) return false;
    }
  return true;
  }

//- Function: "reportFullCookie()"
//-   External: index.html, newuser.html, std\uncookie.js
//-   Show (via alert()) entire cookie and optionally delete it.
function reportFullCookie(qdelete) {
  var temp_cookie = document.cookie;
  var strlen = temp_cookie.length;
  var i = 0;
  var didone = false;
  var numfound=0;
  var outstring="";
  while (i < strlen) {
    var j = temp_cookie.indexOf("=",i);
    var n = temp_cookie.substring(i,j);
    if (qdelete) var dodelete="Deleted Cookie: ";
    else var dodelete="";
    var outstring = outstring+"\n"+dodelete+n+"="+getCookie(n);
    numfound=numfound+1;
    didone = true;
    if (qdelete) deleteCookie(n);
    i = temp_cookie.indexOf(" ",j) + 1;
    if (i == 0) break;
    }
  if (!qdelete) var outstring = "This site keeps certain things in your browser's cookie.\nHere is a listing of all "+numfound+" fields in this site's cookie: "+outstring;
  if (!didone) var outstring = outstring+"\n(No cookies found)";
  if (!qdelete) {
    var outstring = outstring+"\nClick OK to close this message window, CANCEL to erase ENTIRE cookie...";
    var agree = confirm(outstring);
    if (!agree) {
      reportFullCookie(true);
      }
    }
  else {
    //alert(outstring);
    }
  }

//- Function: "setCookie()"
//-   (External?: content\foocart.html)
//-   Set a cookie attribute/value
//-   Optional 3rd arg: when expire, a Date() object.  cf: offsetDays().  Null means ??
//-   Other optional arguments not used here.
function setCookie (name, value) {
  var args = setCookie.arguments;
  var len = setCookie.arguments.length;
  var expires = (len > 2) ? args[2] : null;
  var path = (len > 3) ? args[3] : null;
  var domain = (len > 4) ? args[4] : null;
  var secure = (len > 5) ? args[5] : false;
  document.cookie = name + "=" + escape (value) +
  ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  ((path == null) ? "" : ("; path=" + path)) +
  ((domain == null) ? "" : ("; domain=" + domain)) +
  ((secure == true) ? "; secure" : "");
  }

//- Function: "offsetDays()"
//-   Converts number of days to an offset Date object (e.g., for setCookie())
function offsetDays (days) {
  var args = offsetDays.arguments;
  var len = offsetDays.arguments.length;
  var retDate = (len>1) ? args[1] : new Date();
  retDate.setTime(retDate.getTime() + days * 24 * 60 * 60 * 1000);
  return retDate;
  }

//- Fcn: getCookieVal 1.1
//-   Return value at startpoint, assume delimited by ';'
function getCookieVal (startpoint) {
  var cook=document.cookie.replace(/\n|\r|\r\n|\n\r/g,"")
//alert(cook);
  var endindex = cook.indexOf (";", startpoint);
  if (endindex == -1) endindex = cook.length;
  return unescape(document.cookie.substring(startpoint, endindex));
  }

//- Fcn: getCookie 1.1
//-   External: (content\foocart.htm?), newuser.html, std\uncookie.js
//-   Return value for a attribute in cookie
function getCookie (name) {
  var prefix = name + "=";
  var prefixlen = prefix.length;
  var strlen = document.cookie.length;
  var i = 0;
  while (i < strlen) {
    var j = i + prefixlen;
    if (document.cookie.substring(i, j) == prefix) return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
    }
  return null;
  }

//- Function: "deleteCookie()"
//-   External: (content\foocart.htm?), newuser.html, std\uncookie.js
//-   Delete an attribute/value pair from cookie
function deleteCookie (name) {
  var expires = new Date();
  expires.setTime (expires.getTime() - 1);
  var cookieval = getCookie (name);
  document.cookie = name + "=" + cookieval + "; expires=" + expires.toGMTString();
  }

//- Function: "deleteEntireCookie()"
//-   External: index.html, newuser.html
//-   Calls "reportFullCookie() with arguments to delete it quietly
function deleteEntireCookie () {
  reportFullCookie('DELETE')
  }

//- Function: "logIt()"
//-   External: newuser.html
//-   Append a string to variable logStat
//-   This is displayed (and application reset) when experimenter clicks "View Debug Log" on main page.
function logIt (string,prestring,poststring) {
  if ("undefined" == typeof prestring) prestring="";
  if ("undefined" == typeof poststring) poststring=" ";
  window.top.frames.logStat += "\n"+prestring+(new Date().getTime())+poststring+string;
  }

//- Function: "seeLog()"
//-   External
function seeLog () {
//  var outstring = '<h2>Log</h2><p><xmp>'+logStat+'</xmp>';
  var handle = window.open("logfile.html","openit","toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,width=800,height=600,resizable=yes,top=0,left=0");
//  handle.write(outstring)
//  alert(handle.getString());
//  setTimeout("reportProperties(handle);document.write(logStat);",2000)
//  handle.write(outstring);
  }

//- Function: "reportPropertiesByName()"
//-   Wrapper for "reportProperties"
function reportPropertiesByName(objname) {
  reportProperties(window.top.frames[objname]);
  }

//- Function: "reportProperties()"
//-   Place all information you can find about an object into the debug array via call to "logIt()"
function reportProperties(obj) {
  if ("undefined" == typeof obj) alert("debug* reportProperties() invoked on undefined object (rc=501)");
  else {
    var meid = "";
    logIt("<h2>reportProperties()</h2><table border=1>");
    if (obj != null) { if (obj.name != null) { if ("undefined" != typeof obj.name) {
      if (obj.name != "") meid = obj.name;
      logIt("<td>self.name</td><td>"+obj.name+"</td></tr>","<tr><td>","</td>");}}
      }
    if (obj != null) { if (obj.id != null) { if ("undefined" != typeof obj.id) {
      if (obj.id != "") {
        if (meid != "") meid += "/"+obj.id;
        else meid = obj.id;
        }
      logIt("<td>self.id</td><td>"+obj.id+"</td></tr>","<tr><td>","</td>");}}
      }
//  alert("debug* reportProperties("+meid+")");
    var tempobj = obj;
    if (tempobj != null) {
      if (tempobj.parentElement != null) {
        if ("undefined" != typeof tempobj.parentElement) {
          while (tempobj.parentElement) {
            logIt("<td>parent.id</td><td>"+tempobj.id+"</td></tr>","<tr><td>","</td>");
            tempobj=tempobj.parentElement;
            }
          }
        }
      }
    var tempst='';
    for (property in obj) {
      if (property == "innerHTML") tempst=escape(obj[property]);
      if (property == "outerHTML") tempst=escape(obj[property]);
      else tempst=obj[property];
      logIt("<td>"+property+"</td><td>"+tempst+"</td></tr>","<tr><td>","</td>");
      }
    logIt("</table>");
    }
  }


/*----------------------------------------------------------------------------\
|                            Sortable Table 1.12                              |
|-----------------------------------------------------------------------------|
|                         Created by Erik Arvidsson                           |
|                  (http://webfx.eae.net/contact.html#erik)                   |
|                      For WebFX (http://webfx.eae.net/)                      |
|-----------------------------------------------------------------------------|
| A DOM 1 based script that allows an ordinary HTML table to be sortable.     |
|-----------------------------------------------------------------------------|
|                  Copyright (c) 1998 - 2004 Erik Arvidsson                   |
|-----------------------------------------------------------------------------|
| This software is provided "as is", without warranty of any kind, express or |
| implied, including  but not limited  to the warranties of  merchantability, |
| fitness for a particular purpose and noninfringement. In no event shall the |
| authors or  copyright  holders be  liable for any claim,  damages or  other |
| liability, whether  in an  action of  contract, tort  or otherwise, arising |
| from,  out of  or in  connection with  the software or  the  use  or  other |
| dealings in the software.                                                   |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| This  software is  available under the  three different licenses  mentioned |
| below.  To use this software you must chose, and qualify, for one of those. |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| The WebFX Non-Commercial License          http://webfx.eae.net/license.html |
| Permits  anyone the right to use the  software in a  non-commercial context |
| free of charge.                                                             |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| The WebFX Commercial license           http://webfx.eae.net/commercial.html |
| Permits the  license holder the right to use  the software in a  commercial |
| context. Such license must be specifically obtained, however it's valid for |
| any number of  implementations of the licensed software.                    |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| GPL - The GNU General Public License    http://www.gnu.org/licenses/gpl.txt |
| Permits anyone the right to use and modify the software without limitations |
| as long as proper  credits are given  and the original  and modified source |
| code are included. Requires  that the final product, software derivate from |
| the original  source or any  software  utilizing a GPL  component, such  as |
| this, is also licensed under the GPL license.                               |
|-----------------------------------------------------------------------------|
| 2003-01-10 | First version                                                  |
| 2003-01-19 | Minor changes to the date parsing                              |
| 2003-01-28 | JScript 5.0 fixes (no support for 'in' operator)               |
| 2003-02-01 | Sloppy typo like error fixed in getInnerText                   |
| 2003-07-04 | Added workaround for IE cellIndex bug.                         |
| 2003-11-09 | The bDescending argument to sort was not correctly working     |
|            | Using onclick DOM0 event if no support for addEventListener    |
|            | or attachEvent                                                 |
| 2004-01-13 | Adding addSortType and removeSortType which makes it a lot     |
|            | easier to add new, custom sort types.                          |
| 2004-01-27 | Switch to use descending = false as the default sort order.    |
|            | Change defaultDescending to suit your needs.                   |
| 2004-03-14 | Improved sort type None look and feel a bit                    |
| 2004-08-26 | Made the handling of tBody and tHead more flexible. Now you    |
|            | can use another tHead or no tHead, and you can chose some      |
|            | other tBody.                                                   |
|-----------------------------------------------------------------------------|
| Created 2003-01-10 | All changes are in the log above. | Updated 2004-08-26 |
\----------------------------------------------------------------------------*/


function SortableTable(oTable, oSortTypes) {

	this.sortTypes = oSortTypes || [];

	this.sortColumn = null;
	this.descending = null;

	var oThis = this;
	this._headerOnclick = function (e) {
		oThis.headerOnclick(e);
	};

	if (oTable) {
		this.setTable( oTable );
		this.document = oTable.ownerDocument || oTable.document;
	}
	else {
		this.document = document;
	}


	// only IE needs this
	var win = this.document.defaultView || this.document.parentWindow;
	this._onunload = function () {
		oThis.destroy();
	};
	if (win && typeof win.attachEvent != "undefined") {
		win.attachEvent("onunload", this._onunload);
	}
}

SortableTable.gecko = navigator.product == "Gecko";
SortableTable.msie = /msie/i.test(navigator.userAgent);
// Mozilla is faster when doing the DOM manipulations on
// an orphaned element. MSIE is not
SortableTable.removeBeforeSort = SortableTable.gecko;

SortableTable.prototype.onsort = function () {};

// default sort order. true -> descending, false -> ascending
SortableTable.prototype.defaultDescending = false;

// shared between all instances. This is intentional to allow external files
// to modify the prototype
SortableTable.prototype._sortTypeInfo = {};

SortableTable.prototype.setTable = function (oTable) {
	if ( this.tHead )
		this.uninitHeader();
	this.element = oTable;
	this.setTHead( oTable.tHead );
	this.setTBody( oTable.tBodies[0] );
};

SortableTable.prototype.setTHead = function (oTHead) {
	if (this.tHead && this.tHead != oTHead )
		this.uninitHeader();
	this.tHead = oTHead;
	this.initHeader( this.sortTypes );
};

SortableTable.prototype.setTBody = function (oTBody) {
	this.tBody = oTBody;
};

SortableTable.prototype.setSortTypes = function ( oSortTypes ) {
	if ( this.tHead )
		this.uninitHeader();
	this.sortTypes = oSortTypes || [];
	if ( this.tHead )
		this.initHeader( this.sortTypes );
};

// adds arrow containers and events
// also binds sort type to the header cells so that reordering columns does
// not break the sort types
SortableTable.prototype.initHeader = function (oSortTypes) {
	if (!this.tHead) return;
	var cells = this.tHead.rows[0].cells;
	var doc = this.tHead.ownerDocument || this.tHead.document;
	this.sortTypes = oSortTypes || [];
	var l = cells.length;
	var img, c;
	for (var i = 0; i < l; i++) {
		c = cells[i];
		if (this.sortTypes[i] != null && this.sortTypes[i] != "None") {
			img = doc.createElement("IMG");
			img.src = "blank.png";
			c.appendChild(img);
			if (this.sortTypes[i] != null)
				c._sortType = this.sortTypes[i];
			if (typeof c.addEventListener != "undefined")
				c.addEventListener("click", this._headerOnclick, false);
			else if (typeof c.attachEvent != "undefined")
				c.attachEvent("onclick", this._headerOnclick);
			else
				c.onclick = this._headerOnclick;
		}
		else
		{
			c.setAttribute( "_sortType", oSortTypes[i] );
			c._sortType = "None";
		}
	}
	this.updateHeaderArrows();
};

// remove arrows and events
SortableTable.prototype.uninitHeader = function () {
	if (!this.tHead) return;
	var cells = this.tHead.rows[0].cells;
	var l = cells.length;
	var c;
	for (var i = 0; i < l; i++) {
		c = cells[i];
		if (c._sortType != null && c._sortType != "None") {
			c.removeChild(c.lastChild);
			if (typeof c.removeEventListener != "undefined")
				c.removeEventListener("click", this._headerOnclick, false);
			else if (typeof c.detachEvent != "undefined")
				c.detachEvent("onclick", this._headerOnclick);
			c._sortType = null;
			c.removeAttribute( "_sortType" );
		}
	}
};

SortableTable.prototype.updateHeaderArrows = function () {
	if (!this.tHead) return;
	var cells = this.tHead.rows[0].cells;
	var l = cells.length;
	var img;
	for (var i = 0; i < l; i++) {
		if (cells[i]._sortType != null && cells[i]._sortType != "None") {
			img = cells[i].lastChild;
			if (i == this.sortColumn)
				img.className = "sort-arrow " + (this.descending ? "descending" : "ascending");
			else
				img.className = "sort-arrow";
		}
	}
};

SortableTable.prototype.headerOnclick = function (e) {
	// find TD element
	var el = e.target || e.srcElement;
	while (el.tagName != "TD")
		el = el.parentNode;

	this.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex);
};

// IE returns wrong cellIndex when columns are hidden
SortableTable.getCellIndex = function (oTd) {
	var cells = oTd.parentNode.childNodes
	var l = cells.length;
	var i;
	for (i = 0; cells[i] != oTd && i < l; i++)
		;
	return i;
};

SortableTable.prototype.getSortType = function (nColumn) {
	return this.sortTypes[nColumn] || "String";
};

// only nColumn is required
// if bDescending is left out the old value is taken into account
// if sSortType is left out the sort type is found from the sortTypes array

SortableTable.prototype.sort = function (nColumn, bDescending, sSortType) {
	if (!this.tBody) return;
	if (sSortType == null)
		sSortType = this.getSortType(nColumn);

	// exit if None
	if (sSortType == "None")
		return;

	if (bDescending == null) {
		if (this.sortColumn != nColumn)
			this.descending = this.defaultDescending;
		else
			this.descending = !this.descending;
	}
	else
		this.descending = bDescending;

	this.sortColumn = nColumn;

	if (typeof this.onbeforesort == "function")
		this.onbeforesort();

	var f = this.getSortFunction(sSortType, nColumn);
	var a = this.getCache(sSortType, nColumn);
	var tBody = this.tBody;

	a.sort(f);

	if (this.descending)
		a.reverse();

	if (SortableTable.removeBeforeSort) {
		// remove from doc
		var nextSibling = tBody.nextSibling;
		var p = tBody.parentNode;
		p.removeChild(tBody);
	}

	// insert in the new order
	var l = a.length;
	for (var i = 0; i < l; i++)
		tBody.appendChild(a[i].element);

	if (SortableTable.removeBeforeSort) {
		// insert into doc
		p.insertBefore(tBody, nextSibling);
	}

	this.updateHeaderArrows();

	this.destroyCache(a);

	if (typeof this.onsort == "function")
		this.onsort();
};

SortableTable.prototype.asyncSort = function (nColumn, bDescending, sSortType) {
	var oThis = this;
	this._asyncsort = function () {
		oThis.sort(nColumn, bDescending, sSortType);
	};
	window.setTimeout(this._asyncsort, 1);
};

SortableTable.prototype.getCache = function (sType, nColumn) {
	if (!this.tBody) return [];
	var rows = this.tBody.rows;
	var l = rows.length;
	var a = new Array(l);
	var r;
	for (var i = 0; i < l; i++) {
		r = rows[i];
		a[i] = {
			value:		this.getRowValue(r, sType, nColumn),
			element:	r
		};
	};
	return a;
};

SortableTable.prototype.destroyCache = function (oArray) {
	var l = oArray.length;
	for (var i = 0; i < l; i++) {
		oArray[i].value = null;
		oArray[i].element = null;
		oArray[i] = null;
	}
};

SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) {
	// if we have defined a custom getRowValue use that
	if (this._sortTypeInfo[sType] && this._sortTypeInfo[sType].getRowValue)
		return this._sortTypeInfo[sType].getRowValue(oRow, nColumn);

	var s;
	var c = oRow.cells[nColumn];
	if (typeof c.innerText != "undefined")
		s = c.innerText;
	else
		s = SortableTable.getInnerText(c);
	return this.getValueFromString(s, sType);
};

SortableTable.getInnerText = function (oNode) {
	var s = "";
	var cs = oNode.childNodes;
	var l = cs.length;
	for (var i = 0; i < l; i++) {
		switch (cs[i].nodeType) {
			case 1: //ELEMENT_NODE
				s += SortableTable.getInnerText(cs[i]);
				break;
			case 3:	//TEXT_NODE
				s += cs[i].nodeValue;
				break;
		}
	}
	return s;
};

SortableTable.prototype.getValueFromString = function (sText, sType) {
	if (this._sortTypeInfo[sType])
		return this._sortTypeInfo[sType].getValueFromString( sText );
	return sText;
	/*
	switch (sType) {
		case "Number":
			return Number(sText);
		case "CaseInsensitiveString":
			return sText.toUpperCase();
		case "Date":
			var parts = sText.split("-");
			var d = new Date(0);
			d.setFullYear(parts[0]);
			d.setDate(parts[2]);
			d.setMonth(parts[1] - 1);
			return d.valueOf();
	}
	return sText;
	*/
	};

SortableTable.prototype.getSortFunction = function (sType, nColumn) {
	if (this._sortTypeInfo[sType])
		return this._sortTypeInfo[sType].compare;
	return SortableTable.basicCompare;
};

SortableTable.prototype.destroy = function () {
	this.uninitHeader();
	var win = this.document.parentWindow;
	if (win && typeof win.detachEvent != "undefined") {	// only IE needs this
		win.detachEvent("onunload", this._onunload);
	}
	this._onunload = null;
	this.element = null;
	this.tHead = null;
	this.tBody = null;
	this.document = null;
	this._headerOnclick = null;
	this.sortTypes = null;
	this._asyncsort = null;
	this.onsort = null;
};

// Adds a sort type to all instance of SortableTable
// sType : String - the identifier of the sort type
// fGetValueFromString : function ( s : string ) : T - A function that takes a
//    string and casts it to a desired format. If left out the string is just
//    returned
// fCompareFunction : function ( n1 : T, n2 : T ) : Number - A normal JS sort
//    compare function. Takes two values and compares them. If left out less than,
//    <, compare is used
// fGetRowValue : function( oRow : HTMLTRElement, nColumn : int ) : T - A function
//    that takes the row and the column index and returns the value used to compare.
//    If left out then the innerText is first taken for the cell and then the
//    fGetValueFromString is used to convert that string the desired value and type

SortableTable.prototype.addSortType = function (sType, fGetValueFromString, fCompareFunction, fGetRowValue) {
	this._sortTypeInfo[sType] = {
		type:				sType,
		getValueFromString:	fGetValueFromString || SortableTable.idFunction,
		compare:			fCompareFunction || SortableTable.basicCompare,
		getRowValue:		fGetRowValue
	};
};

// this removes the sort type from all instances of SortableTable
SortableTable.prototype.removeSortType = function (sType) {
	delete this._sortTypeInfo[sType];
};

SortableTable.basicCompare = function compare(n1, n2) {
	if (n1.value < n2.value)
		return -1;
	if (n2.value < n1.value)
		return 1;
	return 0;
};

SortableTable.idFunction = function (x) {
	return x;
};

SortableTable.toUpperCase = function (s) {
	return s.toUpperCase();
};

SortableTable.toDate = function (s) {
	var parts = s.split("-");
	var d = new Date(0);
	d.setFullYear(parts[0]);
	d.setDate(parts[2]);
	d.setMonth(parts[1] - 1);
	return d.valueOf();
};


// add sort types
SortableTable.prototype.addSortType("Number", Number);
SortableTable.prototype.addSortType("CaseInsensitiveString", SortableTable.toUpperCase);
SortableTable.prototype.addSortType("Date", SortableTable.toDate);
SortableTable.prototype.addSortType("String");
// None is a special case


function stripe(sTable) {
 /* recolor here */
 if (typeof sTable == "string") {
  sTable = document.getElementById(sTable);
 }

 // check if the table is defined before continuing
 if(sTable != undefined) {
  var row = null;

  // counter for visible rows
  var vr = 0;

  // go through each row in the table
  for(var i=1; i<sTable.rows.length; i++) {
   row = sTable.rows[i];
   if(i == 0) {
    prevRow = row;
   } else {
    prevRow = sTable.rows[i-1];
   }

   spanningRow = false;

   // alert(row.childNodes[1].attributes.getNamedItem("colspan").value + "//" + row.childNodes[1].innerHTML);

   // if(row.childNodes[0].hasAttribute && row.childNodes[0].hasAttribute("colspan")) {
   if(row.childNodes[0].nodeName != "#text") {
    if(row.childNodes[0].attributes.getNamedItem("colspan").value > 1 ) { //&& prevRow.childNodes[0].attributes.getNamedItem("colspan").value == 1
     spanningRow = true;
    } else {
     spanningRow = false;
    }
   } else if(row.childNodes[1].hasAttribute("colspan")) { // && !prevRow.childNodes[1].hasAttribute("colspan")
     spanningRow = true;
    } else {
     spanningRow = false;
   }
   /* } else if(row.childNodes[1].attributes.length != 0) {
    if(row.childNodes[1].hasAttribute("colspan") && !prevRow.childNodes[1].hasAttribute("colspan")) {
     notSpanningRow = false;
    } else {
     notSpanningRow = true;
    }
   } */

   // check if the row is visible... don't want to stripe invisible rows
   if(row.style.display != "none" && !spanningRow) {
    vr++;
    // if the row index is even, set the row class to the even
    if(vr % 2 == 0) {
     row.className = "evenRow";
    }
    else
    {
     row.className = "oddRow";
    }
   } else if(spanningRow) {
     row.className = prevRow.className;
   }

  } // end for loop
 }
}
