﻿

	// $(".search_suggest").autocomplete({
    //source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
	//	});
		 
/*
*
*  Adds the text autocomplete/autosuggest functionality
* to a textbox with with css class ".search_suggest"
*/
function SetAutocomplete() {
	 var cssSelector = ".search_suggest";
	    var searchresults = null;
	    $(cssSelector).autocomplete({
	        delay: 200,
	        minLength: 3,
	        selectFirst: true,
	        source: function (request, response) {
	            var searchterm = encodeURI(request.term);
	            $.ajax({
	                type: "GET",
	                url:  msc_aws_siteurl + "/property-search/?searchterm=" + searchterm ,
	                contentType: "application/json; charset=utf-8", // to the server
	                dataType: "json", // from the server
	                sucess: function (results) {
	                }, // end sucess
	                complete: function (results) {
	                    if (results.status == 200) { // OK
	                        // Get rid of any focus handler that clears out the text box.
	                        $(cssSelector).unbind('focus');
	                        try {
								var searchresults = json_parse(results.responseText);
							    // set the search results on the text drop down                              
	                            response(searchresults);
	                        }
	                        catch (err) {
		                       // alert("error : " + err);
	                        }
	                    }

	                }, // end complete
	                error: function (msg) {
	                }
	            });  // end ajax
	        } // end source
	    });  // end .autocomplete
}

 


