//*******************************************************************************************************
// Validate the register form
function validate_frm_register()
{
	valid = true;

    if ( document.frm_register.FirstName.value == "" )
    {
        alert ( "Please fill in the 'Your Name' box." );
		document.frm_register.FirstName.focus();
        return false;
    }
	else if ( document.frm_register.SecondName.value == "" )
	{
		alert ( "Please fill in the 'Your Second Name' box." );
        document.frm_register.SecondName.focus();
		return false;
	}
	else if ( document.frm_register.Company.value == "" )
	{
		alert ( "Please fill in the 'Company' box." );
        document.frm_register.Company.focus();
		return false;
	}
	else if ( document.frm_register.Postcode.value == "" )
	{
		alert ( "Please fill in the 'Postcode' box." );
        document.frm_register.Postcode.focus();
		return false;
	}
	else if ( document.frm_register.Terms.checked == false  )
	{
		alert ( "Please check the tick box to confirm you have read and agree to our terms and conditions." );
        document.frm_register.Terms.focus();
		return false;
	}

    return valid;
}

//*******************************************************************************************************
// Validate the contact form
function validate_frm_contact()
{
	valid = true;

    if ( document.frm_contact.Name.value == "" )
    {
        alert ( "Please fill in the 'Your Name' box." );
		document.frm_contact.Name.focus();
        return false;
    }
	else if ( document.frm_contact.Message.value == "" )
	{
		alert ( "Please fill in the 'Message' box." );
        document.frm_contact.Message.focus();
		return false;
	}
	else if ( document.frm_contact.Email.value == "" )
	{
		alert ( "Please fill in the 'Your Email' box." );
        document.frm_contact.Email.focus();
		return false;
	}
	
    return valid;
}


//*******************************************************************************************************
// Validate the membership form
function validate_frm_membership()
{
	valid = true;

    if ( document.frm_membership.FirstName.value == "" )
    {
        alert ( "Please fill in the 'Your Name' box." );
		document.frm_membership.FirstName.focus();
        return false;
    }
	else if ( document.frm_membership.Surname.value == "" )
	{
		alert ( "Please fill in the 'Your Second Name' box." );
        document.frm_membership.Surname.focus();
		return false;
	}
	else if ( document.frm_membership.JobTitle.value == "" )
	{
		alert ( "Please fill in the 'Job title' box." );
        document.frm_membership.JobTitle.focus();
		return false;
	}
	else if ( document.frm_membership.Company.value == "" )
	{
		alert ( "Please fill in the 'Company' box." );
        document.frm_membership.Company.focus();
		return false;
	}
	else if ( document.frm_membership.Tel.value == "" )
	{
		alert ( "Please fill in the 'Telephone' box." );
        document.frm_membership.Tel.focus();
		return false;
	}
	else if ( document.frm_membership.Postcode.value == "" )
	{
		alert ( "Please fill in the 'Postcode' box." );
        document.frm_membership.Postcode.focus();
		return false;
	}	

    return valid;
}




//*******************************************************************************************************
// CHECK if real email
function echeck(str) {

	var message = "Please make sure you enter a valid email address.";
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert(message)
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert(message)
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert(message)
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert(message)
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert(message)
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert(message)
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert(message)
		return false
	 }

	 return true					
}

function alertMessage(myMessage)
{
	alert (myMessage);
	return false;
}