function select_zip_current()
{
	for(i=0;i<document.forms.length;++i)
	{
		if(document.forms[i].name == 'zonechoice_current')
		{
			if(document.forms[i].zip)
			{
				if(document.forms[i].zip.value != '')
				{
					var error = check_for_error(document.forms[i].zip.value);
					if(error)
					{
						alert(error);
						break;
					}
					else
					{
						document.forms[i].submit();
						break;
					}
				}//end value check
			}//end zip check
		}//end form name check
	}
}

function check_for_error(zip_val)
{
	var error = 0;

		if( zip_val.match(/[^0-9]/) )
		{
			error = 1;
		}
		if( zip_val.match(/[^a-zA-Z]/) )
		{
			if(error == 0)
			{	
				if(zip_val == '' || zip_val.length > 7)
				{
					return "Please provide 7 digit zipcode.";
				}
			}
			if( error )
			{
				return "Pleaser provide a valid zipcode or city name.";
			}
			else
			{
				return 0;
			}
		}
		else 
		{
				return 0;
		}
}

function extended_redirect()
{
	if(document.zonechoice_current.zone)
	{
		indx = document.zonechoice_current.zone.selectedIndex;
		if(indx == 0)
		{
			alert('Please select a region.');
		}
		else
		{
			zipcode = document.zonechoice_current.zone.options[indx].value;
			url = "/weather/weather_extended.php?zip="+zipcode;
			window.location.replace(url);
		}
	}
}
