function checkNext(field, next, e)
	{
	field=$(field);
	next=$(next);
	if(e.code >= 33 && e.code <= 126 && e.code != 39 && e.code != 37 )
		{
		if(field.value.length >= field.maxLength)
			{
			next.focus(); 
			e.stop(); 
			}
		}
	}


window.addEvent("domready", function()
	{
	var total = $("order_total");
	if(total != null)
		{
		var updateTotal = function(e)
			{
			var items = 0; 
			$$("input[name^=order_]").each(function(item)
				{
				if(item.name == "order_total" || item.name == 'order_referrer') return;
				var itemValue = item.value * 1;
				if(itemValue > 0)
					items += itemValue; 
				});
			total.value = items;
			}.bind(total); 

		$$("input[name^=order_]").each(function(item)
			{
			if(item.name == "order_total" || item.name == 'order_referrer') return;
			item.addEvent('keyup', updateTotal); 
			});
		}
	});

window.addEvent("domready", function()
	{
	var countyLookup = function() 
		{
		var city_field = $('info_city');
		if(city_field != null)
			{
			var city = city_field.value;
			if(city.length > 0)
				{
				var jsonRequest = new Request.JSON(
					{
					url: "/includes/location.php",
					onSuccess: function(result)
						{
						if(result)
							$('info_county').value = result.county; 
						}
					}).get({'location': city});
				}

			city_field.addEvent("blur", countyLookup); 
			}
		};
	}); 

