function SearchFacade() {
	this.typedSearches = {};
	this.selectedType = null;
}
SearchFacade.prototype.addSearch = function(searchType, typedInvSearch, formName, priceType) {
	this.typedSearches[searchType] = new SearchTypeNode(typedInvSearch, formName, priceType);
}
SearchFacade.prototype.getCurrentSearch = function() { return this.typedSearches[this.selectedType]; }
SearchFacade.prototype.getSelectedType = function() { return this.selectedType; }
SearchFacade.prototype.init = function(defaultSearchType) {
	if (!this.typedSearches[defaultSearchType]) return;
	this.selectedType = defaultSearchType;
	var search = this.typedSearches[this.selectedType];
	setSelected(search.getSearchForm().elements["search"], this.selectedType);
	this.setSearchType(this.selectedType);
}
SearchFacade.prototype.setMake = function(make) { this.typedSearches[this.selectedType].getInvSearch().setMake(make); }
SearchFacade.prototype.setModel = function(model) { this.typedSearches[this.selectedType].getInvSearch().setModel(model); }
SearchFacade.prototype.setSearchType = function(searchType) {
	if (!this.typedSearches[searchType]) return;
	this.setSelectedType(searchType);
	var currSearch = this.typedSearches[searchType];
	if (!currSearch.isInitted()) {
		currSearch.getInvSearch().init(currSearch.getSearchForm(), currSearch.getPriceType());
		currSearch.setInitted(true);
	} else {
		currSearch.getInvSearch().setLocation(ALL_VALUE);
	}
}
SearchFacade.prototype.setSelectedType = function(selectedType) { this.selectedType = selectedType; }
SearchFacade.prototype.setTrim = function(trim) { this.typedSearches[this.selectedType].getInvSearch().setTrim(trim); }
SearchFacade.prototype.setVehicleType = function(vehicleType) { this.typedSearches[this.selectedType].getInvSearch().setVehicleType(vehicleType); }
SearchFacade.prototype.submitForm = function() { return this.typedSearches[this.selectedType].getInvSearch().submitForm(); }



function SearchTypeNode(invSearch, formName, priceType) {
	this.invSearch = invSearch;
	this.formName = formName;
	this.priceType = priceType;
	this.initted = false;
}
SearchTypeNode.prototype.getFormName = function() { return this.formName; }
SearchTypeNode.prototype.getInvSearch = function() { return this.invSearch; }
SearchTypeNode.prototype.getPriceType = function() { return this.priceType; }
SearchTypeNode.prototype.getSearchForm = function() { return document.forms[this.formName]; }
SearchTypeNode.prototype.hasData = function() { return this.hasNonNullNode(this.invSearch.jsdata); }
SearchTypeNode.prototype.hasNonNullNode = function(node) {
	for (var key in node) {
		if ((null != key) && ("" != key)) return true;
		if (node[key] instanceof Object) return this.hasNonNullNode(node[key]);
	}
	return false;
}
SearchTypeNode.prototype.isInitted = function() { return this.initted; }
SearchTypeNode.prototype.setFormName = function(formName) { this.formName = formName; }
SearchTypeNode.prototype.setInitted = function(initted) { this.initted = initted; }
SearchTypeNode.prototype.setInvSearch = function(invSearch) { this.invSearch = invSearch; }
SearchTypeNode.prototype.setPriceType = function(priceType) { this.priceType = priceType; }


