﻿function validate()
{			
	txtZip = document.getElementById("txtZip");			
	txtPhone = document.getElementById("txtPhone");			
	divLblErrorMessageGeneral = document.getElementById("lblErrorMessageGeneral");
	divLblErrorMessageZipCodeInvalid = document.getElementById("lblErrorMessageZipCodeInvalid");
	divLblErrorMessagePhoneNumberInvalid = document.getElementById("lblErrorMessagePhoneNumberInvalid");
	divLblErrorMessageGeneral.className = 'nodisplay';	
	
	if (txtZip != null && !txtZip.value.match('^[A-Za-z]{1,2}[0-9A-Za-z]{1,2}[ ]?[0-9]{0,1}[A-Za-z]{2}$')) 	
	{
			if (divLblErrorMessageGeneral != null)
			{
				divLblErrorMessageGeneral.className = 'error';
			}
			if (divLblErrorMessageZipCodeInvalid != null)
			{
				divLblErrorMessageZipCodeInvalid.className = 'error';
			}
			if (divLblErrorMessagePhoneNumberInvalid != null)
			{
				divLblErrorMessagePhoneNumberInvalid.className = 'nodisplay';
			}			
			document.location.href = '#top';
			return false;
	}
	
	if (txtPhone != null && !txtPhone.value.match('(\s*\(?0\d{4}\)?\s*\d{6}\s*)|(\s*\(?0\d{3}\)?\s*\d{3}\s*\d{4}\s*)')) 
	{
			if (divLblErrorMessageGeneral != null) 
			{
				divLblErrorMessageGeneral.className = 'error';
			}
			if (divLblErrorMessageZipCodeInvalid != null)
			{
				divLblErrorMessageZipCodeInvalid.className = 'nodisplay';
			}
			if (divLblErrorMessagePhoneNumberInvalid != null)
			{
				divLblErrorMessagePhoneNumberInvalid.className = 'error';
			}
			document.location.href = '#top';
			return false;
	} 		
	
	return true;
}	