function validateEmail(addr,man,db) 
	{
	if (addr == '' && man) 
	{
	  if (db) alert('Please enter a valid email address');
	  return false;
	}
		                                
	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) 
	{
	  if (db) 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;
	}

	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 email address');
	    return false;
	}
	return true;
	} 
	           		
function validateform(formType)
{
    var error = '';
    
    if (formType == 'security') {
    
        if (document.verify.securitycheck.value == ''){
            error = 'Please enter the security code';
            document.getElementById('securitycheck').className='errorformtext';
            document.verify.securitycheck.focus();
        }
        else
	    {
		    document.getElementById('securitycheck').className='inputFields';
	    }
	
	}
	
	else {
	
	    if (document.enquiryform.telephone.value == ''){
		    error = 'Please enter your telephone number';
		    document.getElementById('telephone').className='errorformtext';
		    document.enquiryform.telephone.focus();
	    }
	    else
	    {
		    document.getElementById('telephone').className='inputFields';
	    }

	    if (!validateEmail(document.enquiryform.email.value,1,0)){
		    error = 'Please enter a valid email address';
		    document.getElementById('email').className='errorformtext';
		    document.enquiryform.email.focus();
	    }
	    else
	    {
		    document.getElementById('email').className='inputFields';
	    }
    	
	    if (document.enquiryform.contactname.value == ''){
		    error = 'Please enter your name';
		    document.getElementById('contactname').className='errorformtext';
		    document.enquiryform.contactname.focus();
	    }
	    else
	    {
		    document.getElementById('contactname').className='inputFields';
	    }

	    if (document.enquiryform.packagetype.value == ''){
		    error = 'Please enter the package(s) that you are interested in.\n\nFor further information please open the PDF on this page.';
		    document.getElementById('packagetype').className='errorformtext';
		    document.enquiryform.packagetype.focus();
	    }
	    else
	    {
		    document.getElementById('packagetype').className='inputFields';
	    }

	    if (document.enquiryform.approxnumbers.value == ''){
		    error = 'Please provide the approximate numbers you expect to attend.';
		    document.getElementById('approxnumbers').className='errorformtext';
		    document.enquiryform.approxnumbers.focus();
	    }
	    else
	    {
		    document.getElementById('approxnumbers').className='inputFields';
	    }

	    if (document.enquiryform.preferreddates.value == ''){
		    error = 'Please provide your preferred date(s).';
		    document.getElementById('preferreddates').className='errorformtextArea';
		    document.enquiryform.preferreddates.focus();
	    }
	    else
	    {
		    document.getElementById('preferreddates').className='inputFields';

	    }
	    if (document.enquiryform.companyname.value == ''){
		    error = 'Please provide the name of your society / company.';
		    document.getElementById('companyname').className='errorformtext';
		    document.enquiryform.companyname.focus();
	    }
	    else
	    {
		    document.getElementById('companyname').className='inputFields';
	    }
	
	}
	
	if (error == '')
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}

function validatepasswordform()
{
    var error = '';
    
    if (document.passwordForm.logonemail.value == ''){
	    error = 'Please enter your email address into the box';
	    document.getElementById('logonemail').className='errorformtext';
	    document.passwordForm.logonemail.focus();
    }
    else
    {
	    document.getElementById('logonemail').className='inputFields';
    }
    
    if (error == '')
	{
		return true;
	}
	else
	{
		alert(error);
		return false;
	}
}
