HomeSearch = {
	IDX_URL_Root: "http://idx.diversesolutions.com/search/3842/11", //example: http://idx.diversesolutions.com/search/12/4
	URL_Root: "quicksearch.html?", // 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 property_types = document.getElementById('property_types');
		var features = document.getElementById('features');
		var communities = document.getElementById('communities');
		var mls_numbers = document.getElementById('mls_numbers');
		var zipcode = document.getElementById('zipcode');
		var yearbuilt_min = document.getElementById('yearbuilt_min');
		var ispreforeclosure = document.getElementById('ispreforeclosure');
		var isreo = document.getElementById('isreo');
		var tract = document.getElementById('tract');
		var school = document.getElementById('school');


		var propertyTypeResi = document.getElementById('resi').checked;
		var propertyTypeLot = document.getElementById('lot').checked;

		if (propertyTypeResi && propertyTypeLot)
			property_types = "335, 341";
		if (propertyTypeResi && !propertyTypeLot)
			property_types = "335";
		if (!propertyTypeResi && propertyTypeLot)
			property_types = "341";


		var PropertyTypes = "";
		var URLType = "";
		var ForeclosureType = "";

		if (ispreforeclosure.checked && isreo.checked) {
			ForeclosureType = "3";
		} else if (ispreforeclosure.checked) {
			ForeclosureType = "2";
		} else if (isreo.checked) {
			ForeclosureType = "1";
		}

		var queryString =
			(property_types == null || property_types.value == "" ? "" : "&PropertyTypes=" + property_types) +
			(features == null || features.options[features.selectedIndex].value == "" ? "" : "&Features=" + features.options[features.selectedIndex].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 == "" || sqft_min.value == "" ? "" : "&MinImprovedSqFt=" + encodeURIComponent(sqft_min.value)) +
			(bed_min == null || bed_min.value == "" ? "" : "&MinBeds=" + bed_min.value) +
			(bath_min == null || bath_min.value == "" ? "" : "&MinBaths=" + bath_min.value) +
			(city == null || city.value == "" ? "" : "&Cities=" + encodeURIComponent(city.value)) +
			(zipcode == null || zipcode.value == "" ? "" : "&ZipCodes=" + encodeURIComponent(zipcode.value)) +
			(yearbuilt_min == null || yearbuilt_min.value == "" ? "" : "&MinYearBuilt=" + encodeURIComponent(yearbuilt_min.value)) +
			(ForeclosureType == "" ? "" : "&Foreclosures=" + ForeclosureType) +
			(communities == null || communities.value == "" ? "" : "&Communities=" + encodeURIComponent(communities.value)) +
			(tract == null || tract.value == "" ? "" : "&Tracts=" + encodeURIComponent(tract.value)) +
			(school == null || school.value == "" ? "" : "&Schools=" + encodeURIComponent(school.value));


		FinalUrl = "";
		if (typeof showAdvanced != 'undefined' && showAdvanced) {
			FinalUrl = "/" + this.URL_Root + '&ShowAdvanced'; //queryString = queryString + '&ShowAdvanced';
		} else {
			FinalUrl = "/" + this.URL_Root + queryString + (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;
		}
	}
}