function LoadCounties(strStateAbbr)
{
   LoadCountyInfo(strStateAbbr);
   window.scrollBy(0, 1000000);
}

/*************************************************************/
/* Xml data Islands not supported in FireFox                 */
/* Hence a Synchronous HttpRequest has been made to server   */
/* to fill the control values dynamically                    */
/*************************************************************/

function LoadCountyInfo(strStateAbbr)
{
   if(window.ActiveXObject){
    xmlStates = xmlStateCountyCMT.XMLDocument.documentElement.getElementsByTagName("STATE");
   }
   else{
    var httpRequest = null;
    httpRequest = new XMLHttpRequest();
    
    httpRequest.open("GET", "customer_data/state_county_cmt.xml", false);
	 
	  httpRequest.send(null);
    var xmlDocument = null;
    if (httpRequest.readyState == 4 && httpRequest.status == 200) {
      if(httpRequest.responseXML != null)
      	   xmlDocument = httpRequest.responseXML;
	    else{
	       xmlDocument = document.implementation.createDocument("","",null);
	      xmlDocument.async="false";
	      parser = new DOMParser();
      	    xmlDocument = parser.parseFromString(httpRequest.responseText,"text/xml");
	    }
      xmlStates = xmlDocument.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 = 'geobody'><td align = 'left'><b>" + xmlStates[i].getAttribute("NAME") + "</b></td></tr><tr><td>";
         // 
         // id=lstCounties is added for compatibilty with firefox
         //
         strHTML = strHTML + "<select style = 'width:170' name = 'lstCounties' id='lstCounties' size = '8'  onChange = 'LoadDocTypes();'>"

         for (j = 0; j < xmlCounties.length; j++)
         {
            xmlDocTypes = xmlCounties[j].getElementsByTagName("CMT");

            if (xmlDocTypes.length > 0 || xmlCounties[j].getAttribute("RES") == "Y")
            {
               strHTML = strHTML + "<option " + strSelected + " value = '" + xmlCounties[j].getAttribute("FIPS") + "'>&nbsp;" + xmlCounties[j].getAttribute("NAME") + "</option>"
               strSelected = "";
            }
         }
         strHTML = strHTML + "</td></tr></table>";
      }
   }
   
   strHTML = strHTML + "<br><br><br><span class='geobody'><a href='/collateral/geo_coverage.pdf'><img src ='images/icon_pdf.gif' width=22 height=19 border=0> Download a printable version</a></span>";

   document.getElementById("tdCounties").innerHTML = strHTML;

   LoadDocTypes();
}

/*************************************************************/
/* Xml data Islands not supported in FireFox                 */
/* Hence a Synchronous HttpRequest has been made to server   */
/* to fill the control values dynamically                    */
/*************************************************************/

