// function selectValue
//
// Returns the index of a select field for a given select controls id. 
// If control is a multiselect it will return only the highest numbered selected index.
// If no items have been selected -1 will be returned
function selectValue(strId) {
	selectControl = document.getElementById(strId);
	intSelected = -1;

	for (var i=0; i<selectControl.options.length; i++) {
		if(selectControl.options[i].selected == true) {
			intSelected = i;
		}
	}

	return intSelected;
}


// function verify
//
// Called when a form submit is actioned
// Checkes form values and if they meet criteria submission continues as normal, if conditions 
// fail form submission is cancelled and user is informed via an alert message
function verify(){
	if(selectValue("addtown") > 0 & selectValue("addarea") > 0) {
        alert("Please only select a town or area before performing a search.");
	        return false;
    }
    else {
	        return true;
    }
}
