// --------------------------------------------------------------------------------
// FormValidation.js
// Simon Anderson 06-Oct-2004
// Contains Javascript relevant to the Quick Search Form/Control.
// --------------------------------------------------------------------------------

// prefix stems from 'tmpl' for the template, 'ladQuickSearch' for ListingsDirectory QuickSearch mode, and 'ladQS' for the QuickSearch control.
var qs_fieldPrefix = "tmpl_ladQuickSearch_ladQS_";

// --- Attach JS to document elements and execute simple statements. ---
ow_f_AppendLoadEvent(
    function() {
    	if (document.getElementById(qs_fieldPrefix + "lad_btnSearch") != null) {
    		ow_f_AddEvent(document.getElementById(qs_fieldPrefix + "lad_btnSearch"), "click", qs_btnSearchClicked, false);
    	}
    }
);

// --------------------------------------------------------------------------------
// qs_Valid()
// Validates the data selected on the Quick Search control.
// --------------------------------------------------------------------------------
// Arguments:
//	- none
// Returns:
//	- the results of the validation [boolean]
// --------------------------------------------------------------------------------

function qs_Valid() 
{
	// removed the first line "Select..." from the Price and Type drop down lists
	// so these functions are redundant and commented out
	// Simon Anderson, Feb 16, 2005
	
	/*
	var lad_lstPrice = document.getElementById(qs_fieldPrefix + "lad_lstPrice");
	if (lad_lstPrice != null)
		if (lad_lstPrice.options[lad_lstPrice.selectedIndex].value == -1) {
			alert(document.getElementById(qs_fieldPrefix + "lad_cvPrice").value);
			lad_lstPrice.focus();
			return false;
		}
		
	var lad_lstPropTypes = document.getElementById(qs_fieldPrefix + "lad_lstPropTypes");
	if (lad_lstPropTypes != null)
		if (lad_lstPropTypes.options[lad_lstPropTypes.selectedIndex].value == -1) {
			alert(document.getElementById(qs_fieldPrefix + "lad_cvPropTypes").value);
			lad_lstPropTypes.focus();
			return false;
		}
	*/
	return true;
}


// --------------------------------------------------------------------------------
// qs_btnSearchClicked()
// Fires when the submit button was clicked.
// --------------------------------------------------------------------------------
// Arguments:
//	- none
// Returns:
//	- Nothing
// --------------------------------------------------------------------------------
function qs_btnSearchClicked(e) {
	if (!qs_Valid()) {
		//alert("QUICK SEARCH FORM IS INVALID.");
		if (!e) var e = window.event;
		if (e.preventDefault) e.preventDefault(); else e.returnValue = false;
	} else {
		//alert("QUICK SEARCH FORM IS GOOD TO SUBMIT.");
	}
}