function validateEmail(addr,db) {



var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';

for (i=0; i<invalidChars.length; i++) {

   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {

      if (db) alert('email address contains invalid characters');

      return false;

   }

}

for (i=0; i<addr.length; i++) {

   if (addr.charCodeAt(i)>127) {

      if (db) alert("email address contains non ascii characters.");

      return false;

   }

}



var atPos = addr.indexOf('@',0);

if (atPos == -1) {

   alert('email address must contain an @');

   return false;

}

if (atPos == 0) {

   if (db) alert('email address must not start with @');

   return false;

}

if (addr.indexOf('@', atPos + 1) > - 1) {

   if (db) alert('email address must contain only one @');

   return false;

}

if (addr.indexOf('.', atPos) == -1) {

   if (db) alert('email address must contain a period in the domain name');

   return false;

}

if (addr.indexOf('@.',0) != -1) {

   if (db) alert('period must not immediately follow @ in email address');

   return false;

}

if (addr.indexOf('.@',0) != -1){

   if (db) alert('period must not immediately precede @ in email address');

   return false;

}

if (addr.indexOf('..',0) != -1) {

   if (db) alert('two periods must not be adjacent in email address');

   return false;

}



return true;

}



function uf_check(theForm)

{

	



	if(theForm.txt_name.value  == "")

	{

		alert('Please enter a value for the Name field.');

		theForm.txt_name.focus();

		return false;

	}

	

	if(theForm.txt_email.value == "")

	{

		alert('Please enter a value for the Email field');

		theForm.txt_email.focus();

		return false;

	}

	else

	{

		if(validateEmail(theForm.txt_email.value,1) == false)

		{

			theForm.txt_email.focus();

			return false;

		}

	}

	

	

	if(theForm.txt_company_name.value == "")

	{

		alert('Please enter a value for the Company Name field.');

		theForm.txt_company_name.focus();

		return false;

	}

	

	if(theForm.txt_company_phone.value == "")

	{

		alert('Please enter a value for the Company tel. no. field.');

		theForm.txt_company_phone.focus();

		return false;

	}

		

	if(theForm.txt_company_address.value == "")

	{

		alert('Please enter a value for the Company Address field.');

		theForm.txt_company_address.focus();

		return false;

	}

	

	if(theForm.txt_company_fax.value == "")

	{

		alert('Please enter a value for the Company Fax field.');

		theForm.txt_company_fax.focus();

		return false;

	}

	



	return true;

	

} 


