function Len(string)
{
	if (string == null)
		return (false);

	return String(string).length;
}

function setRelativeRoot()
{
  var TestStr2 = "/CFF/";
  TestLen = Len(TestStr2);
  var Pos = 0;
  var PathLen = 0;
  var PathLen4 = 0;
  var MPos = 0;
  var LPos = 0;
  var LLen = 0;
  var CPath = "";
  CPath = location.href;
  PathLen = Len(CPath);
  PathLen4 = PathLen - TestLen + 1;
  var TestStr = ""
  Pos = 1;
  MPos = PathLen4;
  while (Pos <= PathLen4)
    {
    TestStr = CPath.substr(Pos, TestLen);
    if (TestStr == TestStr2)
      {
      MPos = Pos;
      break;
      }
    Pos++;
    }
  if (Pos < PathLen4)
    LPos = Pos + TestLen;
  else
    for (Pos = 8; Pos <= PathLen; Pos++)
      if (CPath.substr(Pos, 1) == "/")
        {
        LPos = Pos + 1;
        break;
        }
  LLen = PathLen - LPos + 1;
  FPath = CPath.substr(LPos, LLen);
  FLen = Len(FPath);
  Pos = 1;
  var SlashCnt = 0;
  while (Pos <= FLen)
    {
    if (FPath.substr(Pos, 1) == "/")
      SlashCnt++;
    Pos++;
    }
  if (SlashCnt == 0)
    relativeRoot = "./";
  else
    {
    relativeRoot = "";
    for (LoopCnt = 1; LoopCnt <= SlashCnt; LoopCnt++)
      relativeRoot += "../";
    }
}

function mailURL()
{ 
  HTMLtitle = document.title;
  docutitle = "";
  pNode = document.getElementById("doctitle");
  if (pNode != null)
    { cNodes = pNode.childNodes;
      for (var i = 0; i < cNodes.length; i++) 
        {
        var child = cNodes[i];
        docutitle = docutitle + child.nodeValue;
        }
    }
  if (Len(HTMLtitle) > Len(docutitle))
    { docutitle = HTMLtitle; }
  titlelen = Len(docutitle);
  titlepos = titlelen;
  while (titlepos >= 0)
    {
    TestPos = docutitle.substr(titlepos, 1);
    escTestPos = escape(TestPos);
    pt1 = docutitle.substring(0, titlepos);
    pt2 = docutitle.substring(titlepos + 1, Len(docutitle));
    if (TestPos == '"')
      {
        if (titlepos == 0)
          { docutitle = "%22" + docutitle.substring(1, Len(docutitle)); }
        else
          {
          if (titlepos == titlelen)
            { docutitle = docutitle.substring(0, Len(docutitle) - 1) + "%22"; }
          else
            { docutitle = pt1 + "%22" + pt2; }
          }
      }
    if (TestPos == "'")
      {
        if (titlepos == 0)
          { docutitle = "%27" + docutitle.substring(1, Len(docutitle)); }
        else
          {
          if (titlepos == titlelen)
            { docutitle = docutitle.substring(0, Len(docutitle) - 1) + "%27"; }
          else
            { docutitle = pt1 + "%27" + pt2; }
          }
      }
    if (TestPos == "?")
      {
        if (titlepos == titlelen)
          { docutitle = docutitle.substring(0, titlelen - 1) + "%3F"; }
        else
          { docutitle = pt1 + "%3F" + pt2; }
      }
    if (TestPos == "&")
      {
        if (docutitle.substr(titlepos, 2) == "& ")
          { docutitle = pt1 + "%26" + pt2; }
        if (docutitle.substr(titlepos, 7) == "&mdash;")
          { docutitle = pt1 + "--" + pt2.substring(6, Len(pt2)); }
        if (docutitle.substr(titlepos, 5) == "&amp;")
          { docutitle = pt1 + "%26" + pt2.substring(4, Len(pt2)); }
      }
    if (escTestPos == "%u2014")
      { docutitle = pt1 + "--" + pt2; }
    if (TestPos == "<")
      {
        if (docutitle.substr(titlepos, 4) == "<br>")
          { docutitle = pt1 + " " + pt2.substring(3, Len(pt2)); }
        if (docutitle.substr(titlepos, 3) == "<u>")
          { docutitle = pt1 + pt2.substring(2, Len(pt2)); }
        if (docutitle.substr(titlepos, 4) == "</u>")
          { docutitle = pt1 + pt2.substring(3, Len(pt2)); }
      }
    if (escTestPos == "%0A")
      { docutitle = pt1 + " " + pt2; }

    if (TestPos == "n")
      { if (docutitle.substr(titlepos, 4) == "null")
          { if (escape(docutitle.substr(titlepos + 4, 1)) == "%20")
              { if (docutitle.substr(titlepos - 1, 1) == " ")
                  { docutitle = pt1.substring(0, Len(pt1) - 1) + " " + pt2.substring(4, Len(pt2)); }
                else
                  { docutitle = pt1 + " " + pt2.substring(4, Len(pt2)); }
              }
            else
              { docutitle = pt1 + " " + pt2.substring(3, Len(pt2)); }
          }
      }
    if (TestPos == "S")
      {
        if (docutitle.substr(titlepos, 3) == "Say")
          { if (docutitle.substr(titlepos + 3, 3) == "%3F")
              { docutitle = pt1 + "Really Say%3F"; }
          }
      }
    titlepos--;
    }
  pageloc = escape(location.href);
  mailToURL = "mailto:&subject=A page from afaithfulword.org&body=" + docutitle + " (" + pageloc + ")";
  window.location = mailToURL;
}

