var populateForm = function() {
	var szQuickValue = $("#fastFind input[@name='szQuickValue']").val();
	if (szQuickValue === origQuickValue) {
		szQuickValue = "";
	}
	var homeslider = document.getElementById("homeslider");
	var searchCriteria = homeslider.getFlexCriteria();
	
	$("#fastFind input").each(function() {
		var inputName = $(this).attr("name");
		if (searchCriteria.hasOwnProperty(inputName)) {
			$(this).val(searchCriteria[inputName]);
		}
	});
	$("#fastFind input[@name='szQuickValue']").val(szQuickValue);
};

var origQuickValue = "";
$("document").ready(function() {
	origQuickValue = $("#quickSearchStart").html();
	$("#fastFind input[@name='szQuickValue']").val(origQuickValue);
	$("#fastFind").bind("submit", function(e) {
		populateForm();
		var szQuickValue = $("#fastFind input[@name='szQuickValue']").val().replace(/^\s+|\s+$/, "");
		if (szQuickValue == "") {
			popSearchMessage("Please specify Address, Town Zip, MLS#, or Keyword");
			e.preventDefault();
		}
	});
});

var forwardToResults = function(searchCriteria) {
	populateForm();
	var szQuickValue = $("#fastFind input[@name='szQuickValue']").val();
	if (szQuickValue == "") {
		popSearchMessage("Please specify Address, Town Zip, MLS#, or Keyword");
	}
	else {
		document.getElementById("fastFind").submit();
	}
};