
// Regular expression that validates a value is numeric
// Return true or false
function isNumeric(x)
{
	// compare the argument to the RegEx. The 'match' function returns 0 if the value doesn't match
	var RegExp = /^[-+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?$/; // Note: this WILL allow a number that ends in a decimal: -452.
	return !!x.match(RegExp);
}


function processForm(frmName)
{
	objForm = document.forms[frmName];

	if ( objForm.Category.value=="" ) {
		alert("Please choose a category");
		return false;
	}

	if ( objForm.Category.value=="Physiotherapy" ) {
		if (isNumeric(objForm.Postcode.value) || objForm.Postcode.value.length<2) {
			alert("Please enter a valid town or suburb name");
			return false;
		}
		postcodePopupURL("http://storefinder.1300physio.com/index.php?region=" + escape(objForm.Postcode.value)); 
		return false;
	}
	
	if (!isNumeric(objForm.Postcode.value) || objForm.Postcode.value.length<3 || objForm.Postcode.value<100 || objForm.Postcode.value>9999) {
		alert("Please enter a valid postcode");
		return false;
	}
	
	return true;
}


function SelectionMade(frmName)
{
	objForm = document.forms[frmName];

	if ( objForm.Category.value=="" ) {
		document.getElementById('step2').style.display = 'none';
		return;
	}
	else {
		document.getElementById('step2').style.display      = 'inline';	
		document.getElementById('non_physio').style.display = (objForm.Category.value=="Physiotherapy") ? 'none' : 'inline';
		document.getElementById('physio').style.display     = (objForm.Category.value!="Physiotherapy") ? 'none' : 'inline';
		document.getElementById('physioLogo').style.display = (objForm.Category.value!="Physiotherapy") ? 'none' : 'inline';

	}
}

