<!--
var fldArray = new Array();
var fldTypeArray = new Array();
var fldLabelArray = new Array();
var fldSortArray = new Array();
var fldCount = 0;
var fldPtr = 9999;

var listArray = new Array();
var searchArray = new Array();
var selectArray = new Array();
var chgtoArray = new Array();

var sortBy = '';
var sortArray = new Array();
var listPage;
var listShown = false;
var viewAs = '';
var viewArray = new Array();
var lastView = '';

var selectCtr;
var loading = new Array('*loading...');

var foundCount = 0;
var allCount = 0;
var err = 0;
var findby = '';

var searchName;
var searchString;
var searchTry;

var ptrYear;
var ptrYearLo;
var ptrYearHi;

function initVars(theForm) {
	
	listArray = new Array(fldCount);
	searchArray = new Array(fldCount);
	selectArray = new Array(fldCount);
	chgtoArray = new Array(fldCount);
	for (var i=0; i<fldCount; i++) {
		listArray[i] = new Array();
		searchArray[i] = '*all';
		selectArray[i] = 9999;
		chgtoArray[i] = 1;
	}
	
	fldPtr = 9999;
	selectCtr = 0;
	
	listPage = 0;
	searchTry = 0;
	
	foundCount = 0;
	allCount = 0;
	findby = '';
	
	ptrYear = 9999.
	ptrYearLo = 9999.
	ptrYearHi = 9999.
	for (var i=0; i<fldCount; i++) {
		if (fldArray[i] == "Year") {
			ptrYear = i;
		}
		if (fldArray[i] == "Year_Lo") {
			ptrYearLo = i;
		}
		if (fldArray[i] == "Year_Hi") {
			ptrYearHi = i;
		}
	}

}
function clearChgTo() {
	for (var i=0; i<fldCount; i++) {
		chgtoArray[i] = 0;
	}
}
function searchChanged(theElement) {
	if (!theElement || !theElement.name) {
		return false;
	}
	fldPtr = 9999;
	for (var i=0; i<fldCount; i++) {
		if (fldArray[i] == theElement.name) {
			fldPtr = i;
			break;
		}
	}
	if (fldPtr == 9999) {
		return false;
	}

	searchArray[fldPtr] = trimIt(theElement.options[theElement.selectedIndex].text);

	selectCtr++;
	if (selectCtr < selectArray[fldPtr]) {	
		selectArray[fldPtr] = selectCtr;
	}
	else {
		selectCtr = selectArray[fldPtr];
	}

	clearChgTo();
	setChgTo();

	if (searchArray[fldPtr].toLowerCase() == '*all') {
		selectArray[fldPtr] = 9999;
		chgtoArray[fldPtr] = 1;
	}

	return true;
}

function trimIt(s) {
	return s.replace(/\s+$/,'');
}

function setChgTo() {
	for (var i=0; i<fldCount; i++) {
		if (i != fldPtr) {
			if (selectCtr <= selectArray[i]) {
				chgtoArray[i] = 1;
				selectArray[i] = 9999;
				searchArray[i] = '*all';
			}
		}
	}
	
	var aBool = true;
	for (var i=0; i<fldCount; i++) {
		if (searchArray[i].toLowerCase() != '*all') {
			aBool = false;
			break;
		}
	}
	if (aBool == true) {
		for (var i=0; i<fldCount; i++) {
			chgtoArray[i] = 1;
			selectArray[i] = 9999;
			searchArray[i] = '*all';
		}
	}
}

function searchSetLoading(theForm) {
	var theElement;
	for (var i=0; i<fldCount; i++) {
		theElement = eval('theForm.'+fldArray[i]);
		if (theElement) {
			if (chgtoArray[i] == 1) {
				moveArrayToObj(loading, theElement, searchArray[i], 'none', 'noall');
			}
			theElement.enabled = false;
			theElement.disabled = true;
		}
	}
}

