

HomeSearch = {
	Search : function(showAdvanced){
		
		var price_min = document.getElementById('price_min');
		var price_max = document.getElementById('price_max');
		var bed_min = document.getElementById('bed_min');
		var bath_min = document.getElementById('bath_min');
		var city = document.getElementById('city');
		var sqft_min = document.getElementById('sqft_min');
		var property_types = document.getElementById('property_types');
		
		var PropertyTypes = "";
		var URLType = "";
		var URLRoot = "";
		
		URLRoot = "mls_search.htm?";
			
		var queryString = 
			"PropertyTypes=" + property_types.value + 
			(price_min == null || price_min.value == "" ? "" : "&MinPrice=" + price_min.value ) + 
			(price_max == null || price_max.value == "" ? "" : "&MaxPrice=" + price_max.value ) + 
			(sqft_min == null || sqft_min.value == "0" || sqft_min.value == "" ? "" : "&MinImprovedSqFt=" + encodeURIComponent(sqft_min.value)) + 
			(bed_min == null || bed_min.value == "0" ? "" : "&MinBeds=" + bed_min.value ) + 
			(bath_min == null || bath_min.value == "0" ? "" : "&MinBaths=" + bath_min.value ) + 
			(city == null || city.value == "" ? "" : "&Cities=" + encodeURIComponent(city.value));
		
		FinalUrl = "";
		if (typeof showAdvanced != 'undefined' && showAdvanced) {
			FinalUrl = "/" + URLRoot + '&ShowAdvanced'; //queryString = queryString + '&ShowAdvanced';
		} else {
			FinalUrl = "/" + URLRoot + queryString + "&PerformSearch&";
		}

		if(typeof window.navigate != "undefined"){
			window.navigate(FinalUrl);
		} else {
			location.href = FinalUrl;
		}
	},
	
	Advanced : function(){
		this.Search(true);
	},
	
	BuildSearchFrame : function(frame){
		var iFrame = document.getElementById(frame);
	
		URL_Root = "http://idx.diversesolutions.com/search/710/";
		
		if(iFrame){
			var hash = "";
			
			if(location.search != ""){
				hash = location.search;
				
				if(hash.substring(0,1) == "?") hash = hash.substring(1);
				if(hash.substring(0,1) == "&") hash = hash.substring(1);
				hash = "#" + hash;
			} else if(location.hash != ""){
				hash = location.hash;
			}
			
			iFrame.src = URL_Root +  hash;
		}
	}
}