function LoadDocTypes()
{
   strHTML = "";
   var strYoMama = ' bgcolor=white';

   if(window.ActiveXObject){
    xmlCounties = xmlStateCountyCMT.XMLDocument.documentElement.getElementsByTagName("COUNTY");
   }
   else{
    var httpRequest = null;
    httpRequest = new XMLHttpRequest();
    
    httpRequest.open("GET", "customer_data/state_county_cmt.xml", false);
	 
	  httpRequest.send(null);

    if (httpRequest.readyState == 4 && httpRequest.status == 200) {
      var xmlDocument = null;
      if(httpRequest.responseXML != null)
      	   xmlDocument = httpRequest.responseXML;
	    else{
	       xmlDocument = document.implementation.createDocument("","",null);
	      xmlDocument.async="false";
	      parser = new DOMParser();
      	    xmlDocument = parser.parseFromString(httpRequest.responseText,"text/xml");
	    }
      xmlCounties = xmlDocument.getElementsByTagName('COUNTY');
      
    }
   }

   strHTML = "<div align=left class='geotitle'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AVAILABLE DOCUMENTS</div><br><table width=100%><tr valign=top align=center><td width=50%>"

   for (i = 0; i < xmlCounties.length; i++)
   {
      if (xmlCounties[i].getAttribute("FIPS") == document.getElementById("lstCounties").value)
      {
         xmlDocTypes = xmlCounties[i].getElementsByTagName("CMT");

         strHTML = strHTML + "<table width = '90%' cellpadding = '2' cellspacing = '0' border = '0' class = 'geobody'>";
         strHTML = strHTML + "<tr class = 'geocounty' colspan=2><td align = 'left'><b>" + xmlCounties[i].getAttribute("NAME") + " County</b></td></tr>";

         if (xmlCounties[i].getAttribute("RES") == 'Y')
         {
            strHTML = strHTML + "<tr><td align = 'left' colspan=2><br><b>Search by Owner Name, Street Address, or APN</b></td></tr>";
            strHTML = strHTML + "<tr><td align = 'left'>&nbsp;</td><td><b>Start Date</td></tr>";
 

            if (xmlCounties[i].getAttribute("XREF") == 'Y'){
	            strHTML = strHTML + "<tr" + strYoMama +"><td align = 'left'>Recorded Documents</td><td>";
        	    if (xmlCounties[i].getAttribute("RESSTART") != null){
               		strHTML = strHTML + xmlCounties[i].getAttribute("RESSTART");
	    	    }
		    else{
        	       strHTML = strHTML + "&nbsp;";
	    	    }
		if (strYoMama == '')
			strYoMama = ' bgcolor=white';
		else
			strYoMama = '';

		strHTML = strHTML + "</td></tr>";
	    }


            if (xmlCounties[i].getAttribute("AMAPS") == 'Y'){
	            strHTML = strHTML + "<tr" + strYoMama +"><td align = 'left'>Assessor Map</td><td>&nbsp;</td>";
		if (strYoMama == '')
			strYoMama = ' bgcolor=white';
		else
			strYoMama = '';
	    }
    if (xmlCounties[i].getAttribute("TRANS") == 'Y')
    {
  		strHTML = strHTML + "<tr" + strYoMama +"><td align = 'left'>Transaction History Search</td><td>&nbsp;</td>";
		  if (strYoMama == '')
			  strYoMama = ' bgcolor=white';
		  else
			  strYoMama = '';
	  }
    if (xmlCounties[i].getAttribute("TRANS") == 'Y')
    {
  		strHTML = strHTML + "<tr" + strYoMama +"><td align = 'left'>Voluntary Lien Search</td><td>&nbsp;</td>";
		  if (strYoMama == '')
			  strYoMama = ' bgcolor=white';
		  else
			  strYoMama = '';
	  }

            if (xmlCounties[i].getAttribute("LIEN") == 'Y')
            {
 		strHTML = strHTML + "<tr" + strYoMama +"><td align = 'left'>Involuntary Lien Search</td><td>";
        	if (xmlCounties[i].getAttribute("LIENSTART") != null){
               		strHTML = strHTML + xmlCounties[i].getAttribute("LIENSTART");
	    	}
		else{
        	       strHTML = strHTML + "&nbsp;";
	    	}

		strHTML = strHTML + "</td>";

		if (strYoMama == '')
			strYoMama = ' bgcolor=white';
		else
			strYoMama = '';
            }


	    strHTML = strHTML + "<tr" + strYoMama +"><td align = 'left'>Property Information Report</td><td>&nbsp;</td>";
	    if (strYoMama == '')
		strYoMama = ' bgcolor=white';
	    else
		strYoMama = '';

	    strHTML = strHTML + "<tr" + strYoMama +"><td align = 'left'>Sales Comparables Report</td><td>&nbsp;</td>";
	    if (strYoMama == '')
		strYoMama = ' bgcolor=white';
	    else
		strYoMama = '';

            if (xmlCounties[i].getAttribute("TAX") == 'Y')
            {
		strHTML = strHTML + "<tr" + strYoMama +"><td align = 'left'>Tax Status Report</td><td>&nbsp;</td>";
		if (strYoMama == '')
			strYoMama = ' bgcolor=white';
		else
			strYoMama = '';
            }
   
            strHTML = strHTML + "<tr" + strYoMama +"><td align = 'left'>Legal and Vesting Report</td><td>&nbsp;</td>";
	    if (strYoMama == '')
		strYoMama = ' bgcolor=white';
	    else
		strYoMama = '';

            strHTML = strHTML + "</tr></table>";
         }

         strHTML = strHTML + "</td><td width=50%>";

	 strYoMama = ' bgcolor=white';
         strHTML = strHTML + "<table width = '90%' cellpadding = '2' cellspacing = '0' border = '0' class = 'geobody'>";
         strHTML = strHTML + "<tr class = 'geobody'><td align = 'left' colspan=2>&nbsp;</td></tr>";

         if (xmlDocTypes.length > 0)
         {
            strHTML = strHTML + "<tr class = 'geobody'><td align = 'left' colspan=2><b><br>Search by Recorded Document ID Number</b></td></tr>";
         strHTML = strHTML + "<tr><td align = 'left'>&nbsp;</td><td><b>Start Date</td></tr>";

         strHTML = strHTML + "<tr" + strYoMama +"><td align = 'left'>";
         for (j = 0; j < xmlDocTypes.length; j++){
            strHTML = strHTML + "<tr" + strYoMama +"><td align = 'left'>" + xmlDocTypes[j].getAttribute("DESC") + "</td><td>";

	    if (xmlDocTypes[j].getAttribute("STARTDATE") != null){
       		strHTML = strHTML + xmlDocTypes[j].getAttribute("STARTDATE");
    	    }
	    else{
	       strHTML = strHTML + "&nbsp;";
    	    }
	    strHTML = strHTML + "</td></tr>";

	    if (strYoMama == '')
		strYoMama = ' bgcolor=white';
	    else
		strYoMama = '';
	}
	}
         break;
      }   
   }

   document.getElementById("tdDocumentTypes").innerHTML = strHTML;
}