	function trim(str)
	{
	   return str.replace(/^\s*|\s*$/g,"");
	}
	
	function validate_form()
	{
		valid = true;
		err_msg = '';
		if ( trim(document.add_agency.AgencyName.value) == '' )
		{
			err_msg += 'Please enter the Agency Name.\n';
		    valid = false;
		}
		if ( trim(document.add_agency.AgentName.value) == '' )
		{
			err_msg += 'Please enter the Agent Name.\n';
		    valid = false;
		}
		if ( document.add_agency.AgencyProvince.selectedIndex < 1 )
		{
			err_msg += 'Please select the Province.\n';
		    valid = false;
		}
		if ( trim(document.add_agency.Town.value) == '' )
		{
			err_msg += 'Please enter Town / Suburb.\n';
		    valid = false;
		}
		if ( trim(document.add_agency.Email.value) == '' )
		{
			err_msg += 'Please enter the Email ID.\n';
		    valid = false;
		}
		if ( (trim(document.add_agency.TelephoneNumber.value) == '') && (trim(document.add_agency.Mobile.value) == '') )
		{
			err_msg += 'Please enter your Telphone number or Mobile number.\n';
		    valid = false;
		}
		if ( trim(document.add_agency.UsrName.value) == '' )
		{
			err_msg += 'Please enter the User Name.\n';
		    valid = false;
		}
		if ( trim(document.add_agency.Pasword.value) == '' )
		{
			err_msg += 'Please enter the Password.\n';
		    valid = false;
		}
		if ( document.add_agency.SecretQuestion.selectedIndex < 1 )
		{
			err_msg += 'Please select the Secret Question.\n';
		    valid = false;
		}
		if ( trim(document.add_agency.Answer.value) == '' )
		{
			err_msg += 'Please enter the Answer to the Secret Question.\n';
		    valid = false;
		}
		if (err_msg != '')
		{
			alert(err_msg);
		}		
	    return valid;
	}

