function checkContent2( field )
{
	var hinputSearchType = document.getElementById('hinputSearchType2');
	var input_searchstr = document.getElementById('input_searchstr2');
	var a_dd = document.getElementById('a_dd');
	var isUSZip = validateUSZip( field );
	
	if(isUSZip)
	{
		hinputSearchType.value = "zip";
	}
	else
	{
		alert('This is not a valid US zipcode please check your input and try again.');
		clearText(input_searchstr);
	}		
}

function on_select_area2()
{
	var hinputSearchType = document.getElementById('hinputSearchType2');
	var hinputSearchstr = document.getElementById('hinputSearchstr2');
	var a_dd = document.getElementById('a_dd2');
	var z_dd = document.getElementById('z_dd2');
	
	hinputSearchType.value = "area";
	hinputSearchstr.value = a_dd[a_dd.selectedIndex].value;
	z_dd.options[0].selected = true;
}

function on_select_zip2()
{
	var hinputSearchType = document.getElementById('hinputSearchType2');
	var hinputSearchstr = document.getElementById('hinputSearchstr2');
	var a_dd = document.getElementById('a_dd2');
	var z_dd = document.getElementById('z_dd2');
		
	hinputSearchType.value = "zip";
	hinputSearchstr.value = z_dd[z_dd.selectedIndex].value;
	a_dd.options[0].selected = true;
}

function clearText2( field )
{
	if (field.defaultValue == field.value) field.value = '';
	else if (field.value == '') field.value = field.defaultValue;
}

function validateUSZip2( field ) 
{
	var isValid = /^[0-9]{5}(?:-[0-9]{4})?$/.test(field.value);
	
	if (isValid)
	{
		return true;
	}
	else
	{
		return false;
	}

}

function checkContent( field )
{
	var hinputSearchType = document.getElementById('hinputSearchType');
	var input_searchstr = document.getElementById('input_searchstr');
	var a_dd = document.getElementById('a_dd');
	var isUSZip = validateUSZip( field );
	
	if(isUSZip)
	{
		hinputSearchType.value = "zip";
	}
	else
	{
		alert('This is not a valid US zipcode please check your input and try again.');
		clearText(input_searchstr);
	}		
}

function on_select_area()
{
	var hinputSearchType = document.getElementById('hinputSearchType');
	var hinputSearchstr = document.getElementById('hinputSearchstr');
	var a_dd = document.getElementById('a_dd');
	var z_dd = document.getElementById('z_dd');
	
	hinputSearchType.value = "area";
	hinputSearchstr.value = a_dd[a_dd.selectedIndex].value;
	z_dd.options[0].selected = true;
}

function on_select_zip()
{
	var hinputSearchType = document.getElementById('hinputSearchType');
	var hinputSearchstr = document.getElementById('hinputSearchstr');
	var a_dd = document.getElementById('a_dd');
	var z_dd = document.getElementById('z_dd');
		
	hinputSearchType.value = "zip";
	hinputSearchstr.value = z_dd[z_dd.selectedIndex].value;
	a_dd.options[0].selected = true;
}

function clearText( field )
{
	if (field.defaultValue == field.value) field.value = '';
	else if (field.value == '') field.value = field.defaultValue;
}

function validateUSZip( field ) 
{
	var isValid = /^[0-9]{5}(?:-[0-9]{4})?$/.test(field.value);
	
	if (isValid)
	{
		return true;
	}
	else
	{
		return false;
	}

}
