function changeSortLocation(obj) {

	var q = location.search.substr(1, location.search.length).split('&');

	var qstr = '?';
	
	for (var i = 0; i < q.length; i++) {
		var s = q[i].split('=');
		if (s[0] != obj.id) qstr += q[i] + '&';
	}

	qstr += obj.id + '=' + obj.options[obj.selectedIndex].value;

	location.href = location.pathname + qstr;
	
}

function changeZip() {

	document.getElementById('currentzip').style.display = 'none';
	document.getElementById('zipform').style.display = 'block';
	document.getElementById('zipCode').focus();
	
}

function validateZip() {

	var zip = document.getElementById('zipCode').value;
	
	if (!zip.match(/^\d{5}$/)) {
		alert('Please enter a valid 5 digit zip code.');
		document.getElementById('zipCode').focus();
		return false;
	}
	
	return true;
	
}

function validateSearch() {
	
	var val = document.getElementById('searchterm').value;

	if (!val.length) {
		alert('Please enter a search term.');
		document.getElementById('searchterm').focus();
		return false;
	}
		
}