

    var lowBandwidthSize = 0;
    var MIN_SERVICE_SIZE = 20000000;
    var gbEntries = new Array();
    var obitCount = 0;
    var oNum;
    var lName;
    var fName;
    var mName;
    var DOD;
    var searchLastName = "";
    var searchFirstName = "";
    var obitList = new Array();
    var obitListTitle;
    var pageType = 0;
    var obitItem;
    var haveLHVideo = false;
    var foreignVideo = false;
    var movieServer = "";



/* Thacker Memorial now uses the new style Obit List,
   BUT USES THE OLD STYLE OBIT DISPLAY.  THEREFOR CHANGE THE URL OF THE OBIT DISPLAY HERE!!!!!
   THE COMMENTED OUT VERSION SHOULD BE RESTORED WHEN CONVERTED TO USE THE NEW OBIT DISPLAY>
*/


function gotoObit(ObitNum){
  var slash = "/";
//  var h = 'http://www.thackerfuneralhome.com/cgi-bin/CompanyInternal?stdout+115+thackerfuneralhome.com+';
//  h += ObitNum + "+" + pageType + "+9103:Lcgi_html" + slash;
  var h = 'http://www.thackerfuneralhome.com/cgi-bin/CompanyInternal?stdout+116+thackerfuneralhome.com+102+4+' + ObitNum;
  location.href = h;
  return(false);
}



/* Thacker Memorial now uses the new style Obit List,
   BUT USES THE OLD STYLE OBIT DISPLAY.  THEREFOR CHANGE THE URL OF THE OBIT DISPLAY HERE!!!!!
   THE COMMENTED OUT VERSION SHOULD BE RESTORED WHEN CONVERTED TO USE THE NEW OBIT DISPLAY>
*/

function getObitURL(ObitNum)
{

  //http://www.thackerfuneralhome.com/cgi-bin/CompanyInternal?stdout+116+thackerfuneralhome.com+102+4+1371

  var slash = "/";
//  var h = 'http://www.thackerfuneralhome.com/cgi-bin/CompanyInternal?stdout+115+thackerfuneralhome.com+';
//  h += ObitNum + "+" + pageType + "+9103:Lcgi_html" + slash;
  var h = 'http://www.thackerfuneralhome.com/cgi-bin/CompanyInternal?stdout+116+thackerfuneralhome.com+102+4+' + ObitNum;
  return(h);
}

