
var RecaptchaOptions = {
theme: 'clean'
};

function multiselect_validate(select) {
    var valid = false;

    for(var i = 0; i < select.options.length; i++) {

		if(select.options[i].selected) {
            valid = true;
            break;
        }
    }
	if (valid == false) {
		alert("\"Product Interest\" is a mandatory field.\nPlease amend and retry.")
	}
    return valid;
}


function isEmpty(strCompany, strForenames, strSurname, strTelephone) {

	strCompany = document.forms.WEB2LEAD.lead_companyname.value 
	strForenames = document.forms.WEB2LEAD.lead_personfirstname.value
	strSurname = document.forms.WEB2LEAD.lead_personlastname.value
	strTelephone = document.forms.WEB2LEAD.lead_personphonenumber.value

    if (strCompany == "" || strCompany == null || strCompany.charAt(0) == ' ')
    {
	    alert("\"Company Name\" is a mandatory field.\nPlease amend and retry.")
	    return false;
    }

    if (strForenames == "" || strForenames == null || strForenames.charAt(0) == ' ')
    {
	    alert("\"Forename(s)\" is a mandatory field.\nPlease amend and retry.")
	    return false;
    }

    if (strSurname == "" || strSurname == null || strSurname.charAt(0) == ' ')
    {
	    alert("\"Surname\" is a mandatory field.\nPlease amend and retry.")
	    return false;
    }
	
    if (strTelephone == "" || strTelephone == null || strTelephone.charAt(0) == ' ')
    {
	    alert("\"Telephone\" is a mandatory field.\nPlease amend and retry.")
	    return false;
    }
	
    return true;
}


//function to check valid email address
function isValidEmail(strEmail){

  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.WEB2LEAD.lead_personemail.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
      alert('A valid e-mail address is required.\nPlease amend and retry');
      return false;
    } 
    return true; 
}


//function that performs all functions, defined in the onsubmit event handler

function check(form){

//if (multiselect_validate(form.lead_products)){
	if (isEmpty(form.lead_personfirstname)){
		if (isEmpty(form.lead_personlastname)){
			if (isEmpty(form.lead_companyname)){
				if (isEmpty(form.lead_personphonenumber)){
					if (isValidEmail(form.lead_personemail)){
	
						return true;
					}
				}
			}
		}
	}
//}

return false;
}

