var bABN = false;

function displayABNField(strCountry)
{
	switch(strCountry)
	{
		case "UNITED STATES":
			bABN = false;
			break;
		case "OTHER":
			bABN = false;
			break;
		default:
			bABN = true;
	}
	var field_abn = document.getElementById('field_abn');
	if (bABN) {
		field_abn.style.display = 'block';
	} else {
		field_abn.style.display = 'none';
	}
}

function ValidateRegistration(objForm) {

	var strBaseMessage = new String('Please rectify the following items before submitting the form:\r\n\r\n');
	var strMessage = new String();

	if(objForm.agencymanager.value.length == 0)
		strMessage += 'an agency manager is required\r\n';
		
	if(objForm.agencyname.value.length == 0)
		strMessage += 'an agency name is required\r\n';
		
	if(objForm.phone.value.length == 0)
		strMessage += 'a phone number is required\r\n';
		
	if(objForm.email.value.length == 0)
		strMessage += 'an email address is required\r\n';
		
	else if(!isEmail(objForm.email.value))
		strMessage += 'a valid email address is required\r\n';
		
	if(objForm.agencynumber.value.length == 0)
		strMessage += 'an agency licence number is required\r\n';
		
	if(objForm.licencedbody.value.length == 0)
		strMessage += 'an licence body is required\r\n';
		
	if(objForm.locationaddress1.value.length == 0)
		strMessage += 'a location address is required\r\n';
		
	if(objForm.locationcity.value.length == 0)
		strMessage += 'a location city is required\r\n';
		
	if(objForm.locationstate.value.length == 0 && blnState)
		strMessage += 'a location state is required\r\n';
		
	if(objForm.locationcountry.value.length == 0)
		strMessage += 'a location country is required\r\n';

	if(objForm.agencyabn.value.length == 0 && bABN)
		strMessage += 'ABN/VAT is required\r\n';

	if(objForm.agencyabn.value.length == 0 && blnABN)
		strMessage += 'ABN/VAT is required\r\n';
		
	else if(!blnABN)
		objForm.agencyabn.value = '';
		
	if(objForm.locationpostcode.value.length == 0)
		strMessage += 'a location zip/postcode is required\r\n';
		
	if(objForm.username.value.length == 0)
		strMessage += 'a username is required\r\n';
		
	if(objForm.password.value.length == 0)
		strMessage += 'a password is required\r\n';
		
	else if(objForm.confirmpassword.value != objForm.password.value)
		strMessage += 'the password and confirmed password do not match\r\n';
		
	if(strMessage.length == 0)
		return true;
	else {
		alert(strBaseMessage + strMessage);
		return false;
	}

}
