function IsNumeric(sText)
{
   var ValidChars = "0123456789-.";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }

function isEmailAddr(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function FormValidator(theForm)
{
   if (document.getElementById('name').value == "")
  {
    alert("Please enter your first name.");
    document.getElementById('name').focus();
    return (false);
  }
  
   if (document.getElementById('phone').value == "")
  {
    alert("Please enter your 10 digit phone number, example: 555-555-1212.");
    document.getElementById('phone').focus();
    return (false);
  }

  if (!IsNumeric(document.getElementById('phone').value))
  {
    alert("Please enter your 10 digit phone number, example: 555-555-1212.");
    document.getElementById('phone').focus();
    return (false);
  }

  if (document.getElementById('phone').length < 12)
  {
    alert("Please enter your 10 digit phone number, example: 555-555-1212.");
    document.getElementById('phone').focus();
    return (false);
  }

  if (document.getElementById('email').value == "")
  {
    alert("Please enter a value for the \"email\" field.");
    document.getElementById('email').focus();
    return (false);
  }

  if (!isEmailAddr(document.getElementById('email').value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    document.getElementById('email').focus();
    return (false);
  }
   
  if (document.getElementById('email').value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"email\" field.");
    document.getElementById('email').focus();
    return (false);
  }
  return (true);
}

function contactUsValid()
{
	
 if (document.getElementById('name_contactus').value == "")
  {
    alert("Please enter your first name.");
    document.getElementById('name_contactus').focus();
    return (false);
  }
  
   if (document.getElementById('phone_contactus').value == "")
  {
    alert("Please enter your 10 digit phone number, example: 555-555-1212.");
    document.getElementById('phone_contactus').focus();
    return (false);
  }

  if (!IsNumeric(document.getElementById('phone_contactus').value))
  {
    alert("Please enter your 10 digit phone number, example: 555-555-1212.");
    document.getElementById('phone_contactus').focus();
    return (false);
  }

  if (document.getElementById('phone_contactus').length < 12)
  {
    alert("Please enter your 10 digit phone number, example: 555-555-1212.");
    document.getElementById('phone_contactus').focus();
    return (false);
  }

  if (document.getElementById('email_contactus').value == "")
  {
    alert("Please enter a value for the \"email\" field.");
    document.getElementById('email_contactus').focus();
    return (false);
  }

  if (!isEmailAddr(document.getElementById('email_contactus').value))
  {
    alert("Please enter a complete email address in the form: yourname@yourdomain.com");
    document.getElementById('email_contactus').focus();
    return (false);
  }
   
  if (document.getElementById('email_contactus').value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"email\" field.");
    document.getElementById('email_contactus').focus();
    return (false);
  }
  
  if(document.getElementById('email_contactus').value != document.getElementById('email_confirm').value)
  {
  		alert('Your email addresses do not match up. Please confirm your email address.')
		document.getElementById('email_confirm').focus();
		return false;
  }
  
  return (true);
	
}

function checkThisIs(check)
{
	if(check == 'Company Related')
	{
		document.getElementById('company_name_title').innerHTML = 'Company Name: ';
		document.getElementById('company_name_field').innerHTML = '<input type="text" name="data[Form][company_name]" />';
	}
	else
	{
		document.getElementById('company_name_title').innerHTML = '';
		document.getElementById('company_name_field').innerHTML = '';
	}
	
}