function searchLoadLists(response, theForm, forceLoad) {
	var wArray1 = response.split('$');
	if (wArray1.length > 0) {
		var wArray2;
		var wArray3;
		for (var i=0; i<wArray1.length; i++) {
			wArray2 = wArray1[i].split('@');
			if (wArray2.length > 0 && wArray2[0] > ' ') {
				if (i == 0) {
					err = wArray2[0];
					foundCount = wArray2[1];
					allCount = wArray2[2];
					findby = wArray2[3];
				}
				else {	
					for (var j=0; j<fldCount; j++) {
						if (fldArray[j] == wArray2[0]) {
							var dups = 'no';
							if (fldArray[j] == 'Price') {
								dups = 'yes';
							}
							wArray3 = new Array();
							if (wArray2.length > 1) {
								for (var k=1; k<wArray2.length; k++) {
									addArray(wArray3, unescape(wArray2[k]), dups);
								}
							}
							listArray[j] = wArray3;
							break;	
						}
					}
				}
			}
		}
		loadFormElements(theForm, forceLoad);
	}
	
}

function loadFormElements(theForm, forceLoad) {
	var yearLo = false;
	var yearHi = false;
	var theElement;
	for (var i=0; i<fldCount; i++) {
		theElement = eval(theForm+'.'+fldArray[i]);
		if (theElement) {
			if (chgtoArray[i] == 1 || forceLoad == true) {
				if (theElement.name == 'Year_Lo') {
					yearLo = true;
				}
				else
				if (theElement.name == 'Year_Hi') {
					yearHi = true;
				}
				else {
					if (theElement.name == 'Price') {
						fillPrices(i);
					}
					moveArrayToObj(listArray[i], theElement, searchArray[i], fldSortArray[i], fldTypeArray[i], 'all');
				}
			}
			theElement.enabled = true;
			theElement.disabled = false;
		}
	}
//special code for year hi-lo
	if (yearLo == true && ptrYear < 9999 && ptrYearLo < 9999) {
		theElement = eval(theForm+'.Year_Lo');
		if (theElement) {
			moveArrayToObj(listArray[ptrYear], theElement, searchArray[ptrYearLo], fldSortArray[ptrYearLo], fldTypeArray[ptrYearLo], 'all');
		}
	}
	if (yearHi == true && ptrYear < 9999 && ptrYearHi < 9999) {
		theElement = eval(theForm+'.Year_Hi');
		if (theElement) {
			moveArrayToObj(listArray[ptrYear], theElement, searchArray[ptrYearHi], fldSortArray[ptrYearHi], fldTypeArray[ptrYearHi], 'all');
		}
	}
//end special code

}

function addArray(arr, val, allowDups) {
	if (!val || val == null || val <= ' ') {
		return;
	}
	var indx = 9999;
	val = val.toString();
	if (allowDups && allowDups == 'yes') {
	}
	else {
		for (var i=0; i<arr.length; i++) {
			if (arr[i] == val) {
				indx = i;
				break;
			}
		}
	}
	if (indx == 9999) {
		indx = arr.length;
		arr[indx] = val;
	}
	return indx;
}
function fillSort(obj, forceLoad) {
	if ((forceLoad && forceLoad == true)) {
		moveArrayToObj(sortArray, obj, sortBy, 'none', 'noall');
	}
}
function moveListToArr(list, arr) {
	for (var i=0; i<list.length; i++) {
		if (list[i] > ' ') {
			addArray(arr, list[i]);
		}
	}
}
function numCompareAscend(a, b) {
	return a - b;
}
function numCompareDescend(a, b) {
	return b - a;
}
function moveArrayToObj(arr, obj, val, order, ftype, noall) {
	if (order && order == 'none') {
	}
	else {
		if (ftype == 'numb') {
			for (var i=0; i<arr.length; i++) {
				arr[i] = parseInt(arr[i]);
			}
			arr.sort(numCompareAscend);
		}
		else {
			arr.sort();
		}
		if (order && order == 'reverse') {
			arr.reverse();
		}
	}
	var aPtr;
	if (noall && noall == 'noall' || arr.length == 1) {
		obj.length = arr.length;
		aPtr = 0;
	}
	else {
		obj.length = arr.length + 1;
		obj.options[0].text = '*All';
		obj.options[0].selected = true;
		aPtr = 1;
	}
	var othr = false;
	for (var i=0; i<arr.length; i++) {
		if (arr[i] > ' ') {
			if (arr[i].toString().toLowerCase() == 'other') {
				othr = true;
			}
			else
			if (i == 0) {
				obj.options[aPtr].text = arr[i];
				if (arr[i].toString().toLowerCase() == val.toString().toLowerCase()) {
					obj.options[aPtr].selected = true;
				}
				aPtr++;
			}
			else
			if (arr[i] != arr[i - 1]) {
				obj.options[aPtr].text = arr[i];
				if (arr[i].toString().toLowerCase() == val.toString().toLowerCase()) {
					obj.options[aPtr].selected = true;
				}
				aPtr++;
			}
		}
	}
	if (aPtr > 1 && othr == true) {
		obj.options[aPtr].text = '*Other';
		if (val.toString().toLowerCase() == 'other') {
			obj.options[aPtr].selected = true;
		}
		aPtr++;
	}
	obj.length = aPtr;
}
function selectObj(obj, val) {
	if (val.toString().toLowerCase() == 'other') {
		val = '*Other';
	}
	obj.options[0].selected = true;
	for (var i=0; i<obj.length; i++) {
		if (obj.options[i].text.toString().toLowerCase() == val.toString().toLowerCase()) {
			obj.options[i].selected = true;
			break;
		}
	}
}
function moveValueToObj(obj, val) {
	obj.value = val;
}

