/*
V1.0 - 03/07/08 TS
- new file for vehicle results javascript actions
*/

function PagedResults() {
	this.resultsForm = null;
	this.sortFields = new Array();

	this.SetForm = SetForm;
	this.GotoPage = GotoPage;
	this.SetSortBy = SetSortBy;
	this.SetPriceRange = SetPriceRange;
	this.AddSortField = AddSortField;
	this.SortByThis = SortByThis;
}

// sets a reference to the form option in the class
function SetForm(formObject) {
	this.resutsForm = formObject;
}

function GotoPage(pageNumber) {
	this.resutsForm.page.value = pageNumber;
	this.resutsForm.submit();
}

function SetSortBy(sortValue) {
	this.resutsForm.page.value = 1;
	this.resutsForm.sort_by.value = sortValue;
	this.resutsForm.submit();
}

function SetPriceRange(minPrice, maxPrice) {
	this.resutsForm.min_price.value = minPrice;
	this.resutsForm.max_price.value = maxPrice;
	this.resutsForm.submit();
}

function AddSortField(fieldName) {
	this.sortFields.push(fieldName);
}

function SortByThis(sortSelect) {
	var i, loopField;
	for (i=0; i < this.sortFields.length; i++) {
		loopField = this.resutsForm[this.sortFields[i]];
		if (loopField.name != sortSelect.name) {
			loopField.selectedIndex = 0;
		}
	}
	this.resutsForm.page.value = 1;
	this.resutsForm.submit();
}

