// JavaScript Document
function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}
function validateform()
{
  
if (trim(document.contact_us.name.value) == "")
  {
     alert("Please enter your name.");
     document.contact_us.name.focus();
     document.contact_us.name.blur();
     document.contact_us.name.select();
     return false;
}
if (trim(document.contact_us.company.value) == "")
  {
     alert("Please enter your company.");
     document.contact_us.company.focus();
     document.contact_us.company.blur();
     document.contact_us.company.select();
     return false;
}
if (trim(document.contact_us.phone.value) == "")
  {
     alert("Please enter your phone number.");
     document.contact_us.phone.focus();
     document.contact_us.phone.blur();
     document.contact_us.phone.select();
     return false;
}


if (document.contact_us.email.value == "")
  {
     alert("Please enter your email address: youremail@domain.com.");
     document.contact_us.email.focus();
     document.contact_us.email.blur();
     document.contact_us.email.select();
     return false;
}

if (!document.contact_us.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.biz)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi) || document.contact_us.email.value.match(/you@domain.com$/))
   
  {
     alert("Please enter their email address in this format: theiremail@domain.com");
     document.contact_us.email.focus();
     document.contact_us.email.blur();
     document.contact_us.email.select();
     return false;
  }

if (document.contact_us.about_us.value == "")
  {
     alert("Please select How you heard about us.");
     document.contact_us.about_us.focus();
     return false;
}
// place any other field validations that you require here
// validate myradiobuttons
myOption = -1;
for (i=document.contact_us.Q1.length-1; i > -1; i--) {
if (document.contact_us.Q1[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("You must select a radio button from Question 1");
return false;
}

myOption = -1;
for (i=document.contact_us.Q2.length-1; i > -1; i--) {
if (document.contact_us.Q2[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("You must select a radio button from Question 2");
return false;
}

myOption = -1;
for (i=document.contact_us.Q3.length-1; i > -1; i--) {
if (document.contact_us.Q3[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("You must select a radio button from Question 3");
return false;
}

myOption = -1;
for (i=document.contact_us.Q4.length-1; i > -1; i--) {
if (document.contact_us.Q4[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("You must select a radio button from Question 4");
return false;

}
myOption = -1;
for (i=document.contact_us.Q5.length-1; i > -1; i--) {
if (document.contact_us.Q5[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("You must select a radio button from Question 5");
return false;
}

myOption = -1;
for (i=document.contact_us.Q6.length-1; i > -1; i--) {
if (document.contact_us.Q6[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("You must select a radio button from Question 6");
return false;
}
myOption = -1;
for (i=document.contact_us.Q7.length-1; i > -1; i--) {
if (document.contact_us.Q7[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("You must select a radio button from Question 7");
return false;
}
return true; 
}