HomeSearch = {
	IDX_URL_Root : "http://idx.diversesolutions.com/search/11809/176", //example: http://idx.diversesolutions.com/search/12/4
	URL_Root : "idxsearch.php?", // CHANGE THIS IF THE PATH TO YOUR IFRAME PAGE IS DIFFERENT for example, if your frame page is http://www.mysite.com/idxsearch.php fill in: idxsearch.php? for URL_Root
	
	Search : function(showAdvanced){
		//price_min, price_max, bed_min, bath_min, city, sqft_min, property_types, features, communities, mls_numbers, zipcode
		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 lotsqft_min = document.getElementById('lotsqft_min');
		var property_types = document.getElementById('property_types');
		var features = document.getElementById('features');
		var communities = document.getElementById('communities');
		var tracts = document.getElementById('tracts');
		var mls_numbers = document.getElementById('mls_numbers');
		var zipcode = document.getElementById('zipcode');
		
		var PropertyTypes = "";
		var URLType = "";
		
		var queryString = 
			(property_types == null || property_types.value == "" ? "" : "&PropertyTypes=" + property_types.value ) + 
			(features == null || features.value == "" ? "" : "&Features=" + features.value ) + 
			(mls_numbers == null || mls_numbers.value == "" ? "" : "&MlsNumbers=" + mls_numbers.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)) + 
			(lotsqft_min == null || lotsqft_min.value == "0" || lotsqft_min.value == "" ? "" : "&MinLotSqFt=" + encodeURIComponent(lotsqft_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)) + 
			(zipcode == null || zipcode.value == "" ? "" : "&ZipCodes=" + encodeURIComponent(zipcode.value)) + 
			(communities == null || communities.value == "" ? "" : "&Communities=" + encodeURIComponent(communities.value));
		
		FinalUrl = "";
		if (typeof showAdvanced != 'undefined' && showAdvanced) {
			FinalUrl = "/" + this.URL_Root + '&ShowAdvanced'; //queryString = queryString + '&ShowAdvanced';
		} else {
			FinalUrl = "/" + this.URL_Root + 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);
	
		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 = this.IDX_URL_Root +  hash;
		}
	}
}
