	$(document).ready(function(){

            /*Search Form*/
            $("#homeFindForm").bind("submit",function(){
                var continent = $.trim($("#homeFindTextContinent").val());
                var country = $.trim($("#homeFindTextCountry").val());
                var state = $.trim($("#homeFindTextState").val());
                var city = $.trim($("#homeFindTextCity").val());
                if(continent=="" || country =="" || state == "" || city == "")
                {
                    alert("Type the city name in the field and when you see the drop-down list select a City,State and Country.");
                    return false;
                }
                var type_property = $.trim($("#homeFindType option:selected").val());
                var listing_type = $.trim($("#homeFindMode option:selected").val());
                var query=new Array();
                if($.trim(continent)!="") query[query.length]="continent="+continent;
                if($.trim(country)!="") query[query.length]="country="+country;
                if($.trim(state)!="") query[query.length]="state="+state;
                if($.trim(city)!="") query[query.length]="city="+city;
                if($.trim(type_property)!="") query[query.length]="type_property="+type_property;
                if($.trim(listing_type)!="") query[query.length]="listing_type="+listing_type;
                //query[query.length]="refinesearch=1";
                location.href="http://www.realestateactive.com/properties/?"+query.join('&');
                return false;
            });

            var cache = {}, lastXhr;
            $( "#homeFindText" ).autocomplete({
                minLength: 2,
                delay: 100,
                source: function( request, response ) {
                    var term = request.term;
                    if ( term in cache ) {
                            response( cache[ term ] );
                            return;
                    }
                    lastXhr = $.post("homeSearch.php", {term:term}, function(data, status, xhr){
                        cache[ term ] = data;
                        if ( xhr === lastXhr ) {
                            response( data );
                        }
                    }, "json");
			    
                },
                select: function(event, ui) {
                    $fields = ui.item.all.split(",");
                    $("#homeFindTextCity").val($.trim($fields[0]));
                    $("#homeFindTextState").val($.trim($fields[1]));
                    $("#homeFindTextCountry").val($.trim($fields[2]));
                    $("#homeFindTextContinent").val($.trim($fields[3]));
                    $("#homeFindText").val($.trim($fields[0]) + ", " + $.trim($fields[1]) + ", " + $.trim($fields[2]));
                }                
	    });

	});

        function iZoom(e,a){
	   if(a) $(e).css({"position":"absolute","margin":"-50px -300px "}).attr("width","400");
	   else $(e).css({"position":"static","margin":"0px"}).attr("width","100");
	}

        function geo(){
	   $("#geo").html("Loading...");
	   $.post("home.html" , {action:9, igeo:$("#igeo").val()}, function(d){ $("#geo").html(d); } ); 
	}



