function submitIt(temp_form) {
	if(!temp_form)
		temp_form=document.form;
	if(validatePage(temp_form))
		temp_form.submit();
}

function submitItSchool(temp_form) {
	if(!temp_form)
		temp_form=document.form;
	if(validatePageSchool(temp_form))
		search_form.submit();
}

function submitItProduct(temp_form)
{
	if(!temp_form)
		temp_form=document.form;
	if(validatePageProduct(temp_form))
		temp_form.submit();
}

function validatePageProduct(temp_form)
{
	if(!temp_form)
		temp_form=document.form;
	if(temp_form.search_product.value == '')	
	{
		showError("Please select a product category for the search");
		return false
	}	
	return true;
}

function submitItAssociation(temp_form)
{
	if(!temp_form)
		temp_form=document.form;
	if(validatePageAssociation(temp_form))
		temp_form.submit();
}

function validatePageAssociation(temp_form)
{
	return true;
}

function validatePageSchool(search_form)
{
	return validate_search_practice(search_form)&&validate_search_zip(search_form);
}

function validatePage(temp_form)
{
	if(!temp_form)
		temp_form=document.form;
	return validate_search_practice(temp_form)&&validate_search_suburb_zip(temp_form)&&validate_search_code(temp_form);
}

function validate_search_practice(temp_form)
{
	if(!temp_form)
		temp_form=document.form;
	if(temp_form.search_practice.value == '')	
	{
		showError("Please select a practice for the search");
		return false
	}	
	return true;
}

function validate_search_state(temp_form)
{
	if(!temp_form)
		temp_form=document.form;
		
	if(temp_form.search_state.value == '')	
	{
		showError("Please Enter a State for the search");
		return false
	}	
	return true;
}
function validate_search_code(temp_form)
{
	if(!temp_form)
		temp_form=document.form;
	if(temp_form.search_code.value == '')	
	{
		showError("Please specify if you are searching for a practitioner or a college");
		return false
	}	
	return true;
}

function validate_search_zip(temp_form)
{
	if(!temp_form)
		temp_form=document.form;
	if(temp_form.search_zip.value == '')	
	{
		showError("Please enter a valid postcode for the search");
		return false;
	}

	return true;
}

function validate_search_suburb_zip(temp_form)
{
	if(!temp_form) {
		temp_form=document.form;
	}	
	
	if(temp_form.search_zip.value.length < 3)	
	{
		showError("Please enter more than 3 character for a suburb or a valid Australian postcode");
		return false;
	}
	
	if(temp_form.search_zip.value =="NSW" )	
	{
		showError("Please enter a suburb or valid postcode for the search");
		return false;
	}
	
	if(temp_form.search_zip.value =="VIC" )	
	{
		showError("Please enter a suburb or valid postcode for the search");
		return false;
	}
	if(temp_form.search_zip.value =="QLD" )	
	{
		showError("Please enter a suburb or valid postcode for the search");
		return false;
	}
	
	if(temp_form.search_zip.value.substr(0,2) == '--')	
	{
		showError("Please enter a suburb or valid postcode for the search");
		return false;
	}

	return true;
}

function validate_check_isnumeric_search_zip(temp_form)
{
	if(!temp_form)
		temp_form=document.form;
	if(temp_form.search_zip.value == '')	
	{
		showError("Please enter a valid postcode for the search");
		return false;
	}	
	else if(!isNumeric(temp_form.search_zip.value))	
	{
		showError("Please enter a valid postcode for the search");
		return false
	}
	
	return true;
}

function setLocationButton(loctype){
	
	
	num_loctype = document.form.loctype.length;
	for(i=0;i<num_loctype;i++)
	{
		compare_value = "search_" + document.form.loctype[i].value;
		if(compare_value == loctype.name)
		{
			document.form.loctype[i].checked = true;
		}
		else
		{
			//erase all other lists
			if(eval("document.form.search_" + document.form.loctype[i].value))
			{
				eval("document.form.search_" + document.form.loctype[i].value + ".value=''");
			}
			
		}
	}
	
}

function  isNumeric( strValue ) {

  var objRegExp  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;

  //check for numeric characters
  return objRegExp.test(strValue);
}