
function validate()
{
	if((document.contactf.c_first_name.value)=='')
	{
		alert('Please Enter the First Name');
		document.contactf.c_first_name.focus();
		return false;
	}
	
	//if((document.contactf.company_name.value)=='')
	//{
		//alert('Please Enter Company Name');
		//document.contactf.company_name.focus();
		//return false;
	//}
	
	if((document.contactf.c_email.value)=='')
	{
		alert('Please Enter E-mail Address');
		document.contactf.c_email.focus();
		return false;
	}
	
	if((document.contactf.Country.value)=='')
	{
		alert('Please Enter the Address');
		document.contactf.Country.focus();
		return false;
	}
	
	if((document.contactf.tel.value)=='')
	{
		alert('Please Enter Contact No.');
		document.contactf.tel.focus();
		return false;
	}
	
	if (!validateEmail(document.contactf.c_email.value,1,1)) 
	{
		return false;
	}
}



function validateEmail(addr,man,db) {
if (addr == '' && man) {
   if (db) alert('E-mail address is mandatory');
   return false;
}
if (addr == '') return true;
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('E-mail address contains invalid characters');
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert("E-mail address contains non ascii characters.");
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert('E-mail address must contain an @');
   return false;
}
if (atPos == 0) {
   if (db) alert('E-mail address must not start with @');
   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert('E-mail address must contain only one @');
   return false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert('E-mail 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 E-mail address');
   return false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert('Period must not immediately precede @ in E-mail address');
   return false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert('Two Periods must not be adjacent in E-mail address');
   return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
   if (db) alert('Invalid Primary Domain in E-mail address');
   return false;
}
return true;
}
