function isEmailAddress(string) {
    return /^[^@]+@[^.]+(\.[^.]+)+$/.test(string);
}

function validate(form) {
    var noerror = true;
    var invalidemail = false;
    var ischecked = false;
    var controls = form.elements,
        emailAddress = controls['Email'].value;

    /* Validate other controls */

   
   	companyName = controls['CompanyName'].value;
    websiteURL = controls['Website URL'].value;
    industry = controls['Industry'].value;
    targetAudience = controls['TargetAudience'].value;
    describeYourBusiness = controls['Describe your Business'].value;
    
   	if (companyName==null||companyName==""||websiteURL==null||websiteURL==""||industry==null||industry==""||targetAudience==null||targetAudience==""|| describeYourBusiness==null||describeYourBusiness=="")
   	{
   	  document.getElementById("companyInfo").style.border="1px solid #ff0000";
   	  document.getElementById("companyInfo").style.backgroundColor="#FFdddd";
   	  noerror = false;
   	}
   	else{
   	  document.getElementById("companyInfo").style.border="none";
   	  document.getElementById("companyInfo").style.backgroundColor="#FFffff";

   	}
   
  
     for (i=0; i<document.WebsiteAudit.websiteAge.length;i++) {
     if (document.WebsiteAudit.websiteAge[i].checked) {
        ischecked=true;
        break;
      }
      ischecked=false;
    }
   
    if (!ischecked)
   	{
   	  document.getElementById("websiteAge").style.border="1px solid #ff0000";
   	  document.getElementById("websiteAge").style.backgroundColor="#FFdddd";
   	  noerror = false;
   	}
   	else{
   	  document.getElementById("websiteAge").style.border="none";
   	  document.getElementById("websiteAge").style.backgroundColor="#FFffff";

   	}
   	
   	
   	
   	 for (i=0; i<document.WebsiteAudit.WebsiteUpdates.length;i++) {
     if (document.WebsiteAudit.WebsiteUpdates[i].checked) {
        ischecked=true;
        break;
      }
      ischecked=false;
    }
   
    if (!ischecked)
   	{
   	  document.getElementById("websiteUpdates").style.border="1px solid #ff0000";
   	  document.getElementById("websiteUpdates").style.backgroundColor="#FFdddd";
   	  noerror = false;
   	}
   	else{
   	  document.getElementById("websiteUpdates").style.border="none";
   	  document.getElementById("websiteUpdates").style.backgroundColor="#FFffff";

   	}
     
     
     for (i=0; i<document.WebsiteAudit.WebsiteTraffic.length;i++) {
     if (document.WebsiteAudit.WebsiteTraffic[i].checked) {
        ischecked=true;
        break;
      }
      ischecked=false;
    }
   
    if (!ischecked)
   	{
   	  document.getElementById("websiteTraffic").style.border="1px solid #ff0000";
   	  document.getElementById("websiteTraffic").style.backgroundColor="#FFdddd";
   	  noerror = false;
   	}
   	else{
   	  document.getElementById("websiteTraffic").style.border="none";
   	  document.getElementById("websiteTraffic").style.backgroundColor="#FFffff";

   	} 
 
    var WebsiteType=document.WebsiteAudit['WebsiteType[]'];
   	for (i=0; i<WebsiteType.length;i++) {
     if (WebsiteType[i].checked) {
        ischecked=true;
        break;
      }
      ischecked=false;
    }
    if (!ischecked)
   	{
   	  document.getElementById("websiteType").style.border="1px solid #ff0000";
   	  document.getElementById("websiteType").style.backgroundColor="#FFdddd";
   	  noerror = false;
   	}
   	else{
   	  document.getElementById("websiteType").style.border="none";
   	  document.getElementById("websiteType").style.backgroundColor="#FFffff";

   	} 
   
   	 var WebsiteChallenge=document.WebsiteAudit['WebsiteChallenge[]'];
   	 for (i=0; i<WebsiteChallenge.length;i++) {
     if (WebsiteChallenge[i].checked) {
        ischecked=true;
        break;
      }
      ischecked=false;
    }
    if (!ischecked)
   	{
   	  document.getElementById("websiteChallenge").style.border="1px solid #ff0000";
   	  document.getElementById("websiteChallenge").style.backgroundColor="#FFdddd";
   	  noerror = false;
   	}
   	else{
   	  document.getElementById("websiteChallenge").style.border="none";
   	  document.getElementById("websiteChallenge").style.backgroundColor="#FFffff";

   	} 
   	
	
	name = controls['Name'].value;
	position = controls['Position'].value;
	email = controls['Email'].value;
	phoneNumber = controls['PhoneNumber'].value;
	if (name==null||name==""||position==null||position==""||email==null||email==""||phoneNumber==null||phoneNumber=="")
   	{
   	  document.getElementById("information").style.border="1px solid #ff0000";
   	  document.getElementById("information").style.backgroundColor="#FFdddd";
   	  noerror = false;
   	}
   	else{
   	  if(!isEmailAddress(emailAddress))
   	  {
   	    invalidemail=true;
   	  	document.getElementById("information").style.border="1px solid #ff0000";
   	    document.getElementById("information").style.backgroundColor="#FFdddd";
   	  	noerror = false;
   	  }
   	  else{
   	  document.getElementById("information").style.border="none";
   	  document.getElementById("information").style.backgroundColor="#FFffff";
   	  }
   	}
   	
	var AuditType=document.WebsiteAudit['AuditType[]'];
   	for (i=0; i<AuditType.length;i++) {
     if (AuditType[i].checked) {
        ischecked=true;
        break;
      }
      ischecked=false;
    }
    if (!ischecked)
   	{
   	  document.getElementById("auditType").style.border="1px solid #ff0000";
   	  document.getElementById("auditType").style.backgroundColor="#FFdddd";
   	  noerror = false;
   	}
   	else{
   	  document.getElementById("auditType").style.border="none";
   	  document.getElementById("auditType").style.backgroundColor="#FFffff";

   	} 
   	 
   	var AborgServiceType=document.WebsiteAudit['AborgServiceType[]'];
   	for (i=0; i<AborgServiceType.length;i++) {
     if (AborgServiceType[i].checked) {
        ischecked=true;
        break;
      }
      ischecked=false;
    }
    if (!ischecked)
   	{
   	  document.getElementById("aborgServiceType").style.border="1px solid #ff0000";
   	  document.getElementById("aborgServiceType").style.backgroundColor="#FFdddd";
   	  noerror = false;
   	}
   	else{
   	  document.getElementById("aborgServiceType").style.border="none";
   	  document.getElementById("aborgServiceType").style.backgroundColor="#FFffff";

   	}   
   	/*
	auditType = controls['Audit Type'].value;
	aborgServiceType = controls['Aborg Service Type'].value;
    */
    /* More validation */


    if (noerror)
   	{
   	  return true;
   	}
   	else{
   	  document.getElementById("error").style.display="block";
   	  if(invalidemail==true){alert("Please enter a valid email address");}
   	  return false;
   	}
    return false;
}



