function select_state()
{
	if(document.myform.state)
	{
			indx = document.myform.state.selectedIndex;
			if(indx == 0)
			{
				alert('Please select a state.');
			}
			else
			{
				if(document.myform.zone)
				{
					document.myform.zone.selectedIndex = 0;
				}
				if(document.myform.zip)
				{
					document.myform.zip.value = '';
				}
				document.myform.teaserData.value='state='+document.myform.state.options[indx].value;
				document.myform.buttonAction.value = '';
				document.myform.submit();
			}
	}
}		

function select_zone2()
{
	if(document.myform.zone)
	{
			var zone_val = '';
			var zips_val = '';
			
			indx = document.myform.zone.selectedIndex;
			zone_val = document.myform.zone.options[indx].value;
			
			if(document.myform.zips)
			{
				zips_val = document.myform.zips.value;
			}
			
			if(indx == 0)
			{
				alert('Please Select A City');
			}
			else
			{
				document.myform.teaserData.value='zip='+document.myform.zip.value+'&zone='+zone_val+'&zips='+zips_val;
				document.myform.buttonAction.value = '';
				document.myform.submit();
			}
	}
}

function select_zone()
{
	if(document.myform.zone)
	{
			var zips_val = '';
			var state_val = '';
			var zone_val = '';

			indx = document.myform.zone.selectedIndex;
			zone_val = document.myform.zone.options[indx].value;

			if(document.myform.zips)
			{
				zips_val = document.myform.zips.value;
			}
			if(document.myform.state)
			{
				state_indx = document.myform.state.selectedIndex;
				state_val = document.myform.state.options[state_indx].value;
			}
			if(indx == 0)
			{
				alert('Please select a region.');
			}
			else
			{
				if(document.myform.zip)
				{
					document.myform.zip.value = '';
				}
				document.myform.teaserData.value='state='+state_val+'&zone='+zone_val+'&zips='+zips_val;
				document.myform.buttonAction.value = '';
				document.myform.submit();
			}
	}
}

function delete_zip(zipcode)
{
	var new_zips_val = '';

	if(document.myform.zips)
	{
			zips_val = document.myform.zips.value;

			z_array = new Array();
			z_array = zips_val.split(',');

			for(i=0;i<z_array.length;i++)
			{
				if(z_array[i] != zipcode)
				{
					if(new_zips_val == ''){ new_zips_val = z_array[i]; }
					else{ new_zips_val +=','+z_array[i]; }
				}	
			}

			document.myform.zips.value = new_zips_val;
			document.myform.teaserData.value='zips='+new_zips_val;
			document.myform.buttonAction.value = '';
			document.myform.submit();
	}
}

function select_state_extended()
{
	if(document.myform.state)
	{
			indx = document.myform.state.selectedIndex;
			if(indx == 0)
			{
				alert('Please select a state.');
			}
			else
			{
				if(document.myform.zone)
				{
					document.myform.zone.selectedIndex = 0;
				}
				if(document.myform.zip)
				{
					document.myform.zip.value = '';
				}
				document.myform.teaserData.value='zip='+document.myform.state.options[indx].value;
				document.myform.buttonAction.value = '';
				document.myform.submit();
			}
	}
}

function select_zip_extended()
{
	var error = 0;
	if(document.myform.zip)
	{
		zip_val = document.myform.zip.value;

		if( zip_val.match(/[^0-9]/) )
		{
			error = 1;
		}
		if( zip_val.match(/[^a-zA-Z]/) )
		{
		
			if(error == 0)
			{	
				if(document.myform.zip.value == '' || document.myform.zip.value.length > 7)
				{
					alert("Please provide 7 digit zipcode.");
					return;
				}
			}
			if( error )
			{
				alert("Pleaser provide a valid zipcode.");
			}
			else
			{
				if(document.myform.teaserData)
				{
					document.myform.teaserData.value= 'zip='+zip_val;
				}
				document.myform.submit();
			}
		}
		else 
		{
				if(document.myform.teaserData)
				{
					document.myform.teaserData.value= 'zip='+zip_val;
				}
				document.myform.submit();
		}
	}
}

function select_zone_extended()
{
	if(document.myform.zone)
	{
			var state_val = '';
			var zone_val = '';

			indx = document.myform.zone.selectedIndex;
			zone_val = document.myform.zone.options[indx].value;

			if(document.myform.state)
			{
				state_indx = document.myform.state.selectedIndex;
				state_val = document.myform.state.options[state_indx].value;
			}
			if(indx == 0)
			{
				alert('Please select a region.');
			}
			else
			{
				document.myform.teaserData.value='state='+state_val+'&zone='+zone_val;
				document.myform.buttonAction.value = '';
				document.myform.submit();
			}
	}
}

function select_zip()
{
	var error = 0;
	if(document.myform.zip)
	{
		zip_val = document.myform.zip.value;
		zips_val = '';

		if(document.myform.zips)
		{
			zips_val = document.myform.zips.value;
		}
	
		if( zip_val.match(/[^0-9]/) )
		{
			error = 1;
		}
		if( zip_val.match(/[^a-zA-Z]/) )
		{
		
			if(error == 0)
			{	
				if(document.myform.zip.value == '' || document.myform.zip.value.length > 7)
				{
					alert("Please provide 7 digit zipcode.");
					return;
				}
			}
			if( error )
			{
				alert("Pleaser provide a valid zipcode or city name.");
			}
			else
			{
				
				document.myform.teaserData.value='zip='+document.myform.zip.value+'&zips='+zips_val;
				document.myform.buttonAction.value = '';
				document.myform.submit();
			}
		}
		else 
		{
				document.myform.teaserData.value='zip='+document.myform.zip.value+'&zips='+zips_val;
				document.myform.buttonAction.value = '';
				document.myform.submit();
		}
	}
}

function viewRadar(url)
{
	ret = window.open(url,"radar", "toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=yes,width=700,height=700");
	ret.focus();
}
