function checkMBIFields() 
{
var alertmessage = ""
var i = 1;
var sLength = document.enquire.email.value.length;
var sEmail = document.enquire.email.value
var sTel = document.enquire.telephone.value
var sName = document.enquire.name.value
	
	if (sName.length < 1) {
		alertmessage += "  You have not entered your name\n";
	}

	if(!isTelephone(sTel))	{
		alertmessage += "  You have not entered a valid telephone number.\n"
	}

	if(!isEmail(sEmail))	{
		alertmessage += "  You have not entered a valid email address.\n"
	}

	if(alertmessage.length>1)
	{
		//alertmessage += "\n- You cannot proceed without correcting the above fields.";
		alert("You cannot proceed without correcting the above fields.\n\n" + alertmessage);
		return false;		
	}
	else
	{
		return true;		
	}
}

function checkFields() 
{
var alertmessage = ""
var i = 1;
var sLength = document.enquire.email.value.length;
var sEmail = document.enquire.email.value
var sTel = document.enquire.telephone.value
var sSector = document.enquire.sector.value
var sEnquiry_Details = document.enquire.enquiry_details.value
var sName = document.enquire.name.value
	
	if (sName.length < 1) {
		alertmessage += "  You have not entered your name\n";
	}

	if (sEnquiry_Details.length < 1) {
		alertmessage += "  You have not entered any enquiry details\n";
	}

	if (sSector.length < 1) {
		alertmessage += "  You have not entered your industry sector\n";
	}
		
	if(!isTelephone(sTel))	{
		alertmessage += "  You have not entered a valid telephone number.\n"
	}

	if(!isEmail(sEmail))	{
		alertmessage += "  You have not entered a valid email address.\n"
	}

	if(alertmessage.length>1)
	{
		//alertmessage += "\n- You cannot proceed without correcting the above fields.";
		alert("You cannot proceed without correcting the above fields.\n\n" + alertmessage);
		return false;		
	}
	else
	{
		return true;		
	}
}


function isTelephone(sTel)	{
	
	if(sTel.length > 6)	{		
		return true;
	}
	else
	{
		return false;
	}
}

function isEmpty(inputStr)	{
	
	if((inputStr == null) || (inputStr.length == 0) || (inputStr == ""))	{
		return true
	}
	return false
}

function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return false;
       else return (isEmail.arguments[1] == true);
    
    // there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
    
    var i = 1;
    var sLength = s.length;

    // look for @
    while ((i < sLength) && (s.charAt(i) != "@"))
    { i++
    }

    if ((i >= sLength) || (s.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < sLength) && (s.charAt(i) != "."))
    { i++
    }

    // there must be at least one character after the dot
    if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
    else return true;
}

