// JavaScript Document
function fncGetCounties(strFormName){  
var blnShowCondition = false;

	if(strFormName=="frmListingAdd"){
		lngCityId=document.frmListingAdd.lngCityId.value	
		document.frmListingAdd.lngCountyId.length = 1; 
		blnShowCondition = true;
	}else if(strFormName=="frmAdvanceSearch"){
		lngCityId=document.frmAdvanceSearch.lngCityId.value	
		document.frmAdvanceSearch.lngCountyId.length = 1; 
		blnShowCondition = true;
	}
	

  var xmlHttp;
  try
    {    // Firefox, Opera 8.0+, Safari   
	xmlHttp=new XMLHttpRequest();    }
  catch (e)
    {    // Internet Explorer    
	try
      {      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      }
    catch (e)
      {      try
        {        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        }
      catch (e)
        {        alert("Your browser does not support AJAX!");        return false;        }      }    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {

//************************
    if (xmlHttp.readyState == 4)
    {
        if (xmlHttp.status == 200)
        {
            // Parse the response and populate dropdowns
            var result = xmlHttp.responseText;
	        var values = result.split("|");


	        for (var i=0; i<values.length; i++)
	        {
	            if (values[i] != "")
	            {
			        var newOption = document.createElement('option');
			        newOption.value = values[i];
			        newOption.innerText = values[i+1]; // IE specific
			        newOption.text = values[i+1]; // Mozilla specific

					if(strFormName=="frmListingAdd")
						document.frmListingAdd.lngCountyId.appendChild(newOption);
					else if(strFormName=="frmAdvanceSearch")
						document.frmAdvanceSearch.lngCountyId.appendChild(newOption);
						
			        i = i + 1;
			    }
	        }
	        
	        // focus on dropdown
			if(strFormName=="frmListingAdd")
		        document.frmListingAdd.lngCountyId.focus();
			else if(strFormName=="frmAdvanceSearch")
		        document.frmAdvanceSearch.lngCountyId.focus();
				
        }
    }

//****************************

        }
      }
	if(strFormName=="frmAdvanceSearch")  
    	xmlHttp.open("GET","misc/getcounties.asp?lngCityId="+lngCityId+"&blnShowCondition="+blnShowCondition,true);
	else
    	xmlHttp.open("GET","../misc/getcounties.asp?lngCityId="+lngCityId+"&blnShowCondition="+blnShowCondition,true);
		
    xmlHttp.send(null);  
}
