function saveSearchParams () {
	var form = $('searchForm');
	iraSuite.localStorage.acreageSearch = {};
	iraSuite.localStorage.acreageSearch = {
		minPrice : form.minprice.value
		,maxPrice : form.maxprice.value
		,acres : form.acres.value
		,maxAcres : form.maxacres.value
		,addDays : form.adddays.value
		,priceDays : form.pricedays.value
		,adText : form.adtext.value
	};
	console.log(iraSuite.localStorage);
}
Event.observe(window, 'load', function () {
	if (!iraSuite.localStorage) {
		iraSuite.localStorage = {};
	}
	if (!iraSuite.localStorage.acreageSearch) {
		iraSuite.localStorage.acreageSearch = {
			minPrice : ''
			,maxPrice : ''
			,counties : ''
			,cities : ''
			,realesType : ''
			,acres : ''
			,maxAcres : ''
			,addDays : ''
			,priceDays : ''
			,adText : ''
		}
	} else {
		var form = $('searchForm');
		form.minprice.value = iraSuite.localStorage.minPrice || '';
	}
	var countiesArray = [];
	var citiesArray = [];
	var propTypesArray = [];
	if (iraSuite.localStorage) {
		if (iraSuite.localStorage.acreageSearch) {
			countiesArray = iraSuite.localStorage.acreageSearch.counties ? iraSuite.localStorage.acreageSearch.counties : [];
			citiesArray = iraSuite.localStorage.acreageSearch.cities ? iraSuite.localStorage.acreageSearch.cities : [];
			propTypesArray = iraSuite.localStorage.acreageSearch.realesType ? iraSuite.localStorage.acreageSearch.realesType : [];
		}
	}
	iraSuite.getCities({initCounties : $A($R(1,83)).join(), onSuccess : function (transport) {
		
		var mem = sessionStorage;
		var tmpSearch = {};
		mem.search = Object.toJSON(tmpSearch);
		
		var countiesArr = [];
		transport.each(function (co) {
			if (countiesArray.indexOf(co.county_id) != -1) {
				var cx = true;
			} else {
				var cx = false;
			}
			countiesArr.push({text: co.county, value: co.county_id, checked: cx, cities: co.cities});
		});
		
		var countiesOpt = {
			cols: 4
			,width: '192px'
			,name: 'counties'
			,id : 'counties'
			,hint: 'All Counties'
			,allHint: 'All Counties'
			,selectAll: true
			,formStyle: {fontSize: '1em',borderColor: '#717171', textAlign:'left'}
			,onChange: function () {
				var citiesArr = [];
				// some counties (some cities)
				if (countiesObj.selected.length != 0) {
					countiesArr.each(function (co) {
						if (countiesObj.selected.indexOf(co.value)+1) {
							co.cities.each(function (ci) {
								citiesArr.push({text: ci.city, value: ci.city_id, checked: (citiesArray.indexOf(ci.city_id) + 1) /* citiesObj.selected.indexOf(ci.city_id)+1 */});
							});
						}
					});
					tmpSearch.counties = countiesObj.selected;
				}
				// if nothing has been selected
				// all counties (all cities)
				else {
					countiesArr.each(function (co) {
						co.cities.each(function (ci) {
							citiesArr.push({text: ci.city, value: ci.city_id, checked: false});
						});
					});
					tmpSearch.counties = countiesObj.unselected;
				}
				mem.search = Object.toJSON(tmpSearch);
				citiesObj.resetOptions(citiesArr);
			}
			,onClose: function () {
				// do nothing
			}
		};
		
		var citiesOpt = {
			cols: 3
			,width: '193px'
			,name: 'cities'
			,id : 'cities'
			,hint: 'All Cities'
			,allHint: 'All Cities'
			,selectAll: true
			,formStyle: {fontSize: '1em',borderColor: '#717171', textAlign:'left'}
			,onChange: function () {
				if (citiesObj.selected.length == 0) {
					tmpSearch.cities = citiesObj.unselected;
				} else {
					tmpSearch.cities = citiesObj.selected;
				}
			}
			,onClose: function () {
				// do nothing
			}
		};
		var propTypeArr = [
			{text: 'Vacant', value: 4,checked: (propTypesArray.indexOf(4) != -1)}
			,{text: 'Farm Land', value: 11,checked: (propTypesArray.indexOf(11) != -1)}
			,{text: 'Hunting and Fishing Land', value: 131,checked: (propTypesArray.indexOf(131) != -1)}
		];
		
		var propTypeOpt = {
			width: '193px'
			,name: 'realestype'
			,id : 'realestype'
			,hint: 'All Property Types'
			,allHint: 'All Property Types'
			,selectedStyle: {color:'#0b2a32', background:'#D1D1D1'}
			,mouseOverStyle: {color:'#0b2a32'}
			,formStyle: {fontSize: '1em',borderColor: '#717171', textAlign:'left'}
			,onChange: function () {
				if (propTypeObj.selected.length == 0) {
					iraSuite.localStorage.acreageSearch.realesType = propTypesArray = propTypeObj.unselected;
				} else {
					iraSuite.localStorage.acreageSearch.realesType = propTypesArray = propTypeObj.selected;
				}
				mem.search = Object.toJSON(tmpSearch);
			}
			,onClose: function () {
				// do nothing
			}
		};


		countiesObj = CSI.createMultiSelect(countiesArr, countiesOpt);

		citiesObj = CSI.createMultiSelect([], citiesOpt);
		propTypeObj = CSI.createMultiSelect(propTypeArr, propTypeOpt);

		$('countiesDiv').appendChild(countiesObj);
		$('citiesDiv').appendChild(citiesObj);
		$('proptypesDiv').appendChild(propTypeObj);
		
		countiesObj.onChange();
		propTypesObj.onChange();
		//code for loading saved values from iraSuite.localStorage : GLB Homesearch only!
	}});
});
