function saveSearchParams () {
	var form = $('searchForm');
	iraSuite.localStorage.commercialSearch = {};
	iraSuite.localStorage.commercialSearch = {
		minPrice : form.minprice.value
		,maxPrice : form.maxprice.value
		,sqFeet : form.sqfeet.value
		,maxSqFeet : form.maxsqfeet.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.commercialSearch) {
		iraSuite.localStorage.commercialSearch = {
			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.commercialSearch) {
			countiesArray = iraSuite.localStorage.commercialSearch.counties ? iraSuite.localStorage.commercialSearch.counties : [];
			citiesArray = iraSuite.localStorage.commercialSearch.cities ? iraSuite.localStorage.commercialSearch.cities : [];
			propTypesArray = iraSuite.localStorage.commercialSearch.realesType ? iraSuite.localStorage.commercialSearch.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: 'Commercial', value: '1,19',checked: (propTypesArray.indexOf('1,19') != -1)}
			,{text: 'Business', value: '6,19',checked: (propTypesArray.indexOf('6,19') != -1)}
			,{text: 'Industrial', value: '7,19',checked: (propTypesArray.indexOf('7,19') != -1)}
			,{text: 'Multifamily', value: '10,19',checked: (propTypesArray.indexOf('71,09') != -1)}
			,{text: 'Office', value: '8,19',checked: (propTypesArray.indexOf('8,19') != -1)}
		];
		var propTypeOpt = {
			width: '193px'
			,name: 'realestype_and'
			,id : 'realestype_and'
			,hint: 'All Classifications'
			,allHint: 'All Classifications'
			,selectedStyle: {color:'#0b2a32', background:'#D1D1D1'}
			,mouseOverStyle: {color:'#0b2a32'}
			,formStyle: {fontSize: '1em',borderColor: '#717171', textAlign:'left'}
			,onChange: function () {
				if (propTypeObj.selected.length == 0) {
					iraSuite.localStorage.commercialSearch.realesType = propTypesArray = propTypeObj.unselected;
				} else {
					iraSuite.localStorage.commercialSearch.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();
	}});
});
