
function form_validate() {
  var ret_val=true;

  var clist=$(".mreq");
  
  for (var i=0;i<clist.length;i++) {
    var f=clist.eq(i);
    if (f.attr('value')=="" ||
	(f.attr('type')=="checkbox" && !f.attr('checked'))) {

      if (f.attr('type')=="checkbox") {
	$("#pp_div").addClass("redselected");
      }

      f.addClass("redselected");
      $("#formmessage").text("You must fill out all required fields");
      ret_val=false;
    } else {
      f.removeClass("redselected");
    }
  }

  if (checkAge()==false) {
    alert("You are not of legal each to use this site.");  
    ret_val=false;
  } 

  return ret_val;
}


function checkAge()		{
  /* the minumum age you want to allow in */
  var min_age = 13;

  /* change "age_form" to whatever your form has for a name="..." */
  var year = parseInt($("#dob_year").val());
  var month = parseInt($("#dob_month").val()) - 1;
  var day = parseInt($("#dob_day").val());

  var theirDate = new Date((year + min_age), month, day);
  var today = new Date;

  if ( (today.getTime() - theirDate.getTime()) < 0) {

    return false;
  }
  else {
    return true;
  }
}