function renderDate(pre,date,post,date_format)
{
  var i;
  var t;
  mnths = new Array("January ","February ","March ","April ","May ","June ","July ","August ","September ","October ","November ","December ");
  var re = /(\d\d\d\d)-(\d\d)-(\d\d)/;
  var dateDecompose = re.exec(date);
  if (dateDecompose == null) return;
  /*
    dateDecompose[1] = year
    dateDecompose[2] = month
    dateDecompose[3] = day
  */


  if (dateDecompose[1] == "0000") {
    document.writeln(pre + "&nbsp;" + post);
    return;
  }
  switch(date_format){
    case 1:
      i = dateDecompose[2] - 1;
      t = pre + mnths[i] + dateDecompose[3] + ", " + dateDecompose[1] + post;
      break;
    case 2:
      t = pre + dateDecompose[2] + "/" + dateDecompose[3] + "/" + dateDecompose[1] + post;
      break;
    default:
      t = pre +  dateDecompose[1] + "-" + dateDecompose[2] + "-" + dateDecompose[3] + post;
      break;
  }
  return(t);
}





    function newObit(obitNum,l_n,f_n,m_n,dod){
      this.obitNum = obitNum;
      this.l_n = l_n;
      this.f_n = f_n;
      this.m_n = m_n;
      this.dod = dod;
    }


    function newFullObit(obitNum,l_n,f_n,m_n,dob,dod,title,visit,funeral,interment,vb,candle){
      this.obitNum = obitNum;
      this.lname = l_n;
      this.fname = f_n;
      this.mname = m_n;
      this.dob = dob;
      this.dod = dod;
      this.title = title;
      this.visit = visit;
      this.funeral = funeral;
      this.interment = interment;
      this.vb = vb;
      this.candle = candle;
      this.picFileName = "";
      this.picW = "__";
      this.picH = "__";
      this.path = "";
      this.showAge = false;
      this.showDOB_DOD = false;
    }


    function newGBItem(obitNum,messageID,LineNum,fn,mn,ln,city,state,lastchange)
    {
      this.obitNum = obitNum;
      this.messageID = messageID;
      this.LineNum = LineNum;
      this.fn = fn;
      this.mn = mn;
      this.ln = ln;
      this.city = city;
      this.state = state;
      this.lastchange = lastchange;
    }



    function renderGBEntries(ordering,nameDOD,obitNum)
    {
      var messageDivId = document.getElementById("visitorBook");
      var t = "";
      var i;
      var visitor;
      var name = "";
      var dod = "";
      var gbHeder = "";
      var returnToObit = "";

      switch(ordering.toLowerCase()){
        case "name":
          gbEntries.sort(orderGBEntriesByName);
          break;
        case "date":
          gbEntries.sort(orderGBEntriesByEntryTime);
          break;
      }
      nameDOD = nameDOD.replace(/~realquote~/g,'&quot;');
      i = nameDOD.indexOf("^");
      if (i > -1){
        name = nameDOD.slice(0,i);
        dod = nameDOD.slice(i+1);
        gbHeader = '<h1>Visitor Book for ' + name + "</h1>\n";
      }
      for (i=0;i<gbEntries.length;i++){
        visitor = "<p class='renderVBName'>" + gbEntries[i].fn + " " + gbEntries[i].mn + " " + gbEntries[i].ln + "</p>\n";
        if (gbEntries[i].city.length + gbEntries[i].state.length > 0){
          visitor += "<p class='renderVBLoc'>" + gbEntries[i].city;
          if (gbEntries[i].state.length > 0) visitor += ", " + gbEntries[i].state + "</p>\n";
        }
        t += visitor;
        t += '<p class="renderVBMessage">' + document.getElementById(gbEntries[i].messageID).innerHTML + "</p>\n";
        t += '<hr class="renderVBSeparator" />\n';
      }
      returnToObit = '<center><br /><form onSubmit="return gotoObit(' +  obitNum + ')"><input type="submit" value="Return to Obituary"></form></center>\n';
      messageDivId.innerHTML = gbHeader + t + returnToObit;
    }

    function orderGBEntriesByName(a,b){
      if (a.ln < b.ln) return -1;
      if (a.ln > b.ln) return 1;
      if (a.fn < b.fn) return -1;
      if (a.fn > b.fn) return 1;
      if (a.mn < b.mn) return -1;
      if (a.mn > b.mn) return 1;
      return 0;
    }

    function orderGBEntriesByEntryTime(a,b){
      if (a.lastchange < b.lastchange) return -1;
      if (a.lastchange > b.lastchange) return 1;
      return 0;
    }

    function orderObits(a,b){
      if (a.dod > b.dod) return -1;
      if (a.dod < b.dod) return 1;
      if (a.l_n < b.l_n) return -1;
      if (a.l_n > b.l_n) return 1;
      if (a.f_n < b.f_n) return -1;
      if (a.f_n > b.f_n) return 1;
      if (a.m_n < b.m_n) return -1;
      if (a.m_n > b.m_n) return 1;
      return 0;
    }


    function returnListElement(i){

      var o = obitList[i];
      var linkCell =  "<td class='fullObitListLinkCell'><a href='" + getObitURL(o.obitNum) + "'><img src='../art/obits/smallView.gif' border='0' /></a></td>\n";
      var nameCell = "<td class='fullObitListNameCell'>" + o.l_n;
      if (o.f_n.length > 0 || o.m_n.length > 0) nameCell += ", " + o.f_n + " " + o.m_n + "<br />";
      var dateCell = renderDate("<span class='fullObitListDateCell'>",o.dod,"</span>\n",1) + "</td>\n"
      return(nameCell + dateCell + linkCell);
    }


    var maxTimeSep = 864000000;  // 10 days in mSec
    var imposeRecentLimit = false;

    function renderRecentList(){
      var i;
      var d = new Date();
      var dd;
      var re = /(\d\d\d\d)-(\d\d)-(\d\d)/;
      var dateDecompose;

      var t1;
      var t2;
      var t3;

      var numRecent = 0;
      for (i=0;i<obitList.length;i++){
        dateDecompose = re.exec(obitList[i].dod);
        t1 = 1 * dateDecompose[1];
        t2 = 1 * dateDecompose[2];
        t3 = 1 * dateDecompose[3];
        dd = new Date(t1,t2-1,t3,0,0,0,0);
        if (Math.abs(d - dd) > maxTimeSep && imposeRecentLimit) break;
        numRecent++;
//alert(dd.getFullYear() + "-" + dd.getMonth() + "-" + dd.getDate() + "\n" + obitList[i].dod);
      }
      if (numRecent > 0){
        t1 = '<table cellpadding="0" cellspacing="0" class="fullObitListTableStyle">\n';
        for (i=0;i<numRecent;i++){
           t1 += "<tr>\n" + returnListElement(i) + "</tr>\n";
           if (i < numRecent - 1) t1 += "<tr><td colspan='2' style='text-align: center;'><hr class='fullObitListSep' /></td></tr>";
        }
        t1 += "</table>\n";
      } else {
        if (obitListTitle == "Archived Obituaries"){
          t1 = "<p>No obituaries were found in the archive that matched your search criterion.  Your search criterion was:</p>";
          t1 += "<table cellpadding='4'>\n<tr><td>Last name starting with: </td><td>" + searchLastName + "</td></tr>\n";
          t1 += "<tr><td>First name starting with: </td><td>" + searchFirstName + "</td></tr>\n</table>";
        } else {
          t1 = "<p>There are no listed obituaries at this time.<br /><br />Please use the archive search to review past obituaries.</p>";
        }
      } 
      document.writeln(t1);
    }


