dojo.addOnLoad(function(){
	var findForm = dojo.byId('find');
	var breedSelect = dojo.byId('breed');
	var distanceSelect = dojo.byId('distance');
	var zipcodeTxt = dojo.byId('zipcode');
	
	if(findForm) {
		dojo.connect(findForm, 'onsubmit', function (e) {
			e.stopPropagation();
			e.preventDefault();
			dojo.stopEvent(e);
			
			if(breedSelect.options[breedSelect.selectedIndex].value != '')
			{
				 var action = findForm.action + (breedSelect.options[breedSelect.selectedIndex].value) + '.html';
				 
				 if (distanceSelect.options[distanceSelect.selectedIndex].value != -1)
				 {
					 action = action + '?distance=' + distanceSelect.options[distanceSelect.selectedIndex].value;
					 
					 if (zipcodeTxt.value != '')
					 {
						 action = action + '&zipcode=' + zipcodeTxt.value;
					 }
				 }
				 
				 document.location.href = action;
			}
			return false;
		});
	}
	
	var sfindForm = dojo.byId('find_small');
	var sbreedSelect = dojo.byId('breed_small');
	
	if(sfindForm) {
		dojo.connect(sfindForm, 'onsubmit', function (e) {
			e.stopPropagation();
			e.preventDefault();
			dojo.stopEvent(e);
			
			if(sbreedSelect.options[sbreedSelect.selectedIndex].value != '')
			{
				document.location.href = sfindForm.action + (sbreedSelect.options[sbreedSelect.selectedIndex].value) + '.html';
			}
			return false;
		});
	}
});