	function createRequestObject()
	{ 
       var req; 
    
       if(window.XMLHttpRequest)
       { 
          // Firefox, Safari, Opera... 
          req = new XMLHttpRequest(); 
       }
       else if(window.ActiveXObject)
       { 
          // Internet Explorer 5+ 
          req = new ActiveXObject("Microsoft.XMLHTTP"); 
       }
       else
       { 
          // There is an error creating the object, 
          // just as an old browser is being used. 
          alert('Problem creating the XMLHttpRequest object'); 
       } 
    
       return req; 
    } 
    
    // Make the XMLHttpRequest object 
    var http = createRequestObject(); 
    
    //Suggests citys listed in the database from what is being typed
    function sendRequest(city,state) { 
    
    	//If the testbox is blank, hide suggestion <div>
		if ( city == '' )
		{
			document.getElementById("searchResults").innerHTML = ''; 
			document.getElementById("searchResults").style.visibility = 'hidden';
		}
		//If textbox is not blank, show suggestion <div> and fill in with suggestion cities
		else
		{
		   document.getElementById("searchResults").style.visibility = 'visible';
		   // Open PHP script for requests 
		   http.open('get', '/idx/suggest.php?search=city&city='+city+'&state='+state); 
		   http.onreadystatechange = handleResponse; 
		   http.send(null); 
		}
    
    } 
    
    //This handles the response and chooses what to update
    function handleResponse()
    { 
    	if(http.readyState == 4 && http.status == 200)
    	{ 
    
          // Text returned FROM the PHP script 
          var response = http.responseText; 
    
          if(response)
          { 
             // UPDATE ajaxTest content 
             document.getElementById("searchResults").innerHTML = response; 
          } 
    
       }
    
    }
	
	
    //This handles the response and chooses what to update
    function handleResponseMLS()
    { 
    	if(http.readyState == 4 && http.status == 200)
    	{ 
    		// Text returned FROM the PHP script 
    		var response = http.responseText; 
    
			if(response)
			{ 
             // UPDATE ajaxTest content 
             document.getElementById("mlsList").innerHTML = response; 
			} 
    
		}
    
    }
	
    //Chooses file to update MLS <div> with
	function filterResults(city,state)
	{
		//alert(city);
		//alert(state);
		document.getElementById("searchResults").style.visibility = 'hidden';
		
		//Open PHP script for requests 
		http.open('get', '/idx/suggest.php?search=mls&city='+city+'&state='+state); 
		http.onreadystatechange = handleResponseMLS; 
		http.send(null); 
	}