function submitForm() {
	var theForm = document.forms["namesearch"];
		
	theForm["pc"].value = theForm["pc"].value.replace(/\s/g, '').toUpperCase();
	
	var storeObj = theForm["store"];
	var namepart = theForm["namepart"].value;
	var postcode = theForm["pc"].value;
	var productrangeObj = theForm["productrange"];
	var productrange = productrangeObj.options[productrangeObj.selectedIndex].value;
	var store = storeObj.options[storeObj.selectedIndex].value;
		
	if (store == '' && namepart == '' && postcode == '' && productrange == '')
	{
		alert('Please either select a store or enter a partial name or postcode');
		return false;
	}

	if (store != '')
	{
		theForm.action = 'details.asp';
	}
	else if (namepart != '')
	{
		theForm.action = 'results.asp';
	}
	else if (postcode != '')
	{
		if (productrange != '')
		{
			theForm["product"].value = productrangeObj.options[productrangeObj.selectedIndex].text;
			theForm["prno"].value = productrangeObj.options[productrangeObj.selectedIndex].value;
		}
		else
		{
			theForm["product"].value = "";
			theForm["prno"].value = "1 != -1 AND 1";
		}
		
		theForm["coordsys"].value = (postcode.indexOf("BT") == 0) ? "mercator": "gb";
		theForm.action = 'http://www.multimap.com/clients/browse.cgi';
	}
	else if (productrange != '')
	{
		theForm.action = 'results.asp';
	}
	
	void theForm.submit();
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function comboVar(combo) {
	return String(combo.options[combo.selectedIndex].value);
} // function String comboVar(Select combo)

function isPostCode(s) {
	// Convert postcode to upper case
	s += '';
	s  = s.toUpperCase();
	var whitespace = " \t\n\r";

	// Array of valid postcode formats
	var valid = "AANANaa,AANNNaa,AANNaa,ANANaa,ANNNaa,ANNaa".split(",");
	
	// Strip out any whitespace
	var strippedPcode = "";
	for (var ix = 0; ix < s.length; ix++) {
		if (whitespace.indexOf(s.charAt(ix)) < 0) strippedPcode += s.charAt(ix);
	} // for (ix)

	var k;
	for (k = 0; k < valid.length && !postcode_testPattern(strippedPcode, valid[k]); k++);
	if (k >= valid.length) return false;
	return true;
} // public function Boolean isPostCode(Object s)

function postcode_testPattern(c, pattern) {
	// Tests if string c validates against the given pattern
	if (c.length != pattern.length) return false;
	var ix;
	for (ix = c.length-1; ix >= 0 && postcode_testChar(c.charAt(ix), pattern.charAt(ix), ix); ix--);
	return (ix < 0);
} // private function Boolean postcode_testPattern(String c, String pattern)

function postcode_testChar(c, targetType) {
	var types = new Array();
	types["A"] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	types["N"] = "1234567890";
	types["a"] = "ABDEFGHJLNPQRSTUWXYZ";
	return (types[targetType].indexOf(c) > -1);
} // private function Boolean postcode_testChar(String c, String targetType)

function isPostcode(s) {
	return isPostCode(s);
} // public function Boolean isPostcode(Object s)