function HomePageUtil(){

	this.formId = 'repDealerLocatorForm';
	this.errorDivId = 'divError';
	this.zipCodeFieldId = 'zipCode';
	this.stateCodeSelectId = 'stateCode';
	this.zipCodeValidationErrorMessage = 'Please enter valid zip code or select state to continue.';

    this.overlayedLoadingPanel = new YAHOO.widget.Panel("divOverlayedLoadingPanel",
                        { width:"240px",
                          fixedcenter:true,
                          close:false,
                          draggable:false,
                          zindex:4,
                          modal:true,
                          visible:false
                        }
                    );
    this.overlayedLoadingPanel.setHeader("Search in progress...");
    this.overlayedLoadingPanel.setBody('<img src="/replocator/images/loading.gif"/>');
    this.overlayedLoadingPanel.render(document.body);

    this.allowNumericKeysAndSubmitOnEnter = function(event) {
		var unicode = event.charCode ? event.charCode : event.keyCode;
		if (unicode == 13) {
			return this.submitRepDealerForm(this.formId, this.zipCodeFieldId, this.errorDivId, this.zipCodeValidationErrorMessage);
		}
		if (unicode > 26) { // don't mess with control chars
			if (unicode < 48 || unicode > 57) { //if not a number
				return false;
 			//disable key press
			}
		}
		return true;
	}

	this.submitRepDealerForm = function() {
		var zipCodeField = document.getElementById(this.zipCodeFieldId);
		var stateCodeSelect = document.getElementById(this.stateCodeSelectId);
		if (this.isNumeric(zipCodeField.value) || this.isSelected(stateCodeSelect.selectedIndex)) {
            this.overlayedLoadingPanel.show();
            this.submitForm();
			return false;
		} else {
			this.displayMessage(this.errorDivId, this.zipCodeValidationErrorMessage);
			zipCodeField.focus();
			zipCodeField.select();
			return false;
		}
	}

    this.isNumeric = function(value) {
		var isNotNull = this.isNotNull(value);
		var matchesPattern = value.toString().match(/\d{5}/);
		return isNotNull && matchesPattern;
	}

	this.isNotNull = function(value){
		return value != null;
	}

	this.isSelected = function(index){
		return index >= 1;
	}

	this.displayMessage = function(errorDivId, message) {
		document.getElementById(errorDivId).style.display = 'block';
		document.getElementById(errorDivId).innerHTML = message;
	}

	this.submitForm = function(action) {
		if(action){
			document.getElementById(this.formId).action = action;
		}
		document.getElementById(this.formId).submit();
	}
}