function setSearchString(how, cID) {
	searchString = '';
	if (how && how == 'dealer') {
		searchString += '?cid='+cID;
	}
	else
	if (searchName > ' ') {
		searchString += '?dlr='+searchName;
	}
	else {
		var v = '';
		var q = '';
		var p = '';
		var pString = '';
		searchString += '?t='+selectCtr+'&qs=';
		for (var i=0; i<fldCount; i++) {
			v = searchArray[i];
			if (v.toLowerCase() == '*all') {
				q = '';
			}
			else {
				q = strTrim(strClean(v));
			}
			if (selectArray[i] == 9999) {
				p = '';
			}
			else {
				p = selectArray[i];
			}
			searchString += escape(q)+'|';
			pString += p+'|';
		}
		searchString += '&ps='+pString;
	}
	searchString += '&p='+listPage+'&l='+lastView+'&f='+findby;
	searchTry++;
	searchString += '&try='+searchTry;
}
function strClean(s) {
	if (s.toLowerCase() == '*other') {
		return '*';
	}
	else {
		return s.replace(/[><=]/g, '');
	}
}
function strTrim(s) {
	return s.replace(/^\s*|\s*$/g,'');
//	return s.replace(/\s+$/,'');
}
function fillPrices(indx) {
	var priceArray = listArray[indx];	
		
	var arr = new Array();
	var tmpPrice;
	var longprice = '0000000';
	for (var i=0; i<priceArray.length; i++) {
		tmpPrice = priceRound(priceArray[i], 'other').toString();
		if (tmpPrice == 'other') {
			arr[i] = tmpPrice;
		}
		else {
			arr[i] = longprice.substring(0, 7 - tmpPrice.length) + tmpPrice.substring(0);
		}
	}
	priceArray = new Array();

	if (arr.length < 10) {
	}
	else {
		arr.sort();
	
		var aCtr = 0;
		tmpPrice = '';
		for (var i=0; i<arr.length; i++) {
			if (aCtr >= 10) {
				if (arr[i] == tmpPrice) {
				}
				else {
					priceArray[priceArray.length] = tmpPrice;
					aCtr = 1;
					tmpPrice = getInt(arr[i], 'other').toString();
				}
			}
			else {
				aCtr++;
				tmpPrice = getInt(arr[i], 'other').toString();
			}
		}
		if (aCtr > 0) {
			priceArray[priceArray.length] = tmpPrice;
		}
	}

	if (priceArray.length < 2) {
		priceArray = new Array();
	}
	for (var i=0; i<priceArray.length; i++) {
		tmpPrice = priceArray[i].toString();
		if (tmpPrice != 'other') {
			tmpPrice = '<= ' + tmpPrice;
		}
		priceArray[i] =  tmpPrice;
	}

	listArray[indx] = priceArray;
}
function priceRound(val, defaultVal) {
	var i = parseInt(val, 10);
	if (i.toString() == 'NaN') {
		i = 0;
	}
	else {
		i = (Math.ceil(i / 1000)) * 1000;
	}
	if (i == 0) {
		if (defaultVal) {
			i = defaultVal;
		}
		else {
			i = '';
		}
	}
	return i;
}
function getInt(val, defaultVal) {
	var i = parseInt(val, 10);
	if (i.toString() == 'NaN') {
		if (defaultVal) {
			i = defaultVal;
		}
		else {
			i = '';
		}
	}
	return i;
}
-->