     function formvalid(){
     // Make quick references to our fields

	 var receive = document.getElementById('receive_copy');
	 var authority = document.getElementById('authority');
	 var title = document.getElementById('title');
	 var firstname = document.getElementById('firstname');
	 var surname = document.getElementById('surname');
	 var position = document.getElementById('position');
	 var company_name = document.getElementById('company_name');
	 var address1 = document.getElementById('address1');
	 var town = document.getElementById('town');
	 var county = document.getElementById('county');
	 var post_code = document.getElementById('post_code');
	 var email = document.getElementById('email');
	 var piq = document.getElementById('piq');

	// alert(receive + "\n" + authority + "\n" + title);return false;
	//alert("Eek!");return false;     
// Check each input in the order that it appears in the form.
     if(isChecked(receive, "In order to receive regular copies of FMJ you must tick the appropriate box.\nIf you are receiving the magazine already and wish to be deleted from our mailing list, please e-mail your details to Angela.White@mpp.co.uk")){
      if(isRadioChecked(authority,"Plese select Yes or No to Are you involved in specifying, authorizing or purchasing.")){
       if(madeSelection(title,"Please select an appropriate title from the drop-down list")){
        if(notEmpty(firstname, "Please enter your firstname - letters only")){
         if(notEmpty(surname, "Please enter your surname - letters only")){
          if(notEmpty(position, "Please enter your company position")){
           if(notEmpty(company_name, "Please enter your Company Name")){
            if(notEmpty(address1, "Please enter your Company Address")){
             if(notEmpty(town, "Please enter the town of your Company Addresss")){
              if(notEmpty(county, "Please enter the county of your Company Addresss")){
               if(isAlphanumeric(post_code, "Please enter Post Code of your Company Address")){
                if(emailValidator(email, "Please enter a valid email address")){
                 if(madeSelection(piq,"Please complete the Personal Identifying Question BEFORE submitting your registration")){
                     isRadioValue(authority,"yes","Unfortunately, under the strict rules of the audit for this magazine, we are unable to qualify you for free readership\n\nIf you would like to take a paid subscription instead, please download the subscription form located at the bottom of this page, complete and fax it back to us.\n\nIf you have any further questions, please contact us on\n Tel: 020 8298 6490 ext 209");
		     return true;
                 }
                }
               }
              }
             }
            }
           }
          }
         }
        }
       }
      }
     }
     return false;
 }

     function notEmpty(elem, helperMsg){
	 if(elem.value.length == 0){
	     alert(helperMsg);
	     elem.focus(); // set the focus to this input
	     return false;
	 }
	 return true;
     }

function isNumeric(elem, helperMsg){
    var numericExpression = /^[0-9]+$/;
    if(elem.value.match(numericExpression)){
	return true;
    }else{
	alert(helperMsg);
	elem.focus();
	return false;
    }
}

function isAlphabet(elem, helperMsg){
    var alphaExp = /^[ a-zA-Z]+$/;
    if(elem.value.match(alphaExp)){
	return true;
    }else{
	alert(helperMsg);
	elem.focus();
	return false;
    }
}

function isAlphanumeric(elem, helperMsg){
    var alphaExp = /^[ 0-9a-zA-Z]+$/;
    if(elem.value.match(alphaExp)){
	return true;
    }else{
	alert(helperMsg);
	elem.focus();
	return false;
    }
}

function lengthRestriction(elem, min, max){
    var uInput = elem.value;
    if(uInput.length >= min && uInput.length <= max){
	return true;
    }else{
	alert("Please enter between " +min+ " and " +max+ " characters");
	elem.focus();
	return false;
    }
}

function madeSelection(elem, helperMsg){
    if(elem.value == "Please Choose"){
	alert(helperMsg);
	elem.focus();
	return false;
    }else{
	return true;
    }
}

function isNo(elem, helperMsg){
    if(elem.value == "no"){
	alert(helperMsg);
	elem.focus();
	return false;
    }else{
	return true;
    }
}

function isRadioValue(elem,val, helperMsg){
    var inputs = elem.getElementsByTagName('input');
    for (var i=0; i < inputs.length; i++)
	{
	    if (inputs[i].checked)
		{
		    var value = inputs[i].value;
		}
	}
    if( value != val ){
	alert(helperMsg);
	elem.focus();
	return false;
    }else{
	return true;
    }
}

function isRadioChecked(elem, helperMsg){
    var inputs = elem.getElementsByTagName('input');
    var checked = false;
    for (var i=0; i < inputs.length; i++)
        {
            if (inputs[i].checked)
                {
                    checked = true;
                }
        }
    if( checked == false ){
        alert(helperMsg);
        elem.focus();
        return false;
    }else{
        return true;
    }
}


function isChecked(elem, helperMsg){
    if(elem.checked == false ){
	alert(helperMsg);
	elem.focus();
	return false;
    }else{
	return true;
    }
}

function emailValidator(elem, helperMsg){
    var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
    if(elem.value.match(emailExp)){
	return true;
    }else{
	alert(helperMsg);
	elem.focus();
	return false;
    }
}


function noAuthority() {
    alert('Unfortunately, under the strict rules of the audit for this magazine, we are unable to qualify you for free readership\n\nIf you would like to take a paid subscription instead, please download the subscription form located at the bottom of this page, complete and fax it back to us.\n\nIf you have any further questions, please contact us on\n Tel: 020 8298 6490 ext 209');
    return false;
}

