// JavaScript Document
function fncGetCities(strFormName){  
var blnShowCondition = false;

	if(strFormName=="frmGetLocation"){
		lngStateId=document.frmGetLocation.lngStateId.value	;
		document.frmGetLocation.lngCityId.length = 1; 
	}else if(strFormName=="frmCountyAdd"){
		lngStateId=document.frmCountyAdd.lngStateId.value;	
		document.frmCountyAdd.lngCityId.length = 1;  
	}else if(strFormName=="frmListingAdd"){
		lngStateId=document.frmListingAdd.lngStateId.value;	
		document.frmListingAdd.lngCityId.length = 1;
		document.frmListingAdd.lngCountyId.length = 1;
		blnShowCondition = true;
	}else if(strFormName=="frmBSearch"){
		lngStateId=document.frmBSearch.lngStateId.value;	
		document.frmBSearch.lngCityId.length = 1; 
		blnShowCondition = true;
	}else if(strFormName=="frmAdvanceSearch"){
		lngStateId=document.frmAdvanceSearch.lngStateId.value;	
		document.frmAdvanceSearch.lngCityId.length = 1;
		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=="frmGetLocation")
						document.frmGetLocation.lngCityId.appendChild(newOption);
					else if(strFormName=="frmCountyAdd")
						document.frmCountyAdd.lngCityId.appendChild(newOption);
					else if(strFormName=="frmListingAdd")
						document.frmListingAdd.lngCityId.appendChild(newOption);			        
					else if(strFormName=="frmBSearch")
						document.frmBSearch.lngCityId.appendChild(newOption);			        
					else if(strFormName=="frmAdvanceSearch")
						document.frmAdvanceSearch.lngCityId.appendChild(newOption);			        						
						
			        i = i + 1;
			    }
	        }
	        
	        // focus on dropdown
			if(strFormName=="frmGetLocation")
		        document.frmGetLocation.lngCityId.focus();
			else if(strFormName=="frmCountyAdd")
		        document.frmCountyAdd.lngCityId.focus();			
			else if(strFormName=="frmListingAdd")
		        document.frmListingAdd.lngCityId.focus();				        
			else if(strFormName=="frmBSearch")
		        document.frmBSearch.lngCityId.focus();				        				
			else if(strFormName=="frmAdvanceSearch")
		        document.frmAdvanceSearch.lngCityId.focus();				        								
        }
    }

//****************************

        }
      }
	if(strFormName=="frmBSearch" || strFormName=="frmAdvanceSearch")  
    	xmlHttp.open("GET","misc/getcities.asp?lngStateId="+lngStateId+"&blnShowCondition="+blnShowCondition,true);
	else
		xmlHttp.open("GET","../misc/getcities.asp?lngStateId="+lngStateId+"&blnShowCondition="+blnShowCondition,true);
	
    xmlHttp.send(null);  
}
