function CheckForm1(form)
{
  var error = 0;
  var r ='';
  
  if(!isNotEmpty(form.name))
  {
    r += '* Please fill in "Your Name".\n';
    error = 1;
  }
  
  if(!isNotEmpty(form.email))
  {
    r += '* Please fill in "Your Email".\n';
    error = 1;
  }
  else if(!isEMailAddr(form.email))
  {
    r += '* Please verify "Your Email".\n';
    error = 1;
  }
  
  if(!isNotEmpty(form.aff_mgr_name))
  {
    r += '* Please fill in "Affiliate Manager\'s Name".\n';
    error = 1;
  }

  if(!isNotEmpty(form.aff_mgr_company))
  {
    r += '* Please fill in "Affiliate Manager\'s Company".\n';
    error = 1;
  }
  
  if(!isNotEmpty(form.aff_mgr_cmp_website))
  {
    r += '* Please fill in "Affiliate Manager\'s Company Website".\n';
    error = 1;
  }
  /*else if(!check_it(form.aff_mgr_cmp_website))
  {
     r += '* Please verify "Affiliate Manager\'s Company Website".\n';
     error = 1;
  }*/
    
  if(!isNotEmpty(form.aff_mgr_email))
  {
    r += '* Please fill in "Affiliate Manager\'s E-mail".\n';
    error = 1;
  }
  else if(!isEMailAddr(form.aff_mgr_email))
  {
    r += '* Please verify "Affiliate Manager\'s E-mail".\n';
    error = 1;
  }
  
  if(!isNotEmpty(form.aff_mgr_why))
  {
    r += '* Please fill in "Why Are You Nominating This Affiliate Manager?".\n';
    error = 1;
  }
  
  if(!isNotEmpty(form.aff_mgr_how_long))
  {
    r += '* Please fill in "How Long Have You Worked With This Manager?".\n';
    error = 1;
  }
  
  if(!form.agree.checked)
  {
    r += '* Please read our terms and agree to them before submitting.\n';
    error = 1;
  }
  
  if(error!=1)
  {
    return true;
  }
  else
  {
    r = "Please correct the following errors before procedding to submit:\n" + r;
    alert(r);
    return false;
  }  
}

function isEMailAddr(elem) 
{
  var str = elem.value;
  var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
  if (!str.match(re)) 
  {
    return 0;
  } 
  else 
  {
    return 1;
  }
}

function check_it(elem)
{
  var theurl=elem.value;
  var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
  if (tomatch.test(theurl))
  {
    return 1;
  }
  else
  {
    return 0; 
  }
}

function isNotEmpty(elem)
{
  var str = elem.value;
  var re = /.+/;
  if(!str.match(re)) 
  {
    return 0;
  } 
  else 
  {
    return 1;
  }
}

function IsNumeric(val)
//  check for valid numeric strings	
{
  var strString = val;
  var strValidChars = "0123456789.-";
  var strChar;
  var blnResult = false;
  
  if (strString.length == 0) return true;
  
  //  test strString consists of valid characters listed above
  for (i = 0; i < strString.length && blnResult == false; i++)
  {
    strChar = strString.charAt(i);
    if (strValidChars.indexOf(strChar) == -1)
    {
      blnResult = true;
    }
  }
  return blnResult;
}
   
function checkInput(data,obj,max)
{
  var result = true;
  if (obj.value.length >= max)
  {
    var stripped = obj.value.substring(0, max);
    document.getElementById(data).value = stripped;
    result = false;
  }
  if (window.event)
    window.event.returnValue = result;
  return result;
}

