function LoadCounties(strStateAbbr)
{
   LoadCountyInfo(strStateAbbr);
   window.scrollBy(0, 1000000);
}

function LoadCountyInfo(strStateAbbr)
{
   xmlStates = xmlStateCountyCMT.XMLDocument.documentElement.getElementsByTagName("STATE");
   strHTML = "";
   strSelected = "selected";

   for (i = 0; i < xmlStates.length; i++)
   {
      if (xmlStates(i).getAttribute("ABBR") == strStateAbbr)
      {
         xmlCounties = xmlStates(i).getElementsByTagName("COUNTY");

         strHTML = "<table cellpadding = '0' cellspacing = '0' border = '0'>";
         strHTML = strHTML + "<tr class = 'body'><td align = 'left'><h2>" + xmlStates(i).getAttribute("NAME") + "</h2></td></tr><tr><td>";
         strHTML = strHTML + "<select style = 'width:170' name = 'lstCounties' size = '8'  onChange = 'LoadDocTypes();'>"

         for (j = 0; j < xmlCounties.length; j++)
         {
            xmlDocTypes = xmlCounties(j).getElementsByTagName("CMT");

            if (xmlDocTypes.length > 0 )
            {
               strHTML = strHTML + "<option " + strSelected + " value = '" + xmlCounties(j).getAttribute("FIPS") + "'>&nbsp;" + xmlCounties(j).getAttribute("NAME") + "</option>"
               strSelected = "";
            }
         }

         strHTML = strHTML + "</td></tr></table>";
      }
   }

   document.getElementById("tdCounties").innerHTML = strHTML;

   LoadDocTypes();
}

function LoadDocTypes()
{
   strHTML = "";

   xmlCounties = xmlStateCountyCMT.XMLDocument.documentElement.getElementsByTagName("COUNTY");

   for (i = 0; i < xmlCounties.length; i++)
   {
      if (xmlCounties(i).getAttribute("FIPS") == document.getElementById("lstCounties").value)
      {
         xmlDocTypes = xmlCounties(i).getElementsByTagName("CMT");

         strHTML = "<table cellpadding = '4' cellspacing = '0' border = '0' align='left'>";
         strHTML = strHTML + "<tr><td align = 'left'><h2>" + xmlCounties(i).getAttribute("NAME") + " County</h2></td></tr>";

          if (xmlDocTypes.length > 0)
         {
            strHTML = strHTML + "<tr><td align = 'left'><p>Search by Recorded Document ID Number</p>";
            if (xmlCounties(i).getAttribute("START") != null)
               strHTML = strHTML + "<br><p>(Start Date: " + xmlCounties(i).getAttribute("START") + ")</p>";
            strHTML = strHTML + "</td></tr>";
         }

         strHTML = strHTML + "<tr><td align = 'left'><ul>";
         for (j = 0; j < xmlDocTypes.length; j++)
            strHTML = strHTML + "<li>" + xmlDocTypes(j).getAttribute("DESC") + "</li>";
         strHTML = strHTML + "</td></tr></ul>";

         strHTML = strHTML + "</table>";

         break;
      }   
   }

   document.getElementById("tdDocumentTypes").innerHTML = strHTML;
}