function validate_contact_form()
{
    
	msg = "";
    valid = true;

    if ( document.contact_form.message.value == "" )
    {
		msg = msg + "You must enter a message.\n";
        valid = false;
    }   
	
    if ( document.contact_form.name.value == "" )
    {
		msg = msg + "You must enter your name.\n";
        valid = false;
    }   	
	
    if ( document.contact_form.captcha_code.value == "" )
    {
		msg = msg + "You must enter the security code.\n";		
        valid = false;
    }   	

	
	if (document.contact_form.email.value != "")
	{
	
		apos = document.contact_form.email.value.indexOf("@");
		dotpos = document.contact_form.email.value.lastIndexOf(".");
		
		if (apos < 1 || dotpos - apos < 2)
		{
			msg = msg + "The email address entered is not valid.\n";		
			valid = false;
		}
		
	}
	
	if(document.contact_form.email.value == "" && document.contact_form.tel.value == "")
    {
		msg = msg + "You must enter either your telephone number or email address.\n";		
        valid = false;
    }   	

	if(valid == false)       
	{
        alert (msg);		
	}
	   

    return valid;
	
}

function validate_mailing_form(){
	
	msg = "";
    valid = true;

    if ( document.mailing_form.email_address.value == "" )
    {
		msg = msg + "You must enter your email address.\n";
        valid = false;
    } 
	
	if(valid == false)       
	{
        alert (msg);		
	}
	   

    return valid;
	
}


function validate_signup(frm) {
    var emailAddress = frm.Email.value;
    var errorString = '';
    if (emailAddress == '' || emailAddress.indexOf('@') == -1) {
            errorString = 'Please enter your email address';
    }


var els = frm.getElementsByTagName('input');
for (var i = 0; i < els.length; i++)
{
if (els[i].className == 'text' || els[i].className == 'date' || els[i].className == 'number')
{
    if (els[i].value == '')
        errorString = 'Please complete all required fields.';
}
else if (els[i].className == 'radio')
{
    var toCheck = document.getElementsByName(els[i].name);
    var radioChecked = false;
    for (var j = 0; j < toCheck.length; j++)
    {
        if (toCheck[j].name == els[i].name && toCheck[j].checked)
            radioChecked = true;
    }
    if (!radioChecked)
        errorString = 'Please complete all required fields.';
}
}



    var isError = false;
if (errorString.length > 0)
    isError = true;

if (isError)
    alert(errorString);
    return !isError;
}

function _dMcA() {
    var dmForm = document.getElementById("signup");
    if (dmForm) {
            dmForm.action = "http://www.dotmailer.co.uk";
    }
}
var dMAd = document.getElementById("dMLink");
if (dMAd) {
    if (dMAd.innerHTML.length < 2) {
            _dMcA();
    }
} else {
    _dMcA();
}