function header()
{
  //general background and text settings
  document.write('<img src="' + relativeRoot + 'graphics/titlebar.gif"><br><br>');
}

function tablestart()
{
  //size table to screen resolution

//  if (screen.width == 800)
//    document.write('<table width="750" frame="void" border="1" cellpadding="4">');
//  else
//  document.write('<table width="920" frame="void" border="1" cellpadding="4">');
  document.write('<table width="770" frame="void" border="1" cellpadding="4">');
  document.write('<tr><td valign="top" width="150" bgcolor="#FFFFD8">');
}

function tablebody()
{
  document.write('</td>');
  document.write('<td bgcolor="#FFFFFF">');
}


function openDir( form ) { 
  var newIndex = form.fieldname.selectedIndex; 
  cururl = form.fieldname.options[ newIndex ].value; 
  window.location.assign( cururl ); 
} 

function googlesearch()
{
  document.write('<table width="770">');
  document.write('<tr><td valign="middle">');
  document.write('<FORM method=GET action="http://www.google.com/search">');
  document.write('<input type=hidden name=ie value=UTF-8>');
  document.write('<input type=hidden name=oe value=UTF-8>');
  document.write('&nbsp;&nbsp;<A HREF="http://www.google.com/"><IMG SRC="' + relativeRoot + 'graphics/Google.gif" border="0" ALT="Google"></A>');
  document.write('</td>');
  document.write('<td valign="middle">');
  document.write('<INPUT TYPE=text name=q size=40 maxlength=255 value="">');
  document.write('</td>');
  document.write('<td valign="middle">');
  document.write('<INPUT type=image name=btnG SRC="' + relativeRoot + 'graphics/search.jpg">');
//  document.write('<INPUT type=submit name=btnG VALUE="Search Contending for the Faith">');
  document.write('<input type=hidden name=domains value="Contending for the Faith">');
  document.write('<input type=hidden name=sitesearch value="contendingforthefaith.*"><span class="textbody">&nbsp;</span>');
  document.write('<input type=hidden name=lr value="lang_en"><span class="textbody">&nbsp;</span>');
  document.write('</FORM>');
  document.write('</td></tr></table>');
  document.write('<table width="750">');
}
// This function inserts a copyright statement with "DCP" as the holder.
function footer()
{
  //End body table
  document.write('</td></tr></table>');
//  if (screen.width == 800)
//    document.write('<table width="750" height="31"><tr>');
//  else
//    document.write('<table width="920" height="31"><tr>');
  googlesearch();
  document.write('<table width="770" height="31"><tr>');
  document.write('<td width="250"><p class="copyright">Copyright &copy; 2004-2008  DCP.  All Rights Reserved</p></td>');
  document.write('<td><a onclick="mailURL()"><img border="0" src="' + relativeRoot + 'graphics/up_email.jpg"></a></td>');
  document.write('<td><a href=' + relativeRoot + 'index.html><img border="0" src="' + relativeRoot + 'graphics/up_homepage.jpg"></a></td>');
  document.write('<td><a href=' + relativeRoot + 'siteMap.html><img border="0" src="' + relativeRoot + 'graphics/up_sitemap.jpg"></a></td>');
  document.write('<td><a href=' + relativeRoot + 'links/index.html><img border="0" src="' + relativeRoot + 'graphics/up_links.jpg"></a></td>');
  document.write('</tr>');
  document.write('<tr><td></td></tr></table>');
}

