function CheckForm(form)
{
  var error = 0;
  var r = '';
  if(isNotEmpty(form.name))
  {
    r += 'Please fill in the name.\n';
    error = 1;
  }
  if(isEMailAddr(form.email))
  {
    r += 'Verify the e-mail address format.\n';
    error = 1;
    //return false;
  }
  
  if(!check_it(form.website))
  {
     r += 'Verify the Url format.\n';
     error = 1;
  }
  
  
  
  if(IsNumeric(form.percent.value))
  {
    r += 'Please check the Percent field.\n';
    error = 1;
  }
  
  if(IsNumeric(form.income1.value))
  {
    r += 'Please check the Income field.\n';
    error = 1;
  }
  
  if(IsNumeric(form.traffic.value))
  {
    r += 'Please check the web traffic field.\n';
    error = 1;
  }
  
  if(!document.emailForm.agree.checked)
  {
    r += 'Please read our terms and agree to them before submitting...\n';
    error = 1;
  }
  
  if(error!=1)
  {
    return true;
  }
  else
  {
    alert(r);
    r = '';
    return false;
  }  
}

function CheckForm1(form)
{
  var error = 0;
  var r ='';
  
  if(!isNotEmpty(form.name))
  {
    r += '* Please fill in Your Name.\n';
    error = 1;
  }
  
  if(!isEMailAddr(form.email))
  {
    r += '* Verify the E-Mail Address.\n';
    error = 1;
    //return false;
  }
  
  if(form.aff_str.value == "")
  {
    r += '* Please select Affiliate Strategy.\n';
    error = 1;
  }
  
  if(form.percent.value == "")
  {
    r += '* Please select Percent Increase in Business.\n';
    error = 1;
  }
  
  if(form.income.value == "")
  {
    r += '* Please select Current Monthly Income.\n';
    error = 1;
  }
  
  if(form.traffic.value == "")
  {
    r += '* Please select Monthly Website Traffic.\n';
    error = 1;
  }
  
  if(form.casestudy.value.length < 25)
  {
    r += '* Please fill in your Testimonial. Atleast 25 characters.\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;
  //alert(str);
    var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        //alert("false");
        //setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
        return 0;
    } else {
    //alert("true");
        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))
 {
 //window.alert("URL OK.");
 return 1;
 }
 else
 {
  //window.alert("URL invalid. Try again.");
 return 0; 
}
}

function isNotEmpty(elem) {
  var str = elem.value;
    var re = /.+/;
    if(!str.match(re)) {
        //alert("Please fill in the required field.");
        //setTimeout("focusElement('" + elem.form.name + "', '" + elem.name + "')", 0);
        return 0;
    } else {
        return 1;
    }
}

function IsNumeric(val)
   //  check for valid numeric strings	
   {
   //alert(val);
   //return 0;
    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;
} 