function invokeArchiveSearch(tf)
{
  var h;
  h = 'http://www.thackerfuneralhome.com/cgi-bin/CompanyInternal?stdout+115+thackerfuneralhome.com+102+3+9105:Lcgi_html/';
//  h = 'http://web1.lovinghonors.com/cgi-bin/CompanyInternal?stdout+115+thackerfuneralhome.com+102+3+9105:Lcgi_html/';
  h = h + "+" + tf.lname.value + "+" + tf.fname.value;
  window.location.href = h;
  return(false);
}


function getName(oi) {
  var decName = "";
  if (oi.title.length > 0) decName += oi.title + " ";
  if (oi.fname.length > 0) decName += oi.fname + " ";
  if (oi.mname.length > 0) decName += oi.mname + " ";
  if (oi.lname.length > 0) decName += oi.lname;
  return(decName);
}

function getYrStr(oi) {
  var t = "";
  if (oi.dob.length == 10 && oi.dod.length == 10){
    t = "<br /><span class='lifeYears'>" + oi.dob.slice(0,4) + " - " + oi.dod.slice(0,4) + "</span>\n";
  }
  return(t);
}

function renderObit(vvTrib,vvType,vvDOD,visitorBookEntries,candleEntries){
  var decName = "";
  var t = "";
  var t1;
  var picRatio;
  var w;
  var h;
  var hh;
  var copyId;
  var havePic = false;

  if (obitItem.picW.indexOf('_') == -1 && obitItem.picH.indexOf('_') == -1){
    picRatio = (obitItem.picW * 1) / (obitItem.picH * 1);
    if (picRatio > 1){
      if (obitItem.picW > 175){
        w = 175;
        h = 175 / picRatio;
      } else {
        w = obitItem.picW;
        h = obitItem.picH;
      }
    } else {
      if (obitItem.picH > 200){
        h = 200;
        w = 200 * picRatio;
      } else {
        w = obitItem.picW;
        h = obitItem.picH;
      }
    }
    t += '<img src="../' + obitItem.picFileName + '" ';
    t += 'width="' + w + '" ';
    t += 'height="' + h + '" ';
    t += 'style="margin-right: 10px;margin-bottom: 5px;" align="left" />\n';
    havePic = true;
  }
  decName = getName(obitItem) + getYrStr(obitItem) + "<br />\n";
  t += decName;

//alert(vvTrib);
  if ((vvTrib == 31)  ||  (vvType == 'F' && vvDOD == "0000-00-00")){
    t += "<a href='" + movieServer + obitItem.obitNum + "/" + obitItem.obitNum + "H.wmv'><img class='upperAreaButtons' src='../art/obits/viewVideo_140x20.jpg'></a>\n";
  }



/* Must place an automatic method to determine if the funeral service is available. */

  if (lowBandwidthSize > MIN_SERVICE_SIZE){
    t += "<a href='" + movieServer + obitItem.obitNum + "/" + obitItem.obitNum + "L.wmv'><img class='upperAreaButtons' src='../art/viewServiceButton.gif'></a>\n";
  }

  if (visitorBookEntries == 'y') {
    hh = 'http://www.thackerfuneralhome.com/cgi-bin/CompanyInternal?stdout+115+thackerfuneralhome.com+' + obitItem.obitNum + '+4+9107:Lcgi_html/';
//    hh = 'http://web1.lovinghonors.com/cgi-bin/CompanyInternal?stdout+115+thackerfuneralhome.com+' + obitItem.obitNum + '+4+9107:Lcgi_html/';
    hh += "+" + obitItem.title + "%20" + obitItem.fname + "%20" + obitItem.mname + "%20" + obitItem.lname;
    hh += "^" + obitItem.dod;
    hh = hh.replace(/"/g,"~realquote~");
    hh = hh.replace(/&quot;/g,"~realquote~");
    hh = hh.replace(/&#34;/g,"~realquote~");

    t += "<a class='upperAreaButtons' href='" + hh + "'><img class='upperAreaButtons' src='../art/obits/viewGuestBook_140x20.jpg'></a><br />\n";
  }

  if (candleEntries == 'y') {
    hh = 'http://www.thackerfuneralhome.com/cgi-bin/CompanyInternal?stdout+115+thackerfuneralhome.com+' + obitItem.obitNum + '+4+9117:Lcgi_html/';
//    hh = 'http://web1.lovinghonors.com/cgi-bin/CompanyInternal?stdout+115+thackerfuneralhome.com+' + obitItem.obitNum + '+4+9117:Lcgi_html/';
    hh += "+" + obitItem.title + "%20" + obitItem.fname + "%20" + obitItem.mname + "%20" + obitItem.lname;
    hh += "^" + obitItem.dod;
    hh = hh.replace(/"/g,"~realquote~");
    hh = hh.replace(/&quot;/g,"~realquote~");
//alert(hh);
    hh = hh.replace(/&#34;/g,"~realquote~");
//alert(hh);
    t += "<a class='upperAreaButtons' href='" + hh + "'><img class='upperAreaButtons' src='../art/obits/viewCandles_140x20.jpg'></a><br />\n";
  }

  t += "<form class='upperAreaButtons' style='margin-bottom: 8px; padding: 0px;' onSubmit='return invokeObitPF();'><input type='image' src='../art/obits/printFriendly_140x20.jpg' border='0' style='margin: 0px; padding: 0px;'></form>\n";

//  if (havePic) t += "<br clear='both' />&nbsp;"
/*
  if (obitItem.title.length > 0) decName += obitItem.title + " ";
  if (obitItem.fname.length > 0) decName += obitItem.fname + " ";
  if (obitItem.mname.length > 0) decName += obitItem.mname + " ";
  if (obitItem.lname.length > 0) decName += obitItem.lname;
*/
  if (decName.length > 0){
    t = '<h1 class="underline" style="width: 640px; margin: 10px 0px 0px 0px;">' + t + '<br clear="left" /></h1>\n';
  }

//alert(t);
//alert(obitItem.visit);
//alert(obitItem.funeral);
//alert(obitItem.interment);
  if (obitItem.visit.length > 0  ||  obitItem.funeral.length > 0  ||  obitItem.interment.length > 0){
    t += "<table style='margin: 10px 0px 10px 0px;'>";
    t1 = "";
    if (obitItem.visit.length > 0) t1 += "<tr><td class='obitDetails'>Visitation</td><td class='obitDetails' style='font-weight: bold;'>" +  obitItem.visit + "</td></tr>\n";
    if (obitItem.funeral.length > 0) t1 += "<tr><td class='obitDetails'>Funeral</td><td class='obitDetails' style='font-weight: bold;'>" +  obitItem.funeral + "</td></tr>\n";
    if (obitItem.interment.length > 0) t1 += "<tr><td class='obitDetails'>Interment</td><td class='obitDetails' style='font-weight: bold;'>" + obitItem.interment + "</td></tr>\n";
    if (obitItem.showAge){
      if (obitItem.dob.slice(0,4) != "0000" && obitItem.dod.slice(0,4) != "0000")
      t1 += "<tr><td class='obitDetails'>Age</td><td class='obitDetails' style='font-weight: bold;'>" + getAge(obitItem.dob,obitItem.dod) + "</td></tr>\n";
    }
    if (obitItem.showDOB_DOD) {
      if (obitItem.dob.slice(0,4) != "0000") t1 += "<tr><td class='obitDetails'>Born</td><td class='obitDetails' style='font-weight: bold;'>" + renderDate("",obitItem.dob,"",1) + "</td></tr>\n";
      if (obitItem.dod.slice(0,4) != "0000") t1 += "<tr><td class='obitDetails'>Died</td><td class='obitDetails' style='font-weight: bold;'>" + renderDate("",obitItem.dod,"",1) + "</td></tr>\n";

    }
    t += t1 + "</table>\n";
  }
//alert(t);
  document.writeln(t);
  copyId = document.getElementById("obitCopy");
  document.writeln(obitCopy.innerHTML);  
}



function lightCandle(tf)
{
  var i;
  if (tf.candleName.value.length <2) {
    alert("Your name is less than two letters long.\nYou must enter a name with more than two letters.");
    tf.candleName.focus();
    return(false);
  }
  if (tf.candleName.value.length > 50){
    alert("the name and message is limited to 50 characters.\nYour entry is " + tf.candleName.value.length + ".\nPlease shorten your message, then light the candle.");
    tf.candleName.focus();
    return(false);
  }
  for (i=0;i<tf.candleNum.length;i++) if (tf.candleNum[i].checked) break;
  tf.message.value = "<candle><name>" + tf.candleName.value + "</name><number>" + tf.candleNum[i].value + "</number></candle>";
  return(true);
}




function gb_checkform(tf,simple)
{
  if (tf.message.value.length > 2045){
    alert("Your message must be less than 2040 characters long.\nYour message is " + tf.message.length + " long.");
    tf.message.focus();
    return(false);
  }

  if (tf.fname.value.length == 0){
    alert("You must enter your first name.");
    tf.fname.focus();
    return(false);
  }
  if (tf.lname.value.length == 0){
    alert("You must enter your last name.");
    tf.lname.focus();
    return(false);
  }
  return(true);
}


function getAge(dob,dod)
{
  re = /(\d\d\d\d)-(\d\d)-(\d\d)/;
  dobDecompose = re.exec(dob);
  if (dobDecompose == null) return;
  dodDecompose = re.exec(dod);
  if (dodDecompose == null) return;
  age = dodDecompose[1] - dobDecompose[1];
  if (dodDecompose[2] < dobDecompose[2]) age--;
  else if (dodDecompose[2] == dobDecompose[2]){
    if (dodDecompose[3] < dobDecompose[3]) age--;
  }
  return(age);

}

function renderGBResponse(f_n,l_n){
  var t = "";


  t += '<h1 style="margin: 0px 0px 0px 0px;">Visitor Book Entry Received</h1>\n';  
  t += '<p class="boldIt">for the family of ' + getName(obitItem) + '</p>\n';
  t += "<p>Dear " + f_n + " " + l_n + ",</p>\n";
  t += "<p>Thank you for signing the visitor book.  Your message will be delivered to the family.</p>\n";
  t += "<br /><p>Sincerely yours,<br />Thacker Memorial Funeral Home</p>\n";
  t += "<center><br /><br /><form onSubmit='return gotoObit(" + obitItem.obitNum + ")'>\n";
  t += "<input type='submit' value='Return to Obituary' />\n";
  t += "</form>"
  document.writeln(t);
}