// This function inserts a copyright statement with "The Church in Fullerton" as the holder.
function footerf()
{
  //End body table
  document.write('</td></tr></table>');
//  if (screen.width == 800)
//    document.write('<table width="750" height="31"><tr>');
//  else
//    document.write('<table width="920" height="31"><tr>');
  googlesearch();
  document.write('<table width="770" height="31"><tr>');
  document.write('<td width="250"><p class="copyright">Copyright &copy; 2003-2008 The Church in Fullerton.<br>Used by Permission.</p></td>');
  document.write('<td><a onclick="mailURL()"><img border="0" src="' + relativeRoot + 'graphics/up_email.jpg"></a></td>');
  document.write('<td><a href=' + relativeRoot + 'index.html><img border="0" src="' + relativeRoot + 'graphics/up_homepage.jpg"></a></td>');
  document.write('<td><a href=' + relativeRoot + 'siteMap.html><img border="0" src="' + relativeRoot + 'graphics/up_sitemap.jpg"></a></td>');
  document.write('<td><a href=' + relativeRoot + 'links/index.html><img border="0" src="' + relativeRoot + 'graphics/up_links.jpg"></a></td>');
  document.write('</tr>');
  document.write('<tr><td></td></tr></table>');
}

function acrobat()
{
document.write('<a href="http://www.adobe.com/products/acrobat/readstep2.html">');
document.write('<img src="' + relativeRoot + 'graphics/get_adobe_reader.gif"></a>');
}

function bam(singplur)
{
document.write('<table cellpadding="8" align="center" width="90%" border="2" bgcolor="#F0FFFF"><tr><td><p class="textbody">');
document.write(singplur + 'issues related to the original "Bible Answer Man," Walter Martin, not the current "Bible Answer Man" and President of the Christian Research Institute, Hank Hanegraaff. ');
document.write('Since 2003, the local churches have engaged in a very fruitful dialog with Hank Hanegraaff, ');
document.write('Gretchen Passantino-Coburn, and Elliot Miller. They receive us as Christian brothers and we count them as friends and fellow believers ');
document.write('(see <a href=' + relativeRoot + 'dialogues/CRIhist.html>');
document.write('"A Brief History of the Relationship between the Local Churches and the Christian Research Institute"</a>).');
document.write('</p></td></tr></table>');
}

function bamsing()
{
bam('This article addresses ');
}

function bamplur(Ast)
{
if (Ast == "NoAst")
  bam('These articles address ')
else
  bam('* These articles address ');
}

function construct()
{
  document.write('<p class="textbody2"><img src=' + relativeRoot + 'graphics/construct.gif></p>');
  document.write('<p class="textbody">This page is currently under construction. ');
}

function webml()
{
m1 = "lt";
m2 = "mai";
m3 = "o:";
a1 = "o@af";
a2 = "ord.";
a3 = "fulw";
a4 = "org";
a5 = "inf";
a6 = "aith";
ml = m2 + m1 + m3 + a5 + a1 + a6 + a3 + a2 + a4;
document.write('<a href="' + ml + '">');
document.write('<p class="textbody"><img src="' + relativeRoot + 'graphics/up_info.jpg" border="0"></a></p>');
}
