var contactus;
function submitContact() {
    contactus = document.contactus;
	if (isName() && isEmail() && isSubject() && isMessage() && isSecemail() && isPhone() && turingOK())
        return true;
    else
       return false;
}

function isName() {
    if (contactus.name.value == "")
    {
        alert ("Your name is blank. \n\nPlease enter your name.");
        contactus.name.focus();
        return false;
    }
    return true;
}

function isPhone() {
    if (contactus.phone.value == '' || contactus.phone.value >= 1) {
    return true;
    } else {
	alert ("Your phone number is  not numeric. \n\nPlease enter a valid phone number.");
    contactus.phone.focus();
    return false;
	}
    
}

function isSecemail()
{
    if (contactus.sec_email.value == '') {
	var agree=confirm("The secondary email field is blank.\n\nPlease note if your email address is from free email providers such as Yahoo,\nthere may be problems in replying to your request.\n\nClick Cancel to return and enter a secondary contact email or OK to continue.");
	if (agree)
	return true;
	else
	contactus.sec_email.focus();
	return false;
    } else if (contactus.sec_email.value != '' && (contactus.sec_email.value.indexOf ('@',0) == -1 || contactus.sec_email.value.indexOf ('.',0) == -1)) {
	alert ("Your secondary email requires an \"@\" and \".\" to be used. \n\nPlease re-enter your secondary contact email address.");
	contactus.sec_email.select();
	contactus.sec_email.focus();
	return false;
    } else if (contactus.sec_email.value == contactus.email.value) {
	var agree=confirm("The secondary email field is the same as your contact email.\n\nPlease note if your email address is from free email providers such as Yahoo,\nthere may be problems in replying to your request.\n\nClick Cancel to return and enter a different secondary contact email or OK to continue.");
	if (agree)
	return true;
	else
	contactus.sec_email.focus();
	return false;
	}
    return true;
}

function isEmail()
{
    if(contactus.email.value == '')
    {
	 alert ("The email field is blank.\n\nPlease enter your email address.");
	 contactus.email.focus();
	 return false;
    }
    if (contactus.email.value.indexOf ('@',0) == -1 ||
    contactus.email.value.indexOf ('.',0) == -1) {
	alert ("Your email requires an \"@\" and \".\" to be used. \n\nPlease re-enter your email address.");
	contactus.email.select();
	contactus.email.focus();
	return false;
    }
        return true;
}

function isSubject() {
    if (contactus.subject.value == "")
    {
        alert ("The subject is blank. \n\nPlease enter the subject of your contact request.");
        contactus.subject.focus();
        return false;
    }
    return true;
}

function isMessage() {
    if (contactus.comments.value == "")
    {
        alert ("The comments field is blank. \n\nPlease enter your comments.");
        contactus.comments.focus();
        return false;
    }
    return true;
}

function turingOK()
{
	contactus.turing.value = contactus.turing.value.replace(/[^0-9]/gi, "");
	if (contactus.turing.value == "")
    {
        alert ("The Turing Number is blank. \n\nPlease enter the Turing Number.");
        contactus.turing.focus();
        return false;
    }
	else if (contactus.turing.value.length != 4)
	{
		alert ("The Turing Number is incorrect. \n\nPlease re-enter the Turing Number.");
        contactus.turing.focus();
        return false;
	}
    return true;		
}